当前位置: 首页>>代码示例>>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;未经允许,请勿转载。