Java Code Examples for com.sun.xml.internal.stream.XMLEntityStorage#getEntity()

The following examples show how to use com.sun.xml.internal.stream.XMLEntityStorage#getEntity() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: XMLStreamReaderImpl.java    From jdk1.8-source-analysis with Apache License 2.0 5 votes vote down vote up
/** Return true if the current event has text, false otherwise
 * The following events have text:
 * CHARACTERS,DTD ,ENTITY_REFERENCE, COMMENT
 */
public boolean hasText() {
    if(DEBUG) pr("XMLReaderImpl#EVENT TYPE = " + fEventType ) ;
    if( fEventType == XMLEvent.CHARACTERS || fEventType == XMLEvent.COMMENT || fEventType == XMLEvent.CDATA) {
        return fScanner.getCharacterData().length > 0;
    } else if(fEventType == XMLEvent.ENTITY_REFERENCE) {
        String name = fScanner.getEntityName();
        if(name != null){
            if(fScanner.foundBuiltInRefs)
                return true;

            XMLEntityStorage entityStore = fEntityManager.getEntityStore();
            Entity en = entityStore.getEntity(name);
            if(en == null)
                return false;
            if(en.isExternal()){
                return ((Entity.ExternalEntity)en).entityLocation.getExpandedSystemId() != null;
            } else{
                return ((Entity.InternalEntity)en).text != null ;
            }
        }else
            return false;
    } else {
        if(fEventType == XMLEvent.DTD)
            return fScanner.fSeenDoctypeDecl;
    }
    return false;
}
 
Example 2
Source File: XMLStreamReaderImpl.java    From openjdk-8-source with GNU General Public License v2.0 5 votes vote down vote up
/** Return true if the current event has text, false otherwise
 * The following events have text:
 * CHARACTERS,DTD ,ENTITY_REFERENCE, COMMENT
 */
public boolean hasText() {
    if(DEBUG) pr("XMLReaderImpl#EVENT TYPE = " + fEventType ) ;
    if( fEventType == XMLEvent.CHARACTERS || fEventType == XMLEvent.COMMENT || fEventType == XMLEvent.CDATA) {
        return fScanner.getCharacterData().length > 0 ? true : false;
    } else if(fEventType == XMLEvent.ENTITY_REFERENCE) {
        String name = fScanner.getEntityName();
        if(name != null){
            if(fScanner.foundBuiltInRefs)
                return true;

            XMLEntityStorage entityStore = fEntityManager.getEntityStore();
            Entity en = entityStore.getEntity(name);
            if(en == null)
                return false;
            if(en.isExternal()){
                return ((Entity.ExternalEntity)en).entityLocation.getExpandedSystemId() != null ? true : false;
            } else{
                return ((Entity.InternalEntity)en).text != null ? true : false ;
            }
        }else
            return false;
    } else {
        if(fEventType == XMLEvent.DTD)
            return fScanner.fSeenDoctypeDecl;
    }
    return false;
}
 
Example 3
Source File: XMLStreamReaderImpl.java    From hottub with GNU General Public License v2.0 5 votes vote down vote up
/** Return true if the current event has text, false otherwise
 * The following events have text:
 * CHARACTERS,DTD ,ENTITY_REFERENCE, COMMENT
 */
public boolean hasText() {
    if(DEBUG) pr("XMLReaderImpl#EVENT TYPE = " + fEventType ) ;
    if( fEventType == XMLEvent.CHARACTERS || fEventType == XMLEvent.COMMENT || fEventType == XMLEvent.CDATA) {
        return fScanner.getCharacterData().length > 0;
    } else if(fEventType == XMLEvent.ENTITY_REFERENCE) {
        String name = fScanner.getEntityName();
        if(name != null){
            if(fScanner.foundBuiltInRefs)
                return true;

            XMLEntityStorage entityStore = fEntityManager.getEntityStore();
            Entity en = entityStore.getEntity(name);
            if(en == null)
                return false;
            if(en.isExternal()){
                return ((Entity.ExternalEntity)en).entityLocation.getExpandedSystemId() != null;
            } else{
                return ((Entity.InternalEntity)en).text != null ;
            }
        }else
            return false;
    } else {
        if(fEventType == XMLEvent.DTD)
            return fScanner.fSeenDoctypeDecl;
    }
    return false;
}
 
Example 4
Source File: XMLStreamReaderImpl.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Return true if the current event has text, false otherwise The following
 * events have text: CHARACTERS,DTD ,ENTITY_REFERENCE, COMMENT
 */
