Java Code Examples for com.sun.org.apache.xerces.internal.util.XMLStringBuffer#append()

The following examples show how to use com.sun.org.apache.xerces.internal.util.XMLStringBuffer#append() . 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: XMLDocumentFragmentScannerImpl.java    From hottub with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Calls document handler with a single character resulting from
 * built-in entity resolution.
 *
 * @param c
 * @param entity built-in name
 * @param XMLStringBuffer append the character to buffer
 *
 * we really dont need to call this function -- this function is only required when
 * we integrate with rest of Xerces2. SO maintaining the current behavior and still
 * calling this function to hanlde built-in entity reference.
 *
 */
private void handleCharacter(char c, String entity, XMLStringBuffer content) throws XNIException {
    foundBuiltInRefs = true;
    content.append(c);
    if (fDocumentHandler != null) {
        fSingleChar[0] = c;
        if (fNotifyBuiltInRefs) {
            fDocumentHandler.startGeneralEntity(entity, null, null, null);
        }
        fTempString.setValues(fSingleChar, 0, 1);
        //fDocumentHandler.characters(fTempString, null);

        if (fNotifyBuiltInRefs) {
            fDocumentHandler.endGeneralEntity(entity, null);
        }
    }
}
 
Example 2
Source File: XMLDocumentFragmentScannerImpl.java    From jdk1.8-source-analysis with Apache License 2.0 6 votes vote down vote up
/**
 * Calls document handler with a single character resulting from
 * built-in entity resolution.
 *
 * @param c
 * @param entity built-in name
 * @param XMLStringBuffer append the character to buffer
 *
 * we really dont need to call this function -- this function is only required when
 * we integrate with rest of Xerces2. SO maintaining the current behavior and still
 * calling this function to hanlde built-in entity reference.
 *
 */
private void handleCharacter(char c, String entity, XMLStringBuffer content) throws XNIException {
    foundBuiltInRefs = true;
    checkEntityLimit(false, fEntityScanner.fCurrentEntity.name, 1);
    content.append(c);
    if (fDocumentHandler != null) {
        fSingleChar[0] = c;
        if (fNotifyBuiltInRefs) {
            fDocumentHandler.startGeneralEntity(entity, null, null, null);
        }
        fTempString.setValues(fSingleChar, 0, 1);
        //fDocumentHandler.characters(fTempString, null);

        if (fNotifyBuiltInRefs) {
            fDocumentHandler.endGeneralEntity(entity, null);
        }
    }
}
 
Example 3
Source File: XMLDocumentFragmentScannerImpl.java    From openjdk-8-source with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Calls document handler with a single character resulting from
 * built-in entity resolution.
 *
 * @param c
 * @param entity built-in name
 * @param XMLStringBuffer append the character to buffer
 *
 * we really dont need to call this function -- this function is only required when
 * we integrate with rest of Xerces2. SO maintaining the current behavior and still
 * calling this function to hanlde built-in entity reference.
 *
 */
private void handleCharacter(char c, String entity, XMLStringBuffer content) throws XNIException {
    foundBuiltInRefs = true;
    content.append(c);
    if (fDocumentHandler != null) {
        fSingleChar[0] = c;
        if (fNotifyBuiltInRefs) {
            fDocumentHandler.startGeneralEntity(entity, null, null, null);
        }
        fTempString.setValues(fSingleChar, 0, 1);
        //fDocumentHandler.characters(fTempString, null);

        if (fNotifyBuiltInRefs) {
            fDocumentHandler.endGeneralEntity(entity, null);
        }
    }
}
 
Example 4
Source File: XMLDocumentFragmentScannerImpl.java    From openjdk-jdk8u with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Calls document handler with a single character resulting from
 * built-in entity resolution.
 *
 * @param c
 * @param entity built-in name
 * @param XMLStringBuffer append the character to buffer
 *
 * we really dont need to call this function -- this function is only required when
 * we integrate with rest of Xerces2. SO maintaining the current behavior and still
 * calling this function to hanlde built-in entity reference.
 *
 */
