org.jdom2.Attribute.getValue()方法的使用及代码示例

x33g5p2x  于2022-01-15 转载在 其他  
字(13.4k)|赞(0)|评价(0)|浏览(118)

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

Attribute.getValue介绍

[英]This will return the actual textual value of this Attribute. This will include all text within the quotation marks.
[中]这将返回此Attribute的实际文本值。这将包括引号内的所有文本。

代码示例

代码示例来源:origin: gocd/gocd

public String getAttribute(Element e, String attribute) {
  Attribute attr = e.getAttribute(attribute);
  if(attr == null) {
    throw bomb("Error finding attribute '" + attribute + "' in config: " + configFile + elementOutput(e));
  }
  return attr.getValue();
}

代码示例来源:origin: jwpttcg66/NettyGameServer

public FieldObject(Element element){
  this.type = element.getAttributeValue("type");
  this.name = element.getAttributeValue("name");
  this.comment =element.getAttributeValue("comment");
  
  Attribute genericAttr = element.getAttribute("generic");
  if(genericAttr != null){
    this.generic = genericAttr.getValue();
  }
  
  MacroObject macroObj = MacroObject.getAllMacros().get(this.type);
  if(macroObj != null){
    this.selfObj = macroObj;
  }
  macroObj = MacroObject.getAllMacros().get(this.generic);
  if(macroObj != null){
    this.genericObj = macroObj;
  }
}

代码示例来源:origin: rometools/rome

/**
 * Return URL string of Atom link element under parent element. Link with no rel attribute is
 * considered to be rel="alternate"
 *
 * @param parent Consider only children of this parent element
 * @param rel Consider only links with this relationship
 */
private String findAtomLink(final Element parent, final String rel) {
  String ret = null;
  final List<Element> linksList = parent.getChildren("link", ATOM_10_NS);
  if (linksList != null) {
    for (final Element element : linksList) {
      final Element link = element;
      final Attribute relAtt = getAttribute(link, "rel");
      final Attribute hrefAtt = getAttribute(link, "href");
      if (relAtt == null && "alternate".equals(rel) || relAtt != null && relAtt.getValue().equals(rel)) {
        ret = hrefAtt.getValue();
        break;
      }
    }
  }
  return ret;
}

代码示例来源:origin: rometools/rome

/** Use feed links and/or xml:base attribute to determine baseURI of feed */
  private static URL findBaseURI(final Element root) {
    URL baseURI = null;
    final List<Element> linksList = root.getChildren("link", OS_NS);
    if (linksList != null) {
      for (final Element element : linksList) {
        final Element link = element;
        if (!root.equals(link.getParent())) {
          break;
        }
        String href = link.getAttribute("href").getValue();
        if (link.getAttribute("rel", OS_NS) == null || link.getAttribute("rel", OS_NS).getValue().equals("alternate")) {
          href = resolveURI(null, link, href);
          try {
            baseURI = new URL(href);
            break;
          } catch (final MalformedURLException e) {
            System.err.println("Base URI is malformed: " + href);
          }
        }
      }
    }
    return baseURI;
  }
}

代码示例来源:origin: rometools/rome

protected void parseCategoriesElement(final Element catsElem) {
  if (catsElem.getAttribute("href", AtomService.ATOM_PROTOCOL) != null) {
    setHref(catsElem.getAttribute("href", AtomService.ATOM_PROTOCOL).getValue());
  }
  if (catsElem.getAttribute("fixed", AtomService.ATOM_PROTOCOL) != null) {
    if ("yes".equals(catsElem.getAttribute("fixed", AtomService.ATOM_PROTOCOL).getValue())) {
      setFixed(true);
    }
  }
  if (catsElem.getAttribute("scheme", AtomService.ATOM_PROTOCOL) != null) {
    setScheme(catsElem.getAttribute("scheme", AtomService.ATOM_PROTOCOL).getValue());
  }
  // Loop to parse <atom:category> elemenents to Category objects
  final List<Element> catElems = catsElem.getChildren("category", AtomService.ATOM_FORMAT);
  for (final Element catElem : catElems) {
    final Category cat = new Category();
    cat.setTerm(catElem.getAttributeValue("term", AtomService.ATOM_FORMAT));
    cat.setLabel(catElem.getAttributeValue("label", AtomService.ATOM_FORMAT));
    cat.setScheme(catElem.getAttributeValue("scheme", AtomService.ATOM_FORMAT));
    addCategory(cat);
  }
}