public boolean hasText() {
    if (DEBUG) {
        pr("XMLReaderImpl#EVENT TYPE = " + fEventType);
    }
    if (fEventType == XMLEvent.CHARACTERS || fEventType == XMLEvent.COMMENT
            || fEventType == XMLEvent.CDATA) {
        return fScanner.getCharacterData().length > 0;
    } else if (fEventType == XMLEvent.ENTITY_REFERENCE) {
        String name = fScanner.getEntityName();
        if (name != null) {
            if (fScanner.foundBuiltInRefs) {
                return true;
            }

            XMLEntityStorage entityStore = fEntityManager.getEntityStore();
            Entity en = entityStore.getEntity(name);
            if (en == null) {
                return false;
            }
            if (en.isExternal()) {
                return ((Entity.ExternalEntity) en).entityLocation.getExpandedSystemId() != null;
            } else {
                return ((Entity.InternalEntity) en).text != null;
            }
        } else {
            return false;
        }
    } else if (fEventType == XMLEvent.DTD) {
        return fScanner.fSeenDoctypeDecl;
    }
    return false;
}
 
Example 5
Source File: XMLStreamReaderImpl.java    From Bytecoder with Apache License 2.0 5 votes vote down vote up
/**
 * Return true if the current event has text, false otherwise The following
 * events have text: CHARACTERS,DTD ,ENTITY_REFERENCE, COMMENT
 */
public boolean hasText() {
    if (DEBUG) {
        pr("XMLReaderImpl#EVENT TYPE = " + fEventType);
    }
    if (fEventType == XMLEvent.CHARACTERS || fEventType == XMLEvent.COMMENT
            || fEventType == XMLEvent.CDATA) {
        return fScanner.getCharacterData().length > 0;
    } else if (fEventType == XMLEvent.ENTITY_REFERENCE) {
        String name = fScanner.getEntityName();
        if (name != null) {
            if (fScanner.foundBuiltInRefs) {
                return true;
            }

            XMLEntityStorage entityStore = fEntityManager.getEntityStore();
            Entity en = entityStore.getEntity(name);
            if (en == null) {
                return false;
            }
            if (en.isExternal()) {
                return ((Entity.ExternalEntity) en).entityLocation.getExpandedSystemId() != null;
            } else {
                return ((Entity.InternalEntity) en).text != null;
            }
        } else {
            return false;
        }
    } else if (fEventType == XMLEvent.DTD) {
        return fScanner.fSeenDoctypeDecl;
    }
    return false;
}
 
Example 6
Source File: XMLStreamReaderImpl.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 5 votes vote down vote up
/** Return true if the current event has text, false otherwise
 * The following events have text:
 * CHARACTERS,DTD ,ENTITY_REFERENCE, COMMENT
 */
public boolean hasText() {
    if(DEBUG) pr("XMLReaderImpl#EVENT TYPE = " + fEventType ) ;
    if( fEventType == XMLEvent.CHARACTERS || fEventType == XMLEvent.COMMENT || fEventType == XMLEvent.CDATA) {
        return fScanner.getCharacterData().length > 0;
    } else if(fEventType == XMLEvent.ENTITY_REFERENCE) {
        String name = fScanner.getEntityName();
        if(name != null){
            if(fScanner.foundBuiltInRefs)
                return true;

            XMLEntityStorage entityStore = fEntityManager.getEntityStore();
            Entity en = entityStore.getEntity(name);
            if(en == null)
                return false;
            if(en.isExternal()){
                return ((Entity.ExternalEntity)en).entityLocation.getExpandedSystemId() != null;
            } else{
                return ((Entity.InternalEntity)en).text != null ;
            }
        }else
            return false;
    } else {
        if(fEventType == XMLEvent.DTD)
            return fScanner.fSeenDoctypeDecl;
    }
    return false;
}
 
Example 7
Source File: XMLStreamReaderImpl.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
/** Return true if the current event has text, false otherwise
 * The following events have text:
 * CHARACTERS,DTD ,ENTITY_REFERENCE, COMMENT
 */