private void handleCharacter(char c, String entity, XMLStringBuffer content) throws XNIException {
    foundBuiltInRefs = true;
    checkEntityLimit(false, fEntityScanner.fCurrentEntity.name, 1);
    content.append(c);
    if (fDocumentHandler != null) {
        fSingleChar[0] = c;
        if (fNotifyBuiltInRefs) {
            fDocumentHandler.startGeneralEntity(entity, null, null, null);
        }
        fTempString.setValues(fSingleChar, 0, 1);
        //fDocumentHandler.characters(fTempString, null);

        if (fNotifyBuiltInRefs) {
            fDocumentHandler.endGeneralEntity(entity, null);
        }
    }
}
 
Example 5
Source File: XMLScanner.java    From openjdk-8 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Scans surrogates and append them to the specified buffer.
 * <p>
 * <strong>Note:</strong> This assumes the current char has already been
 * identified as a high surrogate.
 *
 * @param buf The StringBuffer to append the read surrogates to.
 * @return True if it succeeded.
 */
protected boolean scanSurrogates(XMLStringBuffer buf)
throws IOException, XNIException {

    int high = fEntityScanner.scanChar();
    int low = fEntityScanner.peekChar();
    if (!XMLChar.isLowSurrogate(low)) {
        reportFatalError("InvalidCharInContent",
                new Object[] {Integer.toString(high, 16)});
                return false;
    }
    fEntityScanner.scanChar();

    // convert surrogates to supplemental character
    int c = XMLChar.supplemental((char)high, (char)low);

    // supplemental character must be a valid XML character
    if (isInvalid(c)) {
        reportFatalError("InvalidCharInContent",
                new Object[]{Integer.toString(c, 16)});
                return false;
    }

    // fill in the buffer
    buf.append((char)high);
    buf.append((char)low);

    return true;

}
 
Example 6
Source File: XMLScanner.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Scans surrogates and append them to the specified buffer.
 * <p>
 * <strong>Note:</strong> This assumes the current char has already been
 * identified as a high surrogate.
 *
 * @param buf The StringBuffer to append the read surrogates to.
 * @return True if it succeeded.
 */
protected boolean scanSurrogates(XMLStringBuffer buf)
throws IOException, XNIException {

    int high = fEntityScanner.scanChar(null);
    int low = fEntityScanner.peekChar();
    if (!XMLChar.isLowSurrogate(low)) {
        reportFatalError("InvalidCharInContent",
                new Object[] {Integer.toString(high, 16)});
                return false;
    }
    fEntityScanner.scanChar(null);

    // convert surrogates to supplemental character
    int c = XMLChar.supplemental((char)high, (char)low);

    // supplemental character must be a valid XML character
    if (isInvalid(c)) {
        reportFatalError("InvalidCharInContent",
                new Object[]{Integer.toString(c, 16)});
                return false;
    }

    // fill in the buffer
    buf.append((char)high);
    buf.append((char)low);

    return true;

}
 
Example 7
Source File: XMLScanner.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Resolves character entity references.
 * @param entityName the name of the entity
 * @param stringBuffer the current XMLStringBuffer to append the character to.
 * @return true if resolved, false otherwise
 */
protected boolean resolveCharacter(String entityName, XMLStringBuffer stringBuffer) {
    /**
     * entityNames (symbols) are interned. The equals method would do the same,
     * but I'm leaving it as comparisons by references are common in the impl
     * and it made it explicit to others who read this code.
     */
    if (entityName == fAmpSymbol) {
        stringBuffer.append('&');
        return true;
    } else if (entityName == fAposSymbol) {
        stringBuffer.append('\'');
        return true;
    } else if (entityName == fLtSymbol) {
        stringBuffer.append('<');
        return true;
    } else if (entityName == fGtSymbol) {
        checkEntityLimit(false, fEntityScanner.fCurrentEntity.name, 1);
        stringBuffer.append('>');
        return true;
    } else if (entityName == fQuotSymbol) {
        checkEntityLimit(false, fEntityScanner.fCurrentEntity.name, 1);
        stringBuffer.append('"');
        return true;
    }
    return false;
}
 
