当前位置: 首页>>代码示例>>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;未经允许,请勿转载。