代码示例来源:origin: rometools/rome

attributes.add(new Attribute(a.getName(), a.getValue()));
final List<Element> children = e.getChildren("outline");
outline.setModules(parseItemModules(e, locale));
outline.setChildren(parseOutlines(children, validate, locale));

代码示例来源:origin: Unidata/thredds

/**
 * A convienience function used for displaying information in _Debug mode.
 * Prints an XML element's name, content (if any) and Attributes to
 * System.out
 */
private void showXMLElement(Element e, String indent) {
  System.out.print(parseLevel + indent + "Element: " + e.getName() + "  ");
  String text = e.getTextNormalize();
  if (!text.equals(""))
    System.out.print(" = " + text + "   ");
  //System.out.println("");
 for (Attribute att : e.getAttributes()) {
  //System.out.print(parseLevel + indent + "    ");
  System.out.print(att.getName() + ": " + att.getValue() + "  ");
 }
  System.out.println("");
 for (Element kid : e.getChildren()) {
  showXMLElement(kid, indent + "    ");
 }
}

代码示例来源:origin: com.rometools/rome-modules

/** Use feed links and/or xml:base attribute to determine baseURI of feed */
  private static URL findBaseURI(final Element root) {
    URL baseURI = null;
    final List<Element> linksList = root.getChildren("link", OS_NS);
    if (linksList != null) {
      for (final Element element : linksList) {
        final Element link = element;
        if (!root.equals(link.getParent())) {
          break;
        }
        String href = link.getAttribute("href").getValue();
        if (link.getAttribute("rel", OS_NS) == null || link.getAttribute("rel", OS_NS).getValue().equals("alternate")) {
          href = resolveURI(null, link, href);
          try {
            baseURI = new URL(href);
            break;
          } catch (final MalformedURLException e) {
            System.err.println("Base URI is malformed: " + href);
          }
        }
      }
    }
    return baseURI;
  }
}

代码示例来源:origin: gocd/gocd

