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


Java Element.getName方法代碼示例

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


在下文中一共展示了Element.getName方法的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: readGeneralProductInformation

import org.jdom2.Element; //導入方法依賴的package包/類
/**
 * Read the generalProductInformation:
 * productType,instrumentConfigurationID,
 * missionDataTakeID,transmitterReceiverPolarisation
 * ,productTimelinessCategory,sliceProductFlag
 * 
 * @throws JAXBException
 * @throws SAXException
 */
public void readGeneralProductInformation() throws JAXBException,
		SAXException {
	String xPathGenProdInfo = "/xfdu:XFDU/metadataSection/metadataObject/metadataWrap/xmlData/*[name()='generalProductInformation']";
	String xPathStandAloneInfo = "/xfdu:XFDU/metadataSection/metadataObject/metadataWrap/xmlData/s1sarl1:standAloneProductInformation']";

	XPathExpression<Element> expr = xFactory.compile(xPathGenProdInfo,
			Filters.element(), null, xfdu);
	List<Element> value = expr.evaluate(safe);
	if (value == null || value.isEmpty()) {
		expr = xFactory.compile(xPathStandAloneInfo, Filters.element(),
				null, s1sarl1, xfdu);
		value = expr.evaluate(safe);
	}

	List<Element> informationsNode = value.get(0).getChildren();
	productInformation = new ProductInformation();

	for (Element e : informationsNode) {
		String name = e.getName();
		String val = e.getValue();
		productInformation.putValueInfo(name, val);
	}

}
 
開發者ID:ec-europa,項目名稱:sumo,代碼行數:34,代碼來源:SumoSafeReader.java

示例3: readGeneralProductInformation

import org.jdom2.Element; //導入方法依賴的package包/類
public void readGeneralProductInformation() throws JAXBException,
		SAXException {
	String xPathGenProdInfo = "/xfdu:XFDU/metadataSection/metadataObject/metadataWrap/xmlData/*[name()='generalProductInformation']";
	String xPathStandAloneInfo = "/xfdu:XFDU/metadataSection/metadataObject/metadataWrap/xmlData/s1sarl1:standAloneProductInformation";

	XPathExpression<Element> expr = xFactory.compile(xPathGenProdInfo,
			Filters.element(), null, xfdu);
	List<Element> value = expr.evaluate(safe);
	if (value == null || value.isEmpty()) {
		expr = xFactory.compile(xPathStandAloneInfo, Filters.element(),
				null, s1sarl1, xfdu);
		value = expr.evaluate(safe);
	}

	List<Element> informationsNode = value.get(0).getChildren();
	productInformation = new ProductInformation();

	for (Element e : informationsNode) {
		String name = e.getName();
		String val = e.getValue();
		productInformation.putValueInfo(name, val);
	}

}
 
開發者ID:ec-europa,項目名稱:sumo,代碼行數:25,代碼來源:SumoXPathSafeReader.java

示例4: ClonedElement

import org.jdom2.Element; //導入方法依賴的package包/類
public ClonedElement(Element el) {
    super(el.getName(), el.getNamespace());
    setParent(el.getParent());

    final BoundedElement bounded = (BoundedElement) el;
    setLine(bounded.getLine());
    setColumn(bounded.getColumn());
    setStartLine(bounded.getStartLine());
    setEndLine(bounded.getEndLine());
    this.indexInParent = bounded.indexInParent();

    setContent(el.cloneContent());

    for(Attribute attribute : el.getAttributes()) {
        setAttribute(attribute.clone());
    }
}
 
開發者ID:OvercastNetwork,項目名稱:ProjectAres,代碼行數:18,代碼來源:ClonedElement.java

示例5: parseAtom

import org.jdom2.Element; //導入方法依賴的package包/類
public Composition<T> parseAtom(Element element) throws InvalidXMLException {
    switch(element.getName()) {
        case "none":
            return new None<>();

        case "maybe":
            return new Maybe<>(filterParser.property(element).required(),
                               parseElement(element));
        case "all":
            return parseElement(element);

        case "any":
            return new Any<>(integerRanges.property(element, "count")
                                          .optional(Range.singleton(1)),
                             booleans.property(element, "unique")
                                     .optional(true),
                             element.getChildren()
                                    .stream()
                                    .map(rethrowFunction(this::parseOption)));
        default:
            return new Unit<>(elementParser.parseElement(element));
    }
}
 
開發者ID:OvercastNetwork,項目名稱:ProjectAres,代碼行數:24,代碼來源:CompositionParser.java

示例6: parse