public boolean hasText() {
    if(DEBUG) pr("XMLReaderImpl#EVENT TYPE = " + fEventType ) ;
    if( fEventType == XMLEvent.CHARACTERS || fEventType == XMLEvent.COMMENT || fEventType == XMLEvent.CDATA) {
        return fScanner.getCharacterData().length > 0;
    } else if(fEventType == XMLEvent.ENTITY_REFERENCE) {
        String name = fScanner.getEntityName();
        if(name != null){
            if(fScanner.foundBuiltInRefs)
                return true;

            XMLEntityStorage entityStore = fEntityManager.getEntityStore();
            Entity en = entityStore.getEntity(name);
            if(en == null)
                return false;
            if(en.isExternal()){
                return ((Entity.ExternalEntity)en).entityLocation.getExpandedSystemId() != null;
            } else{
                return ((Entity.InternalEntity)en).text != null ;
            }
        }else
            return false;
    } else {
        if(fEventType == XMLEvent.DTD)
            return fScanner.fSeenDoctypeDecl;
    }
    return false;
}
 
Example 8
Source File: XMLStreamReaderImpl.java    From JDKSourceCode1.8 with MIT License 5 votes vote down vote up
/** Return true if the current event has text, false otherwise
 * The following events have text:
 * CHARACTERS,DTD ,ENTITY_REFERENCE, COMMENT
 */
public boolean hasText() {
    if(DEBUG) pr("XMLReaderImpl#EVENT TYPE = " + fEventType ) ;
    if( fEventType == XMLEvent.CHARACTERS || fEventType == XMLEvent.COMMENT || fEventType == XMLEvent.CDATA) {
        return fScanner.getCharacterData().length > 0;
    } else if(fEventType == XMLEvent.ENTITY_REFERENCE) {
        String name = fScanner.getEntityName();
        if(name != null){
            if(fScanner.foundBuiltInRefs)
                return true;

            XMLEntityStorage entityStore = fEntityManager.getEntityStore();
            Entity en = entityStore.getEntity(name);
            if(en == null)
                return false;
            if(en.isExternal()){
                return ((Entity.ExternalEntity)en).entityLocation.getExpandedSystemId() != null;
            } else{
                return ((Entity.InternalEntity)en).text != null ;
            }
        }else
            return false;
    } else {
        if(fEventType == XMLEvent.DTD)
            return fScanner.fSeenDoctypeDecl;
    }
    return false;
}
 
Example 9
Source File: XMLStreamReaderImpl.java    From openjdk-8 with GNU General Public License v2.0 5 votes vote down vote up
/** Return true if the current event has text, false otherwise
 * The following events have text:
 * CHARACTERS,DTD ,ENTITY_REFERENCE, COMMENT
 */
public boolean hasText() {
    if(DEBUG) pr("XMLReaderImpl#EVENT TYPE = " + fEventType ) ;
    if( fEventType == XMLEvent.CHARACTERS || fEventType == XMLEvent.COMMENT || fEventType == XMLEvent.CDATA) {
        return fScanner.getCharacterData().length > 0 ? true : false;
    } else if(fEventType == XMLEvent.ENTITY_REFERENCE) {
        String name = fScanner.getEntityName();
        if(name != null){
            if(fScanner.foundBuiltInRefs)
                return true;

            XMLEntityStorage entityStore = fEntityManager.getEntityStore();
            Entity en = entityStore.getEntity(name);
            if(en == null)
                return false;
            if(en.isExternal()){
                return ((Entity.ExternalEntity)en).entityLocation.getExpandedSystemId() != null ? true : false;
            } else{
                return ((Entity.InternalEntity)en).text != null ? true : false ;
            }
        }else
            return false;
    } else {
        if(fEventType == XMLEvent.DTD)
            return fScanner.fSeenDoctypeDecl;
    }
    return false;
}
 
Example 10
Source File: XMLStreamReaderImpl.java    From jdk8u60 with GNU General Public License v2.0 5 votes vote down vote up
/** Return true if the current event has text, false otherwise
 * The following events have text:
 * CHARACTERS,DTD ,ENTITY_REFERENCE, COMMENT
 */
public boolean hasText() {
    if(DEBUG) pr("XMLReaderImpl#EVENT TYPE = " + fEventType ) ;
    if( fEventType == XMLEvent.CHARACTERS || fEventType == XMLEvent.COMMENT || fEventType == XMLEvent.CDATA) {
        return fScanner.getCharacterData().length > 0 ? true : false;
    } else if(fEventType == XMLEvent.ENTITY_REFERENCE) {
        String name = fScanner.getEntityName();
        if(name != null){
            if(fScanner.foundBuiltInRefs)
                return true;

            XMLEntityStorage entityStore = fEntityManager.getEntityStore();
            Entity en = entityStore.getEntity(name);
            if(en == null)
                return false;
            if(en.isExternal()){
                return ((Entity.ExternalEntity)en).entityLocation.getExpandedSystemId() != null ? true : false;
            } else{
                return ((Entity.InternalEntity)en).text != null ? true : false ;
            }
        }else
            return false;
    } else {
        if(fEventType == XMLEvent.DTD)
            return fScanner.fSeenDoctypeDecl;
    }
    return false;
}
 
