當前位置: 首頁>>代碼示例>>Java>>正文


Java Element.getChildren方法代碼示例

本文整理匯總了Java中org.jdom2.Element.getChildren方法的典型用法代碼示例。如果您正苦於以下問題:Java Element.getChildren方法的具體用法?Java Element.getChildren怎麽用?Java Element.getChildren使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.jdom2.Element的用法示例。


在下文中一共展示了Element.getChildren方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: getConfig

import org.jdom2.Element; //導入方法依賴的package包/類
/**
 * 獲取指定名稱的Config配置
 * @return
 */
public Map<String,String> getConfig(String name) {
    Element rootEle = doc.getRootElement();
    Element elements = rootEle.getChild(name);

    Map<String,String> configMap = new HashMap<String, String>();
    if (elements != null) {
        List<Element> childElementList = elements.getChildren();
        for(Element childElement : childElementList) {
            String lname = childElement.getName();
            String lvalue = childElement.getValue();

            configMap.put(lname, lvalue);
        }
    }

    return configMap;
}
 
開發者ID:ninelook,項目名稱:wecard-server,代碼行數:22,代碼來源:ConfigHandler.java

示例2: containsClinicalDocumentTemplateId

import org.jdom2.Element; //導入方法依賴的package包/類
private boolean containsClinicalDocumentTemplateId(Element rootElement) {
	boolean containsTemplateId = false;

	List<Element> clinicalDocumentChildren = rootElement.getChildren(TEMPLATE_ID,
																		rootElement.getNamespace());

	for (Element currentChild : clinicalDocumentChildren) {
		final String root = currentChild.getAttributeValue(ROOT_STRING);
		final String extension = currentChild.getAttributeValue(EXTENSION_STRING);

		if (TemplateId.getTemplateId(root, extension, context) == TemplateId.CLINICAL_DOCUMENT) {
			containsTemplateId = true;
			break;
		}
	}
	return containsTemplateId;
}
 
開發者ID:CMSgov,項目名稱:qpp-conversion-tool,代碼行數:18,代碼來源:QrdaXmlDecoder.java

示例3: parseFilter

import org.jdom2.Element; //導入方法依賴的package包/類
private static Filter parseFilter(FilterParser parser, Element el, String name, Filter def) throws InvalidXMLException {
    Filter property = parser.parseOptionalProperty(el, name + "-filter").orElse(null);
    List<Filter> inline = new ArrayList<>();
    for(Element child : el.getChildren(name)) {
        inline.add(new MaterialFilter(XMLUtils.parseMaterialPattern(child)));
    }
    if(property == null) {
        if(inline.isEmpty()) {
            return def;
        } else {
            return new AnyFilter(inline);
        }
    } else {
        if(inline.isEmpty()) {
            return property;
        } else {
            return AllFilter.of(property, new AnyFilter(inline));
        }
    }
}
 
開發者ID:OvercastNetwork,項目名稱:ProjectAres,代碼行數:21,代碼來源:RenewableModule.java

示例4: parseChildren

import org.jdom2.Element; //導入方法依賴的package包/類
public List<Spawn> parseChildren(Element parent, SpawnAttributes attributes) throws InvalidXMLException {
    attributes = this.parseAttributes(parent, attributes);
    List<Spawn> spawns = Lists.newArrayList();
    for(Element spawnsEl : parent.getChildren("spawns")) {
        spawns.addAll(this.parseChildren(spawnsEl, attributes));
    }
    for(Element spawnEl : parent.getChildren("spawn")) {
        spawns.add(this.parse(spawnEl, attributes));
    }
    for(Element defaultEl : parent.getChildren("default")) {
        if(defaultSpawn != null) {
            throw new InvalidXMLException("Cannot have multiple default spawns", defaultEl);
        }
        this.defaultSpawn = parse(defaultEl, attributes);
    }
    return spawns;
}
 
開發者ID:OvercastNetwork,項目名稱:ProjectAres,代碼行數:18,代碼來源:SpawnParser.java

示例5: parseEnchantments

