當前位置: 首頁>>代碼示例>>Java>>正文


Java Attribute.getName方法代碼示例

本文整理匯總了Java中javax.xml.stream.events.Attribute.getName方法的典型用法代碼示例。如果您正苦於以下問題:Java Attribute.getName方法的具體用法?Java Attribute.getName怎麽用?Java Attribute.getName使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在javax.xml.stream.events.Attribute的用法示例。


在下文中一共展示了Attribute.getName方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: anonymizeAttribute

import javax.xml.stream.events.Attribute; //導入方法依賴的package包/類
private Attribute anonymizeAttribute(Attribute attribute) {
    if (attribute.getName().equals(RDF_ID)) {
        return xmlStaxContext.eventFactory.createAttribute(attribute.getName(), dictionary.anonymize(attribute.getValue()));
    } else if (attribute.getName().equals(RDF_RESOURCE) || attribute.getName().equals(RDF_ABOUT)) {
        // skip outside graph rdf:ID references
        AttributeValue value  = AttributeValue.parseValue(attribute);
        if ((value.getNsUri() == null || !value.getNsUri().matches(CIM_URI_PATTERN)) &&
                (rdfIdValues == null || rdfIdValues.contains(value.get()))) {
            return xmlStaxContext.eventFactory.createAttribute(attribute.getName(), value.toString(dictionary));
        } else {
            skipped.add(attribute.getValue());
            return null;
        }
    } else {
        throw new AssertionError("Unknown attribute " + attribute.getName());
    }
}
 
開發者ID:powsybl,項目名稱:powsybl-core,代碼行數:18,代碼來源:CimAnonymizer.java

示例2: addRdfIdValues

import javax.xml.stream.events.Attribute; //導入方法依賴的package包/類
private void addRdfIdValues(InputStream is, Set<String> rdfIdValues) throws XMLStreamException {
    // memoize RDF ID values of the document
    XMLEventReader eventReader = xmlStaxContext.inputFactory.createXMLEventReader(is);
    while (eventReader.hasNext()) {
        XMLEvent event = eventReader.nextEvent();
        if (event.isStartElement()) {
            StartElement startElement = event.asStartElement();
            Iterator it = startElement.getAttributes();
            while (it.hasNext()) {
                Attribute attribute = (Attribute) it.next();
                QName name = attribute.getName();
                if (RDF_ID.equals(name)) {
                    rdfIdValues.add(attribute.getValue());
                }
            }
        }
    }
    eventReader.close();
}
 
開發者ID:powsybl,項目名稱:powsybl-core,代碼行數:20,代碼來源:CimAnonymizer.java

示例3: getAttributeByName

import javax.xml.stream.events.Attribute; //導入方法依賴的package包/類
private Attribute getAttributeByName(final StartElement element,
        final QName attributeName) {
    // call standard API method to retrieve the attribute by name
    Attribute attribute = element.getAttributeByName(attributeName);

    // try to find the attribute without a prefix.
    if (attribute == null) {
        final String localAttributeName = attributeName.getLocalPart();
        final Iterator iterator = element.getAttributes();
        while (iterator.hasNext()) {
            final Attribute nextAttribute = (Attribute) iterator.next();
            final QName aName = nextAttribute.getName();
            final boolean attributeFoundByWorkaround = aName.equals(attributeName) || (aName.getLocalPart().equals(localAttributeName) && (aName.getPrefix() == null || "".equals(aName.getPrefix())));
            if (attributeFoundByWorkaround) {
                attribute = nextAttribute;
                break;
            }

        }
    }

    return attribute;
}
 
開發者ID:SunburstApps,項目名稱:OpenJSharp,代碼行數:24,代碼來源:XmlPolicyModelUnmarshaller.java

示例4: parse