Example 11
Source File: XMLStreamReaderImpl.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
/** Return true if the current event has text, false otherwise
 * The following events have text:
 * CHARACTERS,DTD ,ENTITY_REFERENCE, COMMENT
 */
public boolean hasText() {
    if(DEBUG) pr("XMLReaderImpl#EVENT TYPE = " + fEventType ) ;
    if( fEventType == XMLEvent.CHARACTERS || fEventType == XMLEvent.COMMENT || fEventType == XMLEvent.CDATA) {
        return fScanner.getCharacterData().length > 0;
    } else if(fEventType == XMLEvent.ENTITY_REFERENCE) {
        String name = fScanner.getEntityName();
        if(name != null){
            if(fScanner.foundBuiltInRefs)
                return true;

            XMLEntityStorage entityStore = fEntityManager.getEntityStore();
            Entity en = entityStore.getEntity(name);
            if(en == null)
                return false;
            if(en.isExternal()){
                return ((Entity.ExternalEntity)en).entityLocation.getExpandedSystemId() != null;
            } else{
                return ((Entity.InternalEntity)en).text != null ;
            }
        }else
            return false;
    } else {
        if(fEventType == XMLEvent.DTD)
            return fScanner.fSeenDoctypeDecl;
    }
    return false;
}
 
Example 12
Source File: XMLStreamReaderImpl.java    From openjdk-jdk8u with GNU General Public License v2.0 4 votes vote down vote up
/** Returns the current value of the parse event as a string,
 * this returns the string value of a CHARACTERS event,
 * returns the value of a COMMENT, the replacement value
 * for an ENTITY_REFERENCE,
 * or the String value of the DTD
 * @return the current text or null
 * @throws java.lang.IllegalStateException if this state is not
 * a valid text state.
 */
public String getText() {
    if( fEventType == XMLEvent.CHARACTERS || fEventType == XMLEvent.COMMENT
            || fEventType == XMLEvent.CDATA || fEventType == XMLEvent.SPACE){
        //this requires creation of new string
        //fEventType == XMLEvent.ENTITY_REFERENCE
        return fScanner.getCharacterData().toString() ;
    } else if(fEventType == XMLEvent.ENTITY_REFERENCE){
        String name = fScanner.getEntityName();
        if(name != null){
            if(fScanner.foundBuiltInRefs)
                return fScanner.getCharacterData().toString();

            XMLEntityStorage entityStore = fEntityManager.getEntityStore();
            Entity en = entityStore.getEntity(name);
            if(en == null)
                return null;
            if(en.isExternal())
                return ((Entity.ExternalEntity)en).entityLocation.getExpandedSystemId();
            else
                return ((Entity.InternalEntity)en).text;
        }else
            return null;
    }
    else if(fEventType == XMLEvent.DTD){
            if(fDTDDecl != null){
                return fDTDDecl;
            }
            XMLStringBuffer tmpBuffer = fScanner.getDTDDecl();
            fDTDDecl = tmpBuffer.toString();
            return fDTDDecl;
    } else{
            throw new IllegalStateException("Current state " + getEventTypeString(fEventType)
                 + " is not among the states" + getEventTypeString(XMLEvent.CHARACTERS) + ", "
                 + getEventTypeString(XMLEvent.COMMENT) + ", "
                 + getEventTypeString(XMLEvent.CDATA) + ", "
                 + getEventTypeString(XMLEvent.SPACE) + ", "
                 + getEventTypeString(XMLEvent.ENTITY_REFERENCE) + ", "
                 + getEventTypeString(XMLEvent.DTD) + " valid for getText() " ) ;
    }
}
 
Example 13
Source File: XMLStreamReaderImpl.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 4 votes vote down vote up
/** Returns the current value of the parse event as a string,
 * this returns the string value of a CHARACTERS event,
 * returns the value of a COMMENT, the replacement value
 * for an ENTITY_REFERENCE,
 * or the String value of the DTD
 * @return the current text or null
 * @throws java.lang.IllegalStateException if this state is not
 * a valid text state.
 */
