Search in sources :

Example 1 with DataHandlerProvider

use of org.apache.axiom.ext.stax.datahandler.DataHandlerProvider in project webservices-axiom by apache.

the class XOPEncodingFilterHandler method processCharacterData.

@Override
protected String processCharacterData(Object data) throws StreamException {
    if (data instanceof TextContent) {
        TextContent textContent = (TextContent) data;
        if (textContent.isBinary()) {
            Object dataHandlerObject = textContent.getDataHandlerObject();
            boolean optimize;
            try {
                if (dataHandlerObject instanceof DataHandlerProvider) {
                    optimize = optimizationPolicy.isOptimized((DataHandlerProvider) dataHandlerObject, textContent.isOptimize());
                } else {
                    optimize = optimizationPolicy.isOptimized((DataHandler) dataHandlerObject, textContent.isOptimize());
                }
            } catch (IOException ex) {
                throw new StreamException(ex);
            }
            if (optimize) {
                String contentID = contentIDGenerator.generateContentID(textContent.getContentID());
                dataHandlerObjects.put(contentID, dataHandlerObject);
                return contentID;
            }
        }
    }
    return null;
}
Also used : DataHandlerProvider(org.apache.axiom.ext.stax.datahandler.DataHandlerProvider) DataHandler(javax.activation.DataHandler) IOException(java.io.IOException) TextContent(org.apache.axiom.om.impl.intf.TextContent) StreamException(org.apache.axiom.core.stream.StreamException)

Aggregations

IOException (java.io.IOException)1 DataHandler (javax.activation.DataHandler)1 StreamException (org.apache.axiom.core.stream.StreamException)1 DataHandlerProvider (org.apache.axiom.ext.stax.datahandler.DataHandlerProvider)1 TextContent (org.apache.axiom.om.impl.intf.TextContent)1