org.jdom.Attribute.getName()方法的使用及代码示例

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

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

Attribute.getName介绍

[英]This will retrieve the local name of the Attribute. For any XML attribute which appears as [namespacePrefix]:[attributeName], the local name of the attribute would be [attributeName]. When the attribute has no namespace, the local name is simply the attribute name.

To obtain the namespace prefix for this attribute, the #getNamespacePrefix() method should be used.
[中]这将检索Attribute的本地名称。对于任何显示为[namespacePrefix]:[attributeName]的XML属性,该属性的本地名称将为[attributeName]。当属性没有名称空间时,本地名称就是属性名称。
要获取此属性的命名空间前缀,应使用#getNamespacePrefix()方法。

代码示例

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

public String getAttributeName(Object obj)
{
  Attribute attr = (Attribute) obj;
  return attr.getName();
}

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

public String getAttributeQName(Object obj)
{
  Attribute attr = (Attribute) obj;
  String prefix = attr.getNamespacePrefix();
  if ( prefix == null || "".equals( prefix ) )
  {
    return attr.getName();
  }
  return prefix + ":" + attr.getName();
}

代码示例来源:origin: org.freemarker/freemarker

public List operate(Object node) {
      if (node instanceof Element) {
        Element element = (Element) node;
        return Collections.singletonList(element.getNamespace().getURI() + element.getName());
      } else if (node instanceof Attribute) {
        Attribute attribute = (Attribute) node;
        return Collections.singletonList(attribute.getNamespace().getURI() + attribute.getName());
      }
      // With 2.1 semantics it  makes more sense to just return a null and let the core 
      // throw an InvalidReferenceException and the template writer can use ?exists etcetera. (JR)
      return null;
//            throw new TemplateModelException("_cname can not be applied on " + node.getClass());
    }
  }

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

public QName getAttributeName(int i) {
  Attribute at = getAttribute(i);
  return new QName(at.getNamespaceURI(), at.getName(), at.getNamespacePrefix());
}

代码示例来源:origin: org.freemarker/freemarker

public List operate(Object node) {
      if (node instanceof Element)
        return Collections.singletonList(((Element) node).getName());
      else if (node instanceof Attribute)
        return Collections.singletonList(((Attribute) node).getName());
      else if (node instanceof EntityRef)
        return Collections.singletonList(((EntityRef) node).getName());
      else if (node instanceof ProcessingInstruction)
        return Collections.singletonList(((ProcessingInstruction) node).getTarget());
      else if (node instanceof DocType)
        return Collections.singletonList(((DocType) node).getPublicID());
      else
        return null;
      // With 2.1 semantics it  makes more sense to just return a null and let the core 
      // throw an InvalidReferenceException and the template writer can use ?exists etcetera. (JR)
//                throw new TemplateModelException("_name can not be applied on " + node.getClass());
    }
  }

代码示例来源:origin: org.jdom/jdom-legacy

/**
 * Return index of attribute with same name and Namespace, or
 * -1 if one doesn't exist
 */
private int indexOfDuplicate(Attribute attribute) {
  int duplicate = -1;
  String name = attribute.getName();
  Namespace namespace = attribute.getNamespace();
  duplicate = indexOf(name, namespace);
  return duplicate;
}

代码示例来源:origin: org.freemarker/freemarker

public Object exec(List arguments) {
    Set names = new HashSet(arguments);
    List list = new LinkedList(nodes);
    Iterator it = list.iterator();
    while (it.hasNext()) {
      Object node = it.next();
      String name = null;
      if (node instanceof Element)
        name = ((Element) node).getName();
      else if (node instanceof Attribute)
        name = ((Attribute) node).getName();
      else if (node instanceof ProcessingInstruction)
        name = ((ProcessingInstruction) node).getTarget();
      else if (node instanceof EntityRef)
        name = ((EntityRef) node).getName();
      else if (node instanceof DocType)
        name = ((DocType) node).getPublicID();
      if (name == null || !names.contains(name))
        it.remove();
    }
    return createNodeListModel(list, namespaces);
  }
}

代码示例来源:origin: org.sonatype.maven.archetype/archetype-common

private void printQualifiedName(Writer out, Attribute a) throws IOException {
  String prefix=a.getNamespace().getPrefix();
  if ((prefix != null) && (!prefix.equals(""))) {
    out.write(prefix);
    out.write(':');
    out.write(a.getName());
  }
  else {
    out.write(a.getName());
  }
}

代码示例来源:origin: org.freemarker/freemarker

