Search in sources :

Example 1 with OMSourcedElementImpl

use of org.apache.axiom.om.impl.llom.OMSourcedElementImpl in project wso2-axis2-transports by wso2.

the class PlainTextBuilder method processDocument.

public OMElement processDocument(DataSource dataSource, String contentType, MessageContext msgContext) throws AxisFault {
    OMFactory factory = OMAbstractFactory.getOMFactory();
    Charset cs = Charset.forName(BuilderUtil.getCharSetEncoding(contentType));
    QName wrapperQName = getWrapperQName(msgContext);
    return new OMSourcedElementImpl(wrapperQName, factory, new WrappedTextNodeOMDataSourceFromDataSource(wrapperQName, dataSource, cs));
}
Also used : OMFactory(org.apache.axiom.om.OMFactory) QName(javax.xml.namespace.QName) WrappedTextNodeOMDataSourceFromDataSource(org.apache.axiom.om.ds.WrappedTextNodeOMDataSourceFromDataSource) Charset(java.nio.charset.Charset) OMSourcedElementImpl(org.apache.axiom.om.impl.llom.OMSourcedElementImpl)

Example 2 with OMSourcedElementImpl

use of org.apache.axiom.om.impl.llom.OMSourcedElementImpl in project wso2-axis2-transports by wso2.

the class PlainTextBuilder method processDocument.

public OMElement processDocument(Reader reader, String contentType, MessageContext msgContext) throws AxisFault {
    OMFactory factory = OMAbstractFactory.getOMFactory();
    QName wrapperQName = getWrapperQName(msgContext);
    return new OMSourcedElementImpl(wrapperQName, factory, new WrappedTextNodeOMDataSourceFromReader(wrapperQName, reader));
}
Also used : OMFactory(org.apache.axiom.om.OMFactory) QName(javax.xml.namespace.QName) WrappedTextNodeOMDataSourceFromReader(org.apache.axiom.om.ds.WrappedTextNodeOMDataSourceFromReader) OMSourcedElementImpl(org.apache.axiom.om.impl.llom.OMSourcedElementImpl)

Example 3 with OMSourcedElementImpl

use of org.apache.axiom.om.impl.llom.OMSourcedElementImpl in project wso2-axis2-transports by wso2.

the class PlainTextBuilder method processDocument.

public OMElement processDocument(InputStream inputStream, String contentType, MessageContext msgContext) throws AxisFault {
    OMFactory factory = OMAbstractFactory.getOMFactory();
    String charSetEnc = BuilderUtil.getCharSetEncoding(contentType);
    QName wrapperQName = getWrapperQName(msgContext);
    Reader reader;
    try {
        reader = new InputStreamReader(inputStream, charSetEnc);
    } catch (UnsupportedEncodingException ex) {
        throw new AxisFault("Unsupported encoding: " + charSetEnc, ex);
    }
    return new OMSourcedElementImpl(wrapperQName, factory, new WrappedTextNodeOMDataSourceFromReader(wrapperQName, reader));
}
Also used : OMFactory(org.apache.axiom.om.OMFactory) AxisFault(org.apache.axis2.AxisFault) InputStreamReader(java.io.InputStreamReader) QName(javax.xml.namespace.QName) WrappedTextNodeOMDataSourceFromReader(org.apache.axiom.om.ds.WrappedTextNodeOMDataSourceFromReader) Reader(java.io.Reader) InputStreamReader(java.io.InputStreamReader) UnsupportedEncodingException(java.io.UnsupportedEncodingException) WrappedTextNodeOMDataSourceFromReader(org.apache.axiom.om.ds.WrappedTextNodeOMDataSourceFromReader) OMSourcedElementImpl(org.apache.axiom.om.impl.llom.OMSourcedElementImpl)

Aggregations

QName (javax.xml.namespace.QName)3 OMFactory (org.apache.axiom.om.OMFactory)3 OMSourcedElementImpl (org.apache.axiom.om.impl.llom.OMSourcedElementImpl)3 WrappedTextNodeOMDataSourceFromReader (org.apache.axiom.om.ds.WrappedTextNodeOMDataSourceFromReader)2 InputStreamReader (java.io.InputStreamReader)1 Reader (java.io.Reader)1 UnsupportedEncodingException (java.io.UnsupportedEncodingException)1 Charset (java.nio.charset.Charset)1 WrappedTextNodeOMDataSourceFromDataSource (org.apache.axiom.om.ds.WrappedTextNodeOMDataSourceFromDataSource)1 AxisFault (org.apache.axis2.AxisFault)1