import org.jdom2.Element; //導入方法依賴的package包/類
public Map<Enchantment, Integer> parseEnchantments(Element el, String name) throws InvalidXMLException {
    Map<Enchantment, Integer> enchantments = Maps.newHashMap();

    Node attr = Node.fromAttr(el, name, StringUtils.pluralize(name));
    if(attr != null) {
        Iterable<String> enchantmentTexts = Splitter.on(";").split(attr.getValue());
        for(String enchantmentText : enchantmentTexts) {
            int level = 1;
            List<String> parts = Lists.newArrayList(Splitter.on(":").limit(2).split(enchantmentText));
            Enchantment enchant = XMLUtils.parseEnchantment(attr, parts.get(0));
            if(parts.size() > 1) {
                level = XMLUtils.parseNumber(attr, parts.get(1), Integer.class);
            }
            enchantments.put(enchant, level);
        }
    }

    for(Element elEnchantment : el.getChildren(name)) {
        Pair<Enchantment, Integer> entry = parseEnchantment(elEnchantment);
        enchantments.put(entry.first, entry.second);
    }

    return enchantments;
}
 
開發者ID:OvercastNetwork,項目名稱:ProjectAres,代碼行數:25,代碼來源:GlobalItemParser.java

示例6: loadConfig

import org.jdom2.Element; //導入方法依賴的package包/類
/**
 * Load the configuration provided at <a href=
 * "https://github.com/mudrod/mudrod/blob/master/core/src/main/resources/config.xml">config.xml</a>.
 *
 * @return a populated {@link java.util.Properties} object.
 */
public Properties loadConfig() {
  SAXBuilder saxBuilder = new SAXBuilder();

  InputStream configStream = locateConfig();

  Document document;
  try {
    document = saxBuilder.build(configStream);
    Element rootNode = document.getRootElement();
    List<Element> paraList = rootNode.getChildren("para");

    for (int i = 0; i < paraList.size(); i++) {
      Element paraNode = paraList.get(i);
      String attributeName = paraNode.getAttributeValue("name");
      if (MudrodConstants.SVM_SGD_MODEL.equals(attributeName)) {
        props.put(attributeName, decompressSVMWithSGDModel(paraNode.getTextTrim()));
      } else {
        props.put(attributeName, paraNode.getTextTrim());
      }
    }
  } catch (JDOMException | IOException e) {
    LOG.error("Exception whilst retrieving or processing XML contained within 'config.xml'!", e);
  }
  return getConfig();

}
 
開發者ID:apache,項目名稱:incubator-sdap-mudrod,代碼行數:33,代碼來源:MudrodEngine.java

示例7: parseMessage

import org.jdom2.Element; //導入方法依賴的package包/類
private List<String> parseMessage(Element stageEl) {
    ImmutableList.Builder<String> builder = ImmutableList.builder();

    Element messageEl = stageEl.getChild("message");
    if(messageEl != null) {
        for(Element lineEl : messageEl.getChildren("line")) {
            builder.add(BukkitUtils.colorize(lineEl.getText()));
        }
    }

    return builder.build();
}
 
開發者ID:OvercastNetwork,項目名稱:ProjectAres,代碼行數:13,代碼來源:TutorialParser.java

示例8: getAllChildren

import org.jdom2.Element; //導入方法依賴的package包/類
public final List<Element> getAllChildren() {
    final Element element = getLast();
    if (element == null) {
        return new ArrayList<>();
    }
    return element.getChildren();
}
 
開發者ID:Panzer1119,項目名稱:Supreme-Bot,代碼行數:8,代碼來源:XMLEditor.java

示例9: cargarXml

