@Test public void testGetSource() throws Exception { SQLXMLImpl xml = new SQLXMLImpl(testStr); assertTrue(xml.getSource(null) instanceof StreamSource); StreamSource ss = (StreamSource)xml.getSource(null); assertEquals(testStr, new String(ObjectConverterUtil.convertToByteArray(ss.getInputStream()), Streamable.ENCODING)); }
@SuppressWarnings("unchecked") public <T extends Source> T getSource(Class<T> sourceClass) throws SQLException { if (sourceClass == null || sourceClass == StreamSource.class) { return (T)new StreamSource(getBinaryStream(), this.getStreamFactory().getSystemId()); } else if (sourceClass == StAXSource.class) { XMLInputFactory factory = XMLType.getXmlInputFactory(); try { return (T) new StAXSource(factory.createXMLStreamReader(getBinaryStream())); } catch (XMLStreamException e) { throw new SQLException(e); } } else if (sourceClass == SAXSource.class) { return (T) new SAXSource(new InputSource(getBinaryStream())); } else if (sourceClass == DOMSource.class) { try { DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance(); dbf.setNamespaceAware(true); if (!XMLType.SUPPORT_DTD) { dbf.setFeature("http: dbf.setFeature("http: } DocumentBuilder docBuilder = dbf.newDocumentBuilder(); Node doc = docBuilder.parse(new InputSource(getBinaryStream())); return (T) new DOMSource(doc); } catch (ParserConfigurationException e) { throw new SQLException(e); } catch (SAXException e) { throw new SQLException(e); } catch (IOException e) { throw new SQLException(e); } } throw new SQLException("Unsupported source type " + sourceClass); }
SQLXMLImpl extends BaseLob implements SQLXML { @SuppressWarnings("unchecked") public <T extends Source> T getSource(Class<T> sourceClass) throws SQLException { if (sourceClass == null || sourceClass == StreamSource.class) { return (T)new StreamSource(getBinaryStream(), this.getStreamFactory().getSystemId()); } else if (sourceClass == StAXSource.class) { XMLInputFactory factory = XMLType.getXmlInputFactory(); try { return (T) new StAXSource(factory.createXMLStreamReader(getBinaryStream())); } catch (XMLStreamException e) { throw new SQLException(e); } } else if (sourceClass == SAXSource.class) { return (T) new SAXSource(new InputSource(getBinaryStream())); } else if (sourceClass == DOMSource.class) { try { DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance(); dbf.setNamespaceAware(true); if (!XMLType.SUPPORT_DTD) { dbf.setFeature("http: dbf.setFeature("http: } DocumentBuilder docBuilder = dbf.newDocumentBuilder(); Node doc = docBuilder.parse(new InputSource(getBinaryStream())); return (T) new DOMSource(doc); } catch (ParserConfigurationException e) { throw new SQLException(e); } catch (SAXException e) { throw new SQLException(e); } catch (IOException e) { throw new SQLException(e); } } throw new SQLException("Unsupported source type " + sourceClass); } }
SQLXMLImpl extends BaseLob implements SQLXML { @SuppressWarnings("unchecked") public <T extends Source> T getSource(Class<T> sourceClass) throws SQLException { if (sourceClass == null || sourceClass == StreamSource.class) { return (T)new StreamSource(getBinaryStream(), this.getStreamFactory().getSystemId()); } else if (sourceClass == StAXSource.class) { XMLInputFactory factory = XMLType.getXmlInputFactory(); try { return (T) new StAXSource(factory.createXMLStreamReader(getBinaryStream())); } catch (XMLStreamException e) { throw new SQLException(e); } } else if (sourceClass == SAXSource.class) { return (T) new SAXSource(new InputSource(getBinaryStream())); } else if (sourceClass == DOMSource.class) { try { DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance(); dbf.setNamespaceAware(true); if (!XMLType.SUPPORT_DTD) { dbf.setFeature("http: dbf.setFeature("http: } DocumentBuilder docBuilder = dbf.newDocumentBuilder(); Node doc = docBuilder.parse(new InputSource(getBinaryStream())); return (T) new DOMSource(doc); } catch (ParserConfigurationException e) { throw new SQLException(e); } catch (SAXException e) { throw new SQLException(e); } catch (IOException e) { throw new SQLException(e); } } throw new SQLException("Unsupported source type " + sourceClass); } SQLXMLImpl();  SQLXMLImpl(final byte[] bytes);  SQLXMLImpl(final String str);  SQLXMLImpl(InputStreamFactory factory); }
SQLXMLImpl extends BaseLob implements SQLXML { @SuppressWarnings("unchecked") public <T extends Source> T getSource(Class<T> sourceClass) throws SQLException { if (sourceClass == null || sourceClass == StreamSource.class) { return (T)new StreamSource(getBinaryStream(), this.getStreamFactory().getSystemId()); } else if (sourceClass == StAXSource.class) { XMLInputFactory factory = XMLType.getXmlInputFactory(); try { return (T) new StAXSource(factory.createXMLStreamReader(getBinaryStream())); } catch (XMLStreamException e) { throw new SQLException(e); } } else if (sourceClass == SAXSource.class) { return (T) new SAXSource(new InputSource(getBinaryStream())); } else if (sourceClass == DOMSource.class) { try { DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance(); dbf.setNamespaceAware(true); if (!XMLType.SUPPORT_DTD) { dbf.setFeature("http: dbf.setFeature("http: } DocumentBuilder docBuilder = dbf.newDocumentBuilder(); Node doc = docBuilder.parse(new InputSource(getBinaryStream())); return (T) new DOMSource(doc); } catch (ParserConfigurationException e) { throw new SQLException(e); } catch (SAXException e) { throw new SQLException(e); } catch (IOException e) { throw new SQLException(e); } } throw new SQLException("Unsupported source type " + sourceClass); } SQLXMLImpl();  SQLXMLImpl(final byte[] bytes);  SQLXMLImpl(final String str);  SQLXMLImpl(InputStreamFactory factory); @Override Charset getCharset(); @SuppressWarnings("unchecked") T getSource(Class<T> sourceClass); String getString(); OutputStream setBinaryStream(); Writer setCharacterStream(); void setString(String value); T setResult(Class<T> resultClass); static long quickLength(SQLXML xml); }
SQLXMLImpl extends BaseLob implements SQLXML { @SuppressWarnings("unchecked") public <T extends Source> T getSource(Class<T> sourceClass) throws SQLException { if (sourceClass == null || sourceClass == StreamSource.class) { return (T)new StreamSource(getBinaryStream(), this.getStreamFactory().getSystemId()); } else if (sourceClass == StAXSource.class) { XMLInputFactory factory = XMLType.getXmlInputFactory(); try { return (T) new StAXSource(factory.createXMLStreamReader(getBinaryStream())); } catch (XMLStreamException e) { throw new SQLException(e); } } else if (sourceClass == SAXSource.class) { return (T) new SAXSource(new InputSource(getBinaryStream())); } else if (sourceClass == DOMSource.class) { try { DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance(); dbf.setNamespaceAware(true); if (!XMLType.SUPPORT_DTD) { dbf.setFeature("http: dbf.setFeature("http: } DocumentBuilder docBuilder = dbf.newDocumentBuilder(); Node doc = docBuilder.parse(new InputSource(getBinaryStream())); return (T) new DOMSource(doc); } catch (ParserConfigurationException e) { throw new SQLException(e); } catch (SAXException e) { throw new SQLException(e); } catch (IOException e) { throw new SQLException(e); } } throw new SQLException("Unsupported source type " + sourceClass); } SQLXMLImpl();  SQLXMLImpl(final byte[] bytes);  SQLXMLImpl(final String str);  SQLXMLImpl(InputStreamFactory factory); @Override Charset getCharset(); @SuppressWarnings("unchecked") T getSource(Class<T> sourceClass); String getString(); OutputStream setBinaryStream(); Writer setCharacterStream(); void setString(String value); T setResult(Class<T> resultClass); static long quickLength(SQLXML xml);  }