本文整理汇总了Java中javax.xml.stream.events.XMLEvent.NAMESPACE属性的典型用法代码示例。如果您正苦于以下问题:Java XMLEvent.NAMESPACE属性的具体用法?Java XMLEvent.NAMESPACE怎么用?Java XMLEvent.NAMESPACE使用的例子?那么, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类javax.xml.stream.events.XMLEvent
的用法示例。
在下文中一共展示了XMLEvent.NAMESPACE属性的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getNamespaceURI
/**
* Returns the uri for the namespace declared at the index.
*
* @param index the position of the namespace declaration
* @return returns the namespace uri
* @throws IllegalStateException if this is not a START_ELEMENT, END_ELEMENT
* or NAMESPACE
*/
public String getNamespaceURI(int index) {
if (fEventType == XMLEvent.START_ELEMENT || fEventType == XMLEvent.END_ELEMENT
|| fEventType == XMLEvent.NAMESPACE) {
//namespaceContext is dynamic object.
return fScanner.getNamespaceContext().getURI(fScanner.getNamespaceContext()
.getDeclaredPrefixAt(index));
} else {
throw new IllegalStateException("Current state " + getEventTypeString(fEventType)
+ " is not among the states " + getEventTypeString(XMLEvent.START_ELEMENT)
+ ", " + getEventTypeString(XMLEvent.END_ELEMENT) + ", "
+ getEventTypeString(XMLEvent.NAMESPACE)
+ " valid for getNamespaceURI().");
}
}
示例2: getNamespaceCount
/** Returns the count of namespaces declared on this START_ELEMENT or END_ELEMENT,
* this method is only valid on a START_ELEMENT, END_ELEMENT or NAMESPACE. On
* an END_ELEMENT the count is of the namespaces that are about to go
* out of scope. This is the equivalent of the information reported
* by SAX callback for an end element event.
* @return returns the number of namespace declarations on this specific element
* @throws IllegalStateException if this is not a START_ELEMENT, END_ELEMENT or NAMESPACE
*/
public int getNamespaceCount() {
//namespaceContext is dynamic object.
//REVISIT: check if it specifies all conditions mentioned in the javadoc
if(fEventType == XMLEvent.START_ELEMENT || fEventType == XMLEvent.END_ELEMENT || fEventType == XMLEvent.NAMESPACE){
return fScanner.getNamespaceContext().getDeclaredPrefixCount() ;
} else{
throw new IllegalStateException("Current event state is " + getEventTypeString(fEventType)
+ " is not among the states " + getEventTypeString(XMLEvent.START_ELEMENT)
+ ", " + getEventTypeString(XMLEvent.END_ELEMENT) + ", "
+ getEventTypeString(XMLEvent.NAMESPACE)
+ " valid for getNamespaceCount()." );
}
}
示例3: getNamespacePrefix
/** Returns the prefix for the namespace declared at the
* index. Returns null if this is the default namespace
* declaration
*
* @param index the position of the namespace declaration
* @return returns the namespace prefix
* @throws IllegalStateException if this is not a START_ELEMENT, END_ELEMENT or NAMESPACE
*/
public String getNamespacePrefix(int index) {
if(fEventType == XMLEvent.START_ELEMENT || fEventType == XMLEvent.END_ELEMENT || fEventType == XMLEvent.NAMESPACE){
//namespaceContext is dynamic object.
String prefix = fScanner.getNamespaceContext().getDeclaredPrefixAt(index) ;
return prefix.equals("") ? null : prefix ;
}
else{
throw new IllegalStateException("Current state " + getEventTypeString(fEventType)
+ " is not among the states " + getEventTypeString(XMLEvent.START_ELEMENT)
+ ", " + getEventTypeString(XMLEvent.END_ELEMENT) + ", "
+ getEventTypeString(XMLEvent.NAMESPACE)
+ " valid for getNamespacePrefix()." );
}
}
示例4: getNamespaceURI
/** Returns the uri for the namespace declared at the
* index.
*
* @param index the position of the namespace declaration
* @return returns the namespace uri
* @throws IllegalStateException if this is not a START_ELEMENT, END_ELEMENT or NAMESPACE
*/
public String getNamespaceURI(int index) {
if(fEventType == XMLEvent.START_ELEMENT || fEventType == XMLEvent.END_ELEMENT || fEventType == XMLEvent.NAMESPACE){
//namespaceContext is dynamic object.
return fScanner.getNamespaceContext().getURI(fScanner.getNamespaceContext().getDeclaredPrefixAt(index));
}
else{
throw new IllegalStateException("Current state " + getEventTypeString(fEventType)
+ " is not among the states " + getEventTypeString(XMLEvent.START_ELEMENT)
+ ", " + getEventTypeString(XMLEvent.END_ELEMENT) + ", "
+ getEventTypeString(XMLEvent.NAMESPACE)
+ " valid for getNamespaceURI()." );
}
}
示例5: getNamespaceCount
/**
* Returns the count of namespaces declared on this START_ELEMENT or
* END_ELEMENT, this method is only valid on a START_ELEMENT, END_ELEMENT or
* NAMESPACE. On an END_ELEMENT the count is of the namespaces that are
* about to go out of scope. This is the equivalent of the information
* reported by SAX callback for an end element event.
*
* @return returns the number of namespace declarations on this specific
* element
* @throws IllegalStateException if this is not a START_ELEMENT, END_ELEMENT
* or NAMESPACE
*/
public int getNamespaceCount() {
//namespaceContext is dynamic object.
//REVISIT: check if it specifies all conditions mentioned in the javadoc
if (fEventType == XMLEvent.START_ELEMENT || fEventType == XMLEvent.END_ELEMENT
|| fEventType == XMLEvent.NAMESPACE) {
return fScanner.getNamespaceContext().getDeclaredPrefixCount();
} else {
throw new IllegalStateException("Current event state is " + getEventTypeString(fEventType)
+ " is not among the states " + getEventTypeString(XMLEvent.START_ELEMENT)
+ ", " + getEventTypeString(XMLEvent.END_ELEMENT) + ", "
+ getEventTypeString(XMLEvent.NAMESPACE)
+ " valid for getNamespaceCount().");
}
}
示例6: getNamespacePrefix
/**
* Returns the prefix for the namespace declared at the index. Returns null
* if this is the default namespace declaration
*
* @param index the position of the namespace declaration
* @return returns the namespace prefix
* @throws IllegalStateException if this is not a START_ELEMENT, END_ELEMENT
* or NAMESPACE
*/
public String getNamespacePrefix(int index) {
if (fEventType == XMLEvent.START_ELEMENT || fEventType == XMLEvent.END_ELEMENT
|| fEventType == XMLEvent.NAMESPACE) {
//namespaceContext is dynamic object.
String prefix = fScanner.getNamespaceContext().getDeclaredPrefixAt(index);
return prefix.equals("") ? null : prefix;
} else {
throw new IllegalStateException("Current state " + getEventTypeString(fEventType)
+ " is not among the states " + getEventTypeString(XMLEvent.START_ELEMENT)
+ ", " + getEventTypeString(XMLEvent.END_ELEMENT) + ", "
+ getEventTypeString(XMLEvent.NAMESPACE)
+ " valid for getNamespacePrefix().");
}
}
示例7: isNamespace
/** A utility function to check if this event is a Namespace.
* @see Namespace
*/
public boolean isNamespace() {
return fEventType == XMLEvent.NAMESPACE;
}
示例8: getEventType
public int getEventType(){
return XMLEvent.NAMESPACE;
}