import javax.xml.stream.events.Attribute; //導入方法依賴的package包/類
public TubelineFeature parse(XMLEventReader reader) throws WebServiceException {
    try {
        final StartElement element = reader.nextEvent().asStartElement();
        boolean attributeEnabled = true;
        final Iterator iterator = element.getAttributes();
        while (iterator.hasNext()) {
            final Attribute nextAttribute = (Attribute) iterator.next();
            final QName attributeName = nextAttribute.getName();
            if (ENABLED_ATTRIBUTE_NAME.equals(attributeName)) {
                attributeEnabled = ParserUtil.parseBooleanValue(nextAttribute.getValue());
            } else if (NAME_ATTRIBUTE_NAME.equals(attributeName)) {
                // TODO use name attribute
            } else {
                // TODO logging message
                throw LOGGER.logSevereException(new WebServiceException("Unexpected attribute"));
            }
        }
        return parseFactories(attributeEnabled, element, reader);
    } catch (XMLStreamException e) {
        throw LOGGER.logSevereException(new WebServiceException("Failed to unmarshal XML document", e));
    }
}
 
開發者ID:SunburstApps,項目名稱:OpenJSharp,代碼行數:23,代碼來源:TubelineFeatureReader.java

示例5: handleStartElement

import javax.xml.stream.events.Attribute; //導入方法依賴的package包/類
private void handleStartElement(StartElement startElement) throws SAXException {
	if (getContentHandler() != null) {
		QName qName = startElement.getName();
		if (hasNamespacesFeature()) {
			for (Iterator i = startElement.getNamespaces(); i.hasNext();) {
				Namespace namespace = (Namespace) i.next();
				startPrefixMapping(namespace.getPrefix(), namespace.getNamespaceURI());
			}
			for (Iterator i = startElement.getAttributes(); i.hasNext();){
				Attribute attribute = (Attribute) i.next();
				QName attributeName = attribute.getName();
				startPrefixMapping(attributeName.getPrefix(), attributeName.getNamespaceURI());
			}

			getContentHandler().startElement(qName.getNamespaceURI(), qName.getLocalPart(), toQualifiedName(qName),
					getAttributes(startElement));
		}
		else {
			getContentHandler().startElement("", "", toQualifiedName(qName), getAttributes(startElement));
		}
	}
}
 
開發者ID:langtianya,項目名稱:spring4-understanding,代碼行數:23,代碼來源:StaxEventXMLReader.java

示例6: removeNonSvgAttributes

import javax.xml.stream.events.Attribute; //導入方法依賴的package包/類
/**
 * Modifies a {@link StartElement}, removing attributes that do not have a {@link QName#getNamespaceURI()} that
 * equals {@link SvgDocument#NAMESPACE_URI}.
 * @param element The {@link StartElement} to remove attributes from.
 * @return The modified {@link StartElement}.
 */
@SuppressWarnings("unchecked")
private static XMLEvent removeNonSvgAttributes(StartElement element) {
	Iterator<Attribute> original = element.getAttributes();
	Collection<Attribute> modified = new ArrayList<>();

	while (original.hasNext()) {
		Attribute attribute = original.next();
		QName qName = attribute.getName();
		String namespaceUri = qName.getNamespaceURI();

		if (namespaceUri.isEmpty() || namespaceUri.equals(SvgDocument.NAMESPACE_URI)) {
			modified.add(attribute);
		}
	}

	return events.createStartElement(element.getName(), modified.iterator(), element.getNamespaces());
}
 
開發者ID:michaelbull,項目名稱:svg-stockpile,代碼行數:24,代碼來源:StartElementProcessor.java

示例7: writeAttributeEvent

import javax.xml.stream.events.Attribute; //導入方法依賴的package包/類
private static void writeAttributeEvent(XMLEvent event, XMLStreamWriter writer) 
    throws XMLStreamException {
    
    Attribute attr = (Attribute)event;
    QName name = attr.getName();
    String nsURI = name.getNamespaceURI();
    String localName = name.getLocalPart();
    String prefix = name.getPrefix();
    String value = attr.getValue();

    if (prefix != null) {
        writer.writeAttribute(prefix, nsURI, localName, value);
    } else if (nsURI != null) {
        writer.writeAttribute(nsURI, localName, value);
    } else {
        writer.writeAttribute(localName, value);
    }
}
 
