當前位置: 首頁>>代碼示例>>Java>>正文


Java XMLEvent.NAMESPACE屬性代碼示例

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

}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:23,代碼來源:XMLStreamReaderImpl.java

示例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()." );
    }
}
 
開發者ID:SunburstApps,項目名稱:OpenJSharp,代碼行數:21,代碼來源:XMLStreamReaderImpl.java

示例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()." );
    }
}
 
開發者ID:SunburstApps,項目名稱:OpenJSharp,代碼行數:22,代碼來源:XMLStreamReaderImpl.java

示例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()." );
    }

}
 
開發者ID:SunburstApps,項目名稱:OpenJSharp,代碼行數:21,代碼來源:XMLStreamReaderImpl.java

示例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().");
    }
}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:26,代碼來源:XMLStreamReaderImpl.java

示例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().");
    }
}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:23,代碼來源:XMLStreamReaderImpl.java

示例7: isNamespace

/** A utility function to check if this event is a Namespace.
 * @see Namespace
 */
public boolean isNamespace() {
    return fEventType == XMLEvent.NAMESPACE;
}
 
開發者ID:SunburstApps,項目名稱:OpenJSharp,代碼行數:6,代碼來源:DummyEvent.java

示例8: getEventType

public int getEventType(){
    return XMLEvent.NAMESPACE;
}
 
開發者ID:SunburstApps,項目名稱:OpenJSharp,代碼行數:3,代碼來源:NamespaceImpl.java


注:本文中的javax.xml.stream.events.XMLEvent.NAMESPACE屬性示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。