org.apache.axiom.om.OMAttribute.getLocalName()方法的使用及代码示例

x33g5p2x  于2022-01-25 转载在 其他  
字(10.6k)|赞(0)|评价(0)|浏览(62)

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

OMAttribute.getLocalName介绍

暂无

代码示例

代码示例来源:origin: org.apache.ws.commons.axiom/axiom-api

/**
 * Retrieves the name of the given attribute node.
 *
 * @param object the context attribute node
 * @return Returns the name of the attribute node.
 */
public String getAttributeName(Object object) {
  return ((OMAttribute) object).getLocalName();
}

代码示例来源:origin: org.apache.ws.commons.axiom/axiom-api

/**
 * Retrieves the QName of the given attribute node.
 *
 * @param object the context attribute node
 * @return Returns the qualified name of the attribute node.
 */
public String getAttributeQName(Object object) {
  OMAttribute attr = (OMAttribute) object;
  String prefix = attr.getNamespace().getPrefix();
  if (prefix == null || "".equals(prefix)) {
    return attr.getLocalName();
  }
  return prefix + ":" + attr.getLocalName();
}

代码示例来源:origin: org.apache.ws.commons.axiom/axiom-c14n

public String getLocalName() {
  return (isOMAttribute) ? omattr.getLocalName() : getOMNamespaceLocalName();
}

代码示例来源:origin: org.apache.ws.commons.axiom/axiom-api

/**
 * Gets the collection of attributes which are none namespace declarations for an OMElement
 *
 * @param element
 * @return Returns the collection of attributes which are none namespace declarations
 */
public Collection getAttributesWithoutNS(OMElement element) {
  SortedMap map = new TreeMap();
  Iterator itr = element.getAllAttributes();
  while (itr.hasNext()) {
    OMAttribute attribute = (OMAttribute) itr.next();
    if (!(attribute.getLocalName().equals("xmlns") ||
        attribute.getLocalName().startsWith("xmlns:")))
      map.put(getExpandedName(attribute), attribute);
  }
  return map.values();
}

代码示例来源:origin: usnistgov/iheos-toolkit2

HashMap<String, String> getErrorDetails(OMElement registryError) {
  HashMap<String, String>  err = new HashMap<String, String>();
  for (Iterator<OMAttribute> it=registryError.getAllAttributes(); it.hasNext(); ) {
    OMAttribute att = it.next();
    String name = att.getLocalName();
    String value = att.getAttributeValue();
    err.put(name, value);
  }
  return err;
}

代码示例来源:origin: org.apache.neethi/neethi

public Map<QName, String> getAttributes(OMElement s) {
  Map<QName, String> mp = new HashMap<QName, String>();
  Iterator<?> it = s.getAllAttributes();
  while (it.hasNext()) {
    OMAttribute attr = (OMAttribute)it.next();
    if (attr.getNamespace() == null) {
      mp.put(new QName("", attr.getLocalName()),
          attr.getAttributeValue());
    } else {
      mp.put(new QName(attr.getNamespace().getNamespaceURI(), attr.getLocalName()),
          attr.getAttributeValue());
    }
  }
  return mp;
}

代码示例来源:origin: org.apache.woden/woden-impl-om

/**
 * Returns the value of an attribute of an element. Returns null
 * if the attribute is not found
 * @param omElement Element whose attrib is looked for
 * @param attrName  name of attribute to look for
 * @return the attribute value
 */
public static String getAttribute(OMElement omElement, String attrName) {
  String val = null;
  Iterator allAttr = omElement.getAllAttributes();
  while(allAttr.hasNext()){
    OMAttribute attr = (OMAttribute)allAttr.next();
    if (attr.getLocalName().equals(attrName)){
      val = attr.getAttributeValue();
    }
  }
  return val;
}

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

private Boolean getBoolean(OMElement items) {
  for (Iterator<OMAttribute> iAttr = items.getAllAttributes(); iAttr.hasNext();) {
   OMAttribute test = iAttr.next();
   String localName = test.getLocalName();
   if (localName.equals("nil")) {
    if (test.getAttributeValue().equals("true")) {
     return null;
    } else if (test.getAttributeValue().equals("false")) {
     return false;
    }
   } else {
    return Boolean.parseBoolean(items.getText());
   }
  }
  return false;
 }
}

代码示例来源:origin: usnistgov/iheos-toolkit2

