当前位置: 首页>>代码示例>>Java>>正文


Java Base64Data类代码示例

本文整理汇总了Java中com.sun.xml.internal.bind.v2.runtime.unmarshaller.Base64Data的典型用法代码示例。如果您正苦于以下问题:Java Base64Data类的具体用法?Java Base64Data怎么用?Java Base64Data使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


Base64Data类属于com.sun.xml.internal.bind.v2.runtime.unmarshaller包,在下文中一共展示了Base64Data类的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: text

import com.sun.xml.internal.bind.v2.runtime.unmarshaller.Base64Data; //导入依赖的package包/类
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);
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:25,代码来源:MTOMXmlOutput.java

示例2: text

import com.sun.xml.internal.bind.v2.runtime.unmarshaller.Base64Data; //导入依赖的package包/类
@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());
    }
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:23,代码来源:FastInfosetStreamWriterOutput.java

示例3: parse

import com.sun.xml.internal.bind.v2.runtime.unmarshaller.Base64Data; //导入依赖的package包/类
public Image parse(CharSequence text) throws SAXException  {
    try {
        InputStream is;
        if(text instanceof Base64Data)
            is = ((Base64Data)text).getInputStream();
        else
            is = new ByteArrayInputStream(decodeBase64(text)); // TODO: buffering is inefficient

        // technically we should check the MIME type here, but
        // normally images can be content-sniffed.
        // so the MIME type check will only make us slower and draconian, both of which
        // JAXB 2.0 isn't interested.
        try {
            return ImageIO.read(is);
        } finally {
            is.close();
        }
    } catch (IOException e) {
        UnmarshallingContext.getInstance().handleError(e);
        return null;
    }
}
 
开发者ID:campolake,项目名称:openjdk9,代码行数:23,代码来源:RuntimeBuiltinLeafInfoImpl.java

示例4: print

import com.sun.xml.internal.bind.v2.runtime.unmarshaller.Base64Data; //导入依赖的package包/类
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;
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:41,代码来源:RuntimeBuiltinLeafInfoImpl.java

示例5: parse

import com.sun.xml.internal.bind.v2.runtime.unmarshaller.Base64Data; //导入依赖的package包/类
public DataHandler parse(CharSequence text) {
    if(text instanceof Base64Data)
        return ((Base64Data)text).getDataHandler();
    else
        return new DataHandler(new ByteArrayDataSource(decodeBase64(text),
            UnmarshallingContext.getInstance().getXMIMEContentType()));
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:8,代码来源:RuntimeBuiltinLeafInfoImpl.java

示例6: decodeBase64

import com.sun.xml.internal.bind.v2.runtime.unmarshaller.Base64Data; //导入依赖的package包/类
private static byte[] decodeBase64(CharSequence text) {
    if (text instanceof Base64Data) {
        Base64Data base64Data = (Base64Data) text;
        return base64Data.getExact();
    } else {
        return DatatypeConverterImpl._parseBase64Binary(text.toString());
    }
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:9,代码来源:RuntimeBuiltinLeafInfoImpl.java

示例7: text

import com.sun.xml.internal.bind.v2.runtime.unmarshaller.Base64Data; //导入依赖的package包/类
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());
    }
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:13,代码来源:StAXExStreamWriterOutput.java


注:本文中的com.sun.xml.internal.bind.v2.runtime.unmarshaller.Base64Data类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。