import org.jdom2.Element; //導入方法依賴的package包/類
public static GameRulesModule parse(MapModuleContext context, Logger logger, Document doc) throws InvalidXMLException {
    Map<GameRule, Boolean> gameRules = new HashMap<>();

    for (Element gameRulesElement : doc.getRootElement().getChildren("gamerules")) {
        for (Element gameRuleElement : gameRulesElement.getChildren()) {
            GameRule gameRule = GameRule.forName(gameRuleElement.getName());
            String value = gameRuleElement.getValue();

            if (gameRule == null) {
                throw new InvalidXMLException(gameRuleElement.getName() + " is not a valid gamerule", gameRuleElement);
            }
            if (value == null) {
                throw new InvalidXMLException("Missing value for gamerule " + gameRule.getValue(), gameRuleElement);
            } else if (!(value.equalsIgnoreCase("true") || value.equalsIgnoreCase("false"))) {
                throw new InvalidXMLException(gameRuleElement.getValue() + " is not a valid gamerule value", gameRuleElement);
            }
            if (gameRules.containsKey(gameRule)){
                throw new InvalidXMLException(gameRule.getValue() + " has already been specified", gameRuleElement);
            }

            gameRules.put(gameRule, Boolean.valueOf(value));
        }
    }
    return new GameRulesModule(gameRules);
}
 
開發者ID:OvercastNetwork,項目名稱:ProjectAres,代碼行數:26,代碼來源:GameRulesModule.java

示例7: loopxml

import org.jdom2.Element; //導入方法依賴的package包/類
/**
 * Method of going through OWL structure
 */
public void loopxml() {
  Iterator<?> processDescendants = rootNode.getDescendants(new ElementFilter());
  String text = "";

  while (processDescendants.hasNext()) {
    Element e = (Element) processDescendants.next();
    String currentName = e.getName();
    text = e.getTextTrim();
    if ("".equals(text)) {
      LOG.info(currentName);
    } else {
      LOG.info("{} : {}", currentName, text);
    }
  }
}
 
開發者ID:apache,項目名稱:incubator-sdap-mudrod,代碼行數:19,代碼來源:AggregateTriples.java

示例8: findChild

import org.jdom2.Element; //導入方法依賴的package包/類
/**
 * Method of identifying a specific child given a element name
 *
 * @param str element name
 * @param ele parent element
 * @return the element of child
 */
