com.sun.xml.internal.bind.v2.runtime.unmarshaller.Base64Data Java Examples

The following examples show how to use com.sun.xml.internal.bind.v2.runtime.unmarshaller.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: FastInfosetStreamWriterOutput.java    From openjdk-8-source with GNU General Public License v2.0 6 votes vote down vote up
@Override
public void text(Pcdata value, boolean needsSeparatingWhitespace) throws IOException {
    if (needsSeparatingWhitespace)
        fiout.writeLowLevelText(" ");

    /*
     * Check if the CharSequence is from a base64Binary data type
     */
    if (!(value instanceof Base64Data)) {
        final int len = value.length();
        if(len <buf.length) {
            value.writeTo(buf, 0);
            fiout.writeLowLevelText(buf, len);
        } else {
            fiout.writeLowLevelText(value.toString());
        }
    } else {
        final Base64Data dataValue = (Base64Data)value;
        // Write out the octets using the base64 encoding algorithm
        fiout.writeLowLevelOctets(dataValue.get(), dataValue.getDataLen());
    }
}
 
Example #2
Source File: FastInfosetStreamWriterOutput.java    From TencentKona-8 with GNU General Public License v2.0 6 votes vote down vote up
@Override
public void text(Pcdata value, boolean needsSeparatingWhitespace) throws IOException {
    if (needsSeparatingWhitespace)
        fiout.writeLowLevelText(" ");

    /*
     * Check if the CharSequence is from a base64Binary data type
     */
    if (!(value instanceof Base64Data)) {
        final int len = value.length();
        if(len <buf.length) {
            value.writeTo(buf, 0);
            fiout.writeLowLevelText(buf, len);
        } else {
            fiout.writeLowLevelText(value.toString());
        }
    } else {
        final Base64Data dataValue = (Base64Data)value;
        // Write out the octets using the base64 encoding algorithm
        fiout.writeLowLevelOctets(dataValue.get(), dataValue.getDataLen());
    }
}
 
Example #3
Source File: MTOMXmlOutput.java    From TencentKona-8 with GNU General Public License v2.0 6 votes vote down vote up
public void text( Pcdata value, boolean needsSeparatingWhitespace ) throws IOException, SAXException, XMLStreamException {
    if(value instanceof Base64Data && !serializer.getInlineBinaryFlag()) {
        Base64Data b64d = (Base64Data) value;
        String cid;
        if(b64d.hasData())
            cid = serializer.attachmentMarshaller.addMtomAttachment(
                            b64d.get(),0,b64d.getDataLen(),b64d.getMimeType(),nsUri,localName);
        else
            cid = serializer.attachmentMarshaller.addMtomAttachment(
                b64d.getDataHandler(),nsUri,localName);

        if(cid!=null) {
            nsContext.getCurrent().push();
            int prefix = nsContext.declareNsUri(WellKnownNamespace.XOP,"xop",false);
            beginStartTag(prefix,"Include");
            attribute(-1,"href",cid);
            endStartTag();
            endTag(prefix,"Include");
            nsContext.getCurrent().pop();
            return;
        }
    }
    next.text(value, needsSeparatingWhitespace);
}
 
Example #4
Source File: MTOMXmlOutput.java    From openjdk-8 with GNU General Public License v2.0 6 votes vote down vote up
public void text( Pcdata value, boolean needsSeparatingWhitespace ) throws IOException, SAXException, XMLStreamException {
    if(value instanceof Base64Data && !serializer.getInlineBinaryFlag()) {
        Base64Data b64d = (Base64Data) value;
        String cid;
        if(b64d.hasData())
            cid = serializer.attachmentMarshaller.addMtomAttachment(
                            b64d.get(),0,b64d.getDataLen(),b64d.getMimeType(),nsUri,localName);
        else
            cid = serializer.attachmentMarshaller.addMtomAttachment(
                b64d.getDataHandler(),nsUri,localName);

        if(cid!=null) {
            nsContext.getCurrent().push();
            int prefix = nsContext.declareNsUri(WellKnownNamespace.XOP,"xop",false);
            beginStartTag(prefix,"Include");
            attribute(-1,"href",cid);
            endStartTag();
            endTag(prefix,"Include");
            nsContext.getCurrent().pop();
            return;
        }
    }
    next.text(value, needsSeparatingWhitespace);
}
 
