本文整理了Java中javax.xml.stream.XMLStreamReader.getAttributeName()
方法的一些代码示例,展示了XMLStreamReader.getAttributeName()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。XMLStreamReader.getAttributeName()
方法的具体详情如下:
包路径:javax.xml.stream.XMLStreamReader
类名称:XMLStreamReader
方法名:getAttributeName
[英]Returns the qname of the attribute at the provided index
[中]返回所提供索引处属性的qname
代码示例来源:origin: spring-projects/spring-framework
private Attributes getAttributes() {
AttributesImpl attributes = new AttributesImpl();
for (int i = 0; i < this.reader.getAttributeCount(); i++) {
String namespace = this.reader.getAttributeNamespace(i);
if (namespace == null || !hasNamespacesFeature()) {
namespace = "";
}
String type = this.reader.getAttributeType(i);
if (type == null) {
type = "CDATA";
}
attributes.addAttribute(namespace, this.reader.getAttributeLocalName(i),
toQualifiedName(this.reader.getAttributeName(i)), type, this.reader.getAttributeValue(i));
}
if (hasNamespacePrefixesFeature()) {
for (int i = 0; i < this.reader.getNamespaceCount(); i++) {
String prefix = this.reader.getNamespacePrefix(i);
String namespaceUri = this.reader.getNamespaceURI(i);
String qName;
if (StringUtils.hasLength(prefix)) {
qName = "xmlns:" + prefix;
}
else {
qName = "xmlns";
}
attributes.addAttribute("", "", qName, "CDATA", namespaceUri);
}
}
return attributes;
}
代码示例来源:origin: geotools/geotools
public int getIndex(String uri, String localName) {
for (int i = 0; i < pp.getAttributeCount(); i++) {
if (pp.getAttributeNamespace(i).equals(uri)
&& pp.getAttributeName(i).equals(localName)) {
return i;
}
}
return -1;
}
代码示例来源:origin: geotools/geotools
public int getIndex(String qName) {
for (int i = 0; i < pp.getAttributeCount(); i++) {
if (pp.getAttributeName(i).equals(qName)) {
return i;
}
}
return -1;
}
代码示例来源:origin: org.wildfly.core/wildfly-server
private static void parseTransformer(final XMLStreamReader reader, final List<String> transformerClassNames) throws XMLStreamException {
String className = null;
final Set<Attribute> required = EnumSet.of(Attribute.CLASS);
final int count = reader.getAttributeCount();
for (int i = 0; i < count; i++) {
final Attribute attribute = Attribute.of(reader.getAttributeName(i));
required.remove(attribute);
switch (attribute) {
case CLASS:
className = reader.getAttributeValue(i);
break;
default:
throw unexpectedContent(reader);
}
}
if (!required.isEmpty()) {
throw missingAttributes(reader.getLocation(), required);
}
transformerClassNames.add(className);
// consume remainder of element
parseNoContent(reader);
}
代码示例来源:origin: org.daisy.pipeline/common-utils
public static Map<QName,String> getAttributes(XMLStreamReader reader) {
Map<QName,String> map = new HashMap<QName,String>();
for (int i = 0; i < reader.getAttributeCount(); i++)
map.put(reader.getAttributeName(i), reader.getAttributeValue(i));
return map;
}
代码示例来源:origin: org.codehaus.woodstox/woodstox-core-asl
loc = r.getLocation();
} else {
loc = mLastLocation;
loc = mLastLocation = r.getLocation();
int attrCount = r.getAttributeCount();
if (attrCount < 1) {
attrs = null;
attrs = new LinkedHashMap();
for (int i = 0; i < attrCount; ++i) {
QName aname = r.getAttributeName(i);
attrs.put(aname, new AttributeEventImpl(loc, aname, r.getAttributeValue(i), r.isAttributeSpecified(i)));
代码示例来源:origin: org.wildfly.core/wildfly-server
private static void parsePathName(final XMLStreamReader reader, final Set<String> set) throws XMLStreamException {
String name = null;
final Set<Attribute> required = EnumSet.of(Attribute.NAME);
final int count = reader.getAttributeCount();
for (int i = 0; i < count; i++) {
final Attribute attribute = Attribute.of(reader.getAttributeName(i));
required.remove(attribute);
switch (attribute) {
case NAME:
name = reader.getAttributeValue(i);
break;
default:
throw unexpectedContent(reader);
}
}
if (!required.isEmpty()) {
throw missingAttributes(reader.getLocation(), required);
}
set.add(name);
// consume remainder of element
parseNoContent(reader);
}
代码示例来源:origin: org.glassfish.common/common-util
private Map<String, String> parseAttributes() {
int num = parser.getAttributeCount();
Map<String, String> map = new HashMap<String, String>();
for (int i = 0; i < num; i++) {
map.put(parser.getAttributeName(i).getLocalPart(), parser.getAttributeValue(i));
}
return map;
}
代码示例来源:origin: org.springframework/spring-core
private Attributes getAttributes() {
AttributesImpl attributes = new AttributesImpl();
for (int i = 0; i < this.reader.getAttributeCount(); i++) {
String namespace = this.reader.getAttributeNamespace(i);
if (namespace == null || !hasNamespacesFeature()) {
namespace = "";
}
String type = this.reader.getAttributeType(i);
if (type == null) {
type = "CDATA";
}
attributes.addAttribute(namespace, this.reader.getAttributeLocalName(i),
toQualifiedName(this.reader.getAttributeName(i)), type, this.reader.getAttributeValue(i));
}
if (hasNamespacePrefixesFeature()) {
for (int i = 0; i < this.reader.getNamespaceCount(); i++) {
String prefix = this.reader.getNamespacePrefix(i);
String namespaceUri = this.reader.getNamespaceURI(i);
String qName;
if (StringUtils.hasLength(prefix)) {
qName = "xmlns:" + prefix;
}
else {
qName = "xmlns";
}
attributes.addAttribute("", "", qName, "CDATA", namespaceUri);
}
}
return attributes;
}
代码示例来源:origin: jhannes/eaxy
private Element readElement() {
QName name = streamReader.getName();
Element element = new Element(toName(name), streamReader.getLocation().getLineNumber());
for (int i = 0; i < streamReader.getNamespaceCount(); i++) {
element.namespace(new Namespace(streamReader.getNamespaceURI(i), streamReader.getNamespacePrefix(i)));
}
for (int i = 0; i < streamReader.getAttributeCount(); i++) {
element.attr(toName(streamReader.getAttributeName(i)), streamReader.getAttributeValue(i));
}
return element;
}
代码示例来源:origin: geotools/geotools
public String getType(String qName) {
for (int i = 0; i < pp.getAttributeCount(); i++) {
if (pp.getAttributeName(i).equals(qName)) {
return pp.getAttributeType(i);
}
}
return null;
}
代码示例来源:origin: geotools/geotools
public String getType(String uri, String localName) {
for (int i = 0; i < pp.getAttributeCount(); i++) {
if (pp.getAttributeNamespace(i).equals(uri)
&& pp.getAttributeName(i).equals(localName)) {
return pp.getAttributeType(i);
}
}
return null;
}
代码示例来源:origin: org.wildfly.core/wildfly-server
private static void parseTransformer(final XMLStreamReader reader, final List<String> transformerClassNames) throws XMLStreamException {
String className = null;
final Set<Attribute> required = EnumSet.of(Attribute.CLASS);
final int count = reader.getAttributeCount();
for (int i = 0; i < count; i++) {
final Attribute attribute = Attribute.of(reader.getAttributeName(i));
required.remove(attribute);
switch (attribute) {
case CLASS:
className = reader.getAttributeValue(i);
break;
default:
throw unexpectedContent(reader);
}
}
if (!required.isEmpty()) {
throw missingAttributes(reader.getLocation(), required);
}
transformerClassNames.add(className);
// consume remainder of element
parseNoContent(reader);
}
代码示例来源:origin: org.glassfish.main.common/common-util
private Map<String, String> parseAttributes() {
int num = parser.getAttributeCount();
Map<String, String> map = new HashMap<String, String>();
for (int i = 0; i < num; i++) {
map.put(parser.getAttributeName(i).getLocalPart(), parser.getAttributeValue(i));
}
return map;
}
代码示例来源:origin: geotools/geotools
Attributes attributes(XMLStreamReader xml) {
AttributesImpl atts = new AttributesImpl();
for (int i = 0; i < xml.getAttributeCount(); i++) {
atts.addAttribute(
xml.getAttributeNamespace(i),
xml.getAttributeLocalName(i),
qname(xml.getAttributeName(i)),
xml.getAttributeType(i),
xml.getAttributeValue(i));
}
return atts;
}
代码示例来源:origin: com.yahoo.vespa/document
public boolean hasFieldPath() {
for (int i = 0; i < reader.getAttributeCount(); i++) {
if (reader.getAttributeName(i).toString().equals("fieldpath")) {
return true;
}
}
return false;
}
代码示例来源:origin: org.wildfly.core/wildfly-server
private static void parsePathName(final XMLStreamReader reader, final Set<String> set) throws XMLStreamException {
String name = null;
final Set<Attribute> required = EnumSet.of(Attribute.NAME);
final int count = reader.getAttributeCount();
for (int i = 0; i < count; i++) {
final Attribute attribute = Attribute.of(reader.getAttributeName(i));
required.remove(attribute);
switch (attribute) {
case NAME:
name = reader.getAttributeValue(i);
break;
default:
throw unexpectedContent(reader);
}
}
if (!required.isEmpty()) {
throw missingAttributes(reader.getLocation(), required);
}
set.add(name);
// consume remainder of element
parseNoContent(reader);
}
代码示例来源:origin: eclipse-ee4j/glassfish
private Map<String, String> parseAttributes() {
int num = parser.getAttributeCount();
Map<String, String> map = new HashMap<String, String>();
for (int i = 0; i < num; i++) {
map.put(parser.getAttributeName(i).getLocalPart(), parser.getAttributeValue(i));
}
return map;
}
代码示例来源:origin: camunda/camunda-bpm-platform
private Attributes getAttributes() {
AttributesImpl attributes = new AttributesImpl();
for (int i = 0; i < reader.getAttributeCount(); i++) {
String namespace = reader.getAttributeNamespace(i);
if (namespace == null || !hasNamespacesFeature()) {
namespace = "";
}
String type = reader.getAttributeType(i);
if (type == null) {
type = "CDATA";
}
attributes.addAttribute(namespace, reader.getAttributeLocalName(i),
toQualifiedName(reader.getAttributeName(i)), type, reader.getAttributeValue(i));
}
if (hasNamespacePrefixesFeature()) {
for (int i = 0; i < reader.getNamespaceCount(); i++) {
String prefix = reader.getNamespacePrefix(i);
String namespaceUri = reader.getNamespaceURI(i);
String qName;
if (StringUtils.hasLength(prefix)) {
qName = "xmlns:" + prefix;
}
else {
qName = "xmlns";
}
attributes.addAttribute("", "", qName, "CDATA", namespaceUri);
}
}
return attributes;
}
代码示例来源:origin: com.hynnet/xws-security
private boolean hasValueType(XMLStreamReader reader){
for(int i=0;i<reader.getAttributeCount();i++){
QName name = reader.getAttributeName(i);
if(name != null && "ValueType".equals(name.getLocalPart())){
return true;
}
}
return false;
}
}
内容来源于网络,如有侵权,请联系作者删除!