public String getText() {
    if( fEventType == XMLEvent.CHARACTERS || fEventType == XMLEvent.COMMENT
            || fEventType == XMLEvent.CDATA || fEventType == XMLEvent.SPACE){
        //this requires creation of new string
        //fEventType == XMLEvent.ENTITY_REFERENCE
        return fScanner.getCharacterData().toString() ;
    } else if(fEventType == XMLEvent.ENTITY_REFERENCE){
        String name = fScanner.getEntityName();
        if(name != null){
            if(fScanner.foundBuiltInRefs)
                return fScanner.getCharacterData().toString();

            XMLEntityStorage entityStore = fEntityManager.getEntityStore();
            Entity en = entityStore.getEntity(name);
            if(en == null)
                return null;
            if(en.isExternal())
                return ((Entity.ExternalEntity)en).entityLocation.getExpandedSystemId();
            else
                return ((Entity.InternalEntity)en).text;
        }else
            return null;
    }
    else if(fEventType == XMLEvent.DTD){
            if(fDTDDecl != null){
                return fDTDDecl;
            }
            XMLStringBuffer tmpBuffer = fScanner.getDTDDecl();
            fDTDDecl = tmpBuffer.toString();
            return fDTDDecl;
    } else{
            throw new IllegalStateException("Current state " + getEventTypeString(fEventType)
                 + " is not among the states" + getEventTypeString(XMLEvent.CHARACTERS) + ", "
                 + getEventTypeString(XMLEvent.COMMENT) + ", "
                 + getEventTypeString(XMLEvent.CDATA) + ", "
                 + getEventTypeString(XMLEvent.SPACE) + ", "
                 + getEventTypeString(XMLEvent.ENTITY_REFERENCE) + ", "
                 + getEventTypeString(XMLEvent.DTD) + " valid for getText() " ) ;
    }
}
 
Example 14
Source File: XMLStreamReaderImpl.java    From Bytecoder with Apache License 2.0 4 votes vote down vote up
/**
 * Returns the current value of the parse event as a string, this returns
 * the string value of a CHARACTERS event, returns the value of a COMMENT,
 * the replacement value for an ENTITY_REFERENCE, or the String value of the
 * DTD
 *
 * @return the current text or null
 * @throws java.lang.IllegalStateException if this state is not a valid text
 * state.
 */
public String getText() {
    if (fEventType == XMLEvent.CHARACTERS || fEventType == XMLEvent.COMMENT
            || fEventType == XMLEvent.CDATA || fEventType == XMLEvent.SPACE) {
        //this requires creation of new string
        //fEventType == XMLEvent.ENTITY_REFERENCE
        return fScanner.getCharacterData().toString();
    } else if (fEventType == XMLEvent.ENTITY_REFERENCE) {
        String name = fScanner.getEntityName();
        if (name != null) {
            if (fScanner.foundBuiltInRefs) {
                return fScanner.getCharacterData().toString();
            }

            XMLEntityStorage entityStore = fEntityManager.getEntityStore();
            Entity en = entityStore.getEntity(name);
            if (en == null) {
                return null;
            }
            if (en.isExternal()) {
                return ((Entity.ExternalEntity) en).entityLocation.getExpandedSystemId();
            } else {
                return ((Entity.InternalEntity) en).text;
            }
        } else {
            return null;
        }
    } else if (fEventType == XMLEvent.DTD) {
        if (fDTDDecl != null) {
            return fDTDDecl;
        }
        XMLStringBuffer tmpBuffer = fScanner.getDTDDecl();
        fDTDDecl = tmpBuffer.toString();
        return fDTDDecl;
    } else {
        throw new IllegalStateException("Current state " + getEventTypeString(fEventType)
                + " is not among the states" + getEventTypeString(XMLEvent.CHARACTERS) + ", "
                + getEventTypeString(XMLEvent.COMMENT) + ", "
                + getEventTypeString(XMLEvent.CDATA) + ", "
                + getEventTypeString(XMLEvent.SPACE) + ", "
                + getEventTypeString(XMLEvent.ENTITY_REFERENCE) + ", "
                + getEventTypeString(XMLEvent.DTD) + " valid for getText() ");
    }
}
 
Example 15
Source File: XMLStreamReaderImpl.java    From jdk8u60 with GNU General Public License v2.0 4 votes vote down vote up
/** Returns the current value of the parse event as a string,
 * this returns the string value of a CHARACTERS event,
 * returns the value of a COMMENT, the replacement value
 * for an ENTITY_REFERENCE,
 * or the String value of the DTD
 * @return the current text or null
 * @throws java.lang.IllegalStateException if this state is not
 * a valid text state.
 */