Example #5
Source File: MTOMXmlOutput.java    From jdk8u60 with GNU General Public License v2.0 6 votes vote down vote up
public void text( Pcdata value, boolean needsSeparatingWhitespace ) throws IOException, SAXException, XMLStreamException {
    if(value instanceof Base64Data && !serializer.getInlineBinaryFlag()) {
        Base64Data b64d = (Base64Data) value;
        String cid;
        if(b64d.hasData())
            cid = serializer.attachmentMarshaller.addMtomAttachment(
                            b64d.get(),0,b64d.getDataLen(),b64d.getMimeType(),nsUri,localName);
        else
            cid = serializer.attachmentMarshaller.addMtomAttachment(
                b64d.getDataHandler(),nsUri,localName);

        if(cid!=null) {
            nsContext.getCurrent().push();
            int prefix = nsContext.declareNsUri(WellKnownNamespace.XOP,"xop",false);
            beginStartTag(prefix,"Include");
            attribute(-1,"href",cid);
            endStartTag();
            endTag(prefix,"Include");
            nsContext.getCurrent().pop();
            return;
        }
    }
    next.text(value, needsSeparatingWhitespace);
}
 
Example #6
Source File: FastInfosetStreamWriterOutput.java    From jdk8u60 with GNU General Public License v2.0 6 votes vote down vote up
@Override
public void text(Pcdata value, boolean needsSeparatingWhitespace) throws IOException {
    if (needsSeparatingWhitespace)
        fiout.writeLowLevelText(" ");

    /*
     * Check if the CharSequence is from a base64Binary data type
     */
    if (!(value instanceof Base64Data)) {
        final int len = value.length();
        if(len <buf.length) {
            value.writeTo(buf, 0);
            fiout.writeLowLevelText(buf, len);
        } else {
            fiout.writeLowLevelText(value.toString());
        }
    } else {
        final Base64Data dataValue = (Base64Data)value;
        // Write out the octets using the base64 encoding algorithm
        fiout.writeLowLevelOctets(dataValue.get(), dataValue.getDataLen());
    }
}
 
Example #7
Source File: FastInfosetStreamWriterOutput.java    From openjdk-jdk8u with GNU General Public License v2.0 6 votes vote down vote up
@Override
public void text(Pcdata value, boolean needsSeparatingWhitespace) throws IOException {
    if (needsSeparatingWhitespace)
        fiout.writeLowLevelText(" ");

    /*
     * Check if the CharSequence is from a base64Binary data type
     */
    if (!(value instanceof Base64Data)) {
        final int len = value.length();
        if(len <buf.length) {
            value.writeTo(buf, 0);
            fiout.writeLowLevelText(buf, len);
        } else {
            fiout.writeLowLevelText(value.toString());
        }
    } else {
        final Base64Data dataValue = (Base64Data)value;
        // Write out the octets using the base64 encoding algorithm
        fiout.writeLowLevelOctets(dataValue.get(), dataValue.getDataLen());
    }
}
 
Example #8
Source File: MTOMXmlOutput.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 6 votes vote down vote up
public void text( Pcdata value, boolean needsSeparatingWhitespace ) throws IOException, SAXException, XMLStreamException {
    if(value instanceof Base64Data && !serializer.getInlineBinaryFlag()) {
        Base64Data b64d = (Base64Data) value;
        String cid;
        if(b64d.hasData())
            cid = serializer.attachmentMarshaller.addMtomAttachment(
                            b64d.get(),0,b64d.getDataLen(),b64d.getMimeType(),nsUri,localName);
        else
            cid = serializer.attachmentMarshaller.addMtomAttachment(
                b64d.getDataHandler(),nsUri,localName);

        if(cid!=null) {
            nsContext.getCurrent().push();
            int prefix = nsContext.declareNsUri(WellKnownNamespace.XOP,"xop",false);
            beginStartTag(prefix,"Include");
            attribute(-1,"href",cid);
            endStartTag();
            endTag(prefix,"Include");
            nsContext.getCurrent().pop();
            return;
        }
    }
    next.text(value, needsSeparatingWhitespace);
}
 
Example #9
Source File: FastInfosetStreamWriterOutput.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 6 votes vote down vote up
@Override
public void text(Pcdata value, boolean needsSeparatingWhitespace) throws IOException {
    if (needsSeparatingWhitespace)
        fiout.writeLowLevelText(" ");

    /*
     * Check if the CharSequence is from a base64Binary data type
     */
    if (!(value instanceof Base64Data)) {
        final int len = value.length();
        if(len <buf.length) {
            value.writeTo(buf, 0);
            fiout.writeLowLevelText(buf, len);
        } else {
            fiout.writeLowLevelText(value.toString());
        }
    } else {
        final Base64Data dataValue = (Base64Data)value;
        // Write out the octets using the base64 encoding algorithm
        fiout.writeLowLevelOctets(dataValue.get(), dataValue.getDataLen());
    }
}
 
