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

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

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

Element.getChild介绍

[英]This returns the first child element within this element with the given local name and belonging to no namespace. If no elements exist for the specified name and namespace, null is returned.
[中]这将返回此元素中具有给定本地名称且不属于任何命名空间的第一个子元素。如果指定的名称和命名空间不存在元素,则返回null。

代码示例

代码示例来源:origin: JetBrains/ideavim

public void readData(@NotNull Element element) {
 final Element editor = element.getChild("editor");
 if (editor != null) {
  final Element keyRepeat = editor.getChild("key-repeat");
  if (keyRepeat != null) {
   final String enabled = keyRepeat.getAttributeValue("enabled");
   if (enabled != null) {
    isKeyRepeat = Boolean.valueOf(enabled);
   }
  }
 }
}

代码示例来源:origin: JetBrains/ideavim

public void readData(@NotNull Element element) {
 final Element conflictsElement = element.getChild(SHORTCUT_CONFLICTS_ELEMENT);
 if (conflictsElement != null) {
  final java.util.List<Element> conflictElements = conflictsElement.getChildren(SHORTCUT_CONFLICT_ELEMENT);
  for (Element conflictElement : conflictElements) {
   final String ownerValue = conflictElement.getAttributeValue(OWNER_ATTRIBUTE);
   ShortcutOwner owner = ShortcutOwner.UNDEFINED;
   try {
    owner = ShortcutOwner.fromString(ownerValue);
   }
   catch (IllegalArgumentException ignored) {
   }
   final Element textElement = conflictElement.getChild(TEXT_ELEMENT);
   if (textElement != null) {
    final String text = StringHelper.getSafeXmlText(textElement);
    if (text != null) {
     final KeyStroke keyStroke = KeyStroke.getKeyStroke(text);
     if (keyStroke != null) {
      shortcutConflicts.put(keyStroke, owner);
     }
    }
   }
  }
 }
}