Example 8
Source File: XMLScanner.java    From JDKSourceCode1.8 with MIT License 5 votes vote down vote up
/**
 * Resolves character entity references.
 * @param entityName the name of the entity
 * @param stringBuffer the current XMLStringBuffer to append the character to.
 * @return true if resolved, false otherwise
 */
protected boolean resolveCharacter(String entityName, XMLStringBuffer stringBuffer) {
    /**
     * entityNames (symbols) are interned. The equals method would do the same,
     * but I'm leaving it as comparisons by references are common in the impl
     * and it made it explicit to others who read this code.
     */
    if (entityName == fAmpSymbol) {
        stringBuffer.append('&');
        return true;
    } else if (entityName == fAposSymbol) {
        stringBuffer.append('\'');
        return true;
    } else if (entityName == fLtSymbol) {
        stringBuffer.append('<');
        return true;
    } else if (entityName == fGtSymbol) {
        checkEntityLimit(false, fEntityScanner.fCurrentEntity.name, 1);
        stringBuffer.append('>');
        return true;
    } else if (entityName == fQuotSymbol) {
        checkEntityLimit(false, fEntityScanner.fCurrentEntity.name, 1);
        stringBuffer.append('"');
        return true;
    }
    return false;
}
 
Example 9
Source File: XMLScanner.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Scans surrogates and append them to the specified buffer.
 * <p>
 * <strong>Note:</strong> This assumes the current char has already been
 * identified as a high surrogate.
 *
 * @param buf The StringBuffer to append the read surrogates to.
 * @return True if it succeeded.
 */
protected boolean scanSurrogates(XMLStringBuffer buf)
throws IOException, XNIException {

    int high = fEntityScanner.scanChar(null);
    int low = fEntityScanner.peekChar();
    if (!XMLChar.isLowSurrogate(low)) {
        reportFatalError("InvalidCharInContent",
                new Object[] {Integer.toString(high, 16)});
                return false;
    }
    fEntityScanner.scanChar(null);

    // convert surrogates to supplemental character
    int c = XMLChar.supplemental((char)high, (char)low);

    // supplemental character must be a valid XML character
    if (isInvalid(c)) {
        reportFatalError("InvalidCharInContent",
                new Object[]{Integer.toString(c, 16)});
                return false;
    }

    // fill in the buffer
    buf.append((char)high);
    buf.append((char)low);

    return true;

}
 
Example 10
Source File: XMLScanner.java    From Bytecoder with Apache License 2.0 5 votes vote down vote up
/**
 * Scans surrogates and append them to the specified buffer.
 * <p>
 * <strong>Note:</strong> This assumes the current char has already been
 * identified as a high surrogate.
 *
 * @param buf The StringBuffer to append the read surrogates to.
 * @return True if it succeeded.
 */
protected boolean scanSurrogates(XMLStringBuffer buf)
throws IOException, XNIException {

    int high = fEntityScanner.scanChar(null);
    int low = fEntityScanner.peekChar();
    if (!XMLChar.isLowSurrogate(low)) {
        reportFatalError("InvalidCharInContent",
                new Object[] {Integer.toString(high, 16)});
                return false;
    }
    fEntityScanner.scanChar(null);

    // convert surrogates to supplemental character
    int c = XMLChar.supplemental((char)high, (char)low);

    // supplemental character must be a valid XML character
    if (isInvalid(c)) {
        reportFatalError("InvalidCharInContent",
                new Object[]{Integer.toString(c, 16)});
                return false;
    }

    // fill in the buffer
    buf.append((char)high);
    buf.append((char)low);

    return true;

}
 
Example 11
Source File: XMLScanner.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Scans surrogates and append them to the specified buffer.
 * <p>
 * <strong>Note:</strong> This assumes the current char has already been
 * identified as a high surrogate.
 *
 * @param buf The StringBuffer to append the read surrogates to.
 * @return True if it succeeded.
 */