import org.jdom2.Element; //導入方法依賴的package包/類
private void cargarXml() {
	SAXBuilder builder = new SAXBuilder();
	File xmlFile = new File(xml);
	try {
		Document document = (Document) builder.build(xmlFile);
		Element rootNode = document.getRootElement();
		List list = rootNode.getChildren("pokemon");

		for (int i = 0; i < list.size(); i++) {
			Element tabla = (Element) list.get(i);
			List lista_campos = tabla.getChildren();
			String name = null;
			int height = 0;
			int weight = 0;
			int baseExperience = 0;
			for (int j = 1; j <= 5; j++) {
				Element campo = (Element) lista_campos.get(j);
				if (j == 1) {
					name = campo.getText();
				} else if (j == 3) {
					height = Integer.valueOf(campo.getValue());
				} else if (j == 4) {
					weight = Integer.valueOf(campo.getValue());
				} else if (j == 5) {
					baseExperience = Integer.valueOf(campo.getValue());
				}

			}

			pokemons.add(new Pokemon(name, height, weight, baseExperience));

		}
	} catch (IOException io) {
		System.out.println(io.getMessage());
	} catch (JDOMException jdomex) {
		System.out.println(jdomex.getMessage());
	}
}
 
開發者ID:mistermboy,項目名稱:PokemonXMLFilter,代碼行數:39,代碼來源:XMLReader.java

示例10: parseStages

import org.jdom2.Element; //導入方法依賴的package包/類
private List<TutorialStage> parseStages(PointParser pointParser, Element parent) throws InvalidXMLException {
    List<TutorialStage> stages = Lists.newArrayList();

    for(Element stageEl : parent.getChildren("stage")) {
        String title = BukkitUtils.colorize(XMLUtils.getRequiredAttribute(stageEl, "title").getValue());

        List<String> message = parseMessage(stageEl);
        PointProvider teleport = parseTeleport(pointParser, stageEl);

        stages.add(new TutorialStage(title, message, teleport));
    }

    return stages;
}
 
開發者ID:OvercastNetwork,項目名稱:ProjectAres,代碼行數:15,代碼來源:TutorialParser.java

示例11: getAllClass

import org.jdom2.Element; //導入方法依賴的package包/類
/**
 * Method of extract triples (subclassOf, equivalent class) from OWL file
 *
 * @throws IOException IOException
 */
public void getAllClass() throws IOException {
  List<?> classElements = rootNode.getChildren("Class", Namespace.getNamespace("owl", owl_namespace));

  for (int i = 0; i < classElements.size(); i++) {
    Element classElement = (Element) classElements.get(i);
    String className = classElement.getAttributeValue("about", Namespace.getNamespace("rdf", rdf_namespace));

    if (className == null) {
      className = classElement.getAttributeValue("ID", Namespace.getNamespace("rdf", rdf_namespace));
    }

    List<?> subclassElements = classElement.getChildren("subClassOf", Namespace.getNamespace("rdfs", rdfs_namespace));
    for (int j = 0; j < subclassElements.size(); j++) {
      Element subclassElement = (Element) subclassElements.get(j);
      String subclassName = subclassElement.getAttributeValue("resource", Namespace.getNamespace("rdf", rdf_namespace));
      if (subclassName == null) {
        Element allValuesFromEle = findChild("allValuesFrom", subclassElement);
        if (allValuesFromEle != null) {
          subclassName = allValuesFromEle.getAttributeValue("resource", Namespace.getNamespace("rdf", rdf_namespace));
          bw.write(cutString(className) + ",SubClassOf," + cutString(subclassName) + "\n");
        }
      } else {
        bw.write(cutString(className) + ",SubClassOf," + cutString(subclassName) + "\n");
      }

    }

    List equalClassElements = classElement.getChildren("equivalentClass", Namespace.getNamespace("owl", owl_namespace));
    for (int k = 0; k < equalClassElements.size(); k++) {
      Element equalClassElement = (Element) equalClassElements.get(k);
      String equalClassElementName = equalClassElement.getAttributeValue("resource", Namespace.getNamespace("rdf", rdf_namespace));

      if (equalClassElementName != null) {
        bw.write(cutString(className) + ",equivalentClass," + cutString(equalClassElementName) + "\n");
      }
    }

  }
}
 
開發者ID:apache,項目名稱:incubator-sdap-mudrod,代碼行數:45,代碼來源:AggregateTriples.java

示例12: parseClass

