Search in sources :

Example 1 with CharacterData

use of org.apache.axiom.core.stream.CharacterData in project webservices-axiom by apache.

the class ContentHandlerXmlHandler method processCharacterData.

public void processCharacterData(Object data, boolean ignorable) throws StreamException {
    try {
        switch(characterDataMode) {
            case PASS_THROUGH:
                if (ignorable) {
                    writeToBuffer(data.toString());
                    contentHandler.ignorableWhitespace(buffer, 0, bufferPos);
                    bufferPos = 0;
                } else if (data instanceof CharacterData) {
                    try {
                        ((CharacterData) data).writeTo(this);
                    } catch (IOException ex) {
                        Throwable cause = ex.getCause();
                        SAXException saxException;
                        if (cause instanceof SAXException) {
                            saxException = (SAXException) cause;
                        } else {
                            saxException = new SAXException(ex);
                        }
                        throw new StreamException(saxException);
                    }
                } else {
                    writeToBuffer(data.toString());
                    contentHandler.characters(buffer, 0, bufferPos);
                    bufferPos = 0;
                }
                break;
            case BUFFER:
                writeToBuffer(data.toString());
                break;
            case ACCUMULATE:
                accumulator.append(data);
                break;
            case SKIP:
        }
    } catch (SAXException ex) {
        throw new StreamException(ex);
    }
}
Also used : CharacterData(org.apache.axiom.core.stream.CharacterData) IOException(java.io.IOException) SAXException(org.xml.sax.SAXException) StreamException(org.apache.axiom.core.stream.StreamException)

Aggregations

IOException (java.io.IOException)1 CharacterData (org.apache.axiom.core.stream.CharacterData)1 StreamException (org.apache.axiom.core.stream.StreamException)1 SAXException (org.xml.sax.SAXException)1