Example #10
Source File: MTOMXmlOutput.java    From openjdk-jdk9 with GNU General Public License v2.0 6 votes vote down vote up
public void text( Pcdata value, boolean needsSeparatingWhitespace ) throws IOException, SAXException, XMLStreamException {
    if(value instanceof Base64Data && !serializer.getInlineBinaryFlag()) {
        Base64Data b64d = (Base64Data) value;
        String cid;
        if(b64d.hasData())
            cid = serializer.attachmentMarshaller.addMtomAttachment(
                            b64d.get(),0,b64d.getDataLen(),b64d.getMimeType(),nsUri,localName);
        else
            cid = serializer.attachmentMarshaller.addMtomAttachment(
                b64d.getDataHandler(),nsUri,localName);

        if(cid!=null) {
            nsContext.getCurrent().push();
            int prefix = nsContext.declareNsUri(WellKnownNamespace.XOP,"xop",false);
            beginStartTag(prefix,"Include");
            attribute(-1,"href",cid);
            endStartTag();
            endTag(prefix,"Include");
            nsContext.getCurrent().pop();
            return;
        }
    }
    next.text(value, needsSeparatingWhitespace);
}
 
Example #11
Source File: FastInfosetStreamWriterOutput.java    From openjdk-jdk9 with GNU General Public License v2.0 6 votes vote down vote up
@Override
public void text(Pcdata value, boolean needsSeparatingWhitespace) throws IOException {
    if (needsSeparatingWhitespace)
        fiout.writeLowLevelText(" ");

    /*
     * Check if the CharSequence is from a base64Binary data type
     */
    if (!(value instanceof Base64Data)) {
        final int len = value.length();
        if(len <buf.length) {
            value.writeTo(buf, 0);
            fiout.writeLowLevelText(buf, len);
        } else {
            fiout.writeLowLevelText(value.toString());
        }
    } else {
        final Base64Data dataValue = (Base64Data)value;
        // Write out the octets using the base64 encoding algorithm
        fiout.writeLowLevelOctets(dataValue.get(), dataValue.getDataLen());
    }
}
 
Example #12
Source File: MTOMXmlOutput.java    From hottub with GNU General Public License v2.0 6 votes vote down vote up
public void text( Pcdata value, boolean needsSeparatingWhitespace ) throws IOException, SAXException, XMLStreamException {
    if(value instanceof Base64Data && !serializer.getInlineBinaryFlag()) {
        Base64Data b64d = (Base64Data) value;
        String cid;
        if(b64d.hasData())
            cid = serializer.attachmentMarshaller.addMtomAttachment(
                            b64d.get(),0,b64d.getDataLen(),b64d.getMimeType(),nsUri,localName);
        else
            cid = serializer.attachmentMarshaller.addMtomAttachment(
                b64d.getDataHandler(),nsUri,localName);

        if(cid!=null) {
            nsContext.getCurrent().push();
            int prefix = nsContext.declareNsUri(WellKnownNamespace.XOP,"xop",false);
            beginStartTag(prefix,"Include");
            attribute(-1,"href",cid);
            endStartTag();
            endTag(prefix,"Include");
            nsContext.getCurrent().pop();
            return;
        }
    }
    next.text(value, needsSeparatingWhitespace);
}
 
Example #13
Source File: FastInfosetStreamWriterOutput.java    From hottub with GNU General Public License v2.0 6 votes vote down vote up
@Override
public void text(Pcdata value, boolean needsSeparatingWhitespace) throws IOException {
    if (needsSeparatingWhitespace)
        fiout.writeLowLevelText(" ");

    /*
     * Check if the CharSequence is from a base64Binary data type
     */
    if (!(value instanceof Base64Data)) {
        final int len = value.length();
        if(len <buf.length) {
            value.writeTo(buf, 0);
            fiout.writeLowLevelText(buf, len);
        } else {
            fiout.writeLowLevelText(value.toString());
        }
    } else {
        final Base64Data dataValue = (Base64Data)value;
        // Write out the octets using the base64 encoding algorithm
        fiout.writeLowLevelOctets(dataValue.get(), dataValue.getDataLen());
    }
}
 
