org.jdom.Element.getChildText()方法的使用及代码示例

x33g5p2x  于2022-01-18 转载在 其他  
字(10.1k)|赞(0)|评价(0)|浏览(258)

本文整理了Java中org.jdom.Element.getChildText()方法的一些代码示例,展示了Element.getChildText()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Element.getChildText()方法的具体详情如下:
包路径:org.jdom.Element
类名称:Element
方法名:getChildText

Element.getChildText介绍

[英]Returns the textual content of the named child element, or null if there's no such child. This method is a convenience because calling getChild().getText() can throw a NullPointerException.
[中]返回命名子元素的文本内容,如果没有这样的子元素,则返回null。此方法非常方便,因为调用getChild().getText()会引发NullPointerException。

代码示例

代码示例来源:origin: voldemort/voldemort

public static SerializerDefinition readSerializer(Element elmt) {
  String name = elmt.getChild(STORE_SERIALIZATION_TYPE_ELMT).getText();
  boolean hasVersion = true;
  Map<Integer, String> schemaInfosByVersion = new HashMap<Integer, String>();
    throw new IllegalArgumentException("Specified multiple schemas AND version=none, which is not permitted.");
  Element compressionElmt = elmt.getChild(STORE_COMPRESSION_ELMT);
  Compression compression = null;
  if(compressionElmt != null)
    compression = new Compression(compressionElmt.getChildText("type"),
                   compressionElmt.getChildText("options"));
  return new SerializerDefinition(name, schemaInfosByVersion, hasVersion, compression);

代码示例来源:origin: voldemort/voldemort

private StoreDefinition readView(Element store, List<StoreDefinition> stores) {
  String name = store.getChildText(STORE_NAME_ELMT);
  String targetName = store.getChildText(VIEW_TARGET_ELMT);
  String description = store.getChildText(STORE_DESCRIPTION_ELMT);
  String ownerText = store.getChildText(STORE_OWNERS_ELMT);
  List<String> owners = Lists.newArrayList();
  if(ownerText != null) {
  if(store.getChildText(VIEW_SERIALIZER_FACTORY_ELMT) != null) {
    viewSerializerFactoryName = store.getChild(VIEW_SERIALIZER_FACTORY_ELMT).getText();
  if(store.getChild(STORE_VALUE_SERIALIZER_ELMT) != null)
    valueSerializer = readSerializer(store.getChild(STORE_VALUE_SERIALIZER_ELMT));
  if(store.getChildText(STORE_ROUTING_TIER_ELMT) != null) {
    routingTier = RoutingTier.fromDisplay(store.getChildText(STORE_ROUTING_TIER_ELMT));
  } else {
    routingTier = target.getRoutingPolicy();
  String viewClass = store.getChildText(VIEW_TRANS_ELMT);

代码示例来源:origin: uk.org.mygrid.taverna/taverna-workbench

private String findNamedWorkflowInstanceContainerFactory(Element rootElement) {
  String result=null;
  Element named = rootElement.getChild("namedcomponents");
  if (named!=null) {
    List<Element> namedComponents = named.getChildren("namedcomponent");
    for (Element namedComponent : namedComponents) {
      String className=namedComponent.getChildTextTrim("classname");
      if (className!=null && className.equals("org.embl.ebi.escience.scuflui.WorkflowInstanceContainerFactory")) {
        result=namedComponent.getChildText("name");
        break;
      }
    }
  }
  return result;
}

代码示例来源:origin: geosolutions-it/geoserver-manager

public String getWorkspace() {
    Element rootLayer = rootElem.getChild("workspace");
    if (rootLayer != null) {
      return rootLayer.getChildText("name");
    } else {
      return null;
    }                
}

代码示例来源:origin: voldemort/voldemort

@SuppressWarnings("unchecked")
private static StoreDefinition readStore(Element store) {
  String name = store.getChildText(STORE_NAME_ELMT);
  String storeType = store.getChildText(STORE_PERSISTENCE_ELMT);
  String description = store.getChildText(STORE_DESCRIPTION_ELMT);
  String ownerText = store.getChildText(STORE_OWNERS_ELMT);
  List<String> owners = Lists.newArrayList();
  if(ownerText != null) {
  int replicationFactor = Integer.parseInt(store.getChildText(STORE_REPLICATION_FACTOR_ELMT));
  HashMap<Integer, Integer> zoneReplicationFactor = null;
  Element zoneReplicationFactorNode = store.getChild(STORE_ZONE_REPLICATION_FACTOR_ELMT);
  if(zoneReplicationFactorNode != null) {
    zoneReplicationFactor = new HashMap<Integer, Integer>();
  String zoneCountReadsStr = store.getChildText(STORE_ZONE_COUNT_READS);
  Integer zoneCountReads = null;
  if(zoneCountReadsStr != null)
    zoneCountReads = Integer.parseInt(zoneCountReadsStr);
  String zoneCountWritesStr = store.getChildText(STORE_ZONE_COUNT_WRITES);
  Integer zoneCountWrites = null;
  if(zoneCountWritesStr != null)
    zoneCountWrites = Integer.parseInt(zoneCountWritesStr);
  int requiredReads = Integer.parseInt(store.getChildText(STORE_REQUIRED_READS_ELMT));
  int requiredWrites = Integer.parseInt(store.getChildText(STORE_REQUIRED_WRITES_ELMT));
  String preferredReadsStr = store.getChildText(STORE_PREFERRED_READS_ELMT);
  Integer preferredReads = null;
  if(preferredReadsStr != null)

代码示例来源:origin: geosolutions-it/geoserver-manager

public String getRootLayer() {
  Element rootLayer = rootElem.getChild("rootLayer");
  if (rootLayer != null) {
    return rootLayer.getChildText("name");
  } else {
    return null;
  }
}

代码示例来源:origin: pl.edu.icm.sedno/sedno-tools

public OpenSearchResults(Document response) {
  if (response.getRootElement().getName().equals(OutputFormat.rss.getRootElementName())) {
    format = OutputFormat.rss;
    Element channel = response.getRootElement().getChild("channel");
    
    totalResults = Integer.parseInt( channel.getChildText("totalResults", OPEN_SEARCH_NAMESPACE));
    //itemsPerPage = Integer.parseInt( channel.getChildText("itemsPerPage", OPEN_SEARCH_NAMESPACE));
    
    items = ImmutableList.copyOf(channel.getChildren("item"));
  }else if (response.getRootElement().getName().equals(OutputFormat.xml.getRootElementName())) {
    format = OutputFormat.xml;
    totalResults = Integer.parseInt( response.getRootElement().getChildText("totalResults"));
    
    Element results = response.getRootElement().getChild("results");			
    
    items = ImmutableList.copyOf(results.getChildren("result"));
  } else {
    throw new NotImplementedException("parser of output format ["+response.getRootElement().getName()+"] is not implemented");
  }
}

代码示例来源:origin: geosolutions-it/geoserver-manager

public String getCRS() {
  Element bounds = rootElem.getChild("bounds");
  return bounds.getChildText("crs");
}

代码示例来源:origin: net.anotheria/ano-doc

@SuppressWarnings("unchecked")
private static  Context parseLanguages(Context src, Element languages){
  src.enableMultiLanguageSupport();
  Element supportedLanguages = languages.getChild("supported");
  List<Element> supLangs = supportedLanguages.getChildren("language");
  for (Element e: supLangs){
    src.addLanguage(e.getText());
  }
  
  String defLang = languages.getChild("default").getChildText("language");
  src.setDefaultLanguage(defLang);
  
  return src;
}

代码示例来源:origin: geosolutions-it/geoserver-manager

public String getDefaultStyleWorkspace() {
  Element defaultStyle = layerElem.getChild("defaultStyle");
  return defaultStyle == null? null : defaultStyle.getChildText("workspace");
 }

代码示例来源:origin: geosolutions-it/geoserver-manager

public List<GSAttributeEncoder> getEncodedAttributeList() {
    List<GSAttributeEncoder> attrsList = null;

    final Element attrsRoot = rootElem.getChild("attributes");
    if(attrsRoot!=null){
      final List<Element> attrs = attrsRoot.getChildren();
      if (attrs != null) {
        attrsList = new ArrayList<GSAttributeEncoder>(attrs.size());
        for (Element attr : attrs) {
          final GSAttributeEncoder attrEnc = new GSAttributeEncoder();
          for (FeatureTypeAttribute at : FeatureTypeAttribute.values()) {
            String key = at.toString();
            attrEnc.setAttribute(at, attr.getChildText(key));
          }
          attrsList.add(attrEnc);
        }
  
      }
    }
    return attrsList;
  }
}

代码示例来源:origin: geosolutions-it/geoserver-manager

public String getTitle() {
  Element resource = layerElem.getChild("resource");
  return resource.getChildText("title");
}

代码示例来源:origin: dboissier/jenkins-control-plugin

private Map<String, Build> createLatestBuildList(Document doc) {

    Map<String, Build> buildMap = new LinkedHashMap<String, Build>();
    Element rootElement = doc.getRootElement();

    List<Element> elements = rootElement.getChildren(RSS_ENTRY, rootElement.getNamespace());
    for (Element element : elements) {
      String title = element.getChildText(RSS_TITLE, rootElement.getNamespace());
      String publishedBuild = element.getChildText(RSS_PUBLISHED, rootElement.getNamespace());
      String jobName = RssUtil.extractBuildJob(title);
      String number = RssUtil.extractBuildNumber(title);
      BuildStatusEnum status = RssUtil.extractStatus(title);
      Element linkElement = element.getChild(RSS_LINK, rootElement.getNamespace());
      String link = linkElement.getAttributeValue(RSS_LINK_HREF);

      if (!BuildStatusEnum.NULL.equals(status)) {
        buildMap.put(jobName, Build.createBuildFromRss(link, number, status.getStatus(), Boolean.FALSE.toString(), publishedBuild, title));

      }

    }

    return buildMap;
  }
}

代码示例来源:origin: geosolutions-it/geoserver-manager

public String getAbstract() {
  Element resource = layerElem.getChild("resource");
  return resource.getChildText("abstract");
}

代码示例来源:origin: bcdev/beam

private void validateGroundOverlay(String name, Object overlay, Namespace namespace) {
  Element groundOverlay = (Element) overlay;
  assertEquals("GroundOverlay", groundOverlay.getName());
  assertEquals(3, groundOverlay.getChildren().size());
  assertEquals(name, groundOverlay.getChildText("name", namespace));
  Element icon = groundOverlay.getChild("Icon", namespace);
  assertEquals(name + ".png", icon.getChildText("href", namespace));
  final Element latLonBox = groundOverlay.getChild("LatLonBox", namespace);
  assertNotNull(latLonBox);
  assertEquals("70.0", latLonBox.getChildText("north", namespace));
  assertEquals("30.0", latLonBox.getChildText("south", namespace));
  assertEquals("20.0", latLonBox.getChildText("east", namespace));
  assertEquals("0.0", latLonBox.getChildText("west", namespace));
}

代码示例来源:origin: geosolutions-it/geoserver-manager

public String getDefaultStyle() {
  Element defaultStyle = layerElem.getChild("defaultStyle");
  return defaultStyle == null? null : defaultStyle.getChildText("name");
 }

代码示例来源:origin: geosolutions-it/geoserver-manager

public String getStoreName() {
  return rootElem.getChild("store").getChildText("name");
}

代码示例来源:origin: geosolutions-it/geoserver-manager

public String getWorkspaceName() {
  return dsElem.getChild("workspace").getChildText("name");
}

代码示例来源:origin: geosolutions-it/geoserver-manager

public String getNameSpace() {
  return rootElem.getChild("namespace").getChildText("name");
}

代码示例来源:origin: geosolutions-it/geoserver-manager

public String getWorkspaceName() {
  return cs.getChild("workspace").getChildText("name");
}

相关文章

微信公众号

最新文章

更多