本文整理匯總了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;
}