本文整理汇总了Java中javax.xml.stream.events.XMLEvent.ATTRIBUTE属性的典型用法代码示例。如果您正苦于以下问题:Java XMLEvent.ATTRIBUTE属性的具体用法?Java XMLEvent.ATTRIBUTE怎么用?Java XMLEvent.ATTRIBUTE使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类javax.xml.stream.events.XMLEvent
的用法示例。
在下文中一共展示了XMLEvent.ATTRIBUTE属性的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getAttributeValue
/**
* @param namespaceURI
* @param localName
* @return
*/
public String getAttributeValue(String namespaceURI, String localName) {
//State should be either START_ELEMENT or ATTRIBUTE
if (fEventType == XMLEvent.START_ELEMENT || fEventType == XMLEvent.ATTRIBUTE) {
XMLAttributesImpl attributes = fScanner.getAttributeIterator();
if (namespaceURI == null) { //sjsxp issue 70
return attributes.getValue(attributes.getIndexByLocalName(localName));
} else {
return fScanner.getAttributeIterator().getValue(
namespaceURI.length() == 0 ? null : namespaceURI, localName);
}
} else {
throw new java.lang.IllegalStateException("Current state is not among the states "
+ getEventTypeString(XMLEvent.START_ELEMENT) + " , "
+ getEventTypeString(XMLEvent.ATTRIBUTE)
+ "valid for getAttributeValue()");
}
}
示例2: handleEvent
private void handleEvent(XMLStreamReader xmlr, int eventType) {
switch (eventType) {
case XMLEvent.START_ELEMENT:
handleStartElement(xmlr);
break;
case XMLEvent.END_ELEMENT:
handleEndElement(xmlr);
break;
case XMLEvent.CHARACTERS:
handleCharacters(xmlr);
break;
case XMLEvent.COMMENT:
handleComment(xmlr);
break;
case XMLEvent.ENTITY_REFERENCE:
break;
case XMLEvent.ATTRIBUTE:
break;
case XMLEvent.DTD:
break;
case XMLEvent.CDATA:
break;
default:
break;
}
}
示例3: getEventTypeString
final static String getEventTypeString(int eventType) {
switch (eventType){
case XMLEvent.START_ELEMENT:
return "START_ELEMENT";
case XMLEvent.END_ELEMENT:
return "END_ELEMENT";
case XMLEvent.PROCESSING_INSTRUCTION:
return "PROCESSING_INSTRUCTION";
case XMLEvent.CHARACTERS:
return "CHARACTERS";
case XMLEvent.COMMENT:
return "COMMENT";
case XMLEvent.START_DOCUMENT:
return "START_DOCUMENT";
case XMLEvent.END_DOCUMENT:
return "END_DOCUMENT";
case XMLEvent.ENTITY_REFERENCE:
return "ENTITY_REFERENCE";
case XMLEvent.ATTRIBUTE:
return "ATTRIBUTE";
case XMLEvent.DTD:
return "DTD";
case XMLEvent.CDATA:
return "CDATA";
case XMLEvent.SPACE:
return "SPACE";
}
return "UNKNOWN_EVENT_TYPE, " + String.valueOf(eventType);
}
示例4: getAttributeName
/** Returns the localName of the attribute at the provided
* index
* @param index the position of the attribute
* @return the localName of the attribute
* @throws IllegalStateException if this is not a START_ELEMENT or ATTRIBUTE
*/
public QName getAttributeName(int index) {
//State should be either START_ELEMENT or ATTRIBUTE
if( fEventType == XMLEvent.START_ELEMENT || fEventType == XMLEvent.ATTRIBUTE) {
return convertXNIQNametoJavaxQName(fScanner.getAttributeIterator().getQualifiedName(index)) ;
} else{
throw new java.lang.IllegalStateException("Current state is not among the states "
+ getEventTypeString(XMLEvent.START_ELEMENT) + " , "
+ getEventTypeString(XMLEvent.ATTRIBUTE)
+ "valid for getAttributeName()") ;
}
}
示例5: getAttributeLocalName
/**
* @param index
* @return
*/
public String getAttributeLocalName(int index) {
//State should be either START_ELEMENT or ATTRIBUTE
if( fEventType == XMLEvent.START_ELEMENT || fEventType == XMLEvent.ATTRIBUTE) {
return fScanner.getAttributeIterator().getLocalName(index) ;
} else{
throw new java.lang.IllegalStateException() ;
}
}
示例6: getAttributeNamespace
/** Returns the namespace of the attribute at the provided
* index
* @param index the position of the attribute
* @return the namespace URI (can be null)
* @throws IllegalStateException if this is not a START_ELEMENT or ATTRIBUTE
*/
public String getAttributeNamespace(int index) {
//State should be either START_ELEMENT or ATTRIBUTE
if( fEventType == XMLEvent.START_ELEMENT || fEventType == XMLEvent.ATTRIBUTE) {
return fScanner.getAttributeIterator().getURI(index);
} else{
throw new java.lang.IllegalStateException("Current state is not among the states "
+ getEventTypeString(XMLEvent.START_ELEMENT) + " , "
+ getEventTypeString(XMLEvent.ATTRIBUTE)
+ "valid for getAttributeNamespace()") ;
}
}
示例7: getAttributePrefix
/** Returns the prefix of this attribute at the
* provided index
* @param index the position of the attribute
* @return the prefix of the attribute
* @throws IllegalStateException if this is not a START_ELEMENT or ATTRIBUTE
*/
public String getAttributePrefix(int index) {
//State should be either START_ELEMENT or ATTRIBUTE
if( fEventType == XMLEvent.START_ELEMENT || fEventType == XMLEvent.ATTRIBUTE) {
return fScanner.getAttributeIterator().getPrefix(index);
} else{
throw new java.lang.IllegalStateException("Current state is not among the states "
+ getEventTypeString(XMLEvent.START_ELEMENT) + " , "
+ getEventTypeString(XMLEvent.ATTRIBUTE)
+ "valid for getAttributePrefix()") ;
}
}
示例8: getAttributeQName
/** Returns the qname of the attribute at the provided index
*
* @param index the position of the attribute
* @return the QName of the attribute
* @throws IllegalStateException if this is not a START_ELEMENT or ATTRIBUTE
*/
public javax.xml.namespace.QName getAttributeQName(int index) {
//State should be either START_ELEMENT or ATTRIBUTE
if( fEventType == XMLEvent.START_ELEMENT || fEventType == XMLEvent.ATTRIBUTE) {
// create new object at runtime..
String localName = fScanner.getAttributeIterator().getLocalName(index) ;
String uri = fScanner.getAttributeIterator().getURI(index) ;
return new javax.xml.namespace.QName(uri, localName) ;
} else{
throw new java.lang.IllegalStateException("Current state is not among the states "
+ getEventTypeString(XMLEvent.START_ELEMENT) + " , "
+ getEventTypeString(XMLEvent.ATTRIBUTE)
+ "valid for getAttributeQName()") ;
}
}
示例9: getAttributeType
/** Returns the XML type of the attribute at the provided
* index
* @param index the position of the attribute
* @return the XML type of the attribute
* @throws IllegalStateException if this is not a START_ELEMENT or ATTRIBUTE
*/
public String getAttributeType(int index) {
//State should be either START_ELEMENT or ATTRIBUTE
if( fEventType == XMLEvent.START_ELEMENT || fEventType == XMLEvent.ATTRIBUTE) {
return fScanner.getAttributeIterator().getType(index) ;
} else{
throw new java.lang.IllegalStateException("Current state is not among the states "
+ getEventTypeString(XMLEvent.START_ELEMENT) + " , "
+ getEventTypeString(XMLEvent.ATTRIBUTE)
+ "valid for getAttributeType()") ;
}
}
示例10: isAttributeSpecified
/**
* Returns a boolean which indicates if this attribute was created by
* default
*
* @param index the position of the attribute
* @return true if this is a default attribute
* @throws IllegalStateException if this is not a START_ELEMENT or ATTRIBUTE
*/
public boolean isAttributeSpecified(int index) {
//check that current state should be either START_ELEMENT or ATTRIBUTE
if ((fEventType == XMLEvent.START_ELEMENT) || (fEventType == XMLEvent.ATTRIBUTE)) {
return fScanner.getAttributeIterator().isSpecified(index);
} else {
throw new IllegalStateException("Current state is not among the states "
+ getEventTypeString(XMLEvent.START_ELEMENT) + " , "
+ getEventTypeString(XMLEvent.ATTRIBUTE)
+ "valid for isAttributeSpecified()");
}
}
示例11: isAttributeSpecified
/** Returns a boolean which indicates if this
* attribute was created by default
* @param index the position of the attribute
* @return true if this is a default attribute
* @throws IllegalStateException if this is not a START_ELEMENT or ATTRIBUTE
*/
public boolean isAttributeSpecified(int index) {
//check that current state should be either START_ELEMENT or ATTRIBUTE
if( (fEventType == XMLEvent.START_ELEMENT) || (fEventType == XMLEvent.ATTRIBUTE)){
return fScanner.getAttributeIterator().isSpecified(index) ;
} else{
throw new IllegalStateException("Current state is not among the states "
+ getEventTypeString(XMLEvent.START_ELEMENT) + " , "
+ getEventTypeString(XMLEvent.ATTRIBUTE)
+ "valid for isAttributeSpecified()") ;
}
}
示例12: getEventTypeString
final static String getEventTypeString(int eventType) {
switch (eventType) {
case XMLEvent.START_ELEMENT:
return "START_ELEMENT";
case XMLEvent.END_ELEMENT:
return "END_ELEMENT";
case XMLEvent.PROCESSING_INSTRUCTION:
return "PROCESSING_INSTRUCTION";
case XMLEvent.CHARACTERS:
return "CHARACTERS";
case XMLEvent.COMMENT:
return "COMMENT";
case XMLEvent.START_DOCUMENT:
return "START_DOCUMENT";
case XMLEvent.END_DOCUMENT:
return "END_DOCUMENT";
case XMLEvent.ENTITY_REFERENCE:
return "ENTITY_REFERENCE";
case XMLEvent.ATTRIBUTE:
return "ATTRIBUTE";
case XMLEvent.DTD:
return "DTD";
case XMLEvent.CDATA:
return "CDATA";
case XMLEvent.SPACE:
return "SPACE";
}
return "UNKNOWN_EVENT_TYPE, " + String.valueOf(eventType);
}
示例13: getAttributeCount
/**
* Returns the count of attributes on this START_ELEMENT, this method is
* only valid on a START_ELEMENT or ATTRIBUTE. This count excludes namespace
* definitions. Attribute indices are zero-based.
*
* @return returns the number of attributes
* @throws IllegalStateException if this is not a START_ELEMENT or ATTRIBUTE
*/
public int getAttributeCount() {
//xxx: recognize SAX properties namespace, namespace-prefix to get XML Namespace declarations
//does length includes namespace declarations ?
//State should be either START_ELEMENT or ATTRIBUTE
if (fEventType == XMLEvent.START_ELEMENT || fEventType == XMLEvent.ATTRIBUTE) {
return fScanner.getAttributeIterator().getLength();
} else {
throw new java.lang.IllegalStateException("Current state is not among the states "
+ getEventTypeString(XMLEvent.START_ELEMENT) + " , "
+ getEventTypeString(XMLEvent.ATTRIBUTE)
+ "valid for getAttributeCount()");
}
}
示例14: getAttributeLocalName
/**
* @param index
* @return
*/
public String getAttributeLocalName(int index) {
//State should be either START_ELEMENT or ATTRIBUTE
if (fEventType == XMLEvent.START_ELEMENT || fEventType == XMLEvent.ATTRIBUTE) {
return fScanner.getAttributeIterator().getLocalName(index);
} else {
throw new java.lang.IllegalStateException();
}
}
示例15: getAttributePrefix
/**
* Returns the prefix of this attribute at the provided index
*
* @param index the position of the attribute
* @return the prefix of the attribute
* @throws IllegalStateException if this is not a START_ELEMENT or ATTRIBUTE
*/
public String getAttributePrefix(int index) {
//State should be either START_ELEMENT or ATTRIBUTE
if (fEventType == XMLEvent.START_ELEMENT || fEventType == XMLEvent.ATTRIBUTE) {
return fScanner.getAttributeIterator().getPrefix(index);
} else {
throw new java.lang.IllegalStateException("Current state is not among the states "
+ getEventTypeString(XMLEvent.START_ELEMENT) + " , "
+ getEventTypeString(XMLEvent.ATTRIBUTE)
+ "valid for getAttributePrefix()");
}
}