protected boolean scanSurrogates(XMLStringBuffer buf)
throws IOException, XNIException {

    int high = fEntityScanner.scanChar(null);
    int low = fEntityScanner.peekChar();
    if (!XMLChar.isLowSurrogate(low)) {
        reportFatalError("InvalidCharInContent",
                new Object[] {Integer.toString(high, 16)});
                return false;
    }
    fEntityScanner.scanChar(null);

    // convert surrogates to supplemental character
    int c = XMLChar.supplemental((char)high, (char)low);

    // supplemental character must be a valid XML character
    if (isInvalid(c)) {
        reportFatalError("InvalidCharInContent",
                new Object[]{Integer.toString(c, 16)});
                return false;
    }

    // fill in the buffer
    buf.append((char)high);
    buf.append((char)low);

    return true;

}
 
Example 12
Source File: XMLScanner.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Resolves character entity references.
 * @param entityName the name of the entity
 * @param stringBuffer the current XMLStringBuffer to append the character to.
 * @return true if resolved, false otherwise
 */
protected boolean resolveCharacter(String entityName, XMLStringBuffer stringBuffer) {
    /**
     * entityNames (symbols) are interned. The equals method would do the same,
     * but I'm leaving it as comparisons by references are common in the impl
     * and it made it explicit to others who read this code.
     */
    if (entityName == fAmpSymbol) {
        stringBuffer.append('&');
        return true;
    } else if (entityName == fAposSymbol) {
        stringBuffer.append('\'');
        return true;
    } else if (entityName == fLtSymbol) {
        stringBuffer.append('<');
        return true;
    } else if (entityName == fGtSymbol) {
        checkEntityLimit(false, fEntityScanner.fCurrentEntity.name, 1);
        stringBuffer.append('>');
        return true;
    } else if (entityName == fQuotSymbol) {
        checkEntityLimit(false, fEntityScanner.fCurrentEntity.name, 1);
        stringBuffer.append('"');
        return true;
    }
    return false;
}
 
Example 13
Source File: XML11DocumentScannerImpl.java    From openjdk-8 with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Scans element content.
 *
 * @return Returns the next character on the stream.
 */
protected int scanContent(XMLStringBuffer content) throws IOException, XNIException {

    fTempString.length = 0;
    int c = fEntityScanner.scanContent(fTempString);
    content.append(fTempString);

    if (c == '\r' || c == 0x85 || c == 0x2028) {
        // happens when there is the character reference &#13;
        // but scanContent doesn't do entity expansions...
        // is this *really* necessary???  - NG
        fEntityScanner.scanChar();
        content.append((char)c);
        c = -1;
    }
    /*if (fDocumentHandler != null && content.length > 0) {
        fDocumentHandler.characters(content, null);
    } */

    if (c == ']') {
        content.append((char)fEntityScanner.scanChar());
        // remember where we are in case we get an endEntity before we
        // could flush the buffer out - this happens when we're parsing an
        // entity which ends with a ]
        fInScanContent = true;
        //
        // We work on a single character basis to handle cases such as:
        // ']]]>' which we might otherwise miss.
        //
        if (fEntityScanner.skipChar(']')) {
            content.append(']');
            while (fEntityScanner.skipChar(']')) {
                content.append(']');
            }
            if (fEntityScanner.skipChar('>')) {
                reportFatalError("CDEndInContent", null);
            }
        }
        /*if (fDocumentHandler != null && fStringBuffer.length != 0) {
            fDocumentHandler.characters(fStringBuffer, null);
        }*/
        fInScanContent = false;
        c = -1;
    }
    return c;

}
 
Example 14
Source File: XMLDocumentFragmentScannerImpl.java    From jdk8u60 with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Scans element content.
 *
 * @return Returns the next character on the stream.
 */
