com.sun.xml.internal.org.jvnet.staxex.Base64Data Java Examples

The following examples show how to use com.sun.xml.internal.org.jvnet.staxex.Base64Data. 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: XMLStreamReaderToXMLStreamWriter.java    From openjdk-8 with GNU General Public License v2.0 6 votes vote down vote up
protected void handleCharacters() throws XMLStreamException {

        CharSequence c = null;

        if (optimizeBase64Data) {
            c = ((XMLStreamReaderEx)in).getPCDATA();
        }

        if ((c != null) && (c instanceof Base64Data)) {
            if (mtomAttachmentMarshaller != null) {
                Base64Data b64d = (Base64Data) c;
                ((XMLStreamWriterEx)out).writeBinary(b64d.getDataHandler());
            } else {
                try {
                    ((Base64Data)c).writeTo(out);
                } catch (IOException e) {
                    throw new XMLStreamException(e);
                }
            }
        } else {
            for (int start=0,read=buf.length; read == buf.length; start+=buf.length) {
                read = in.getTextCharacters(start, buf, 0, buf.length);
                out.writeCharacters(buf, 0, read);
            }
        }
    }
 
Example #2
Source File: XMLStreamReaderToXMLStreamWriter.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 6 votes vote down vote up
protected void handleCharacters() throws XMLStreamException {

        CharSequence c = null;

        if (optimizeBase64Data) {
            c = ((XMLStreamReaderEx)in).getPCDATA();
        }

        if ((c != null) && (c instanceof Base64Data)) {
            if (mtomAttachmentMarshaller != null) {
                Base64Data b64d = (Base64Data) c;
                ((XMLStreamWriterEx)out).writeBinary(b64d.getDataHandler());
            } else {
                try {
                    ((Base64Data)c).writeTo(out);
                } catch (IOException e) {
                    throw new XMLStreamException(e);
                }
            }
        } else {
            for (int start=0,read=buf.length; read == buf.length; start+=buf.length) {
                read = in.getTextCharacters(start, buf, 0, buf.length);
                out.writeCharacters(buf, 0, read);
            }
        }
    }
 
Example #3
Source File: XMLStreamReaderToXMLStreamWriter.java    From openjdk-jdk8u with GNU General Public License v2.0 6 votes vote down vote up
protected void handleCharacters() throws XMLStreamException {

        CharSequence c = null;

        if (optimizeBase64Data) {
            c = ((XMLStreamReaderEx)in).getPCDATA();
        }

        if ((c != null) && (c instanceof Base64Data)) {
            if (mtomAttachmentMarshaller != null) {
                Base64Data b64d = (Base64Data) c;
                ((XMLStreamWriterEx)out).writeBinary(b64d.getDataHandler());
            } else {
                try {
                    ((Base64Data)c).writeTo(out);
                } catch (IOException e) {
                    throw new XMLStreamException(e);
                }
            }
        } else {
            for (int start=0,read=buf.length; read == buf.length; start+=buf.length) {
                read = in.getTextCharacters(start, buf, 0, buf.length);
                out.writeCharacters(buf, 0, read);
            }
        }
    }
 
Example #4
Source File: XMLStreamReaderToXMLStreamWriter.java    From openjdk-jdk9 with GNU General Public License v2.0 6 votes vote down vote up
protected void handleCharacters() throws XMLStreamException {

        CharSequence c = null;

        if (optimizeBase64Data) {
            c = ((XMLStreamReaderEx)in).getPCDATA();
        }

        if ((c != null) && (c instanceof Base64Data)) {
            if (mtomAttachmentMarshaller != null) {
                Base64Data b64d = (Base64Data) c;
                ((XMLStreamWriterEx)out).writeBinary(b64d.getDataHandler());
            } else {
                try {
                    ((Base64Data)c).writeTo(out);
                } catch (IOException e) {
                    throw new XMLStreamException(e);
                }
            }
        } else {
            for (int start=0,read=buf.length; read == buf.length; start+=buf.length) {
                read = in.getTextCharacters(start, buf, 0, buf.length);
                out.writeCharacters(buf, 0, read);
            }
        }
    }
 