開發者ID:beemsoft,項目名稱:techytax-zk,代碼行數:19,代碼來源:StaxUtils.java

示例8: parseTagAttributes

import javax.xml.stream.events.Attribute; //導入方法依賴的package包/類
public static Map<String, String> parseTagAttributes(StartElement start) {
  // Using a map to deduplicate xmlns declarations on the attributes.
  Map<String, String> attributeMap = new LinkedHashMap<>();
  Iterator<Attribute> attributes = iterateAttributesFrom(start);
  while (attributes.hasNext()) {
    Attribute attribute = attributes.next();
    QName name = attribute.getName();
    // Name used as the resource key, so skip it here.
    if (ATTR_NAME.equals(name)) {
      continue;
    }
    String value = escapeXmlValues(attribute.getValue()).replace("\"", "&quot;");
    if (!name.getNamespaceURI().isEmpty()) {
      attributeMap.put(name.getPrefix() + ":" + attribute.getName().getLocalPart(), value);
    } else {
      attributeMap.put(attribute.getName().getLocalPart(), value);
    }
    Iterator<Namespace> namespaces = iterateNamespacesFrom(start);
    while (namespaces.hasNext()) {
      Namespace namespace = namespaces.next();
      attributeMap.put("xmlns:" + namespace.getPrefix(), namespace.getNamespaceURI());
    }
  }
  return attributeMap;
}
 
開發者ID:bazelbuild,項目名稱:bazel,代碼行數:26,代碼來源:XmlResourceValues.java

示例9: outputNsAndAttr

import javax.xml.stream.events.Attribute; //導入方法依賴的package包/類
@Override
protected void outputNsAndAttr(XMLStreamWriter w) throws XMLStreamException
{
    // First namespace declarations, if any:
    if (mNsCtxt != null) {
        mNsCtxt.outputNamespaceDeclarations(w);
    }
    // Then attributes, if any:
    if (mAttrs != null && mAttrs.size() > 0) {
        for (Attribute attr : mAttrs.values()) {
            // Let's only output explicit attribute values:
            if (!attr.isSpecified()) {
                continue;
            }
            QName name = attr.getName();
            String prefix = name.getPrefix();
            String ln = name.getLocalPart();
            String nsURI = name.getNamespaceURI();
            w.writeAttribute(prefix, nsURI, ln, attr.getValue());
        }
    }
}
 
開發者ID:FasterXML,項目名稱:woodstox,代碼行數:23,代碼來源:SimpleStartElement.java

示例10: writeStartElement

import javax.xml.stream.events.Attribute; //導入方法依賴的package包/類
@Override
public void writeStartElement(StartElement elem)
    throws XMLStreamException
{
    /* In repairing mode this is simple: let's just pass info
     * we have, and things should work... a-may-zing!
     */
    QName name = elem.getName();
    writeStartElement(name.getPrefix(), name.getLocalPart(),
                      name.getNamespaceURI());
    @SuppressWarnings("unchecked")
    Iterator<Attribute> it = elem.getAttributes();
    while (it.hasNext()) {
        Attribute attr = it.next();
        name = attr.getName();
        writeAttribute(name.getPrefix(), name.getNamespaceURI(),
                       name.getLocalPart(), attr.getValue());
    }
}
 
開發者ID:FasterXML,項目名稱:woodstox,代碼行數:20,代碼來源:RepairingNsStreamWriter.java

示例11: parseAssertionData

