com.sun.xml.internal.stream.Entity Java Examples

The following examples show how to use com.sun.xml.internal.stream.Entity. 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: XMLEntityManager.java    From openjdk-jdk9 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Adds an unparsed 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 publicId The public identifier of the entity.
 * @param systemId The system identifier of the entity.
 * @param notation The name of the notation.
 *
 * @see SymbolTable
 */
public void addUnparsedEntity(String name,
        String publicId, String systemId,
        String baseSystemId, String notation) {
    if (!fEntities.containsKey(name)) {
        Entity.ExternalEntity entity = new Entity.ExternalEntity(name,
                new XMLEntityDescriptionImpl(name, publicId, systemId, baseSystemId, null),
                notation, fInExternalSubset);
        fEntities.put(name, entity);
    } else{
        if(fWarnDuplicateEntityDef){
            fErrorReporter.reportError(XMLMessageFormatter.XML_DOMAIN,
                    "MSG_DUPLICATE_ENTITY_DEFINITION",
                    new Object[]{ name },
                    XMLErrorReporter.SEVERITY_WARNING );
        }
    }
}
 
Example #2
Source File: XMLEntityManager.java    From openjdk-8 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Return the line number where the current document event ends.
 * <p>
 * <strong>Warning:</strong> The return value from the method
 * is intended only as an approximation for the sake of error
 * reporting; it is not intended to provide sufficient information
 * to edit the character content of the original XML document.
 * <p>
 * The return value is an approximation of the line number
 * in the document entity or external parsed entity where the
 * markup triggering the event appears.
 * <p>
 * If possible, the SAX driver should provide the line position
 * of the first character after the text associated with the document
 * event.  The first line in the document is line 1.
 *
 * @return The line number, or -1 if none is available.
 */
public int getLineNumber() {
    if (fCurrentEntity != null) {
        if (fCurrentEntity.isExternal()) {
            return fCurrentEntity.lineNumber;
        } else {
            // search for the first external entity on the stack
            int size = fEntityStack.size();
            for (int i=size-1; i>0 ; i--) {
                Entity.ScannedEntity firstExternalEntity = (Entity.ScannedEntity)fEntityStack.elementAt(i);
                if (firstExternalEntity.isExternal()) {
                    return firstExternalEntity.lineNumber;
                }
            }
        }
    }

    return -1;

}
 
Example #3
Source File: XMLEntityManager.java    From hottub with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Adds an unparsed 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 publicId The public identifier of the entity.
 * @param systemId The system identifier of the entity.
 * @param notation The name of the notation.
 *
 * @see SymbolTable
 */