import org.jdom2.Element; //導入方法依賴的package包/類
private static PlayerClass parseClass(Element classEl, KitParser kitParser, String family) throws InvalidXMLException {
    String name = classEl.getAttributeValue("name");
    if(name == null) {
        throw new InvalidXMLException("class must have a name", classEl);
    }

    String description = classEl.getAttributeValue("description");
    if(description != null) {
        description = BukkitUtils.colorize(description);
    }

    String longdescription = classEl.getAttributeValue("longdescription");
    if(longdescription != null) {
        longdescription = BukkitUtils.colorize(longdescription);
    }

    boolean sticky = XMLUtils.parseBoolean(classEl.getAttribute("sticky"), false);

    ImmutableSet.Builder<Kit> kits = ImmutableSet.builder();
    for(Element kitEl : classEl.getChildren("kit")) {
        Kit kit = kitParser.parseElement(kitEl);
        kits.add(kit);
    }

    MaterialData icon = XMLUtils.parseMaterialData(Node.fromAttr(classEl, "icon"));

    boolean restrict = XMLUtils.parseBoolean(classEl.getAttribute("restrict"), false);

    return new PlayerClass(name, family, description, longdescription, sticky, kits.build(), icon, restrict);
}
 
開發者ID:OvercastNetwork,項目名稱:ProjectAres,代碼行數:31,代碼來源:ClassModule.java

示例13: parseChildren

import org.jdom2.Element; //導入方法依賴的package包/類
private List<PointProvider> parseChildren(List<PointProvider> providers, Element el, PointProviderAttributes attributes) throws InvalidXMLException {
    attributes = parseAttributes(el, attributes);
    for(Element elChild : el.getChildren()) {
        parseChild(providers, elChild, attributes);
    }
    return providers;
}
 
開發者ID:OvercastNetwork,項目名稱:ProjectAres,代碼行數:8,代碼來源:PointParser.java

示例14: createArticlefromScopusMulti

import org.jdom2.Element; //導入方法依賴的package包/類
/**
 * this is called if multipleElements consists of scopus-elements
 *
 * @param scopusElement one single potential result from the scopus database
 * @return Article created from scopusElement
 */
private Article createArticlefromScopusMulti(Element scopusElement) {
    Article art = new Article();
    // extract title
    String title = scopusElement.getChild("extension", modsNS)
            .getChild("abstracts-retrieval-response", ELSEVIER_Namespace)
            .getChild("coredata", ELSEVIER_Namespace)
            .getChild("title", DC_Namespace).getText();
    art.setTitle(title);

    // extract authors
    // format: SURNAME, GIVEN-NAME
    List<Element> authorGroupElements = scopusElement.getChild("extension", modsNS)
            .getChild("abstracts-retrieval-response", ELSEVIER_Namespace)
            .getChild("item")
            .getChild("bibrecord")
            .getChild("head")
            .getChildren("author-group");
    for (Element authorGroupElement : authorGroupElements) {
        List<Element> authorElements = authorGroupElement.getChildren("author");
        for (Element authorElement : authorElements) {
            String surname = authorElement.getChild("surname", CE_Namespace).getText();
            String givenName = authorElement.getChild("given-name", CE_Namespace).getText();
            art.addAuthor(surname + ", " + givenName);
        }
    }
    return art;
}
 
開發者ID:ETspielberg,項目名稱:bibliometrics,代碼行數:34,代碼來源:ExportComparator.java

示例15: parse

import org.jdom2.Element; //導入方法依賴的package包/類
@Override
public DamageModule parse(MapModuleContext context, Logger logger, Document doc) throws InvalidXMLException {
    List<Filter> filters = new ArrayList<>();

    for(Element elDamage : doc.getRootElement().getChildren("damage")) {
        for(Element elFilter : elDamage.getChildren()) {
            filters.add(context.needModule(FilterParser.class).parseElement(elFilter));
        }
    }

    return new DamageModule(ImmutableList.copyOf(filters));
}
 
開發者ID:OvercastNetwork,項目名稱:ProjectAres,代碼行數:13,代碼來源:DamageModule.java


注:本文中的org.jdom2.Element.getChildren方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。