Example #5
Source File: SaajStaxWriterEx.java    From openjdk-jdk9 with GNU General Public License v2.0 6 votes vote down vote up
@Override
public void writePCDATA(CharSequence arg0) throws XMLStreamException {
    if (arg0 instanceof Base64Data) {
        // The fix of StreamReaderBufferCreator preserves this dataHandler
        addBinaryText(((Base64Data) arg0).getDataHandler());
    } else {
        // We should not normally get here as we expect a DataHandler,
        // but this is the most general solution.  If we do get
        // something other than a Data Handler, create a Text node with
        // the data.  Another alternative would be to throw an exception,
        // but in the most general case, we don't know whether this input
        // is expected.
        try {
            currentElement.addTextNode(arg0.toString());
        } catch (SOAPException e) {
            throw new XMLStreamException("Cannot add Text node", e);
        }
    }
}
 
Example #6
Source File: XMLStreamReaderToXMLStreamWriter.java    From openjdk-jdk9 with GNU General Public License v2.0 6 votes vote down vote up
protected void handleCharacters() throws XMLStreamException {

        CharSequence c = null;

        if (optimizeBase64Data) {
            c = ((XMLStreamReaderEx)in).getPCDATA();
        }

        if ((c != null) && (c instanceof Base64Data)) {
            if (mtomAttachmentMarshaller != null) {
                Base64Data b64d = (Base64Data) c;
                ((XMLStreamWriterEx)out).writeBinary(b64d.getDataHandler());
            } else {
                try {
                    ((Base64Data)c).writeTo(out);
                } catch (IOException e) {
                    throw new XMLStreamException(e);
                }
            }
        } else {
            for (int start=0,read=buf.length; read == buf.length; start+=buf.length) {
                read = in.getTextCharacters(start, buf, 0, buf.length);
                out.writeCharacters(buf, 0, read);
            }
        }
    }
 
Example #7
Source File: XMLStreamReaderToXMLStreamWriter.java    From jdk8u60 with GNU General Public License v2.0 6 votes vote down vote up
protected void handleCharacters() throws XMLStreamException {

        CharSequence c = null;

        if (optimizeBase64Data) {
            c = ((XMLStreamReaderEx)in).getPCDATA();
        }

        if ((c != null) && (c instanceof Base64Data)) {
            if (mtomAttachmentMarshaller != null) {
                Base64Data b64d = (Base64Data) c;
                ((XMLStreamWriterEx)out).writeBinary(b64d.getDataHandler());
            } else {
                try {
                    ((Base64Data)c).writeTo(out);
                } catch (IOException e) {
                    throw new XMLStreamException(e);
                }
            }
        } else {
            for (int start=0,read=buf.length; read == buf.length; start+=buf.length) {
                read = in.getTextCharacters(start, buf, 0, buf.length);
                out.writeCharacters(buf, 0, read);
            }
        }
    }
 
Example #8
Source File: XMLStreamReaderToXMLStreamWriter.java    From hottub with GNU General Public License v2.0 6 votes vote down vote up
protected void handleCharacters() throws XMLStreamException {

        CharSequence c = null;

        if (optimizeBase64Data) {
            c = ((XMLStreamReaderEx)in).getPCDATA();
        }

        if ((c != null) && (c instanceof Base64Data)) {
            if (mtomAttachmentMarshaller != null) {
                Base64Data b64d = (Base64Data) c;
                ((XMLStreamWriterEx)out).writeBinary(b64d.getDataHandler());
            } else {
                try {
                    ((Base64Data)c).writeTo(out);
                } catch (IOException e) {
                    throw new XMLStreamException(e);
                }
            }
        } else {
            for (int start=0,read=buf.length; read == buf.length; start+=buf.length) {
                read = in.getTextCharacters(start, buf, 0, buf.length);
                out.writeCharacters(buf, 0, read);
            }
        }
    }
 
Example #9
Source File: XMLStreamReaderToXMLStreamWriter.java    From TencentKona-8 with GNU General Public License v2.0 6 votes vote down vote up
protected void handleCharacters() throws XMLStreamException {

        CharSequence c = null;

        if (optimizeBase64Data) {
            c = ((XMLStreamReaderEx)in).getPCDATA();
        }

        if ((c != null) && (c instanceof Base64Data)) {
            if (mtomAttachmentMarshaller != null) {
                Base64Data b64d = (Base64Data) c;
                ((XMLStreamWriterEx)out).writeBinary(b64d.getDataHandler());
            } else {
                try {
                    ((Base64Data)c).writeTo(out);
                } catch (IOException e) {
                    throw new XMLStreamException(e);
                }
            }
        } else {
            for (int start=0,read=buf.length; read == buf.length; start+=buf.length) {
                read = in.getTextCharacters(start, buf, 0, buf.length);
                out.writeCharacters(buf, 0, read);
            }
        }
    }
 
