Java Code Examples for com.sun.xml.internal.bind.v2.util.ByteArrayOutputStreamEx#set()
The following examples show how to use
com.sun.xml.internal.bind.v2.util.ByteArrayOutputStreamEx#set() .
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: RuntimeBuiltinLeafInfoImpl.java From TencentKona-8 with GNU General Public License v2.0 | 5 votes |
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 2
Source File: RuntimeBuiltinLeafInfoImpl.java From jdk8u60 with GNU General Public License v2.0 | 5 votes |
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 3
Source File: RuntimeBuiltinLeafInfoImpl.java From openjdk-jdk8u with GNU General Public License v2.0 | 5 votes |
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 4
Source File: RuntimeBuiltinLeafInfoImpl.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 5 votes |
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 5
Source File: RuntimeBuiltinLeafInfoImpl.java From openjdk-jdk9 with GNU General Public License v2.0 | 5 votes |
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 6
Source File: RuntimeBuiltinLeafInfoImpl.java From hottub with GNU General Public License v2.0 | 5 votes |
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 7
Source File: RuntimeBuiltinLeafInfoImpl.java From openjdk-8-source with GNU General Public License v2.0 | 5 votes |
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 8
Source File: RuntimeBuiltinLeafInfoImpl.java From openjdk-8 with GNU General Public License v2.0 | 5 votes |
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; }