//CHANGED:
//EARLIER: scanContent()
//NOW: scanContent(XMLStringBuffer)
//It makes things easy if this functions takes XMLStringBuffer as parameter..
//this function appends the data to the buffer.
protected int scanContent(XMLStringBuffer content) throws IOException, XNIException {
    //set the fTempString length to 0 before passing it on to scanContent
    //scanContent sets the correct co-ordinates as per the content read
    fTempString.length = 0;
    int c = fEntityScanner.scanContent(fTempString);
    content.append(fTempString);
    fTempString.length = 0;
    if (c == '\r') {
        // happens when there is the character reference &#13;
        //xxx: We know the next chracter.. we should just skip it and add ']' directlry
        fEntityScanner.scanChar();
        content.append((char)c);
        c = -1;
    } else if (c == ']') {
        //fStringBuffer.clear();
        //xxx: We know the next chracter.. we should just skip it and add ']' directlry
        content.append((char)fEntityScanner.scanChar());
        // remember where we are in case we get an endEntity before we
        // could flush the buffer out - this happens when we're parsing an
        // entity which ends with a ]
        fInScanContent = true;
        //
        // We work on a single character basis to handle cases such as:
        // ']]]>' which we might otherwise miss.
        //
        if (fEntityScanner.skipChar(']')) {
            content.append(']');
            while (fEntityScanner.skipChar(']')) {
                content.append(']');
            }
            if (fEntityScanner.skipChar('>')) {
                reportFatalError("CDEndInContent", null);
            }
        }
        fInScanContent = false;
        c = -1;
    }
    if (fDocumentHandler != null && content.length > 0) {
        //fDocumentHandler.characters(content, null);
    }
    return c;

}
 
Example 15
Source File: XMLDocumentFragmentScannerImpl.java    From openjdk-jdk8u with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Scans element content.
 *
 * @return Returns the next character on the stream.
 */
//CHANGED:
//EARLIER: scanContent()
//NOW: scanContent(XMLStringBuffer)
//It makes things easy if this functions takes XMLStringBuffer as parameter..
//this function appends the data to the buffer.
protected int scanContent(XMLStringBuffer content) throws IOException, XNIException {
    //set the fTempString length to 0 before passing it on to scanContent
    //scanContent sets the correct co-ordinates as per the content read
    fTempString.length = 0;
    int c = fEntityScanner.scanContent(fTempString);
    content.append(fTempString);
    fTempString.length = 0;
    if (c == '\r') {
        // happens when there is the character reference &#13;
        //xxx: We know the next chracter.. we should just skip it and add ']' directlry
        fEntityScanner.scanChar(null);
        content.append((char)c);
        c = -1;
    } else if (c == ']') {
        //fStringBuffer.clear();
        //xxx: We know the next chracter.. we should just skip it and add ']' directlry
        content.append((char)fEntityScanner.scanChar(null));
        // remember where we are in case we get an endEntity before we
        // could flush the buffer out - this happens when we're parsing an
        // entity which ends with a ]
        fInScanContent = true;
        //
        // We work on a single character basis to handle cases such as:
        // ']]]>' which we might otherwise miss.
        //
        if (fEntityScanner.skipChar(']', null)) {
            content.append(']');
            while (fEntityScanner.skipChar(']', null)) {
                content.append(']');
            }
            if (fEntityScanner.skipChar('>', null)) {
                reportFatalError("CDEndInContent", null);
            }
        }
        fInScanContent = false;
        c = -1;
    }
    if (fDocumentHandler != null && content.length > 0) {
        //fDocumentHandler.characters(content, null);
    }
    return c;

}
 
Example 16
Source File: XMLDocumentFragmentScannerImpl.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Scans element content.
 *
 * @return Returns the next character on the stream.
 */
//CHANGED:
//EARLIER: scanContent()
//NOW: scanContent(XMLStringBuffer)
//It makes things easy if this functions takes XMLStringBuffer as parameter..
//this function appends the data to the buffer.
protected int scanContent(XMLStringBuffer content) throws IOException, XNIException {
    //set the fTempString length to 0 before passing it on to scanContent
    //scanContent sets the correct co-ordinates as per the content read
    fTempString.length = 0;
    int c = fEntityScanner.scanContent(fTempString);
    content.append(fTempString);
    fTempString.length = 0;
    if (c == '\r') {
        // happens when there is the character reference &#13;
        //xxx: We know the next chracter.. we should just skip it and add ']' directlry
        fEntityScanner.scanChar(null);
        content.append((char)c);
        c = -1;
    } else if (c == ']') {
        //fStringBuffer.clear();
        //xxx: We know the next chracter.. we should just skip it and add ']' directlry
        content.append((char)fEntityScanner.scanChar(null));
        // remember where we are in case we get an endEntity before we
        // could flush the buffer out - this happens when we're parsing an
        // entity which ends with a ]
        fInScanContent = true;
        //
        // We work on a single character basis to handle cases such as:
        // ']]]>' which we might otherwise miss.
        //
        if (fEntityScanner.skipChar(']', null)) {
            content.append(']');
            while (fEntityScanner.skipChar(']', null)) {
                content.append(']');
            }
            if (fEntityScanner.skipChar('>', null)) {
                reportFatalError("CDEndInContent", null);
            }
        }
        fInScanContent = false;
        c = -1;
    }
    if (fDocumentHandler != null && content.length > 0) {
        //fDocumentHandler.characters(content, null);
    }
    return c;

}
 
