当前位置: 首页>>代码示例>>Java>>正文


Java Element.getChild方法代码示例

本文整理汇总了Java中org.jdom2.Element.getChild方法的典型用法代码示例。如果您正苦于以下问题:Java Element.getChild方法的具体用法?Java Element.getChild怎么用?Java Element.getChild使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.jdom2.Element的用法示例。


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

import org.jdom2.Element; //导入方法依赖的package包/类
@Override
public Tutorial parseElement(Element element) throws InvalidXMLException {
    List<TutorialStage> prefixStages = Lists.newArrayList();
    List<TutorialStage> stages = Lists.newArrayList();
    List<TutorialStage> suffixStages = Lists.newArrayList();

    for(Element tutorialEl : element.getChildren("tutorial")) {
        Element prefixEl = tutorialEl.getChild("prefix");
        if(prefixEl != null) {
            prefixStages.addAll(parseStages(pointParser, prefixEl));
        }

        Element suffixEl = tutorialEl.getChild("suffix");
        if(suffixEl != null) {
            suffixStages.addAll(parseStages(pointParser, suffixEl));
        }

        stages.addAll(parseStages(pointParser, tutorialEl));
    }

    stages.addAll(0, prefixStages);
    stages.addAll(suffixStages);

    return new Tutorial(stages);
}
 
开发者ID:OvercastNetwork,项目名称:ProjectAres,代码行数:26,代码来源:TutorialParser.java

示例3: parseLegacyTimeLimit

import org.jdom2.Element; //导入方法依赖的package包/类
private @Nullable TimeLimitDefinition parseLegacyTimeLimit(MapModuleContext context, Element el, String legacyTag, TimeLimitDefinition oldTimeLimit) throws InvalidXMLException {
    el = el.getChild(legacyTag);
    if(el != null) {
        TimeLimitDefinition newTimeLimit = parseTimeLimit(el);
        if(newTimeLimit != null) {
            if(context.getProto().isNoOlderThan(ProtoVersions.REMOVE_SCORE_TIME_LIMIT)) {
                throw new InvalidXMLException("<time> inside <" + legacyTag + "> is no longer supported, use root <time> instead", el);
            }
            if(oldTimeLimit != null) {
                throw new InvalidXMLException("Time limit conflicts with another one that is already defined", el);
            }
            return newTimeLimit;
        }
    }

    return oldTimeLimit;
}
 
开发者ID:OvercastNetwork,项目名称:ProjectAres,代码行数:18,代码来源:TimeLimitModule.java

示例4: retrieveScopusAuthorID

import org.jdom2.Element; //导入方法依赖的package包/类
/**
   * retrieves the ScopusAuthorID for an author and puts it into the <code>PublicationAuthor</code> object
   * @throws HttpException thrown upon connecting to the source
* @throws JDOMException thrown upon parsing the source response
* @throws IOException thrown upon reading profiles from disc
* @throws SAXException thrown when parsing the files from disc
*/
  public void retrieveScopusAuthorID() throws HttpException, JDOMException, IOException, SAXException {
      ScopusConnector connection = new ScopusConnector();
      Element result = connection.retrieveScopusAuthorID(author).asXML().detachRootElement().clone();
      
      List<String> allIDs = new ArrayList<>();
      for (Element child : result.getChildren()) {
          if (result.getName().equals("error")) continue;
          if (child.getName().equals("entry")) {
              Element identifier = child.getChild("identifier",DC_NS);
              String value = identifier.getValue().replace("AUTHOR_ID:", "");
              allIDs.add(value);
          }
      }
      if (allIDs.size() == 1) {
          author.setScopusAuthorID(allIDs.get(0));
          LOGGER.info("found ScopusID: " + author.getScopusAuthorID());
      } else
          author.setScopusAuthorID(toBeChecked);
  }
 
开发者ID:ETspielberg,项目名称:bibliometrics,代码行数:27,代码来源:AuthorBuilder.java

示例5: getPreferredRubricLabel