public String getText() {
    if( fEventType == XMLEvent.CHARACTERS || fEventType == XMLEvent.COMMENT
            || fEventType == XMLEvent.CDATA || fEventType == XMLEvent.SPACE){
        //this requires creation of new string
        //fEventType == XMLEvent.ENTITY_REFERENCE
        return fScanner.getCharacterData().toString() ;
    } else if(fEventType == XMLEvent.ENTITY_REFERENCE){
        String name = fScanner.getEntityName();
        if(name != null){
            if(fScanner.foundBuiltInRefs)
                return fScanner.getCharacterData().toString();

            XMLEntityStorage entityStore = fEntityManager.getEntityStore();
            Entity en = entityStore.getEntity(name);
            if(en == null)
                return null;
            if(en.isExternal())
                return ((Entity.ExternalEntity)en).entityLocation.getExpandedSystemId();
            else
                return ((Entity.InternalEntity)en).text;
        }else
            return null;
    }
    else if(fEventType == XMLEvent.DTD){
            if(fDTDDecl != null){
                return fDTDDecl;
            }
            XMLStringBuffer tmpBuffer = fScanner.getDTDDecl();
            fDTDDecl = tmpBuffer.toString();
            return fDTDDecl;
    } else{
            throw new IllegalStateException("Current state " + getEventTypeString(fEventType)
                 + " is not among the states" + getEventTypeString(XMLEvent.CHARACTERS) + ", "
                 + getEventTypeString(XMLEvent.COMMENT) + ", "
                 + getEventTypeString(XMLEvent.CDATA) + ", "
                 + getEventTypeString(XMLEvent.SPACE) + ", "
                 + getEventTypeString(XMLEvent.ENTITY_REFERENCE) + ", "
                 + getEventTypeString(XMLEvent.DTD) + " valid for getText() " ) ;
    }
}
 
Example 16
Source File: XMLStreamReaderImpl.java    From openjdk-jdk9 with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Returns the current value of the parse event as a string, this returns
 * the string value of a CHARACTERS event, returns the value of a COMMENT,
 * the replacement value for an ENTITY_REFERENCE, or the String value of the
 * DTD
 *
 * @return the current text or null
 * @throws java.lang.IllegalStateException if this state is not a valid text
 * state.
 */
public String getText() {
    if (fEventType == XMLEvent.CHARACTERS || fEventType == XMLEvent.COMMENT
            || fEventType == XMLEvent.CDATA || fEventType == XMLEvent.SPACE) {
        //this requires creation of new string
        //fEventType == XMLEvent.ENTITY_REFERENCE
        return fScanner.getCharacterData().toString();
    } else if (fEventType == XMLEvent.ENTITY_REFERENCE) {
        String name = fScanner.getEntityName();
        if (name != null) {
            if (fScanner.foundBuiltInRefs) {
                return fScanner.getCharacterData().toString();
            }

            XMLEntityStorage entityStore = fEntityManager.getEntityStore();
            Entity en = entityStore.getEntity(name);
            if (en == null) {
                return null;
            }
            if (en.isExternal()) {
                return ((Entity.ExternalEntity) en).entityLocation.getExpandedSystemId();
            } else {
                return ((Entity.InternalEntity) en).text;
            }
        } else {
            return null;
        }
    } else if (fEventType == XMLEvent.DTD) {
        if (fDTDDecl != null) {
            return fDTDDecl;
        }
        XMLStringBuffer tmpBuffer = fScanner.getDTDDecl();
        fDTDDecl = tmpBuffer.toString();
        return fDTDDecl;
    } else {
        throw new IllegalStateException("Current state " + getEventTypeString(fEventType)
                + " is not among the states" + getEventTypeString(XMLEvent.CHARACTERS) + ", "
                + getEventTypeString(XMLEvent.COMMENT) + ", "
                + getEventTypeString(XMLEvent.CDATA) + ", "
                + getEventTypeString(XMLEvent.SPACE) + ", "
                + getEventTypeString(XMLEvent.ENTITY_REFERENCE) + ", "
                + getEventTypeString(XMLEvent.DTD) + " valid for getText() ");
    }
}
 
Example 17
Source File: XMLStreamReaderImpl.java    From hottub with GNU General Public License v2.0 4 votes vote down vote up
/** Returns the current value of the parse event as a string,
 * this returns the string value of a CHARACTERS event,
 * returns the value of a COMMENT, the replacement value
 * for an ENTITY_REFERENCE,
 * or the String value of the DTD
 * @return the current text or null
 * @throws java.lang.IllegalStateException if this state is not
 * a valid text state.
 */