Example 17
Source File: XMLDocumentFragmentScannerImpl.java    From JDKSourceCode1.8 with MIT License 4 votes vote down vote up
/**
 * Scans element content.
 *
 * @return Returns the next character on the stream.
 */
//CHANGED:
//EARLIER: scanContent()
//NOW: scanContent(XMLStringBuffer)
//It makes things easy if this functions takes XMLStringBuffer as parameter..
//this function appends the data to the buffer.
protected int scanContent(XMLStringBuffer content) throws IOException, XNIException {
    //set the fTempString length to 0 before passing it on to scanContent
    //scanContent sets the correct co-ordinates as per the content read
    fTempString.length = 0;
    int c = fEntityScanner.scanContent(fTempString);
    content.append(fTempString);
    fTempString.length = 0;
    if (c == '\r') {
        // happens when there is the character reference &#13;
        //xxx: We know the next chracter.. we should just skip it and add ']' directlry
        fEntityScanner.scanChar(null);
        content.append((char)c);
        c = -1;
    } else if (c == ']') {
        //fStringBuffer.clear();
        //xxx: We know the next chracter.. we should just skip it and add ']' directlry
        content.append((char)fEntityScanner.scanChar(null));
        // remember where we are in case we get an endEntity before we
        // could flush the buffer out - this happens when we're parsing an
        // entity which ends with a ]
        fInScanContent = true;
        //
        // We work on a single character basis to handle cases such as:
        // ']]]>' which we might otherwise miss.
        //
        if (fEntityScanner.skipChar(']', null)) {
            content.append(']');
            while (fEntityScanner.skipChar(']', null)) {
                content.append(']');
            }
            if (fEntityScanner.skipChar('>', null)) {
                reportFatalError("CDEndInContent", null);
            }
        }
        fInScanContent = false;
        c = -1;
    }
    if (fDocumentHandler != null && content.length > 0) {
        //fDocumentHandler.characters(content, null);
    }
    return c;

}
 
Example 18
Source File: XML11DocumentScannerImpl.java    From Bytecoder with Apache License 2.0 4 votes vote down vote up
/**
 * Scans element content.
 *
 * @return Returns the next character on the stream.
 */
protected int scanContent(XMLStringBuffer content) throws IOException, XNIException {

    fTempString.length = 0;
    int c = fEntityScanner.scanContent(fTempString);
    content.append(fTempString);

    if (c == '\r' || c == 0x85 || c == 0x2028) {
        // happens when there is the character reference &#13;
        // but scanContent doesn't do entity expansions...
        // is this *really* necessary???  - NG
        fEntityScanner.scanChar(null);
        content.append((char)c);
        c = -1;
    }
    /*if (fDocumentHandler != null && content.length > 0) {
        fDocumentHandler.characters(content, null);
    } */

    if (c == ']') {
        content.append((char)fEntityScanner.scanChar(null));
        // remember where we are in case we get an endEntity before we
        // could flush the buffer out - this happens when we're parsing an
        // entity which ends with a ]
        fInScanContent = true;
        //
        // We work on a single character basis to handle cases such as:
        // ']]]>' which we might otherwise miss.
        //
        if (fEntityScanner.skipChar(']', null)) {
            content.append(']');
            while (fEntityScanner.skipChar(']', null)) {
                content.append(']');
            }
            if (fEntityScanner.skipChar('>', null)) {
                reportFatalError("CDEndInContent", null);
            }
        }
        /*if (fDocumentHandler != null && fStringBuffer.length != 0) {
            fDocumentHandler.characters(fStringBuffer, null);
        }*/
        fInScanContent = false;
        c = -1;
    }
    return c;

}
 