List<Element> encryptedPasswordElements = xpathExpression.evaluate(document);
for (Element element : encryptedPasswordElements) {
  Attribute encryptedPassword = element.getAttribute(attributeName);
  encryptedPassword.setValue(reEncryptUsingNewKey(decodeHex(oldCipher), decodeHex(newCipher), encryptedPassword.getValue()));
  LOGGER.debug("Replaced encrypted value at {}", element.toString());

代码示例来源:origin: ch.epfl.bbp.nlp/bluima_xml

Element rootNode = doc.getRootElement();
Iterator<Element> cs = rootNode.getChildren().iterator();
while (cs.hasNext()) {
  Element concept = cs.next();
  List<Element> variants = concept.getChild("synonyms").getChildren();
  for (Element variant : variants) {
    if (variant.getAttribute("synonymLanguage").getValue()
        .matches("Latin|English")) {

代码示例来源:origin: Renanse/Ardor3D

str.append(attr.getName());
  str.append("=\"");
  str.append(attr.getValue());
  str.append('"');
  if (i < attrs.size() - 1) {
if (!e.getChildren().isEmpty() || !"".equals(e.getText())) {
  str.append('>');
  if (depth < maxDepth) {
    str.append('\n');
    for (final Element child : e.getChildren()) {
      getElementString(child, str, depth + 1, maxDepth, showDots);

代码示例来源:origin: org.mycore.mir/mir-module

/**
   * Checks if given user is exists.
   *
   * @param nodes the user element
   * @return true on exists or false if not
   */
  public static boolean userExists(final List<Element> nodes) {
    final Element user = nodes.get(0);
    final String userName = user.getAttributeValue("name");
    final String realmId = user.getAttribute("realm").getValue();

    LOGGER.debug("check user exists " + userName + " " + realmId);
    return MCRUserManager.exists(userName, realmId);
  }
}

代码示例来源:origin: com.rometools/rome

/**
 * Return URL string of Atom link element under parent element. Link with no rel attribute is
 * considered to be rel="alternate"
 *
 * @param parent Consider only children of this parent element
 * @param rel Consider only links with this relationship
 */
private String findAtomLink(final Element parent, final String rel) {
  String ret = null;
  final List<Element> linksList = parent.getChildren("link", ATOM_10_NS);
  if (linksList != null) {
    for (final Element element : linksList) {
      final Element link = element;
      final Attribute relAtt = getAttribute(link, "rel");
      final Attribute hrefAtt = getAttribute(link, "href");
      if (relAtt == null && "alternate".equals(rel) || relAtt != null && relAtt.getValue().equals(rel)) {
        ret = hrefAtt.getValue();
        break;
      }
    }
  }
  return ret;
}

代码示例来源:origin: org.apache.marmotta/sesame-tools-rio-rss

/** Use feed links and/or xml:base attribute to determine baseURI of feed */
  private static URL findBaseURI(Element root) {
    URL baseURI = null;
    List linksList = root.getChildren("link", OS_NS);
    if (linksList != null) {
      for (Iterator links = linksList.iterator(); links.hasNext(); ) {
        Element link = (Element)links.next();
        if (!root.equals(link.getParent())) break;
        String href = link.getAttribute("href").getValue();
        if (   link.getAttribute("rel", OS_NS) == null
          || link.getAttribute("rel", OS_NS).getValue().equals("alternate")) {
          href = resolveURI(null, link, href);
          try {
            baseURI = new URL(href);
            break;
          } catch (MalformedURLException e) {
            System.err.println("Base URI is malformed: " + href);
          }
        }
      }
    }
    return baseURI;
  } 
}

代码示例来源:origin: gocd/gocd

public T parse() {
  bombUnless(atElement(),
      "Unable to parse element <" + e.getName() + "> for class " + aClass.getSimpleName());
  T o = createInstance();
  if (isAnnotationPresent(aClass, ConfigReferenceCollection.class)) {
    ConfigReferenceCollection referenceCollection = aClass.getAnnotation(ConfigReferenceCollection.class);
    String collectionName = referenceCollection.collectionName();
    String idFieldName = referenceCollection.idFieldName();
    if (e.getAttribute(idFieldName) != null) {
      String id = e.getAttribute(idFieldName).getValue();
      configReferenceElements.add(collectionName, id, o);
    }
  }
  for (GoConfigFieldLoader field : allFields(o)) {
    field.parse();
  }
  if (isConfigCollection()) {
    parseCollection((Collection) o);
  }
  //check whether there are public PostConstruct methods and call them
  postConstruct(o);
  return o;
}

代码示例来源:origin: Renanse/Ardor3D

final AnimationItem animationItemRoot) {
if (animationRoot.getChild("animation") != null) {
  Attribute nameAttribute = animationRoot.getAttribute("name");
  if (nameAttribute == null) {
    nameAttribute = animationRoot.getAttribute("id");
  final String name = nameAttribute != null ? nameAttribute.getValue() : "Default";
  for (final Element animationElement : animationRoot.getChildren("animation")) {
    parseAnimations(channelMap, animationElement, animationItem);
    logger.fine("\n-- Parsing animation channels --");
  final List<Element> channels = animationRoot.getChildren("channel");
  for (final Element channel : channels) {
    final String source = channel.getAttributeValue("source");

代码示例来源:origin: bcdev/beam

private static void addDomToMetadata(Element childDE, String name, MetadataElement parentME) {
  if (childDE.getChildren().size() > 0 || childDE.getAttributes().size() > 0) {
    final MetadataElement childME = new MetadataElement(name);
    addDomToMetadata(childDE, childME);
    parentME.addElement(childME);
    if (childDE.getAttributes().size() != 0) {
      List attrList = childDE.getAttributes();
      for (Object o : attrList) {
        Attribute attribute = (Attribute) o;
        String attributeName = attribute.getName();
        String attributeValue = attribute.getValue();
        final ProductData valueMEAtrr = ProductData.createInstance(attributeValue);
        final MetadataAttribute mdAttribute = new MetadataAttribute(attributeName, valueMEAtrr, true);
        childME.addAttribute(mdAttribute);
      }
    }
  } else {
    String valueDE = childDE.getValue();
    if (valueDE == null) {
      valueDE = "";
    }
    final ProductData valueME = ProductData.createInstance(valueDE);
    final MetadataAttribute attribute = new MetadataAttribute(name, valueME, true);
    parentME.addAttribute(attribute);
  }
}

代码示例来源:origin: pwm-project/pwm

private static StoredResponseItem parseAnswerElement( final Element element )
{
  final String answerValue = element.getText();
  final String salt = element.getAttribute( XML_ATTRIBUTE_SALT ) == null ? "" : element.getAttribute( XML_ATTRIBUTE_SALT ).getValue();
  final String hashCount = element.getAttribute( XML_ATTRIBUTE_HASH_COUNT ) == null ? "1" : element.getAttribute( XML_ATTRIBUTE_HASH_COUNT ).getValue();
  int saltCount = 1;
  try
  {
    saltCount = Integer.parseInt( hashCount );
  }
  catch ( NumberFormatException e )
  { /* noop */ }
  final String formatStr = element.getAttributeValue( XML_ATTRIBUTE_CONTENT_FORMAT ) == null ? "" : element.getAttributeValue( XML_ATTRIBUTE_CONTENT_FORMAT );
  return StoredResponseItem.builder()
      .format( formatStr )
      .salt( salt )
      .hash( answerValue )
      .iterations( saltCount )
      .build();
}

代码示例来源:origin: org.apache.marmotta/sesame-tools-rio-rss

/** 
 * Return URL string of Atom link element under parent element.
 * Link with no rel attribute is considered to be rel="alternate"
 * @param parent Consider only children of this parent element
 * @param rel    Consider only links with this relationship
 */
private  String findAtomLink(Element parent, String rel) {
  String ret = null;
  List linksList = parent.getChildren("link", ATOM_10_NS);
  if (linksList != null) {
    for (Iterator links = linksList.iterator(); links.hasNext(); ) {
      Element link = (Element)links.next();
      Attribute relAtt = getAttribute(link, "rel");
      Attribute hrefAtt = getAttribute(link, "href");
      if (   (relAtt == null && "alternate".equals(rel)) 
        || (relAtt != null && relAtt.getValue().equals(rel))) {
        ret = hrefAtt.getValue();
        break;
      }
    }
  }
  return ret;
}

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

/** Use feed links and/or xml:base attribute to determine baseURI of feed */
  private static URL findBaseURI(Element root) {
    URL baseURI = null;
    List linksList = root.getChildren("link", OS_NS);
    if (linksList != null) {
      for (Object aLinksList : linksList) {
        Element link = (Element) aLinksList;
        if (!root.equals(link.getParent())) break;
        String href = link.getAttribute("href").getValue();
        if (link.getAttribute("rel", OS_NS) == null
            || link.getAttribute("rel", OS_NS).getValue().equals("alternate")) {
          href = resolveURI(null, link, href);
          try {
            baseURI = new URL(href);
            break;
          } catch (MalformedURLException e) {
            System.err.println("Base URI is malformed: " + href);
          }
        }
      }
    }
    return baseURI;
  } 
}

相关文章