本文整理汇总了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;
}
示例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);
}
示例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;
}
示例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);
}
示例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;
}
示例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");
}
}
示例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;
}
示例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);
}
示例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");
}
}
示例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);
}
示例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();
}
示例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;
}
}
示例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)
);
}
示例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");
}
}
示例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;
}