Example 19
Source File: XMLDocumentFragmentScannerImpl.java    From openjdk-8 with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Scans element content.
 *
 * @return Returns the next character on the stream.
 */
//CHANGED:
//EARLIER: scanContent()
//NOW: scanContent(XMLStringBuffer)
//It makes things easy if this functions takes XMLStringBuffer as parameter..
//this function appends the data to the buffer.
protected int scanContent(XMLStringBuffer content) throws IOException, XNIException {
    //set the fTempString length to 0 before passing it on to scanContent
    //scanContent sets the correct co-ordinates as per the content read
    fTempString.length = 0;
    int c = fEntityScanner.scanContent(fTempString);
    content.append(fTempString);
    fTempString.length = 0;
    if (c == '\r') {
        // happens when there is the character reference &#13;
        //xxx: We know the next chracter.. we should just skip it and add ']' directlry
        fEntityScanner.scanChar();
        content.append((char)c);
        c = -1;
    } else if (c == ']') {
        //fStringBuffer.clear();
        //xxx: We know the next chracter.. we should just skip it and add ']' directlry
        content.append((char)fEntityScanner.scanChar());
        // remember where we are in case we get an endEntity before we
        // could flush the buffer out - this happens when we're parsing an
        // entity which ends with a ]
        fInScanContent = true;
        //
        // We work on a single character basis to handle cases such as:
        // ']]]>' which we might otherwise miss.
        //
        if (fEntityScanner.skipChar(']')) {
            content.append(']');
            while (fEntityScanner.skipChar(']')) {
                content.append(']');
            }
            if (fEntityScanner.skipChar('>')) {
                reportFatalError("CDEndInContent", null);
            }
        }
        fInScanContent = false;
        c = -1;
    }
    if (fDocumentHandler != null && content.length > 0) {
        //fDocumentHandler.characters(content, null);
    }
    return c;

}
 
Example 20
Source File: XMLDocumentFragmentScannerImpl.java    From hottub with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Scans element content.
 *
 * @return Returns the next character on the stream.
 */
//CHANGED:
//EARLIER: scanContent()
//NOW: scanContent(XMLStringBuffer)
//It makes things easy if this functions takes XMLStringBuffer as parameter..
//this function appends the data to the buffer.
protected int scanContent(XMLStringBuffer content) throws IOException, XNIException {
    //set the fTempString length to 0 before passing it on to scanContent
    //scanContent sets the correct co-ordinates as per the content read
    fTempString.length = 0;
    int c = fEntityScanner.scanContent(fTempString);
    content.append(fTempString);
    fTempString.length = 0;
    if (c == '\r') {
        // happens when there is the character reference &#13;
        //xxx: We know the next chracter.. we should just skip it and add ']' directlry
        fEntityScanner.scanChar();
        content.append((char)c);
        c = -1;
    } else if (c == ']') {
        //fStringBuffer.clear();
        //xxx: We know the next chracter.. we should just skip it and add ']' directlry
        content.append((char)fEntityScanner.scanChar());
        // remember where we are in case we get an endEntity before we
        // could flush the buffer out - this happens when we're parsing an
        // entity which ends with a ]
        fInScanContent = true;
        //
        // We work on a single character basis to handle cases such as:
        // ']]]>' which we might otherwise miss.
        //
        if (fEntityScanner.skipChar(']')) {
            content.append(']');
            while (fEntityScanner.skipChar(']')) {
                content.append(']');
            }
            if (fEntityScanner.skipChar('>')) {
                reportFatalError("CDEndInContent", null);
            }
        }
        fInScanContent = false;
        c = -1;
    }
    if (fDocumentHandler != null && content.length > 0) {
        //fDocumentHandler.characters(content, null);
    }
    return c;

}