public Element findChild(String str, Element ele) {
  Iterator<?> processDescendants = ele.getDescendants(new ElementFilter());
  String name = "";
  Element result = null;

  while (processDescendants.hasNext()) {
    Element e = (Element) processDescendants.next();
    name = e.getName();
    if (name.equals(str)) {
      result = e;
      return result;
    }
  }
  return result;

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

示例9: processChildren

import org.jdom2.Element; //導入方法依賴的package包/類
private void processChildren(Path file, Element parent) throws InvalidXMLException {
    for(int i = 0; i < parent.getContentSize(); i++) {
        Content content = parent.getContent(i);
        if(!(content instanceof Element)) continue;

        Element child = (Element) content;
        List<Content> replacement = null;

        switch(child.getName()) {
            case "include":
                replacement = processIncludeElement(file, child);
                break;

            case "if":
                replacement = processConditional(child, false);
                break;

            case "unless":
                replacement = processConditional(child, true);
                break;
        }

        if(replacement != null) {
            parent.removeContent(i);
            parent.addContent(i, replacement);
            i--; // Process replacement content
        } else {
            processChildren(file, child);
        }
    }
}
 
開發者ID:OvercastNetwork,項目名稱:ProjectAres,代碼行數:32,代碼來源:MapFilePreprocessor.java

示例10: parseMaterialMatcher

import org.jdom2.Element; //導入方法依賴的package包/類
public static MaterialMatcher parseMaterialMatcher(Element el, MaterialMatcher empty) throws InvalidXMLException {
    Set<MaterialMatcher> matchers = new HashSet<>();

    final Attribute attrMaterial = el.getAttribute("material");
    if(attrMaterial != null) {
        matchers.add(parseMaterialPattern(attrMaterial));
    }

    for(Element elChild : el.getChildren()) {
        switch(elChild.getName()) {
            case "all-materials":
            case "all-items":
                return AllMaterialMatcher.INSTANCE;

            case "all-blocks":
                matchers.add(BlockMaterialMatcher.INSTANCE);
                break;

            case "material":
            case "item":
                matchers.add(parseMaterialPattern(elChild));
                break;

            default:
                throw new InvalidXMLException("Unknown material matcher tag", elChild);
        }
    }

    return CompoundMaterialMatcher.of(matchers, empty);
}
 
開發者ID:OvercastNetwork,項目名稱:ProjectAres,代碼行數:31,代碼來源:XMLUtils.java

示例11: parseRequiredItem

import org.jdom2.Element; //導入方法依賴的package包/類
public ItemStack parseRequiredItem(Element parent) throws InvalidXMLException {
    final Element el = XMLUtils.getRequiredUniqueChild(parent);
    switch(el.getName()) {
        case "item": return parseItem(el, false);
        case "head": return parseItem(el, Material.SKULL_ITEM, (short) 3);
        case "book": return parseItem(el, Material.WRITTEN_BOOK);
    }
    throw new InvalidXMLException("Item expected", el);
}
 
開發者ID:OvercastNetwork,項目名稱:ProjectAres,代碼行數:10,代碼來源:GlobalItemParser.java

示例12: parseOptions

import org.jdom2.Element; //導入方法依賴的package包/類
private static void parseOptions(MapModuleContext context, Element el, StaminaOptions options) throws InvalidXMLException {
    options.mutators.sneak = parseMutator(el, "sneak");
    options.mutators.stand = parseMutator(el, "stand");
    options.mutators.walk = parseMutator(el, "walk");
    options.mutators.run = parseMutator(el, "run");

    options.mutators.jump = parseMutator(el, "jump");
    options.mutators.runJump = parseMutator(el, "run-jump");
    options.mutators.injury = parseMutator(el, "injury");
    options.mutators.meleeMiss = parseMutator(el, "melee-miss");
    options.mutators.meleeHit = parseMutator(el, "melee-hit");
    options.mutators.archery = parseMutator(el, "archery");

    for(Element elSymptoms : XMLUtils.flattenElements(el, "symptoms")) {
        switch(elSymptoms.getName()) {
            case "potion":
                options.symptoms.add(parsePotionSymptom(elSymptoms));
                break;

            case "melee":
                options.symptoms.add(parseMeleeSymptom(elSymptoms));
                break;

            case "archery":
                options.symptoms.add(parseArcherySymptom(elSymptoms));
                break;

            default:
                throw new InvalidXMLException("Invalid symptom type", elSymptoms);
        }
    }
}
 
開發者ID:OvercastNetwork,項目名稱:ProjectAres,代碼行數:33,代碼來源:StaminaModule.java

示例13: getFittingElement

import org.jdom2.Element; //導入方法依賴的package包/類
/**
 * finds the one result out of multipleResults that matches singleResult
 *
 * @param multipleResults this element contains an export with more than one
 * result
 * @param singleResult this element contains one single result with which
 * every one of multipleResults is compared with
 * @return one of multipleResults, which matches singleResult closely null
 * otherwise
 */
public Element getFittingElement(Element multipleResults, Element singleResult) {
    // determine export types (Scopus, Crossref...)
    String multipleResultsType = multipleResults.getName();
    String singleResultType = singleResult.getName();

    // create Article classes
    List<Article> candidateArticles = prepareMultipleArticles(multipleResults,
            multipleResultsType);
    Article compArticle = prepareSingleArticle(singleResult, singleResultType);

    // compare Articles
    for (Article art : candidateArticles) {
        art.calcLevDist(compArticle);
    }

    // determine Article with lowest Levenshtein-distance
    Collections.sort(candidateArticles);
    Article fittingArticle = candidateArticles.get(0);
    int indexOfFittingElement = fittingArticle.getPositionInFile();
    System.out.println("Position in Datei: " + indexOfFittingElement);

    // return fitting Element
    List<Element> multipleResultsChildren = multipleResults.getChild("mods", modsNS)
            .getChildren("potential-result");
    return multipleResultsChildren.get(indexOfFittingElement);
}
 
開發者ID:ETspielberg,項目名稱:bibliometrics,代碼行數:37,代碼來源:ExportComparator.java

示例14: describe

import org.jdom2.Element; //導入方法依賴的package包/類
private static String describe(Element el) {
    return "'" + el.getName() + "' element";
}
 
開發者ID:OvercastNetwork,項目名稱:ProjectAres,代碼行數:4,代碼來源:Node.java

示例15: parse

import org.jdom2.Element; //導入方法依賴的package包/類
@Override
public @Nullable CraftingModule parse(MapModuleContext context, Logger logger, Document doc) throws InvalidXMLException {
    Set<Recipe> customRecipes = new HashSet<>();
    Set<MaterialPattern> disabledRecipes = new HashSet<>();

    for(Element elCrafting : doc.getRootElement().getChildren("crafting")) {
        for(Element elDisable : elCrafting.getChildren("disable")) {
            disabledRecipes.add(XMLUtils.parseMaterialPattern(elDisable));
        }

        for(Element elRecipe : XMLUtils.getChildren(elCrafting, "shapeless", "shaped", "smelt")) {
            Recipe recipe;
            switch(elRecipe.getName()) {
                case "shapeless":
                    recipe = parseShapelessRecipe(context, elRecipe);
                    break;

                case "shaped":
                    recipe = parseShapedRecipe(context, elRecipe);
                    break;

                case "smelt":
                    recipe = parseSmeltingRecipe(context, elRecipe);
                    break;

                default: throw new IllegalStateException();
            }

            customRecipes.add(recipe);
            if(XMLUtils.parseBoolean(elRecipe.getAttribute("override"), false)) {
                // Disable specific material + data
                disabledRecipes.add(new MaterialPattern(recipe.getResult().getData()));
            } else if(XMLUtils.parseBoolean(elRecipe.getAttribute("override-all"), false)) {
                // Disable all of this material
                disabledRecipes.add(new MaterialPattern(recipe.getResult().getType()));
            }
        }
    }

    return customRecipes.isEmpty() && disabledRecipes.isEmpty() ? null : new CraftingModule(customRecipes, disabledRecipes);
}
 
開發者ID:OvercastNetwork,項目名稱:ProjectAres,代碼行數:42,代碼來源:CraftingModule.java


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