Java Code Examples for com.sun.xml.internal.bind.v2.runtime.XMLSerializer#handleEvent()
The following examples show how to use
com.sun.xml.internal.bind.v2.runtime.XMLSerializer#handleEvent() .
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 | 6 votes |
public String print(XMLGregorianCalendar cal) { XMLSerializer xs = XMLSerializer.getInstance(); QName type = xs.getSchemaType(); if (type != null) { try { checkXmlGregorianCalendarFieldRef(type, cal); String format = xmlGregorianCalendarFormatString.get(type); if (format != null) { return format(format, cal); } } catch (javax.xml.bind.MarshalException e) { // see issue 649 xs.handleEvent(new ValidationEventImpl(ValidationEvent.WARNING, e.getMessage(), xs.getCurrentLocation(null) )); return ""; } } return cal.toXMLFormat(); }
Example 2
Source File: RuntimeBuiltinLeafInfoImpl.java From jdk8u60 with GNU General Public License v2.0 | 6 votes |
public String print(XMLGregorianCalendar cal) { XMLSerializer xs = XMLSerializer.getInstance(); QName type = xs.getSchemaType(); if (type != null) { try { checkXmlGregorianCalendarFieldRef(type, cal); String format = xmlGregorianCalendarFormatString.get(type); if (format != null) { return format(format, cal); } } catch (javax.xml.bind.MarshalException e) { // see issue 649 xs.handleEvent(new ValidationEventImpl(ValidationEvent.WARNING, e.getMessage(), xs.getCurrentLocation(null) )); return ""; } } return cal.toXMLFormat(); }
Example 3
Source File: RuntimeBuiltinLeafInfoImpl.java From openjdk-jdk8u with GNU General Public License v2.0 | 6 votes |
public String print(XMLGregorianCalendar cal) { XMLSerializer xs = XMLSerializer.getInstance(); QName type = xs.getSchemaType(); if (type != null) { try { checkXmlGregorianCalendarFieldRef(type, cal); String format = xmlGregorianCalendarFormatString.get(type); if (format != null) { return format(format, cal); } } catch (javax.xml.bind.MarshalException e) { // see issue 649 xs.handleEvent(new ValidationEventImpl(ValidationEvent.WARNING, e.getMessage(), xs.getCurrentLocation(null) )); return ""; } } return cal.toXMLFormat(); }
Example 4
Source File: RuntimeBuiltinLeafInfoImpl.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 6 votes |
public String print(XMLGregorianCalendar cal) { XMLSerializer xs = XMLSerializer.getInstance(); QName type = xs.getSchemaType(); if (type != null) { try { checkXmlGregorianCalendarFieldRef(type, cal); String format = xmlGregorianCalendarFormatString.get(type); if (format != null) { return format(format, cal); } } catch (javax.xml.bind.MarshalException e) { // see issue 649 xs.handleEvent(new ValidationEventImpl(ValidationEvent.WARNING, e.getMessage(), xs.getCurrentLocation(null) )); return ""; } } return cal.toXMLFormat(); }
Example 5
Source File: RuntimeBuiltinLeafInfoImpl.java From openjdk-jdk9 with GNU General Public License v2.0 | 6 votes |
public String print(XMLGregorianCalendar cal) { XMLSerializer xs = XMLSerializer.getInstance(); QName type = xs.getSchemaType(); if (type != null) { try { checkXmlGregorianCalendarFieldRef(type, cal); String format = xmlGregorianCalendarFormatString.get(type); if (format != null) { return format(format, cal); } } catch (javax.xml.bind.MarshalException e) { // see issue 649 xs.handleEvent(new ValidationEventImpl(ValidationEvent.WARNING, e.getMessage(), xs.getCurrentLocation(null) )); return ""; } } return cal.toXMLFormat(); }
Example 6
Source File: RuntimeBuiltinLeafInfoImpl.java From hottub with GNU General Public License v2.0 | 6 votes |
public String print(XMLGregorianCalendar cal) { XMLSerializer xs = XMLSerializer.getInstance(); QName type = xs.getSchemaType(); if (type != null) { try { checkXmlGregorianCalendarFieldRef(type, cal); String format = xmlGregorianCalendarFormatString.get(type); if (format != null) { return format(format, cal); } } catch (javax.xml.bind.MarshalException e) { // see issue 649 xs.handleEvent(new ValidationEventImpl(ValidationEvent.WARNING, e.getMessage(), xs.getCurrentLocation(null) )); return ""; } } return cal.toXMLFormat(); }
Example 7
Source File: RuntimeBuiltinLeafInfoImpl.java From openjdk-8-source with GNU General Public License v2.0 | 6 votes |
public String print(XMLGregorianCalendar cal) { XMLSerializer xs = XMLSerializer.getInstance(); QName type = xs.getSchemaType(); if (type != null) { try { checkXmlGregorianCalendarFieldRef(type, cal); String format = xmlGregorianCalendarFormatString.get(type); if (format != null) { return format(format, cal); } } catch (javax.xml.bind.MarshalException e) { // see issue 649 xs.handleEvent(new ValidationEventImpl(ValidationEvent.WARNING, e.getMessage(), xs.getCurrentLocation(null) )); return ""; } } return cal.toXMLFormat(); }
Example 8
Source File: RuntimeBuiltinLeafInfoImpl.java From openjdk-8 with GNU General Public License v2.0 | 6 votes |
public String print(XMLGregorianCalendar cal) { XMLSerializer xs = XMLSerializer.getInstance(); QName type = xs.getSchemaType(); if (type != null) { try { checkXmlGregorianCalendarFieldRef(type, cal); String format = xmlGregorianCalendarFormatString.get(type); if (format != null) { return format(format, cal); } } catch (javax.xml.bind.MarshalException e) { // see issue 649 xs.handleEvent(new ValidationEventImpl(ValidationEvent.WARNING, e.getMessage(), xs.getCurrentLocation(null) )); return ""; } } return cal.toXMLFormat(); }
Example 9
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 10
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 11
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 12
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 13
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 14
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 15
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 16
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; }