import javax.xml.stream.events.Attribute; //導入方法依賴的package包/類
private void parseAssertionData(NamespaceVersion nsVersion, String value, ModelNode childNode, final StartElement childElement) throws IllegalArgumentException, PolicyException {
    // finish assertion node processing: create and set assertion data...
    final Map<QName, String> attributeMap = new HashMap<QName, String>();
    boolean optional = false;
    boolean ignorable = false;

    final Iterator iterator = childElement.getAttributes();
    while (iterator.hasNext()) {
        final Attribute nextAttribute = (Attribute) iterator.next();
        final QName name = nextAttribute.getName();
        if (attributeMap.containsKey(name)) {
            throw LOGGER.logSevereException(new PolicyException(LocalizationMessages.WSP_0059_MULTIPLE_ATTRS_WITH_SAME_NAME_DETECTED_FOR_ASSERTION(nextAttribute.getName(), childElement.getName())));
        } else {
            if (nsVersion.asQName(XmlToken.Optional).equals(name)) {
                optional = parseBooleanValue(nextAttribute.getValue());
            } else if (nsVersion.asQName(XmlToken.Ignorable).equals(name)) {
                ignorable = parseBooleanValue(nextAttribute.getValue());
            } else {
                attributeMap.put(name, nextAttribute.getValue());
            }
        }
    }
    final AssertionData nodeData = new AssertionData(childElement.getName(), value, attributeMap, childNode.getType(), optional, ignorable);

    // check visibility value syntax if present...
    if (nodeData.containsAttribute(PolicyConstants.VISIBILITY_ATTRIBUTE)) {
        final String visibilityValue = nodeData.getAttributeValue(PolicyConstants.VISIBILITY_ATTRIBUTE);
        if (!PolicyConstants.VISIBILITY_VALUE_PRIVATE.equals(visibilityValue)) {
            throw LOGGER.logSevereException(new PolicyException(LocalizationMessages.WSP_0004_UNEXPECTED_VISIBILITY_ATTR_VALUE(visibilityValue)));
        }
    }

    childNode.setOrReplaceNodeData(nodeData);
}
 
開發者ID:SunburstApps,項目名稱:OpenJSharp,代碼行數:35,代碼來源:XmlPolicyModelUnmarshaller.java

示例12: getAttributes

import javax.xml.stream.events.Attribute; //導入方法依賴的package包/類
/**
 * Get the attributes associated with the given START_ELEMENT StAXevent.
 *
 * @return the StAX attributes converted to an org.xml.sax.Attributes
 */
private Attributes getAttributes(StartElement event) {
    attrs.clear();

    // in SAX, namespace declarations are not part of attributes by default.
    // (there's a property to control that, but as far as we are concerned
    // we don't use it.) So don't add xmlns:* to attributes.

    // gather non-namespace attrs
    for (Iterator i = event.getAttributes(); i.hasNext();) {
        Attribute staxAttr = (Attribute)i.next();

        QName name = staxAttr.getName();
        String uri = fixNull(name.getNamespaceURI());
        String localName = name.getLocalPart();
        String prefix = name.getPrefix();
        String qName;
        if (prefix == null || prefix.length() == 0)
            qName = localName;
        else
            qName = prefix + ':' + localName;
        String type = staxAttr.getDTDType();
        String value = staxAttr.getValue();

        attrs.addAttribute(uri, localName, qName, type, value);
    }

    return attrs;
}
 
開發者ID:SunburstApps,項目名稱:OpenJSharp,代碼行數:34,代碼來源:StAXEventConnector.java

示例13: getAttributes

import javax.xml.stream.events.Attribute; //導入方法依賴的package包/類
/**
 * Get the attributes associated with the given START_ELEMENT StAXevent.
 *
 * @return the StAX attributes converted to an org.xml.sax.Attributes
 */