Example #14
Source File: MTOMXmlOutput.java    From openjdk-8-source with GNU General Public License v2.0 6 votes vote down vote up
public void text( Pcdata value, boolean needsSeparatingWhitespace ) throws IOException, SAXException, XMLStreamException {
    if(value instanceof Base64Data && !serializer.getInlineBinaryFlag()) {
        Base64Data b64d = (Base64Data) value;
        String cid;
        if(b64d.hasData())
            cid = serializer.attachmentMarshaller.addMtomAttachment(
                            b64d.get(),0,b64d.getDataLen(),b64d.getMimeType(),nsUri,localName);
        else
            cid = serializer.attachmentMarshaller.addMtomAttachment(
                b64d.getDataHandler(),nsUri,localName);

        if(cid!=null) {
            nsContext.getCurrent().push();
            int prefix = nsContext.declareNsUri(WellKnownNamespace.XOP,"xop",false);
            beginStartTag(prefix,"Include");
            attribute(-1,"href",cid);
            endStartTag();
            endTag(prefix,"Include");
            nsContext.getCurrent().pop();
            return;
        }
    }
    next.text(value, needsSeparatingWhitespace);
}
 
Example #15
Source File: RuntimeBuiltinLeafInfoImpl.java    From hottub with GNU General Public License v2.0 5 votes vote down vote up
private static byte[] decodeBase64(CharSequence text) {
    if (text instanceof Base64Data) {
        Base64Data base64Data = (Base64Data) text;
        return base64Data.getExact();
    } else {
        return DatatypeConverterImpl._parseBase64Binary(text.toString());
    }
}
 
Example #16
Source File: RuntimeBuiltinLeafInfoImpl.java    From hottub with GNU General Public License v2.0 5 votes vote down vote up
public DataHandler parse(CharSequence text) {
    if(text instanceof Base64Data)
        return ((Base64Data)text).getDataHandler();
    else
        return new DataHandler(new ByteArrayDataSource(decodeBase64(text),
            UnmarshallingContext.getInstance().getXMIMEContentType()));
}
 
Example #17
Source File: RuntimeBuiltinLeafInfoImpl.java    From hottub with GNU General Public License v2.0 5 votes vote down vote up
public Source parse(CharSequence text) throws SAXException  {
    try {
        if(text instanceof Base64Data)
            return new DataSourceSource( ((Base64Data)text).getDataHandler() );
        else
            return new DataSourceSource(new ByteArrayDataSource(decodeBase64(text),
                UnmarshallingContext.getInstance().getXMIMEContentType()));
    } catch (MimeTypeParseException e) {
        UnmarshallingContext.getInstance().handleError(e);
        return null;
    }
}
 
Example #18
Source File: RuntimeBuiltinLeafInfoImpl.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
public Base64Data print(byte[] v) {
    XMLSerializer w = XMLSerializer.getInstance();
    Base64Data bd = new Base64Data();
    String mimeType = w.getXMIMEContentType();
    bd.set(v,mimeType);
    return bd;
}
 
Example #19
Source File: StAXExStreamWriterOutput.java    From hottub with GNU General Public License v2.0 5 votes vote down vote up
public void text(Pcdata value, boolean needsSeparatingWhitespace) throws XMLStreamException {
    if(needsSeparatingWhitespace) {
        out.writeCharacters(" ");
    }

    if (!(value instanceof Base64Data)) {
        out.writeCharacters(value.toString());
    } else {
        Base64Data v = (Base64Data)value;
        out.writeBinary(v.getDataHandler());
    }
}
 
Example #20
Source File: RuntimeBuiltinLeafInfoImpl.java    From hottub with GNU General Public License v2.0 5 votes vote down vote up
public Base64Data print(byte[] v) {
    XMLSerializer w = XMLSerializer.getInstance();
    Base64Data bd = new Base64Data();
    String mimeType = w.getXMIMEContentType();
    bd.set(v,mimeType);
    return bd;
}
 
Example #21
Source File: RuntimeBuiltinLeafInfoImpl.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
public Base64Data print(byte[] v) {
    XMLSerializer w = XMLSerializer.getInstance();
    Base64Data bd = new Base64Data();
    String mimeType = w.getXMIMEContentType();
    bd.set(v,mimeType);
    return bd;
}
 
Example #22
Source File: RuntimeBuiltinLeafInfoImpl.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
public Source parse(CharSequence text) throws SAXException  {
    try {
        if(text instanceof Base64Data)
            return new DataSourceSource( ((Base64Data)text).getDataHandler() );
        else
            return new DataSourceSource(new ByteArrayDataSource(decodeBase64(text),
                UnmarshallingContext.getInstance().getXMIMEContentType()));
    } catch (MimeTypeParseException e) {
        UnmarshallingContext.getInstance().handleError(e);
        return null;
    }
}
 