代码示例来源: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>();
  for(Object schemaInfo: elmt.getChildren(STORE_SERIALIZATION_META_ELMT)) {
    Element schemaInfoElmt = (Element) schemaInfo;
    String versionStr = schemaInfoElmt.getAttributeValue(STORE_VERSION_ATTR);
    int version;
    if(versionStr == null) {
      version = Integer.parseInt(versionStr);
    String info = schemaInfoElmt.getText();
    String previous = schemaInfosByVersion.put(version, info);
    if(previous != null)
    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: kiegroup/optaplanner

private void readRequiredEmployeeSizes(NurseRoster nurseRoster, Element coverRequirementsElement) {
  List<Element> coverRequirementElementList = (List<Element>) coverRequirementsElement.getChildren();
  for (Element element : coverRequirementElementList) {
    if (element.getName().equals("DayOfWeekCover")) {
      Element dayOfWeekElement = element.getChild("Day");
      DayOfWeek dayOfWeek = null;
      for (DayOfWeek possibleDayOfWeek : DayOfWeek.values()) {
        if (possibleDayOfWeek.name().equalsIgnoreCase(dayOfWeekElement.getText())) {
          dayOfWeek = possibleDayOfWeek;
          break;
      List<Element> coverElementList = (List<Element>) element.getChildren("Cover");
      for (Element coverElement : coverElementList) {
        Element shiftTypeElement = coverElement.getChild("Shift");
        ShiftType shiftType = shiftTypeMap.get(shiftTypeElement.getText());
              + ") of an entity DayOfWeekCover does not have any shifts.");
        int requiredEmployeeSize = Integer.parseInt(coverElement.getChild("Preferred").getText());
        for (Shift shift : shiftList) {
          shift.setRequiredEmployeeSize(shift.getRequiredEmployeeSize() + requiredEmployeeSize);
      Element dateElement = element.getChild("Date");
      List<Element> coverElementList = (List<Element>) element.getChildren("Cover");
      for (Element coverElement : coverElementList) {
        Element shiftTypeElement = coverElement.getChild("Shift");
        int requiredEmployeeSize = Integer.parseInt(coverElement.getChild("Preferred").getText());
        shift.setRequiredEmployeeSize(shift.getRequiredEmployeeSize() + requiredEmployeeSize);

代码示例来源:origin: JetBrains/ideavim

private void readData(@NotNull Element element, String key) {
 HistoryBlock block = histories.get(key);
 if (block != null) {
  return;
 }
 block = new HistoryBlock();
 histories.put(key, block);
 final Element root = element.getChild("history-" + key);
 if (root != null) {
  //noinspection unchecked
  List<Element> items = root.getChildren("entry");
  for (Element item : items) {
   final String text = StringHelper.getSafeXmlText(item);
   if (text != null) {
    block.addEntry(text);
   }
  }
 }
}

代码示例来源:origin: org.entando.entando/entando-core-engine

private void extractDescriptions(Element element, AbstractBaseBean bean) {
  Element descrElement = element.getChild("description");
  if (null != descrElement) {
    bean.setDescription(descrElement.getText());
    bean.setDescriptionKey(descrElement.getAttributeValue("key"));
  }
  Element longdescElement = element.getChild("longdesc");
  if (null != longdescElement) {
    bean.setLongDescription(longdescElement.getText());
    bean.setLongDescriptionKey(longdescElement.getAttributeValue("key"));
  }
}

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

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

代码示例来源:origin: apache/oozie

private static String getTagElement(Element elem, String tagName) {
  if (elem != null
      && elem.getChild(tagName, elem.getNamespace("sla")) != null) {
    return elem.getChild(tagName, elem.getNamespace("sla")).getText()
        .trim();
  }
  else {
    return null;
  }
}

代码示例来源:origin: apache/oozie

/**
 * Return the sharelib name for the action.
 *
 * @return returns <code>streaming</code> if mapreduce-streaming action, <code>NULL</code> otherwise.
 * @param actionXml
 */
@Override
protected String getDefaultShareLibName(Element actionXml) {
  Namespace ns = actionXml.getNamespace();
  return (actionXml.getChild("streaming", ns) != null) ? "mapreduce-streaming" : null;
}

代码示例来源: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: apache/oozie

@SuppressWarnings("unchecked")
public Configuration getActionConf(CoordinatorActionBean actionBean) throws JDOMException {
  Configuration conf = new XConfiguration();
  Element eAction = XmlUtils.parseXml(actionBean.getActionXml());
  Element configElem = eAction.getChild("action", eAction.getNamespace())
      .getChild("workflow", eAction.getNamespace()).getChild("configuration", eAction.getNamespace());
  List<Element> elementList = configElem.getChildren("property", eAction.getNamespace());
  for (Element element : elementList) {
    conf.set(((Element) element.getChildren().get(0)).getText(),
        ((Element) element.getChildren().get(1)).getText());
  }
  return conf;
}

代码示例来源:origin: apache/oozie

private void injectConfigClass(Configuration conf, Element actionXml) {
  // Inject config-class for launcher to use for action
  Element e = actionXml.getChild("config-class", actionXml.getNamespace());
  if (e != null) {
    conf.set(LauncherAMUtils.OOZIE_ACTION_CONFIG_CLASS, e.getTextTrim());
  }
}

代码示例来源:origin: org.openwfe/openwfe-engine

protected java.util.List decodeHistory (final org.jdom.Element elt)
{
  java.util.List history = new java.util.ArrayList(7);
  org.jdom.Element hElt = elt.getChild(HISTORY, elt.getNamespace());
  if (hElt == null) return history;
  java.util.Iterator it = hElt
    .getChildren(HISTORY_ITEM, elt.getNamespace())
    .iterator();
  while (it.hasNext())
    history.add(decodeHistoryItem((org.jdom.Element)it.next()));
  return history;
}

代码示例来源:origin: banq/jdonframework

public static  Map loadMapping(String fileName, String nodeName, String keyName,
            String valueName) {
 Map map = new HashMap();
 FileLocator fileLocator = new FileLocator();
 try {
  String xmlFile = fileLocator.getConfFile(fileName);
  Debug.logVerbose("[JdonFramework] mapping file:" + xmlFile, module);
  SAXBuilder builder = new SAXBuilder();
  Document doc = builder.build(new File(xmlFile));
  Debug.logVerbose("[JdonFramework] got mapping file ", module);
  // Get the root element
  Element root = doc.getRootElement();
  List mappings = root.getChildren(nodeName);
  Iterator i = mappings.iterator();
  while (i.hasNext()) {
   Element mapping = (Element) i.next();
   String key = mapping.getChild(keyName).getTextTrim();
   String value = mapping.getChild(valueName).getTextTrim();
    Debug.logVerbose("[JdonFramework] get the " + key + "=" + value, module);
   map.put(key, value);
  }
  Debug.logVerbose("[JdonFramework] read finished", module);
 } catch (Exception ex) {
  Debug.logError("[JdonFramework] error: " + ex, module);
 }
 return map;
}

代码示例来源:origin: JetBrains/ideavim

public void readData(@NotNull Element element) {
 logger.debug("readData");
 Element search = element.getChild("search");
 if (search == null) {
  return;
 }
 lastSearch = getSafeChildText(search, "last-search");
 lastOffset = getSafeChildText(search, "last-offset");
 lastPattern = getSafeChildText(search, "last-pattern");
 lastReplace = getSafeChildText(search, "last-replace");
 lastSubstitute = getSafeChildText(search, "last-substitute");
 Element dir = search.getChild("last-dir");
 lastDir = Integer.parseInt(dir.getText());
 Element show = search.getChild("show-last");
 final ListOption vimInfo = Options.getInstance().getListOption(Options.VIMINFO);
 final boolean disableHighlight = vimInfo != null && vimInfo.contains("h");
 showSearchHighlight = !disableHighlight && Boolean.valueOf(show.getText());
 if (logger.isDebugEnabled()) {
  logger.debug("show=" + show + "(" + show.getText() + ")");
  logger.debug("showSearchHighlight=" + showSearchHighlight);
 }
}

代码示例来源:origin: apache/oozie

private void doChmodOperation(Context context, XConfiguration fsConf, Path nameNodePath,
               Element commandElement) throws ActionExecutorException {
  Path path = getPath(commandElement, FS_TAG_PATH);
  String permissionsTag = commandElement.getAttributeValue(FS_TAG_PERMISSIONS).trim();
  String dirFilesTag = commandElement.getAttributeValue(FS_TAG_DIRFILES);
  boolean dirFiles = (dirFilesTag == null) || Boolean.parseBoolean(dirFilesTag);
  boolean recursive = commandElement.getChild(FS_TAG_RECURSIVE, commandElement.getNamespace()) != null;
  chmod(context, fsConf, nameNodePath, path, permissionsTag, dirFiles, recursive);
}

代码示例来源: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: 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(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.getChild(STORE_TRANSFORM_SERIALIZER_ELMT) != null)
    transformSerializer = readSerializer(store.getChild(STORE_TRANSFORM_SERIALIZER_ELMT));

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

private DocAffiliation restoreAffiliation(Element root) {
  DocAffiliation affiliation = new DocAffiliation();
  
  affiliation.setKey(root.getAttributeValue(MetadataDumpConstants.A_KEY));
  Element e = root.getChild(MetadataDumpConstants.E_TEXT);
  if (e != null)
    affiliation.setText(e.getTextTrim());
  return affiliation;
}

代码示例来源:origin: kiegroup/optaplanner

shiftOffRequestList = Collections.emptyList();
} else {
  List<Element> shiftOffElementList = (List<Element>) shiftOffRequestsElement.getChildren();
  shiftOffRequestList = new ArrayList<>(shiftOffElementList.size());
  long id = 0L;
    shiftOffRequest.setId(id);
    Element employeeElement = element.getChild("EmployeeID");
    Employee employee = employeeMap.get(employeeElement.getText());
    if (employee == null) {
      throw new IllegalArgumentException("The shift (" + employeeElement.getText()
          + ") of shiftOffRequest (" + shiftOffRequest + ") does not exist.");
    Element dateElement = element.getChild("Date");
    Element shiftTypeElement = element.getChild("ShiftTypeID");
    LocalDate date = LocalDate.parse(dateElement.getText(), DateTimeFormatter.ISO_DATE);
    Shift shift = dateAndShiftTypeToShiftMap.get(Pair.of(date, shiftTypeElement.getText()));
    if (shift == null) {

相关文章

微信公众号

最新文章

更多