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

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

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

Element.getAttributeValue介绍

[英]This returns the attribute value for the attribute with the given name and within no namespace, null if there is no such attribute, and the empty string if the attribute value is empty.
[中]这将返回具有给定名称且不在任何命名空间内的属性的属性值,如果没有此类属性,则返回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: go-lang-plugin-org/go-lang-idea-plugin

private static boolean isAttachProjectDirToLibraries(Element rootElement) {
 Element goProjectSettings = JDomSerializationUtil.findComponent(rootElement, "GoProjectSettings");
 if (goProjectSettings != null) {
  for (Element option : goProjectSettings.getChildren("option")) {
   if ("prependGoPath".equals(option.getAttributeValue("name"))) {
    goProjectSettings.detach();
    return "true".equalsIgnoreCase(option.getAttributeValue("value"));
   }
  }
  goProjectSettings.detach();
 }
 return false;
}

代码示例来源: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) {
    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)

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

public void parse(Element root, Map mps) throws Exception {        
  List components = root.getChildren("component");
  Debug.logVerbose("[JdonFramework] found component size:" + components.size(), module);
  Iterator iter = components.iterator();
   String name = component.getAttributeValue("name");
   String className = component.getAttributeValue("class");   
   List mappings = component.getChildren("constructor");
   String[] constructors = null;
   if ((mappings != null) && (mappings.size() != 0)) {
     while (i.hasNext()) {
      Element constructor = (Element) i.next();
      String value = constructor.getAttributeValue("value");
      Debug.logVerbose("[JdonFramework] component constructor=" + value, module);
      constructors[j] = value;

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

@Override
public void loadState(@NotNull final Element element) {
 LOG.debug("Loading state");
 // Restore whether the plugin is enabled or not
 Element state = element.getChild("state");
 if (state != null) {
  try {
   previousStateVersion = Integer.valueOf(state.getAttributeValue("version"));
  }
  catch (NumberFormatException ignored) {
  }
  enabled = Boolean.valueOf(state.getAttributeValue("enabled"));
  previousKeyMap = state.getAttributeValue("keymap");
 }
 mark.readData(element);
 register.readData(element);
 search.readData(element);
 history.readData(element);
 key.readData(element);
 editor.readData(element);
}

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

public void readData(@NotNull final Element element) {
 logger.debug("readData");
 final Element registersElement = element.getChild("registers");
 if (registersElement != null) {
  final List<Element> registerElements = registersElement.getChildren("register");
  for (Element registerElement : registerElements) {
   final char key = registerElement.getAttributeValue("name").charAt(0);
   final Register register;
   final Element textElement = registerElement.getChild("text");
   final String typeText = registerElement.getAttributeValue("type");
   final SelectionType type = SelectionType.fromValue(Integer.parseInt(typeText));
   if (textElement != null) {
    final Element keysElement = registerElement.getChild("keys");
    final List<Element> keyElements = keysElement.getChildren("key");
    final List<KeyStroke> strokes = new ArrayList<>();
    for (Element keyElement : keyElements) {
     final int code = Integer.parseInt(keyElement.getAttributeValue("code"));
     final int modifiers = Integer.parseInt(keyElement.getAttributeValue("mods"));
     final char c = (char)Integer.parseInt(keyElement.getAttributeValue("char"));

代码示例来源:origin: x-ream/x7

Element configRoot = doc.getRootElement();
List<?> configList = configRoot.getChildren("book");
fileNames.clear();
  Element configItem = (Element) configObject;
  String fileName = configItem.getAttributeValue("name");
  fileNames.add(fileName);
  fileSheetNameClassMap.put(fileName, sheetNameList);
  List<Element> sheetElementList = configItem.getChildren("sheet");
    String sheetName = sheetE.getAttributeValue("name");
      Class<ITemplateable> clz = (Class<ITemplateable>) Class.forName(sheetE.getAttributeValue("type"));

代码示例来源:origin: org.sakaiproject.metaobj/sakai-metaobj-impl

protected String processStringRestriction(Element restrictions, String s, Namespace xsdNamespace) {
 Element currentRestriction = restrictions.getChild(s, xsdNamespace);
 if (currentRestriction == null) {
   return null;
 }
 return currentRestriction.getAttributeValue("value");
}

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

Element marksElem = element.getChild("globalmarks");
if (marksElem != null) {
 List markList = marksElem.getChildren("mark");
 for (Object aMarkList : markList) {
  Element markElem = (Element)aMarkList;
  Mark mark = new Mark(markElem.getAttributeValue("key").charAt(0),
             Integer.parseInt(markElem.getAttributeValue("line")),
             Integer.parseInt(markElem.getAttributeValue("column")),
             markElem.getAttributeValue("filename"),
             markElem.getAttributeValue("protocol"));
Element fileMarksElem = element.getChild("filemarks");
if (fileMarksElem != null) {
 List fileList = fileMarksElem.getChildren("file");
 for (Object aFileList : fileList) {
  Element fileElem = (Element)aFileList;
  String filename = fileElem.getAttributeValue("name");
  Date timestamp = new Date();
  try {
   long date = Long.parseLong(fileElem.getAttributeValue("timestamp"));
   timestamp.setTime(date);
  List markList = fileElem.getChildren("mark");
  for (Object aMarkList : markList) {
   Element markElem = (Element)aMarkList;
   Mark mark = new Mark(markElem.getAttributeValue("key").charAt(0),
              Integer.parseInt(markElem.getAttributeValue("line")),
              Integer.parseInt(markElem.getAttributeValue("column")),
              filename,

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

public void parse(Element root, Map mps) throws Exception {
  List interceptors = root.getChildren("interceptor");
  Debug.logVerbose("[JdonFramework] found interceptor size:" + interceptors.size(), module);
  Iterator iter = interceptors.iterator();
    String name = component.getAttributeValue("name");
    Debug.logVerbose("[JdonFramework] found interceptor name:" + name, module);
    String className = component.getAttributeValue("class");
    String pointcut = component.getAttributeValue("pointcut");
    List mappings = component.getChildren("constructor");
    String[] constructors = null;
    if ((mappings != null) && (mappings.size() != 0)) {
      while (i.hasNext()) {
        Element constructor = (Element) i.next();
        String value = constructor.getAttributeValue("value");
        Debug.logVerbose("[JdonFramework] interceptor " + name + "constructor=" + value, module);
        constructors[j] = value;

代码示例来源:origin: dragome/dragome-sdk

/**
 * Returns a comma-separated list of interfaces this resources implements.
 */
public String getInterfaces()
{
  Element clazz= xmlvmDocument.getRootElement().getChild(TAG_CLASS, nsXMLVM);
  return clazz.getAttributeValue("interfaces");
}

代码示例来源:origin: hsz/idea-gitignore

/**
 * Loads {@link UserTemplate} objects from the {@link Element}.
 *
 * @param element source
 * @return {@link UserTemplate} list
 */
@NotNull
public static List<UserTemplate> loadTemplates(@NotNull Element element) {
  final String key = KEY.USER_TEMPLATES.toString();
  final List<UserTemplate> list = ContainerUtil.newArrayList();
  if (!key.equals(element.getName())) {
    element = element.getChild(key);
  }
  for (Element template : element.getChildren()) {
    list.add(new UserTemplate(
        template.getAttributeValue(KEY.USER_TEMPLATES_NAME.toString()),
        template.getText()
    ));
  }
  return list;
}

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

String name = pojoService.getAttributeValue("name");
String className = pojoService.getAttributeValue("class");
Debug.logVerbose("[JdonFramework] pojoService/component name=" + name
    + " class=" + className, module);
  throw new Exception("className is null ");
List mappings = pojoService.getChildren("constructor");
String[] constructors = null;
if ((mappings != null) && (mappings.size() != 0)) {
  while (i.hasNext()) {
    Element constructor = (Element) i.next();
    String value = constructor.getAttributeValue("value");
    Debug.logVerbose("[JdonFramework] pojoService constructor="
        + value, module);

代码示例来源:origin: dragome/dragome-sdk

/**
 * @return the size of the interface table
 */
public Integer getInterfaceTableSize()
{
  Element clazz= xmlvmDocument.getRootElement().getChild(TAG_CLASS, nsXMLVM);
  String interfaceTableSize= clazz.getAttributeValue(ATTRIBUTE_INTERFACE_TABLE_SIZE);
  return interfaceTableSize == null ? null : Integer.parseInt(interfaceTableSize);
}

代码示例来源:origin: hsz/idea-gitignore

String value = element.getAttributeValue(KEY.MISSING_GITIGNORE.toString());
if (value != null) {
  missingGitignore = Boolean.parseBoolean(value);
value = element.getAttributeValue(KEY.IGNORED_FILE_STATUS.toString());
if (value != null) {
  ignoredFileStatus = Boolean.parseBoolean(value);
value = element.getAttributeValue(KEY.OUTER_IGNORE_RULES.toString());
if (value != null) {
  outerIgnoreRules = Boolean.parseBoolean(value);
value = element.getAttributeValue(KEY.VERSION.toString());
if (value != null) {
  version = value;
value = element.getAttributeValue(KEY.OUTER_IGNORE_WRAPPER_HEIGHT.toString());
if (value != null) {
  outerIgnoreWrapperHeight = Integer.parseInt(value);
value = element.getAttributeValue(KEY.STARRED_TEMPLATES.toString());
if (value != null) {
  setStarredTemplates(StringUtil.split(value, Constants.DOLLAR));
value = element.getAttributeValue(KEY.HIDE_IGNORED_FILES.toString());
if (value != null) {
  hideIgnoredFiles = Boolean.parseBoolean(value);
value = element.getAttributeValue(KEY.INFORM_TRACKED_IGNORED.toString());

代码示例来源:origin: stackoverflow.com

Element root = doc.getRootElement();
 List children = root.getChildren();     
 out.println(root);  
 if (children != null)
 {
   for (Element child : children) 
   {
    out.println(child.getAttributeValue( "Title" ));
   }
 }

代码示例来源:origin: dragome/dragome-sdk

/**
 * Checks if this class is abstract
 * 
 * @return true if it's an abstract class otherwise false
 */
public boolean isAbstract()
{
  Element clazz= xmlvmDocument.getRootElement().getChild(TAG_CLASS, nsXMLVM);
  String flag= clazz.getAttributeValue("isAbstract");
  return flag != null && flag.equals("true");
}

代码示例来源:origin: mars-sim/mars-sim

private String getValueAsString(int index, String param) {
  Element root = robotDoc.getRootElement();
  Element robotList = root.getChild(ROBOT_LIST);
  Element robotElement = (Element) robotList.getChildren(ROBOT).get(index);
  return robotElement.getAttributeValue(param);
}

代码示例来源:origin: stackoverflow.com

public void loadXML(Element root) {

    Element child;

  //Naslov naslov;  // for Naslov because it could be an object itself

    davcna = root.getAttributeValue(Constants.DAVCNA); //define the string constant
    matSub = root.getAttributeValue(Constants.MATSUB); //define the string constant
    drz = Integer.parseInt(root.getAttributeValue(Constants.DRZ)); //define the string constant


    List children = root.getChildren(); // your root is Imetnik now

    for (Iterator iter = children.iterator(); iter.hasNext();) {
     .....
     .......
    }
}

相关文章

微信公众号

最新文章

更多