public void addUnparsedEntity(String name,
        String publicId, String systemId,
        String baseSystemId, String notation) {
    if (!fEntities.containsKey(name)) {
        Entity.ExternalEntity entity = new Entity.ExternalEntity(name,
                new XMLEntityDescriptionImpl(name, publicId, systemId, baseSystemId, null),
                notation, 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: XMLEntityManager.java    From openjdk-8-source with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Adds an unparsed 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 publicId The public identifier of the entity.
 * @param systemId The system identifier of the entity.
 * @param notation The name of the notation.
 *
 * @see SymbolTable
 */
public void addUnparsedEntity(String name,
        String publicId, String systemId,
        String baseSystemId, String notation) {
    if (!fEntities.containsKey(name)) {
        Entity.ExternalEntity entity = new Entity.ExternalEntity(name,
                new XMLEntityDescriptionImpl(name, publicId, systemId, baseSystemId, null),
                notation, fInExternalSubset);
        fEntities.put(name, entity);
    } else{
        if(fWarnDuplicateEntityDef){
            fErrorReporter.reportError(XMLMessageFormatter.XML_DOMAIN,
                    "MSG_DUPLICATE_ENTITY_DEFINITION",
                    new Object[]{ name },
                    XMLErrorReporter.SEVERITY_WARNING );
        }
    }
}
 
Example #5
Source File: XMLEntityManager.java    From openjdk-8 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Return the expanded system identifier for the current document event.
 * <p>
 * The return value is the expanded system identifier of the document
 * entity or of the external parsed entity in which the markup
 * triggering the event appears.
 * <p>
 * If the system identifier is a URL, the parser must resolve it
 * fully before passing it to the application.
 *
 * @return A string containing the expanded system identifier, or null
 *         if none is available.
 */
public String getExpandedSystemId() {
    if (fCurrentEntity != null) {
        if (fCurrentEntity.entityLocation != null &&
                fCurrentEntity.entityLocation.getExpandedSystemId() != null ) {
            return fCurrentEntity.entityLocation.getExpandedSystemId();
        } else {
            // search for the first external entity on the stack
            int size = fEntityStack.size();
            for (int i = size - 1; i >= 0 ; i--) {
                Entity.ScannedEntity externalEntity =
                        (Entity.ScannedEntity)fEntityStack.elementAt(i);

                if (externalEntity.entityLocation != null &&
                        externalEntity.entityLocation.getExpandedSystemId() != null) {
                    return externalEntity.entityLocation.getExpandedSystemId();
                }
            }
        }
    }
    return null;
}
 
Example #6
Source File: XMLEntityManager.java    From JDKSourceCode1.8 with MIT License 6 votes vote down vote up
/**
 * Return the expanded system identifier for the current document event.
 * <p>
 * The return value is the expanded system identifier of the document
 * entity or of the external parsed entity in which the markup
 * triggering the event appears.
 * <p>
 * If the system identifier is a URL, the parser must resolve it
 * fully before passing it to the application.
 *
 * @return A string containing the expanded system identifier, or null
 *         if none is available.
 */
public String getExpandedSystemId() {
    if (fCurrentEntity != null) {
        if (fCurrentEntity.entityLocation != null &&
                fCurrentEntity.entityLocation.getExpandedSystemId() != null ) {
            return fCurrentEntity.entityLocation.getExpandedSystemId();
        } else {
            // search for the first external entity on the stack
            int size = fEntityStack.size();
            for (int i = size - 1; i >= 0 ; i--) {
                Entity.ScannedEntity externalEntity =
                        (Entity.ScannedEntity)fEntityStack.elementAt(i);

                if (externalEntity.entityLocation != null &&
                        externalEntity.entityLocation.getExpandedSystemId() != null) {
                    return externalEntity.entityLocation.getExpandedSystemId();
                }
            }
        }
    }
    return null;
}
 
Example #7
Source File: XMLEntityManager.java    From openjdk-jdk8u with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Return the line number where the current document event ends.
 * <p>
 * <strong>Warning:</strong> The return value from the method
 * is intended only as an approximation for the sake of error
 * reporting; it is not intended to provide sufficient information
 * to edit the character content of the original XML document.
 * <p>
 * The return value is an approximation of the line number
 * in the document entity or external parsed entity where the
 * markup triggering the event appears.
 * <p>
 * If possible, the SAX driver should provide the line position
 * of the first character after the text associated with the document
 * event.  The first line in the document is line 1.
 *
 * @return The line number, or -1 if none is available.
 */
public int getLineNumber() {
    if (fCurrentEntity != null) {
        if (fCurrentEntity.isExternal()) {
            return fCurrentEntity.lineNumber;
        } else {
            // search for the first external entity on the stack
            int size = fEntityStack.size();
            for (int i=size-1; i>0 ; i--) {
                Entity.ScannedEntity firstExternalEntity = (Entity.ScannedEntity)fEntityStack.elementAt(i);
                if (firstExternalEntity.isExternal()) {
                    return firstExternalEntity.lineNumber;
                }
            }
        }
    }

    return -1;

}
 
Example #8
Source File: XMLEntityManager.java    From openjdk-8-source with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Return the expanded system identifier for the current document event.
 * <p>
 * The return value is the expanded system identifier of the document
 * entity or of the external parsed entity in which the markup
 * triggering the event appears.
 * <p>
 * If the system identifier is a URL, the parser must resolve it
 * fully before passing it to the application.
 *
 * @return A string containing the expanded system identifier, or null
 *         if none is available.
 */
public String getExpandedSystemId() {
    if (fCurrentEntity != null) {
        if (fCurrentEntity.entityLocation != null &&
                fCurrentEntity.entityLocation.getExpandedSystemId() != null ) {
            return fCurrentEntity.entityLocation.getExpandedSystemId();
        } else {
            // search for the first external entity on the stack
            int size = fEntityStack.size();
            for (int i = size - 1; i >= 0 ; i--) {
                Entity.ScannedEntity externalEntity =
                        (Entity.ScannedEntity)fEntityStack.elementAt(i);

                if (externalEntity.entityLocation != null &&
                        externalEntity.entityLocation.getExpandedSystemId() != null) {
                    return externalEntity.entityLocation.getExpandedSystemId();
                }
            }
        }
    }
    return null;
}
 
Example #9
Source File: XMLEntityScanner.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 5 votes vote down vote up
/** set the instance of current scanned entity.
 *   @param ScannedEntity
 */

public final void setCurrentEntity(Entity.ScannedEntity scannedEntity){
    fCurrentEntity = scannedEntity ;
    if(fCurrentEntity != null){
        isExternal = fCurrentEntity.isExternal();
        if(DEBUG_BUFFER)
            System.out.println("Current Entity is "+scannedEntity.name);
    }
}
 
Example #10
Source File: XMLEntityScanner.java    From Bytecoder with Apache License 2.0 5 votes vote down vote up
/** set the instance of current scanned entity.
 *   @param ScannedEntity
 */

public final void setCurrentEntity(Entity.ScannedEntity scannedEntity){
    fCurrentEntity = scannedEntity ;
    if(fCurrentEntity != null){
        isExternal = fCurrentEntity.isExternal();
        if(DEBUG_BUFFER)
            System.out.println("Current Entity is "+scannedEntity.name);
    }
}
 
Example #11
Source File: XMLEntityManager.java    From openjdk-8-source with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Adds an external 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 publicId     The public identifier of the entity.
 * @param literalSystemId     The system identifier of the entity.
 * @param baseSystemId The base system identifier of the entity.
 *                     This is the system identifier of the entity
 *                     where <em>the entity being added</em> and
 *                     is used to expand the system identifier when
 *                     the system identifier is a relative URI.
 *                     When null the system identifier of the first
 *                     external entity on the stack is used instead.
 *
 * @see SymbolTable
 */
public void addExternalEntity(String name,
        String publicId, String literalSystemId,
        String baseSystemId) throws IOException {
    if (!fEntities.containsKey(name)) {
        if (baseSystemId == null) {
            // search for the first external entity on the stack
            int size = fEntityStack.size();
            if (size == 0 && fCurrentEntity != null && fCurrentEntity.entityLocation != null) {
                baseSystemId = fCurrentEntity.entityLocation.getExpandedSystemId();
            }
            for (int i = size - 1; i >= 0 ; i--) {
                Entity.ScannedEntity externalEntity =
                        (Entity.ScannedEntity)fEntityStack.elementAt(i);
                if (externalEntity.entityLocation != null && externalEntity.entityLocation.getExpandedSystemId() != null) {
                    baseSystemId = externalEntity.entityLocation.getExpandedSystemId();
                    break;
                }
            }
        }
        Entity entity = new Entity.ExternalEntity(name,
                new XMLEntityDescriptionImpl(name, publicId, literalSystemId, baseSystemId,
                expandSystemId(literalSystemId, baseSystemId, false)), null, fInExternalSubset);
        fEntities.put(name, entity);
    } else{
        if(fWarnDuplicateEntityDef){
            fErrorReporter.reportError(XMLMessageFormatter.XML_DOMAIN,
                    "MSG_DUPLICATE_ENTITY_DEFINITION",
                    new Object[]{ name },
                    XMLErrorReporter.SEVERITY_WARNING );
        }
    }

}
 
Example #12
Source File: XMLDocumentScannerImpl.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 5 votes vote down vote up
public XMLStringBuffer getDTDDecl(){
    Entity entity = fEntityScanner.getCurrentEntity();
    fDTDDecl.append(((Entity.ScannedEntity)entity).ch,fStartPos , fEndPos-fStartPos);
    if(fSeenInternalSubset)
        fDTDDecl.append("]>");
    return fDTDDecl;
}
 
Example #13
Source File: XMLDocumentScannerImpl.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
public XMLStringBuffer getDTDDecl(){
    Entity entity = fEntityScanner.getCurrentEntity();
    fDTDDecl.append(((Entity.ScannedEntity)entity).ch,fStartPos , fEndPos-fStartPos);
    if(fSeenInternalSubset)
        fDTDDecl.append("]>");
    return fDTDDecl;
}
 
Example #14
Source File: XMLEntityManager.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Checks whether an entity given by name is external.
 *
 * @param entityName The name of the entity to check.
 * @return True if the entity is external, false otherwise
 * (including when the entity is not declared).
 */
public boolean isExternalEntity(String entityName) {

    Entity entity = fEntities.get(entityName);
    if (entity == null) {
        return false;
    }
    return entity.isExternal();
}
 
Example #15
Source File: XMLDocumentScannerImpl.java    From JDKSourceCode1.8 with MIT License 5 votes vote down vote up
public XMLStringBuffer getDTDDecl(){
    Entity entity = fEntityScanner.getCurrentEntity();
    fDTDDecl.append(((Entity.ScannedEntity)entity).ch,fStartPos , fEndPos-fStartPos);
    if(fSeenInternalSubset)
        fDTDDecl.append("]>");
    return fDTDDecl;
}
 
Example #16
Source File: XMLEntityManager.java    From Bytecoder with Apache License 2.0 5 votes vote down vote up
public int read(byte[] b, int off, int len) throws IOException {
    final int bytesLeft = fLength - fOffset;
    if (bytesLeft == 0) {
        if (fOffset == fEndOffset) {
            return -1;
        }

        // read a block of data as requested
        if(fCurrentEntity.mayReadChunks || !fCurrentEntity.xmlDeclChunkRead) {

            if (!fCurrentEntity.xmlDeclChunkRead)
            {
                fCurrentEntity.xmlDeclChunkRead = true;
                len = Entity.ScannedEntity.DEFAULT_XMLDECL_BUFFER_SIZE;
            }
            return fInputStream.read(b, off, len);
        }
        int returnedVal = readAndBuffer();
        if (returnedVal == -1) {
            fEndOffset = fOffset;
            return -1;
        }
        b[off] = (byte)returnedVal;
        return 1;
    }
    if (len < bytesLeft) {
        if (len <= 0) {
            return 0;
        }
    } else {
        len = bytesLeft;
    }
    if (b != null) {
        System.arraycopy(fData, fOffset, b, off, len);
    }
    fOffset += len;
    return len;
}
 
Example #17
Source File: XMLEntityScanner.java    From JDKSourceCode1.8 with MIT License 5 votes vote down vote up
/** set the instance of current scanned entity.
 *   @param ScannedEntity
 */

public final void setCurrentEntity(Entity.ScannedEntity scannedEntity){
    fCurrentEntity = scannedEntity ;
    if(fCurrentEntity != null){
        isExternal = fCurrentEntity.isExternal();
        if(DEBUG_BUFFER)
            System.out.println("Current Entity is "+scannedEntity.name);
    }
}
 
Example #18
Source File: XMLEntityManager.java    From openjdk-8-source with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Checks whether an entity given by name is external.
 *
 * @param entityName The name of the entity to check.
 * @return True if the entity is external, false otherwise
 * (including when the entity is not declared).
 */
public boolean isExternalEntity(String entityName) {

    Entity entity = (Entity)fEntities.get(entityName);
    if (entity == null) {
        return false;
    }
    return entity.isExternal();
}
 
Example #19
Source File: XMLEntityManager.java    From openjdk-8-source with GNU General Public License v2.0 5 votes vote down vote up
public boolean isUnparsedEntity(String entityName) {

        Entity entity = (Entity)fEntities.get(entityName);
        if (entity == null) {
            return false;
        }
        return entity.isUnparsed();
    }
 
Example #20
Source File: XMLEntityManager.java    From JDKSourceCode1.8 with MIT License 5 votes vote down vote up
public boolean isUnparsedEntity(String entityName) {

        Entity entity = fEntities.get(entityName);
        if (entity == null) {
            return false;
        }
        return entity.isUnparsed();
    }
 
Example #21
Source File: XMLDocumentScannerImpl.java    From jdk8u60 with GNU General Public License v2.0 5 votes vote down vote up
public XMLStringBuffer getDTDDecl(){
    Entity entity = fEntityScanner.getCurrentEntity();
    fDTDDecl.append(((Entity.ScannedEntity)entity).ch,fStartPos , fEndPos-fStartPos);
    if(fSeenInternalSubset)
        fDTDDecl.append("]>");
    return fDTDDecl;
}
 
Example #22
Source File: XMLEntityManager.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Checks whether the declaration of an entity given by name is
 * // in the external subset.
 *
 * @param entityName The name of the entity to check.
 * @return True if the entity was declared in the external subset, false otherwise
 *           (including when the entity is not declared).
 */
public boolean isEntityDeclInExternalSubset(String entityName) {

    Entity entity = fEntities.get(entityName);
    if (entity == null) {
        return false;
    }
    return entity.isEntityDeclInExternalSubset();
}
 
Example #23
Source File: XMLEntityManager.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
public boolean isUnparsedEntity(String entityName) {

        Entity entity = fEntities.get(entityName);
        if (entity == null) {
            return false;
        }
        return entity.isUnparsed();
    }
 
Example #24
Source File: XMLEntityScanner.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
/** set the instance of current scanned entity.
 *   @param ScannedEntity
 */

public final void setCurrentEntity(Entity.ScannedEntity scannedEntity){
    fCurrentEntity = scannedEntity ;
    if(fCurrentEntity != null){
        isExternal = fCurrentEntity.isExternal();
        if(DEBUG_BUFFER)
            System.out.println("Current Entity is "+scannedEntity.name);
    }
}
 
Example #25
Source File: XMLDocumentScannerImpl.java    From Bytecoder with Apache License 2.0 5 votes vote down vote up
public XMLStringBuffer getDTDDecl(){
    Entity entity = fEntityScanner.getCurrentEntity();
    fDTDDecl.append(((Entity.ScannedEntity)entity).ch,fStartPos , fEndPos-fStartPos);
    if(fSeenInternalSubset)
        fDTDDecl.append("]>");
    return fDTDDecl;
}
 
Example #26
Source File: XMLEntityManager.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Checks whether the declaration of an entity given by name is
 * // in the external subset.
 *
 * @param entityName The name of the entity to check.
 * @return True if the entity was declared in the external subset, false otherwise
 *           (including when the entity is not declared).
 */
public boolean isEntityDeclInExternalSubset(String entityName) {

    Entity entity = fEntities.get(entityName);
    if (entity == null) {
        return false;
    }
    return entity.isEntityDeclInExternalSubset();
}
 
Example #27
Source File: XMLEntityManager.java    From openjdk-8 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Adds an external 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 publicId     The public identifier of the entity.
 * @param literalSystemId     The system identifier of the entity.
 * @param baseSystemId The base system identifier of the entity.
 *                     This is the system identifier of the entity
 *                     where <em>the entity being added</em> and
 *                     is used to expand the system identifier when
 *                     the system identifier is a relative URI.
 *                     When null the system identifier of the first
 *                     external entity on the stack is used instead.
 *
 * @see SymbolTable
 */
public void addExternalEntity(String name,
        String publicId, String literalSystemId,
        String baseSystemId) throws IOException {
    if (!fEntities.containsKey(name)) {
        if (baseSystemId == null) {
            // search for the first external entity on the stack
            int size = fEntityStack.size();
            if (size == 0 && fCurrentEntity != null && fCurrentEntity.entityLocation != null) {
                baseSystemId = fCurrentEntity.entityLocation.getExpandedSystemId();
            }
            for (int i = size - 1; i >= 0 ; i--) {
                Entity.ScannedEntity externalEntity =
                        (Entity.ScannedEntity)fEntityStack.elementAt(i);
                if (externalEntity.entityLocation != null && externalEntity.entityLocation.getExpandedSystemId() != null) {
                    baseSystemId = externalEntity.entityLocation.getExpandedSystemId();
                    break;
                }
            }
        }
        Entity entity = new Entity.ExternalEntity(name,
                new XMLEntityDescriptionImpl(name, publicId, literalSystemId, baseSystemId,
                expandSystemId(literalSystemId, baseSystemId, false)), null, fInExternalSubset);
        fEntities.put(name, entity);
    } else{
        if(fWarnDuplicateEntityDef){
            fErrorReporter.reportError(XMLMessageFormatter.XML_DOMAIN,
                    "MSG_DUPLICATE_ENTITY_DEFINITION",
                    new Object[]{ name },
                    XMLErrorReporter.SEVERITY_WARNING );
        }
    }

}
 
Example #28
Source File: XMLDocumentScannerImpl.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
public XMLStringBuffer getDTDDecl(){
    Entity entity = fEntityScanner.getCurrentEntity();
    fDTDDecl.append(((Entity.ScannedEntity)entity).ch,fStartPos , fEndPos-fStartPos);
    if(fSeenInternalSubset)
        fDTDDecl.append("]>");
    return fDTDDecl;
}
 
Example #29
Source File: XMLEntityManager.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Adds an external 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 publicId     The public identifier of the entity.
 * @param literalSystemId     The system identifier of the entity.
 * @param baseSystemId The base system identifier of the entity.
 *                     This is the system identifier of the entity
 *                     where <em>the entity being added</em> and
 *                     is used to expand the system identifier when
 *                     the system identifier is a relative URI.
 *                     When null the system identifier of the first
 *                     external entity on the stack is used instead.
 *
 * @see SymbolTable
 */
public void addExternalEntity(String name,
        String publicId, String literalSystemId,
        String baseSystemId) throws IOException {
    if (!fEntities.containsKey(name)) {
        if (baseSystemId == null) {
            // search for the first external entity on the stack
            int size = fEntityStack.size();
            if (size == 0 && fCurrentEntity != null && fCurrentEntity.entityLocation != null) {
                baseSystemId = fCurrentEntity.entityLocation.getExpandedSystemId();
            }
            for (int i = size - 1; i >= 0 ; i--) {
                Entity.ScannedEntity externalEntity =
                        (Entity.ScannedEntity)fEntityStack.elementAt(i);
                if (externalEntity.entityLocation != null && externalEntity.entityLocation.getExpandedSystemId() != null) {
                    baseSystemId = externalEntity.entityLocation.getExpandedSystemId();
                    break;
                }
            }
        }
        Entity entity = new Entity.ExternalEntity(name,
                new XMLEntityDescriptionImpl(name, publicId, literalSystemId, baseSystemId,
                expandSystemId(literalSystemId, baseSystemId, false)), null, fInExternalSubset);
        fEntities.put(name, entity);
    } else{
        if(fWarnDuplicateEntityDef){
            fErrorReporter.reportError(XMLMessageFormatter.XML_DOMAIN,
                    "MSG_DUPLICATE_ENTITY_DEFINITION",
                    new Object[]{ name },
                    XMLErrorReporter.SEVERITY_WARNING );
        }
    }

}
 
Example #30
Source File: XMLEntityScanner.java    From jdk8u60 with GNU General Public License v2.0 5 votes vote down vote up
/** set the instance of current scanned entity.
 *   @param ScannedEntity
 */

public final void setCurrentEntity(Entity.ScannedEntity scannedEntity){
    fCurrentEntity = scannedEntity ;
    if(fCurrentEntity != null){
        isExternal = fCurrentEntity.isExternal();
        if(DEBUG_BUFFER)
            System.out.println("Current Entity is "+scannedEntity.name);
    }
}