Example #23
Source File: RuntimeBuiltinLeafInfoImpl.java    From openjdk-8 with GNU General Public License v2.0 5 votes vote down vote up
private static byte[] decodeBase64(CharSequence text) {
    if (text instanceof Base64Data) {
        Base64Data base64Data = (Base64Data) text;
        return base64Data.getExact();
    } else {
        return DatatypeConverterImpl._parseBase64Binary(text.toString());
    }
}
 
Example #24
Source File: RuntimeBuiltinLeafInfoImpl.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
public DataHandler parse(CharSequence text) {
    if(text instanceof Base64Data)
        return ((Base64Data)text).getDataHandler();
    else
        return new DataHandler(new ByteArrayDataSource(decodeBase64(text),
            UnmarshallingContext.getInstance().getXMIMEContentType()));
}
 
Example #25
Source File: RuntimeBuiltinLeafInfoImpl.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
public Base64Data print(Image v) {
    ByteArrayOutputStreamEx imageData = new ByteArrayOutputStreamEx();
    XMLSerializer xs = XMLSerializer.getInstance();

    String mimeType = xs.getXMIMEContentType();
    if(mimeType==null || mimeType.startsWith("image/*"))
        // because PNG is lossless, it's a good default
        //
        // mime type can be a range, in which case we can't just pass that
        // to ImageIO.getImageWritersByMIMEType, so here I'm just assuming
        // the default of PNG. Not sure if this is complete.
        mimeType = "image/png";

    try {
        Iterator<ImageWriter> itr = ImageIO.getImageWritersByMIMEType(mimeType);
        if(itr.hasNext()) {
            ImageWriter w = itr.next();
            ImageOutputStream os = ImageIO.createImageOutputStream(imageData);
            w.setOutput(os);
            w.write(convertToBufferedImage(v));
            os.close();
            w.dispose();
        } else {
            // no encoder
            xs.handleEvent(new ValidationEventImpl(
                ValidationEvent.ERROR,
                Messages.NO_IMAGE_WRITER.format(mimeType),
                xs.getCurrentLocation(null) ));
            // TODO: proper error reporting
            throw new RuntimeException("no encoder for MIME type "+mimeType);
        }
    } catch (IOException e) {
        xs.handleError(e);
        // TODO: proper error reporting
        throw new RuntimeException(e);
    }
    Base64Data bd = new Base64Data();
    imageData.set(bd,mimeType);
    return bd;
}
 
Example #26
Source File: RuntimeBuiltinLeafInfoImpl.java    From openjdk-8-source with GNU General Public License v2.0 5 votes vote down vote up
public DataHandler parse(CharSequence text) {
    if(text instanceof Base64Data)
        return ((Base64Data)text).getDataHandler();
    else
        return new DataHandler(new ByteArrayDataSource(decodeBase64(text),
            UnmarshallingContext.getInstance().getXMIMEContentType()));
}
 
Example #27
Source File: StAXExStreamWriterOutput.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 5 votes vote down vote up
public void text(Pcdata value, boolean needsSeparatingWhitespace) throws XMLStreamException {
    if(needsSeparatingWhitespace) {
        out.writeCharacters(" ");
    }

    if (!(value instanceof Base64Data)) {
        out.writeCharacters(value.toString());
    } else {
        Base64Data v = (Base64Data)value;
        out.writeBinary(v.getDataHandler());
    }
}
 
Example #28
Source File: StAXExStreamWriterOutput.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
public void text(Pcdata value, boolean needsSeparatingWhitespace) throws XMLStreamException {
    if(needsSeparatingWhitespace) {
        out.writeCharacters(" ");
    }

    if (!(value instanceof Base64Data)) {
        out.writeCharacters(value.toString());
    } else {
        Base64Data v = (Base64Data)value;
        out.writeBinary(v.getDataHandler());
    }
}
 
Example #29
Source File: RuntimeBuiltinLeafInfoImpl.java    From openjdk-8-source with GNU General Public License v2.0 5 votes vote down vote up
public Source parse(CharSequence text) throws SAXException  {
    try {
        if(text instanceof Base64Data)
            return new DataSourceSource( ((Base64Data)text).getDataHandler() );
        else
            return new DataSourceSource(new ByteArrayDataSource(decodeBase64(text),
                UnmarshallingContext.getInstance().getXMIMEContentType()));
    } catch (MimeTypeParseException e) {
        UnmarshallingContext.getInstance().handleError(e);
        return null;
    }
}
 
Example #30
Source File: RuntimeBuiltinLeafInfoImpl.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
private static byte[] decodeBase64(CharSequence text) {
    if (text instanceof Base64Data) {
        Base64Data base64Data = (Base64Data) text;
        return base64Data.getExact();
    } else {
        return DatatypeConverterImpl._parseBase64Binary(text.toString());
    }
}