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; } }
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; } }
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; } }
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; } }