public String getText() {
    if( fEventType == XMLEvent.CHARACTERS || fEventType == XMLEvent.COMMENT
            || fEventType == XMLEvent.CDATA || fEventType == XMLEvent.SPACE){
        //this requires creation of new string
        //fEventType == XMLEvent.ENTITY_REFERENCE
        return fScanner.getCharacterData().toString() ;
    } else if(fEventType == XMLEvent.ENTITY_REFERENCE){
        String name = fScanner.getEntityName();
        if(name != null){
            if(fScanner.foundBuiltInRefs)
                return fScanner.getCharacterData().toString();

            XMLEntityStorage entityStore = fEntityManager.getEntityStore();
            Entity en = entityStore.getEntity(name);
            if(en == null)
                return null;
            if(en.isExternal())
                return ((Entity.ExternalEntity)en).entityLocation.getExpandedSystemId();
            else
                return ((Entity.InternalEntity)en).text;
        }else
            return null;
    }
    else if(fEventType == XMLEvent.DTD){
            if(fDTDDecl != null){
                return fDTDDecl;
            }
            XMLStringBuffer tmpBuffer = fScanner.getDTDDecl();
            fDTDDecl = tmpBuffer.toString();
            return fDTDDecl;
    } else{
            throw new IllegalStateException("Current state " + getEventTypeString(fEventType)
                 + " is not among the states" + getEventTypeString(XMLEvent.CHARACTERS) + ", "
                 + getEventTypeString(XMLEvent.COMMENT) + ", "
                 + getEventTypeString(XMLEvent.CDATA) + ", "
                 + getEventTypeString(XMLEvent.SPACE) + ", "
                 + getEventTypeString(XMLEvent.ENTITY_REFERENCE) + ", "
                 + getEventTypeString(XMLEvent.DTD) + " valid for getText() " ) ;
    }
}
 
Example 18
Source File: XMLStreamReaderImpl.java    From openjdk-8 with GNU General Public License v2.0 4 votes vote down vote up
/** Returns the current value of the parse event as a string,
 * this returns the string value of a CHARACTERS event,
 * returns the value of a COMMENT, the replacement value
 * for an ENTITY_REFERENCE,
 * or the String value of the DTD
 * @return the current text or null
 * @throws java.lang.IllegalStateException if this state is not
 * a valid text state.
 */
public String getText() {
    if( fEventType == XMLEvent.CHARACTERS || fEventType == XMLEvent.COMMENT
            || fEventType == XMLEvent.CDATA || fEventType == XMLEvent.SPACE){
        //this requires creation of new string
        //fEventType == XMLEvent.ENTITY_REFERENCE
        return fScanner.getCharacterData().toString() ;
    } else if(fEventType == XMLEvent.ENTITY_REFERENCE){
        String name = fScanner.getEntityName();
        if(name != null){
            if(fScanner.foundBuiltInRefs)
                return fScanner.getCharacterData().toString();

            XMLEntityStorage entityStore = fEntityManager.getEntityStore();
            Entity en = entityStore.getEntity(name);
            if(en == null)
                return null;
            if(en.isExternal())
                return ((Entity.ExternalEntity)en).entityLocation.getExpandedSystemId();
            else
                return ((Entity.InternalEntity)en).text;
        }else
            return null;
    }
    else if(fEventType == XMLEvent.DTD){
            if(fDTDDecl != null){
                return fDTDDecl;
            }
            XMLStringBuffer tmpBuffer = fScanner.getDTDDecl();
            fDTDDecl = tmpBuffer.toString();
            return fDTDDecl;
    } else{
            throw new IllegalStateException("Current state " + getEventTypeString(fEventType)
                 + " is not among the states" + getEventTypeString(XMLEvent.CHARACTERS) + ", "
                 + getEventTypeString(XMLEvent.COMMENT) + ", "
                 + getEventTypeString(XMLEvent.CDATA) + ", "
                 + getEventTypeString(XMLEvent.SPACE) + ", "
                 + getEventTypeString(XMLEvent.ENTITY_REFERENCE) + ", "
                 + getEventTypeString(XMLEvent.DTD) + " valid for getText() " ) ;
    }
}
 