@Override
String getLocalName(Object node) {
  if (node instanceof Element) {
    return ((Element) node).getName();
  }
  if (node instanceof Attribute) {
    return ((Attribute) node).getName();
  }
  if (node instanceof EntityRef) {
    return ((EntityRef) node).getName();
  }
  if (node instanceof ProcessingInstruction) {
    return ((ProcessingInstruction) node).getTarget();
  }
  if (node instanceof DocType) {
    return ((DocType) node).getElementName();
  }
  return null;
}

代码示例来源:origin: org.jdom/jdom-legacy

private void printQualifiedName(Writer out, Attribute a) throws IOException {
  String prefix = a.getNamespace().getPrefix();
  if ((prefix != null) && (!prefix.equals(""))) {
    out.write(prefix);
    out.write(':');
    out.write(a.getName());
  }
  else {
    out.write(a.getName());
  }
}

代码示例来源:origin: com.google.code.sortpom/maven-sortpom-sorter

@Override
  public int compare(final Attribute o1, final Attribute o2) {
    return o1.getName().compareTo(o2.getName());
  }
}

代码示例来源:origin: org.compass-project/compass

/**
 * Returns the JDOM node name.
 */
public String getName() {
  if (attribute != null) {
    return attribute.getName();
  }
  return element.getName();
}

代码示例来源:origin: info.magnolia/magnolia-core

@Override
protected void printName(Writer out, Attribute a) throws IOException {
  out.write(decode(a.getName()));
}

代码示例来源:origin: codehaus-cargo/cargo

/**
 * @return System property name.
 */
public String getElementId()
{
  return ((Attribute) getAttributes().get(0)).getName();
}

代码示例来源:origin: qcadoo/mes

private void parseAndAddAddressType(final Map<Integer, Map<String, String>> addressTypesAttributes,
    final List<Element> listOfRows, final int rowNum) {
  Element node = listOfRows.get(rowNum);
  @SuppressWarnings("unchecked")
  List<Attribute> listOfAtributes = node.getAttributes();
  Map<String, String> addressTypeAttributes = Maps.newHashMap();
  for (int attributeNum = 0; attributeNum < listOfAtributes.size(); attributeNum++) {
    addressTypeAttributes.put(listOfAtributes.get(attributeNum).getName().toLowerCase(Locale.ENGLISH), listOfAtributes
        .get(attributeNum).getValue());
  }
  addressTypesAttributes.put(rowNum, addressTypeAttributes);
}

代码示例来源:origin: qcadoo/mes

private void parseAndAddColor(final Map<Integer, Map<String, String>> colorsAttributes, final List<Element> listOfRows,
    final int rowNum) {
  Element node = listOfRows.get(rowNum);
  @SuppressWarnings("unchecked")
  List<Attribute> listOfAtributes = node.getAttributes();
  Map<String, String> colorAttributes = Maps.newHashMap();
  for (int attributeNum = 0; attributeNum < listOfAtributes.size(); attributeNum++) {
    colorAttributes.put(listOfAtributes.get(attributeNum).getName().toLowerCase(Locale.ENGLISH),
        listOfAtributes.get(attributeNum).getValue());
  }
  colorsAttributes.put(rowNum, colorAttributes);
}

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

protected java.util.Map extractAttributes (org.jdom.Element elt)
{
  java.util.Map result = new java.util.HashMap();
  java.util.Iterator it = elt.getAttributes().iterator();
  while (it.hasNext())
  {
    org.jdom.Attribute a = (org.jdom.Attribute)it.next();
    result.put(a.getName(), a.getValue());
  }
  return result;
}

代码示例来源:origin: qcadoo/mes

private void parseAndAddCountry(final Element node) {
  @SuppressWarnings("unchecked")
  List<Attribute> attributes = node.getAttributes();
  Map<String, String> values = Maps.newHashMap();
  for (Attribute attribute : attributes) {
    values.put(attribute.getName().toLowerCase(Locale.ENGLISH), attribute.getValue());
  }
  addCountry(values);
}

代码示例来源:origin: qcadoo/mes

private void parseAndAddFaultType(final Element node) {
  @SuppressWarnings("unchecked")
  List<Attribute> attributes = node.getAttributes();
  Map<String, String> values = new HashMap<String, String>();
  for (Attribute attribute : attributes) {
    values.put(attribute.getName().toLowerCase(Locale.ENGLISH), attribute.getValue());
  }
  addAction(values);
}

代码示例来源:origin: qcadoo/mes

private void parseAndAddFaultType(final Element node) {
  @SuppressWarnings("unchecked")
  List<Attribute> attributes = node.getAttributes();
  Map<String, String> values = Maps.newHashMap();
  for (Attribute attribute : attributes) {
    values.put(attribute.getName().toLowerCase(Locale.ENGLISH), attribute.getValue());
  }
  addFaultType(values);
}

相关文章