String getAttributeName(OMAttribute a) {
  attNamespace = a.getNamespace();
  String prefix = "";
  if (attNamespace != null) {
    prefix = attNamespace.getPrefix();
    if (prefix != null && !prefix.equals(""))
      prefix = prefix + ":";
    //			if (nsPrefix != null && nsPrefix.equals("xml")) {
    //				prefix = "xml:";
    //				attNamespace = null;  // so namespace does not get added to element
    //			}
  }
  String attName = a.getLocalName();
  return prefix + attName;
}

代码示例来源:origin: org.apache.ws.commons.axiom/axiom-api

/**
 * This method is an overloaded method for the digest generation for OMAttribute
 *
 * @param attribute
 * @param digestAlgorithm
 * @return Returns a byte array representing the calculated digest value
 */
public byte[] getDigest(OMAttribute attribute, String digestAlgorithm) throws OMException {
  byte[] digest = new byte[0];
  if (!(attribute.getLocalName().equals("xmlns") ||
      attribute.getLocalName().startsWith("xmlns:"))) try {
    MessageDigest md = MessageDigest.getInstance(digestAlgorithm);
    md.update((byte) 0);
    md.update((byte) 0);
    md.update((byte) 0);
    md.update((byte) 2);
    md.update(getExpandedName(attribute).getBytes("UnicodeBigUnmarked"));
    md.update((byte) 0);
    md.update((byte) 0);
    md.update(attribute.getAttributeValue().getBytes("UnicodeBigUnmarked"));
    digest = md.digest();
  } catch (NoSuchAlgorithmException e) {
    throw new OMException(e);
  } catch (UnsupportedEncodingException e) {
    throw new OMException(e);
  }
  return digest;
}

代码示例来源:origin: org.apache.ws.commons.axiom/axiom-common-impl

/**
 * @param i
 * @return Returns String.
 * @see javax.xml.stream.XMLStreamReader#getAttributeLocalName
 */
public String getAttributeLocalName(int i) {
  String returnString = null;
  if (parser != null) {
    returnString = parser.getAttributeLocalName(i);
  } else {
    if (isStartElement()) {
      loadAttributes();
      returnString = attributes[i].getLocalName();
    } else {
      throw new IllegalStateException(
          "attribute localName accessed in illegal event!");
    }
  }
  return returnString;
}

代码示例来源:origin: org.apache.ws.commons.axiom/axiom-api