import org.jdom2.Element; //导入方法依赖的package包/类
protected static String getPreferredRubricLabel(Element classElement, String lang) {
	Iterator<Element> it = classElement.getChildren(ClamlConstants.RUBRIC_ELEMENT).iterator();
	String label = null;
	while (it.hasNext() && label == null) {
		Element rubric = it.next();
		if (ClamlConstants.RUBRIC_KIND_PREFFERD_ATTR.equals(rubric.getAttributeValue(ClamlConstants.KIND_ATTR))) {
			Element labelElement = rubric.getChild(ClamlConstants.LABEL_ELEMENT);
			if (labelElement != null) {
				if (CommonUtil.isEmptyString(lang) || lang.equals(labelElement.getAttributeValue(ClamlConstants.XML_LANG, Namespace.XML_NAMESPACE))) {
					label = labelElement.getTextTrim();
				}
			} else {
				throw new IllegalArgumentException(getKind(classElement) + " " + getCode(classElement) + ": " + ClamlConstants.RUBRIC_ELEMENT + " without "
						+ ClamlConstants.LABEL_ELEMENT);
			}
		}
	}
	return label;
}
 
开发者ID:phoenixctms,项目名称:ctsms,代码行数:20,代码来源:ClamlClassProcessor.java

示例6: getChapter

import org.jdom2.Element; //导入方法依赖的package包/类
private static Element getChapter(Element blockClassElement, Map<String, Map<String, Element>> classKinds) throws Exception {
	Element superClass = blockClassElement.getChild(ClamlConstants.SUPERCLASS_ELEMENT); // single parent assumed
	if (superClass == null) {
		throw new IllegalArgumentException(getKind(blockClassElement) + " " + getCode(blockClassElement) + ": no " + ClamlConstants.SUPERCLASS_ELEMENT);
	}
	String code = getCode(superClass);
	if (!CommonUtil.isEmptyString(code)) {
		return classKinds.get(ClamlConstants.CLASS_KIND_CHAPTER_ATTR).get(code);
	} else {
		throw new IllegalArgumentException(getKind(blockClassElement) + " " + getCode(blockClassElement) + ": no " + ClamlConstants.SUPERCLASS_ELEMENT + " code");
	}
}
 
开发者ID:phoenixctms,项目名称:ctsms,代码行数:13,代码来源:ClamlClassProcessor.java

示例7: goDown

import org.jdom2.Element; //导入方法依赖的package包/类
public final Element goDown(String childName) {
    final Element element = getLast();
    if (element == null) {
        return null;
    }
    final Element child = element.getChild(childName);
    if (child == null) {
        return null;
    }
    addLast(child);
    return child;
}
 
开发者ID:Panzer1119,项目名称:Supreme-Bot,代码行数:13,代码来源:XMLEditor.java

示例8: parse

import org.jdom2.Element; //导入方法依赖的package包/类
public static ModifyBowProjectileModule parse(MapModuleContext context, Logger logger, Document doc) throws InvalidXMLException {
    boolean changed = false;
    Class<? extends Entity> projectile = Arrow.class;
    float velocityMod = 1;
    Set<PotionEffect> potionEffects = new HashSet<>();

    for(Element parent : doc.getRootElement().getChildren("modifybowprojectile")) {
        if(context.getProto().isNoOlderThan(ProtoVersions.FILTER_FEATURES)) {
            throw new InvalidXMLException("Module is discontinued as of " + ProtoVersions.FILTER_FEATURES.toString(), doc.getRootElement().getChild("modifybowprojectile"));
        }

        Element projectileElement = parent.getChild("projectile");
        if(projectileElement != null) {
            projectile = XMLUtils.parseEntityType(projectileElement);
            changed = true;
        }

        Element velocityModElement = parent.getChild("velocityMod");
        if(velocityModElement != null) {
            velocityMod = XMLUtils.parseNumber(velocityModElement, Float.class);
            changed = true;
        }

        for(Element elEffect : XMLUtils.getChildren(parent, "effect", "potion")) {
            potionEffects.add(XMLUtils.parsePotionEffect(elEffect));
            changed = true;
        }
    }

    return !changed ? null : new ModifyBowProjectileModule(projectile, velocityMod, potionEffects);
}
 
开发者ID:OvercastNetwork,项目名称:ProjectAres,代码行数:32,代码来源:ModifyBowProjectileModule.java

示例9: getBlock