Example #10
Source File: XMLStreamReaderToXMLStreamWriter.java    From openjdk-8-source with GNU General Public License v2.0 6 votes vote down vote up
protected void handleCharacters() throws XMLStreamException {

        CharSequence c = null;

        if (optimizeBase64Data) {
            c = ((XMLStreamReaderEx)in).getPCDATA();
        }

        if ((c != null) && (c instanceof Base64Data)) {
            if (mtomAttachmentMarshaller != null) {
                Base64Data b64d = (Base64Data) c;
                ((XMLStreamWriterEx)out).writeBinary(b64d.getDataHandler());
            } else {
                try {
                    ((Base64Data)c).writeTo(out);
                } catch (IOException e) {
                    throw new XMLStreamException(e);
                }
            }
        } else {
            for (int start=0,read=buf.length; read == buf.length; start+=buf.length) {
                read = in.getTextCharacters(start, buf, 0, buf.length);
                out.writeCharacters(buf, 0, read);
            }
        }
    }
 
Example #11
Source File: StreamWriterBufferCreator.java    From openjdk-8 with GNU General Public License v2.0 5 votes vote down vote up
public void writeBinary(byte[] bytes, int offset, int length, String endpointURL) throws XMLStreamException {
    Base64Data d = new Base64Data();
    byte b[] = new byte[length];
    System.arraycopy(bytes, offset, b, 0, length);
    d.set(b, length, null, true);
    storeStructure(T_TEXT_AS_OBJECT);
    storeContentObject(d);
}
 
Example #12
Source File: StreamWriterBufferCreator.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
public void writePCDATA(CharSequence charSequence) throws XMLStreamException {
    if (charSequence instanceof Base64Data) {
        storeStructure(T_TEXT_AS_OBJECT);
        storeContentObject(((Base64Data)charSequence).clone());
    } else {
        writeCharacters(charSequence.toString());
    }
}
 
Example #13
Source File: MtomCodec.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 5 votes vote down vote up
@Override
public void writePCDATA(CharSequence data) throws XMLStreamException {
    if(data == null)
        return;
    if(data instanceof Base64Data){
        Base64Data binaryData = (Base64Data)data;
        writeBinary(binaryData.getDataHandler());
        return;
    }
    writeCharacters(data.toString());
}
 
Example #14
Source File: MtomCodec.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 5 votes vote down vote up
@Override
public int next() throws XMLStreamException {
    int event = reader.next();
    if (event == XMLStreamConstants.START_ELEMENT && reader.getLocalName().equals(XOP_LOCALNAME) && reader.getNamespaceURI().equals(XOP_NAMESPACEURI)) {
        //its xop reference, take the URI reference
        String href = reader.getAttributeValue(null, "href");
        try {
            xopHref = href;
            Attachment att = getAttachment(href);
            if(att != null){
                DataHandler dh = att.asDataHandler();
                if (dh instanceof StreamingDataHandler) {
                    ((StreamingDataHandler)dh).setHrefCid(att.getContentId());
                }
                base64AttData = new Base64Data();
                base64AttData.set(dh);
            }
            xopReferencePresent = true;
        } catch (IOException e) {
            throw new WebServiceException(e);
        }
        //move to the </xop:Include>
        XMLStreamReaderUtil.nextElementContent(reader);
        return XMLStreamConstants.CHARACTERS;
    }
    if(xopReferencePresent){
        xopReferencePresent = false;
        base64EncodedText = null;
        xopHref = null;
    }
    return event;
}
 
Example #15
Source File: StreamWriterBufferCreator.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
public void writeBinary(byte[] bytes, int offset, int length, String endpointURL) throws XMLStreamException {
    Base64Data d = new Base64Data();
    byte b[] = new byte[length];
    System.arraycopy(bytes, offset, b, 0, length);
    d.set(b, length, null, true);
    storeStructure(T_TEXT_AS_OBJECT);
    storeContentObject(d);
}
 
Example #16
Source File: StreamWriterBufferCreator.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
public void writePCDATA(CharSequence charSequence) throws XMLStreamException {
    if (charSequence instanceof Base64Data) {
        storeStructure(T_TEXT_AS_OBJECT);
        storeContentObject(((Base64Data)charSequence).clone());
    } else {
        writeCharacters(charSequence.toString());
    }
}
 
Example #17
Source File: StreamWriterBufferCreator.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
public void writePCDATA(CharSequence charSequence) throws XMLStreamException {
    if (charSequence instanceof Base64Data) {
        storeStructure(T_TEXT_AS_OBJECT);
        storeContentObject(((Base64Data)charSequence).clone());
    } else {
        writeCharacters(charSequence.toString());
    }
}
 