if (prefix != null) {
  writer.writeAttribute(prefix, namespaceName,
             attr.getLocalName(), attr.getAttributeValue());
} else {
  writer.writeAttribute(namespaceName, attr.getLocalName(),
             attr.getAttributeValue());
String localName = attr.getLocalName();
String attributeValue = attr.getAttributeValue();
writer.writeAttribute(localName, attributeValue);

代码示例来源:origin: usnistgov/iheos-toolkit2

void fix_v2_ns_recursive(OMElement ele, OMNamespace ns) {
  ele.setNamespace(ns);
  for (@SuppressWarnings("unchecked")
     Iterator<OMAttribute> it = ele.getAllAttributes(); it.hasNext();) {
    OMAttribute a = it.next();
    if (a.getLocalName().equals("lang"))
      a.setOMNamespace(MetadataSupport.xml_namespace);
  }
  for (@SuppressWarnings("unchecked")
     Iterator<OMElement> it = ele.getChildElements(); it.hasNext();) {
    OMElement child = (OMElement) it.next();
    fix_v2_ns_recursive(child, MetadataSupport.ebRIMns2);
  }
}

代码示例来源:origin: org.wso2.carbon.data/org.wso2.carbon.dataservices.ui

@SuppressWarnings("unchecked")
private List<Validator> getValidators(Iterator<OMElement> valItr) {
  List<Validator> vals = new ArrayList<Validator>();
  OMElement valEl;
  String valElementName;
  Iterator<OMAttribute> attrItr;
  Map<String,  String> propMap;
  OMAttribute attr;
  while (valItr.hasNext()) {
    valEl = valItr.next();
    valElementName = valEl.getLocalName();
    attrItr = valEl.getAllAttributes();
    propMap = new HashMap<String,  String>();
    while (attrItr.hasNext()) {
      attr = attrItr.next();
      propMap.put(attr.getLocalName(), attr.getAttributeValue());
    }
    Map<String, String> customPropMap = extractAdvancedProps(valEl);
    vals.add(new Validator(valElementName, propMap, customPropMap));
  }
  return vals;
}

代码示例来源:origin: org.wso2.carbon.data/org.wso2.carbon.dataservices.ui

@SuppressWarnings("unchecked")
private List<Validator> getValidators(Iterator<OMElement> valItr) {
  List<Validator> vals = new ArrayList<Validator>();
  OMElement valEl;
  String valElementName;
  Iterator<OMAttribute> attrItr;
  Map<String, String> propMap;
  OMAttribute attr;
  while (valItr.hasNext()) {
    valEl = valItr.next();
    valElementName = valEl.getLocalName();
    attrItr = valEl.getAllAttributes();
    propMap = new HashMap<String, String>();
    while (attrItr.hasNext()) {
      attr = attrItr.next();
      propMap.put(attr.getLocalName(), attr.getAttributeValue());
    }
    Map<String, String> customPropMap = extractAdvancedProps(valEl);
    vals.add(new Validator(valElementName, propMap, customPropMap));
  }
  return vals;
}

代码示例来源:origin: org.paxml/PaxmlCore

/**
 * Visit all attributes of an xml element.
 * 
 * @param ele
 *            the element
 * @param visitor
 *            the visitor
 */
public static void traverseAttributes(OMElement ele, IAttributeVisitor visitor) {
  for (OMAttribute attr : new Attributes(ele)) {
    visitor.visit(ele, attr.getLocalName(), attr.getAttributeValue());
  }
}

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

/**
 * Visit all attributes of an xml element.
 * 
 * @param ele
 *            the element
 * @param visitor
 *            the visitor
 */
public static void traverseAttributes(OMElement ele, IAttributeVisitor visitor) {
  for (OMAttribute attr : new Attributes(ele)) {
    visitor.visit(ele, attr.getLocalName(), attr.getAttributeValue());
  }
}

代码示例来源:origin: org.bluestemsoftware.open.eoa.ext/open-eoa-aspect-axiom

/**
 * @param i
 * @return Returns String.
 * @see javax.xml.stream.XMLStreamReader#getAttributeLocalName
 */
public String getAttributeLocalName(int i) {
  String returnString = null;
  if (parser != null) {
    returnString = parser.getAttributeLocalName(i);
  } else {
    if (isStartElement() || (currentEvent == ATTRIBUTE)) {
      OMAttribute attrib = getAttribute((OMElement) lastNode, i);
      if (attrib != null) {
        if (attrib.getNamespace() != null) {
          returnString = attrib.getLocalName();
        } else {
          returnString = ((Attr) attrib).getNodeName();
        }
      }
    } else {
      throw new IllegalStateException(
          "attribute localName accessed in illegal event!");
    }
  }
  return returnString;
}

代码示例来源:origin: usnistgov/iheos-toolkit2

OMElement dup_wrapper1(OMElement e) {
  OMElement e_dup = om_factory().createOMElement(e.getLocalName(),
      e.getNamespace());
  for (@SuppressWarnings("unchecked")
     Iterator<OMAttribute> it = e.getAllAttributes(); it.hasNext();) {
    OMAttribute a = it.next();
    String name = a.getLocalName();
    String value = a.getAttributeValue();
    e_dup.addAttribute(name, value, null);
  }
  if (e.getLocalName().equals(wrapper.getLocalName())) {
    wrapperDup = e_dup;
    return e_dup;
  }
  for (@SuppressWarnings("unchecked")
     Iterator<OMElement> it = e.getChildElements(); it.hasNext();) {
    OMElement ele = it.next();
    OMElement ele_dup = dup_wrapper1(ele);
    e_dup.addChild(ele_dup);
  }
  return e_dup;
}

代码示例来源:origin: org.apache.ws.commons.axiom/axiom-api

/**
   * In Axiom, a single tree should always contain objects created from the same type of factory
   * (eg: LinkedListImplFactory, DOMFactory, etc.,). This method will convert omAttribute to the
   * given omFactory.
   *
   * @see ElementHelper#importOMElement(OMElement, OMFactory) to convert instances of OMElement
   */
  public static void importOMAttribute(OMAttribute omAttribute, OMElement omElement) {
    // first check whether the given OMAttribute has the same OMFactory
    if (omAttribute.getOMFactory().getMetaFactory() == omElement.getOMFactory().getMetaFactory()) {
      omElement.addAttribute(omAttribute);
    } else {
      OMNamespace ns = omAttribute.getNamespace();
      omElement.addAttribute(omAttribute.getLocalName(), omAttribute.getAttributeValue(),
                  omElement.getOMFactory().createOMNamespace(ns.getNamespaceURI(), ns.getPrefix()));
    }
  }
}

相关文章