Example 19
Source File: XMLStreamReaderImpl.java    From openjdk-8-source with GNU General Public License v2.0 4 votes vote down vote up
/** Returns the current value of the parse event as a string,
 * this returns the string value of a CHARACTERS event,
 * returns the value of a COMMENT, the replacement value
 * for an ENTITY_REFERENCE,
 * or the String value of the DTD
 * @return the current text or null
 * @throws java.lang.IllegalStateException if this state is not
 * a valid text state.
 */
public String getText() {
    if( fEventType == XMLEvent.CHARACTERS || fEventType == XMLEvent.COMMENT
            || fEventType == XMLEvent.CDATA || fEventType == XMLEvent.SPACE){
        //this requires creation of new string
        //fEventType == XMLEvent.ENTITY_REFERENCE
        return fScanner.getCharacterData().toString() ;
    } else if(fEventType == XMLEvent.ENTITY_REFERENCE){
        String name = fScanner.getEntityName();
        if(name != null){
            if(fScanner.foundBuiltInRefs)
                return fScanner.getCharacterData().toString();

            XMLEntityStorage entityStore = fEntityManager.getEntityStore();
            Entity en = entityStore.getEntity(name);
            if(en == null)
                return null;
            if(en.isExternal())
                return ((Entity.ExternalEntity)en).entityLocation.getExpandedSystemId();
            else
                return ((Entity.InternalEntity)en).text;
        }else
            return null;
    }
    else if(fEventType == XMLEvent.DTD){
            if(fDTDDecl != null){
                return fDTDDecl;
            }
            XMLStringBuffer tmpBuffer = fScanner.getDTDDecl();
            fDTDDecl = tmpBuffer.toString();
            return fDTDDecl;
    } else{
            throw new IllegalStateException("Current state " + getEventTypeString(fEventType)
                 + " is not among the states" + getEventTypeString(XMLEvent.CHARACTERS) + ", "
                 + getEventTypeString(XMLEvent.COMMENT) + ", "
                 + getEventTypeString(XMLEvent.CDATA) + ", "
                 + getEventTypeString(XMLEvent.SPACE) + ", "
                 + getEventTypeString(XMLEvent.ENTITY_REFERENCE) + ", "
                 + getEventTypeString(XMLEvent.DTD) + " valid for getText() " ) ;
    }
}
 
Example 20
Source File: XMLStreamReaderImpl.java    From jdk1.8-source-analysis with Apache License 2.0 4 votes vote down vote up
/** Returns the current value of the parse event as a string,
 * this returns the string value of a CHARACTERS event,
 * returns the value of a COMMENT, the replacement value
 * for an ENTITY_REFERENCE,
 * or the String value of the DTD
 * @return the current text or null
 * @throws java.lang.IllegalStateException if this state is not
 * a valid text state.
 */
public String getText() {
    if( fEventType == XMLEvent.CHARACTERS || fEventType == XMLEvent.COMMENT
            || fEventType == XMLEvent.CDATA || fEventType == XMLEvent.SPACE){
        //this requires creation of new string
        //fEventType == XMLEvent.ENTITY_REFERENCE
        return fScanner.getCharacterData().toString() ;
    } else if(fEventType == XMLEvent.ENTITY_REFERENCE){
        String name = fScanner.getEntityName();
        if(name != null){
            if(fScanner.foundBuiltInRefs)
                return fScanner.getCharacterData().toString();

            XMLEntityStorage entityStore = fEntityManager.getEntityStore();
            Entity en = entityStore.getEntity(name);
            if(en == null)
                return null;
            if(en.isExternal())
                return ((Entity.ExternalEntity)en).entityLocation.getExpandedSystemId();
            else
                return ((Entity.InternalEntity)en).text;
        }else
            return null;
    }
    else if(fEventType == XMLEvent.DTD){
            if(fDTDDecl != null){
                return fDTDDecl;
            }
            XMLStringBuffer tmpBuffer = fScanner.getDTDDecl();
            fDTDDecl = tmpBuffer.toString();
            return fDTDDecl;
    } else{
            throw new IllegalStateException("Current state " + getEventTypeString(fEventType)
                 + " is not among the states" + getEventTypeString(XMLEvent.CHARACTERS) + ", "
                 + getEventTypeString(XMLEvent.COMMENT) + ", "
                 + getEventTypeString(XMLEvent.CDATA) + ", "
                 + getEventTypeString(XMLEvent.SPACE) + ", "
                 + getEventTypeString(XMLEvent.ENTITY_REFERENCE) + ", "
                 + getEventTypeString(XMLEvent.DTD) + " valid for getText() " ) ;
    }
}