Java Code Examples for com.sun.xml.internal.stream.Entity#InternalEntity
The following examples show how to use
com.sun.xml.internal.stream.Entity#InternalEntity .
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 JDKSourceCode1.8 with MIT License | 5 votes |
/** 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 Bytecoder with Apache License 2.0 | 5 votes |
/** * 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 3
Source File: XMLEntityManager.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 5 votes |
/** * Adds an internal entity declaration. * <p> * <strong>Note:</strong> This method ignores subsequent entity * declarations. * <p> * <strong>Note:</strong> The name should be a unique symbol. The * SymbolTable can be used for this purpose. * * @param name The name of the entity. * @param text The text of the entity. * * @see SymbolTable */ public void addInternalEntity(String name, String text) { if (!fEntities.containsKey(name)) { Entity entity = new Entity.InternalEntity(name, text, fInExternalSubset); fEntities.put(name, entity); } else{ if(fWarnDuplicateEntityDef){ fErrorReporter.reportError(XMLMessageFormatter.XML_DOMAIN, "MSG_DUPLICATE_ENTITY_DEFINITION", new Object[]{ name }, XMLErrorReporter.SEVERITY_WARNING ); } } }
Example 4
Source File: XMLStreamReaderImpl.java From openjdk-8 with GNU General Public License v2.0 | 5 votes |
/** 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 5
Source File: XMLStreamReaderImpl.java From openjdk-8-source with GNU General Public License v2.0 | 5 votes |
/** 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 6
Source File: XMLStreamReaderImpl.java From hottub with GNU General Public License v2.0 | 5 votes |
/** 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 |
/** 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: XMLEntityManager.java From hottub with GNU General Public License v2.0 | 5 votes |
/** * Adds an internal entity declaration. * <p> * <strong>Note:</strong> This method ignores subsequent entity * declarations. * <p> * <strong>Note:</strong> The name should be a unique symbol. The * SymbolTable can be used for this purpose. * * @param name The name of the entity. * @param text The text of the entity. * * @see SymbolTable */ public void addInternalEntity(String name, String text) { if (!fEntities.containsKey(name)) { Entity entity = new Entity.InternalEntity(name, text, fInExternalSubset); fEntities.put(name, entity); } else{ if(fWarnDuplicateEntityDef){ fErrorReporter.reportError(XMLMessageFormatter.XML_DOMAIN, "MSG_DUPLICATE_ENTITY_DEFINITION", new Object[]{ name }, XMLErrorReporter.SEVERITY_WARNING ); } } }
Example 9
Source File: XMLEntityManager.java From JDKSourceCode1.8 with MIT License | 5 votes |
/** * Adds an internal entity declaration. * <p> * <strong>Note:</strong> This method ignores subsequent entity * declarations. * <p> * <strong>Note:</strong> The name should be a unique symbol. The * SymbolTable can be used for this purpose. * * @param name The name of the entity. * @param text The text of the entity. * * @see SymbolTable */ public void addInternalEntity(String name, String text) { if (!fEntities.containsKey(name)) { Entity entity = new Entity.InternalEntity(name, text, fInExternalSubset); fEntities.put(name, entity); } else{ if(fWarnDuplicateEntityDef){ fErrorReporter.reportError(XMLMessageFormatter.XML_DOMAIN, "MSG_DUPLICATE_ENTITY_DEFINITION", new Object[]{ name }, XMLErrorReporter.SEVERITY_WARNING ); } } }
Example 10
Source File: XMLEntityManager.java From openjdk-8-source with GNU General Public License v2.0 | 5 votes |
/** * Adds an internal entity declaration. * <p> * <strong>Note:</strong> This method ignores subsequent entity * declarations. * <p> * <strong>Note:</strong> The name should be a unique symbol. The * SymbolTable can be used for this purpose. * * @param name The name of the entity. * @param text The text of the entity. * * @see SymbolTable */ public void addInternalEntity(String name, String text) { if (!fEntities.containsKey(name)) { Entity entity = new Entity.InternalEntity(name, text, fInExternalSubset); fEntities.put(name, entity); } else{ if(fWarnDuplicateEntityDef){ fErrorReporter.reportError(XMLMessageFormatter.XML_DOMAIN, "MSG_DUPLICATE_ENTITY_DEFINITION", new Object[]{ name }, XMLErrorReporter.SEVERITY_WARNING ); } } }
Example 11
Source File: XMLStreamReaderImpl.java From jdk8u60 with GNU General Public License v2.0 | 5 votes |
/** 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 12
Source File: XMLEntityManager.java From TencentKona-8 with GNU General Public License v2.0 | 5 votes |
/** * Adds an internal entity declaration. * <p> * <strong>Note:</strong> This method ignores subsequent entity * declarations. * <p> * <strong>Note:</strong> The name should be a unique symbol. The * SymbolTable can be used for this purpose. * * @param name The name of the entity. * @param text The text of the entity. * * @see SymbolTable */ public void addInternalEntity(String name, String text) { if (!fEntities.containsKey(name)) { Entity entity = new Entity.InternalEntity(name, text, fInExternalSubset); fEntities.put(name, entity); } else{ if(fWarnDuplicateEntityDef){ fErrorReporter.reportError(XMLMessageFormatter.XML_DOMAIN, "MSG_DUPLICATE_ENTITY_DEFINITION", new Object[]{ name }, XMLErrorReporter.SEVERITY_WARNING ); } } }
Example 13
Source File: XMLEntityManager.java From openjdk-jdk9 with GNU General Public License v2.0 | 5 votes |
/** * Adds an internal entity declaration. * <p> * <strong>Note:</strong> This method ignores subsequent entity * declarations. * <p> * <strong>Note:</strong> The name should be a unique symbol. The * SymbolTable can be used for this purpose. * * @param name The name of the entity. * @param text The text of the entity. * * @see SymbolTable */ public void addInternalEntity(String name, String text) { if (!fEntities.containsKey(name)) { Entity entity = new Entity.InternalEntity(name, text, fInExternalSubset); fEntities.put(name, entity); } else{ if(fWarnDuplicateEntityDef){ fErrorReporter.reportError(XMLMessageFormatter.XML_DOMAIN, "MSG_DUPLICATE_ENTITY_DEFINITION", new Object[]{ name }, XMLErrorReporter.SEVERITY_WARNING ); } } }
Example 14
Source File: XMLStreamReaderImpl.java From JDKSourceCode1.8 with MIT License | 4 votes |
/** 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 jdk1.8-source-analysis with Apache License 2.0 | 4 votes |
/** 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 jdk8u60 with GNU General Public License v2.0 | 4 votes |
/** 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 openjdk-8-source with GNU General Public License v2.0 | 4 votes |
/** 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-jdk9 with GNU General Public License v2.0 | 4 votes |
/** * 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 Bytecoder with Apache License 2.0 | 4 votes |
/** * 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 hottub with GNU General Public License v2.0 | 4 votes |
/** 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() " ) ; } }