@Override @Nullable public Source getXmlAsSource(ResultSet rs, int columnIndex, @Nullable Class<? extends Source> sourceClass) throws SQLException { SQLXML xmlObject = rs.getSQLXML(columnIndex); if (xmlObject == null) { return null; } return (sourceClass != null ? xmlObject.getSource(sourceClass) : xmlObject.getSource(DOMSource.class)); }
@Override @Nullable public Source getXmlAsSource(ResultSet rs, String columnName, @Nullable Class<? extends Source> sourceClass) throws SQLException { SQLXML xmlObject = rs.getSQLXML(columnName); if (xmlObject == null) { return null; } return (sourceClass != null ? xmlObject.getSource(sourceClass) : xmlObject.getSource(DOMSource.class)); }
@Override public T call() throws SQLException { return sqlXML.getSource(sourceClass); } });
public <T extends Source> T getSource(Class<T> sourceClass) throws SQLException { return this.reference.getSource(sourceClass); }
public <T extends Source> T getSource(Class<T> sourceClass) throws SQLException { return this.reference.getSource(sourceClass); }
@Override @Nullable public Source getXmlAsSource(ResultSet rs, String columnName, @Nullable Class<? extends Source> sourceClass) throws SQLException { SQLXML xmlObject = rs.getSQLXML(columnName); if (xmlObject == null) { return null; } return (sourceClass != null ? xmlObject.getSource(sourceClass) : xmlObject.getSource(DOMSource.class)); }
@SuppressWarnings("unchecked") public Source getXmlAsSource(ResultSet rs, int columnIndex, Class sourceClass) throws SQLException { return rs.getSQLXML(columnIndex).getSource(sourceClass != null ? sourceClass : DOMSource.class); }
@SuppressWarnings("unchecked") public Source getXmlAsSource(ResultSet rs, String columnName, Class sourceClass) throws SQLException { return rs.getSQLXML(columnName).getSource(sourceClass != null ? sourceClass : DOMSource.class); }
public static Source convertToSource(Object value) throws TeiidProcessingException { if (value == null) { return null; } try { if (value instanceof SQLXML) { return ((SQLXML)value).getSource(null); } if (value instanceof Clob) { return new StreamSource(((Clob)value).getCharacterStream()); } if (value instanceof Blob) { return new StreamSource(((Blob)value).getBinaryStream()); } if (value instanceof String) { return new StreamSource(new StringReader((String)value)); } } catch (SQLException e) { throw new TeiidProcessingException(QueryPlugin.Event.TEIID30443, e); } throw new AssertionError("Unknown type"); //$NON-NLS-1$ }
public static String prettyPrint(SQLXML xml) throws SQLException { try { TransformerFactory transFactory = TransformerFactory.newInstance(); transFactory.setAttribute("indent-number", new Integer(2)); //$NON-NLS-1$ Transformer tf = transFactory.newTransformer(); tf.setOutputProperty(OutputKeys.OMIT_XML_DECLARATION, "yes"); //$NON-NLS-1$ tf.setOutputProperty(OutputKeys.ENCODING, "UTF-8");//$NON-NLS-1$ tf.setOutputProperty(OutputKeys.INDENT, "yes");//$NON-NLS-1$ tf.setOutputProperty(OutputKeys.METHOD, "xml");//$NON-NLS-1$ tf.setOutputProperty(OutputKeys.STANDALONE, "yes");//$NON-NLS-1$ tf.setOutputProperty("{http://xml.apache.org/xslt}indent-amount", "4"); //$NON-NLS-1$ //$NON-NLS-2$ ByteArrayOutputStream out = new ByteArrayOutputStream(); StreamResult xmlOut = new StreamResult(new BufferedOutputStream(out)); tf.transform(xml.getSource(StreamSource.class), xmlOut); return out.toString(); } catch (Exception e) { return xml.getString(); } } }
public static Source convertToSource(Object value) throws TeiidProcessingException { if (value == null) { return null; } try { if (value instanceof SQLXML) { return ((SQLXML)value).getSource(null); } if (value instanceof Clob) { return new StreamSource(((Clob)value).getCharacterStream()); } if (value instanceof Blob) { return new StreamSource(((Blob)value).getBinaryStream()); } if (value instanceof String) { return new StreamSource(new StringReader((String)value)); } } catch (SQLException e) { throw new TeiidProcessingException(QueryPlugin.Event.TEIID30443, e); } throw new AssertionError("Unknown type"); //$NON-NLS-1$ }
public static Source convertToSource(Object value) throws TeiidProcessingException { if (value == null) { return null; } try { if (value instanceof SQLXML) { return ((SQLXML)value).getSource(null); } if (value instanceof Clob) { return new StreamSource(((Clob)value).getCharacterStream()); } if (value instanceof Blob) { return new StreamSource(((Blob)value).getBinaryStream()); } if (value instanceof String) { return new StreamSource(new StringReader((String)value)); } } catch (SQLException e) { throw new TeiidProcessingException(QueryPlugin.Event.TEIID30443, e); } throw new AssertionError("Unknown type"); //$NON-NLS-1$ }
public static String prettyPrint( SQLXML xml ) throws SQLException { try { TransformerFactory transFactory = TransformerFactory.newInstance(); transFactory.setAttribute("indent-number", new Integer(2)); //$NON-NLS-1$ Transformer tf = transFactory.newTransformer(); tf.setOutputProperty(OutputKeys.OMIT_XML_DECLARATION, "yes"); //$NON-NLS-1$ tf.setOutputProperty(OutputKeys.ENCODING, "UTF-8");//$NON-NLS-1$ tf.setOutputProperty(OutputKeys.INDENT, "yes");//$NON-NLS-1$ tf.setOutputProperty(OutputKeys.METHOD, "xml");//$NON-NLS-1$ tf.setOutputProperty(OutputKeys.STANDALONE, "yes");//$NON-NLS-1$ tf.setOutputProperty("{http://xml.apache.org/xslt}indent-amount", "4"); //$NON-NLS-1$ //$NON-NLS-2$ ByteArrayOutputStream out = new ByteArrayOutputStream(); StreamResult xmlOut = new StreamResult(new BufferedOutputStream(out)); tf.transform(xml.getSource(StreamSource.class), xmlOut); return out.toString(); } catch (Exception e) { return xml.getString(); } } }