import org.jdom2.Element; //导入方法依赖的package包/类
private static Element getBlock(Element categoryClassElement, Map<String, Map<String, Element>> classKinds) throws Exception {
	Element superClass = categoryClassElement.getChild(ClamlConstants.SUPERCLASS_ELEMENT); // single parent assumed
	if (superClass == null) {
		throw new IllegalArgumentException(getKind(categoryClassElement) + " " + getCode(categoryClassElement) + ": no " + ClamlConstants.SUPERCLASS_ELEMENT);
	}
	String code = getCode(superClass);
	if (!CommonUtil.isEmptyString(code)) {
		return classKinds.get(ClamlConstants.CLASS_KIND_BLOCK_ATTR).get(code);
	} else {
		throw new IllegalArgumentException(getKind(categoryClassElement) + " " + getCode(categoryClassElement) + ": no " + ClamlConstants.SUPERCLASS_ELEMENT + " code");
	}
}
 
开发者ID:phoenixctms,项目名称:ctsms,代码行数:13,代码来源:ClamlClassProcessor.java

示例10: parseMutator

import org.jdom2.Element; //导入方法依赖的package包/类
private static StaminaMutator parseMutator(Element el, String name) throws InvalidXMLException {
    NumericModifier modifier = null;
    Element elMutators = el.getChild("mutators");
    if(elMutators != null) {
        modifier = XMLUtils.parseNumericModifier(elMutators.getChild(name), null);
    }
    return new SimpleMutator(name, modifier != null ? modifier : NumericModifier.ZERO, "stamina.mutator." + name);
}
 
开发者ID:OvercastNetwork,项目名称:ProjectAres,代码行数:9,代码来源:StaminaModule.java

示例11: 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

示例12: parseTeleport

import org.jdom2.Element; //导入方法依赖的package包/类
private PointProvider parseTeleport(PointParser parser, Element stageEl) throws InvalidXMLException {
    Element teleportEl = stageEl.getChild("teleport");
    if(teleportEl != null) {
        return new RandomPointProvider(parser.parse(teleportEl, new PointProviderAttributes()));
    } else {
        return null;
    }
}
 
开发者ID:OvercastNetwork,项目名称:ProjectAres,代码行数:9,代码来源:TutorialParser.java

示例13: parseTimeLimit

import org.jdom2.Element; //导入方法依赖的package包/类
private @Nullable TimeLimitDefinition parseTimeLimit(Element el) throws InvalidXMLException {
    el = el.getChild("time");
    if(el == null) return null;

    final Duration duration = XMLUtils.parseDuration(Node.of(el));
    if(Comparables.greaterThan(duration, TimeLimit.MAX_DURATION)) {
        throw new InvalidXMLException("Time limit cannot exceed " + TimeLimit.MAX_DURATION.toDays() + " days", el);
    }

    return new TimeLimitDefinition(
        duration,
        parseVictoryCondition(Node.tryAttr(el, "result")),
        XMLUtils.parseBoolean(el.getAttribute("show"), true)
    );
}
 
开发者ID:OvercastNetwork,项目名称:ProjectAres,代码行数:16,代码来源:TimeLimitModule.java

示例14: getCategory

import org.jdom2.Element; //导入方法依赖的package包/类
private static Element getCategory(Element subCategoryClassElement, Map<String, Map<String, Element>> classKinds) throws Exception {
	Element superClass = subCategoryClassElement.getChild(ClamlConstants.SUPERCLASS_ELEMENT); // single parent assumed
	if (superClass == null) {
		throw new IllegalArgumentException(getKind(subCategoryClassElement) + " " + getCode(subCategoryClassElement) + ": no " + ClamlConstants.SUPERCLASS_ELEMENT);
	}
	String code = getCode(superClass);
	if (!CommonUtil.isEmptyString(code)) {
		return classKinds.get(ClamlConstants.CLASS_KIND_CATEGORY_ATTR).get(code);
	} else {
		throw new IllegalArgumentException(getKind(subCategoryClassElement) + " " + getCode(subCategoryClassElement) + ": no " + ClamlConstants.SUPERCLASS_ELEMENT + " code");
	}
}
 
开发者ID:phoenixctms,项目名称:ctsms,代码行数:13,代码来源:ClamlClassProcessor.java

示例15: getNodeValue

import org.jdom2.Element; //导入方法依赖的package包/类
private String getNodeValue(Element element, String nodeName)
{
	Element e = element.getChild(nodeName, MerlotTopLevelModule.NAMESPACE);
	if( e != null )
	{
		return e.getText();
	}
	return null;
}
 
开发者ID:equella,项目名称:Equella,代码行数:10,代码来源:MerlotTopLevelModuleParser.java


注:本文中的org.jdom2.Element.getChild方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。