Example #18
Source File: MtomCodec.java    From openjdk-8 with GNU General Public License v2.0 5 votes vote down vote up
@Override
public int next() throws XMLStreamException {
    int event = reader.next();
    if (event == XMLStreamConstants.START_ELEMENT && reader.getLocalName().equals(XOP_LOCALNAME) && reader.getNamespaceURI().equals(XOP_NAMESPACEURI)) {
        //its xop reference, take the URI reference
        String href = reader.getAttributeValue(null, "href");
        try {
            xopHref = href;
            Attachment att = getAttachment(href);
            if(att != null){
                DataHandler dh = att.asDataHandler();
                if (dh instanceof StreamingDataHandler) {
                    ((StreamingDataHandler)dh).setHrefCid(att.getContentId());
                }
                base64AttData = new Base64Data();
                base64AttData.set(dh);
            }
            xopReferencePresent = true;
        } catch (IOException e) {
            throw new WebServiceException(e);
        }
        //move to the </xop:Include>
        XMLStreamReaderUtil.nextElementContent(reader);
        return XMLStreamConstants.CHARACTERS;
    }
    if(xopReferencePresent){
        xopReferencePresent = false;
        base64EncodedText = null;
        xopHref = null;
    }
    return event;
}
 
Example #19
Source File: MtomCodec.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
@Override
public void writePCDATA(CharSequence data) throws XMLStreamException {
    if(data == null)
        return;
    if(data instanceof Base64Data){
        Base64Data binaryData = (Base64Data)data;
        writeBinary(binaryData.getDataHandler());
        return;
    }
    writeCharacters(data.toString());
}
 
Example #20
Source File: MtomCodec.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
@Override
public int next() throws XMLStreamException {
    int event = reader.next();
    if (event == XMLStreamConstants.START_ELEMENT && reader.getLocalName().equals(XOP_LOCALNAME) && reader.getNamespaceURI().equals(XOP_NAMESPACEURI)) {
        //its xop reference, take the URI reference
        String href = reader.getAttributeValue(null, "href");
        try {
            xopHref = href;
            Attachment att = getAttachment(href);
            if(att != null){
                DataHandler dh = att.asDataHandler();
                if (dh instanceof StreamingDataHandler) {
                    ((StreamingDataHandler)dh).setHrefCid(att.getContentId());
                }
                base64AttData = new Base64Data();
                base64AttData.set(dh);
            }
            xopReferencePresent = true;
        } catch (IOException e) {
            throw new WebServiceException(e);
        }
        //move to the </xop:Include>
        XMLStreamReaderUtil.nextElementContent(reader);
        return XMLStreamConstants.CHARACTERS;
    }
    if(xopReferencePresent){
        xopReferencePresent = false;
        base64EncodedText = null;
        xopHref = null;
    }
    return event;
}
 
Example #21
Source File: MtomCodec.java    From openjdk-8 with GNU General Public License v2.0 5 votes vote down vote up
@Override
public void writePCDATA(CharSequence data) throws XMLStreamException {
    if(data == null)
        return;
    if(data instanceof Base64Data){
        Base64Data binaryData = (Base64Data)data;
        writeBinary(binaryData.getDataHandler());
        return;
    }
    writeCharacters(data.toString());
}
 
Example #22
Source File: MtomCodec.java    From openjdk-8-source with GNU General Public License v2.0 5 votes vote down vote up
@Override
public int next() throws XMLStreamException {
    int event = reader.next();
    if (event == XMLStreamConstants.START_ELEMENT && reader.getLocalName().equals(XOP_LOCALNAME) && reader.getNamespaceURI().equals(XOP_NAMESPACEURI)) {
        //its xop reference, take the URI reference
        String href = reader.getAttributeValue(null, "href");
        try {
            xopHref = href;
            Attachment att = getAttachment(href);
            if(att != null){
                DataHandler dh = att.asDataHandler();
                if (dh instanceof StreamingDataHandler) {
                    ((StreamingDataHandler)dh).setHrefCid(att.getContentId());
                }
                base64AttData = new Base64Data();
                base64AttData.set(dh);
            }
            xopReferencePresent = true;
        } catch (IOException e) {
            throw new WebServiceException(e);
        }
        //move to the </xop:Include>
        XMLStreamReaderUtil.nextElementContent(reader);
        return XMLStreamConstants.CHARACTERS;
    }
    if(xopReferencePresent){
        xopReferencePresent = false;
        base64EncodedText = null;
        xopHref = null;
    }
    return event;
}
 