private Attributes getAttributes(StartElement event) {
    attrs.clear();

    // in SAX, namespace declarations are not part of attributes by default.
    // (there's a property to control that, but as far as we are concerned
    // we don't use it.) So don't add xmlns:* to attributes.

    // gather non-namespace attrs
    for (Iterator i = event.getAttributes(); i.hasNext();) {
        Attribute staxAttr = (Attribute)i.next();

        QName name = staxAttr.getName();
        String uri = fixNull(name.getNamespaceURI());
        String localName = name.getLocalPart();
        String prefix = name.getPrefix();
        String qName;
        if (prefix == null || prefix.length() == 0)
            qName = localName;
        else
            qName = prefix + ':' + localName;
        String type = staxAttr.getDTDType();
        String value = staxAttr.getValue();
        
        attrs.addAttribute(uri, localName, qName, type, value);
    }

    return attrs;
}
 
開發者ID:GeeQuery,項目名稱:cxf-plus,代碼行數:34,代碼來源:StAXEventConnector.java

示例14: getJAASEntry

import javax.xml.stream.events.Attribute; //導入方法依賴的package包/類
@SuppressWarnings("unchecked")
private AppConfigurationEntry getJAASEntry(XMLEventReader xmlEventReader) throws XMLStreamException
{
   XMLEvent xmlEvent = xmlEventReader.nextEvent();
   Map<String, Object> options = new HashMap<String, Object>();

   String codeName = null;
   LoginModuleControlFlag controlFlag = LoginModuleControlFlag.REQUIRED;

   //We got the login-module element
   StartElement loginModuleElement = (StartElement) xmlEvent;
   //We got the login-module element
   Iterator<Attribute> attrs = loginModuleElement.getAttributes();
   while (attrs.hasNext())
   {
      Attribute attribute = attrs.next();
      QName attQName = attribute.getName();
      String attributeValue = StaxParserUtil.getAttributeValue(attribute);

      if ("code".equals(attQName.getLocalPart()))
      {
         codeName = attributeValue;
      }
      else if ("flag".equals(attQName.getLocalPart()))
      {
         controlFlag = getControlFlag(attributeValue);
      }
   }
   //See if there are options
   ModuleOptionParser moParser = new ModuleOptionParser();
   options.putAll(moParser.parse(xmlEventReader));

   return new AppConfigurationEntry(codeName, controlFlag, options);
}
 
開發者ID:picketbox,項目名稱:picketbox,代碼行數:35,代碼來源:AuthenticationJASPIConfigParser.java

示例15: getEntry

import javax.xml.stream.events.Attribute; //導入方法依賴的package包/類
@SuppressWarnings("unchecked")
private AppConfigurationEntry getEntry(XMLEventReader xmlEventReader) throws XMLStreamException
{
   XMLEvent xmlEvent = xmlEventReader.nextEvent();
   Map<String, Object> options = new HashMap<String,Object>();
   
   String codeName = null;
   LoginModuleControlFlag controlFlag = LoginModuleControlFlag.REQUIRED;
   
   //We got the login-module element
   StartElement loginModuleElement = (StartElement) xmlEvent;
   //We got the login-module element
   Iterator<Attribute> attrs = loginModuleElement.getAttributes();
   while(attrs.hasNext())
   {
      Attribute attribute = attrs.next();
      
      QName attQName = attribute.getName();
      String attributeValue = StaxParserUtil.getAttributeValue(attribute);
      
      if("code".equals(attQName.getLocalPart()))
      {
         codeName = attributeValue;
      }
      else if("flag".equals(attQName.getLocalPart()))
      {
         controlFlag = getControlFlag(attributeValue);
      } 
   } 
   //See if there are options
   ModuleOptionParser moParser = new ModuleOptionParser();
   options.putAll(moParser.parse(xmlEventReader));
   
   return new AppConfigurationEntry(codeName, controlFlag, options); 
}
 
開發者ID:picketbox,項目名稱:picketbox,代碼行數:36,代碼來源:AuthenticationConfigParser.java


注:本文中的javax.xml.stream.events.Attribute.getName方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。