Example #23
Source File: StreamWriterBufferCreator.java    From openjdk-8 with GNU General Public License v2.0 5 votes vote down vote up
public void writePCDATA(CharSequence charSequence) throws XMLStreamException {
    if (charSequence instanceof Base64Data) {
        storeStructure(T_TEXT_AS_OBJECT);
        storeContentObject(((Base64Data)charSequence).clone());
    } else {
        writeCharacters(charSequence.toString());
    }
}
 
Example #24
Source File: StreamWriterBufferCreator.java    From hottub with GNU General Public License v2.0 5 votes vote down vote up
public void writePCDATA(CharSequence charSequence) throws XMLStreamException {
    if (charSequence instanceof Base64Data) {
        storeStructure(T_TEXT_AS_OBJECT);
        storeContentObject(((Base64Data)charSequence).clone());
    } else {
        writeCharacters(charSequence.toString());
    }
}
 
Example #25
Source File: StreamWriterBufferCreator.java    From hottub with GNU General Public License v2.0 5 votes vote down vote up
public void writeBinary(byte[] bytes, int offset, int length, String endpointURL) throws XMLStreamException {
    Base64Data d = new Base64Data();
    byte b[] = new byte[length];
    System.arraycopy(bytes, offset, b, 0, length);
    d.set(b, length, null, true);
    storeStructure(T_TEXT_AS_OBJECT);
    storeContentObject(d);
}
 
Example #26
Source File: MtomCodec.java    From hottub with GNU General Public License v2.0 5 votes vote down vote up
@Override
public void writePCDATA(CharSequence data) throws XMLStreamException {
    if(data == null)
        return;
    if(data instanceof Base64Data){
        Base64Data binaryData = (Base64Data)data;
        writeBinary(binaryData.getDataHandler());
        return;
    }
    writeCharacters(data.toString());
}
 
Example #27
Source File: MtomCodec.java    From hottub with GNU General Public License v2.0 5 votes vote down vote up
@Override
public int next() throws XMLStreamException {
    int event = reader.next();
    if (event == XMLStreamConstants.START_ELEMENT && reader.getLocalName().equals(XOP_LOCALNAME) && reader.getNamespaceURI().equals(XOP_NAMESPACEURI)) {
        //its xop reference, take the URI reference
        String href = reader.getAttributeValue(null, "href");
        try {
            xopHref = href;
            Attachment att = getAttachment(href);
            if(att != null){
                DataHandler dh = att.asDataHandler();
                if (dh instanceof StreamingDataHandler) {
                    ((StreamingDataHandler)dh).setHrefCid(att.getContentId());
                }
                base64AttData = new Base64Data();
                base64AttData.set(dh);
            }
            xopReferencePresent = true;
        } catch (IOException e) {
            throw new WebServiceException(e);
        }
        //move to the </xop:Include>
        XMLStreamReaderUtil.nextElementContent(reader);
        return XMLStreamConstants.CHARACTERS;
    }
    if(xopReferencePresent){
        xopReferencePresent = false;
        base64EncodedText = null;
        xopHref = null;
    }
    return event;
}
 
Example #28
Source File: StreamWriterBufferCreator.java    From openjdk-8-source with GNU General Public License v2.0 5 votes vote down vote up
public void writePCDATA(CharSequence charSequence) throws XMLStreamException {
    if (charSequence instanceof Base64Data) {
        storeStructure(T_TEXT_AS_OBJECT);
        storeContentObject(((Base64Data)charSequence).clone());
    } else {
        writeCharacters(charSequence.toString());
    }
}
 
Example #29
Source File: StreamWriterBufferCreator.java    From openjdk-8-source with GNU General Public License v2.0 5 votes vote down vote up
public void writeBinary(byte[] bytes, int offset, int length, String endpointURL) throws XMLStreamException {
    Base64Data d = new Base64Data();
    byte b[] = new byte[length];
    System.arraycopy(bytes, offset, b, 0, length);
    d.set(b, length, null, true);
    storeStructure(T_TEXT_AS_OBJECT);
    storeContentObject(d);
}
 
Example #30
Source File: MtomCodec.java    From openjdk-8-source with GNU General Public License v2.0 5 votes vote down vote up
@Override
public void writePCDATA(CharSequence data) throws XMLStreamException {
    if(data == null)
        return;
    if(data instanceof Base64Data){
        Base64Data binaryData = (Base64Data)data;
        writeBinary(binaryData.getDataHandler());
        return;
    }
    writeCharacters(data.toString());
}