/** * This method transforms a value of the source type into a value * of the target type. * @param value Incoming value of source type * @return Outgoing value of target type * @throws TransformationException if value is an incorrect input type or * the transformation fails */ public Object transformDirect(Object value) throws TransformationException { XMLType source = (XMLType)value; Reader reader = null; try { char[] result = new char[DataTypeManager.MAX_STRING_LENGTH]; reader = source.getCharacterStream(); int read = reader.read(result); return new String(result, 0, read); } catch (SQLException e) { throw new TransformationException(CorePlugin.Event.TEIID10080, e, CorePlugin.Util.gs(CorePlugin.Event.TEIID10080, new Object[] {getSourceType().getName(), getTargetType().getName()})); } catch (IOException e) { throw new TransformationException(CorePlugin.Event.TEIID10080, e, CorePlugin.Util.gs(CorePlugin.Event.TEIID10080, new Object[] {getSourceType().getName(), getTargetType().getName()})); } finally { try { if (reader != null) { reader.close(); } } catch (IOException e) { } } }
/** * This method transforms a value of the source type into a value * of the target type. * @param value Incoming value of source type * @return Outgoing value of target type * @throws TransformationException if value is an incorrect input type or * the transformation fails */ public Object transformDirect(Object value) throws TransformationException { XMLType source = (XMLType)value; Reader reader = null; try { char[] result = new char[DataTypeManager.MAX_STRING_LENGTH]; reader = source.getCharacterStream(); int read = reader.read(result); return new String(result, 0, read); } catch (SQLException e) { throw new TransformationException(CorePlugin.Event.TEIID10080, e, CorePlugin.Util.gs(CorePlugin.Event.TEIID10080, new Object[] {getSourceType().getName(), getTargetType().getName()})); } catch (IOException e) { throw new TransformationException(CorePlugin.Event.TEIID10080, e, CorePlugin.Util.gs(CorePlugin.Event.TEIID10080, new Object[] {getSourceType().getName(), getTargetType().getName()})); } finally { try { if (reader != null) { reader.close(); } } catch (IOException e) { } } }
int read = -1; if (r == null) { r = xml.getCharacterStream(); case TEXT: if (r == null) { r = xml.getCharacterStream();
int read = -1; if (r == null) { r = xml.getCharacterStream(); case TEXT: if (r == null) { r = xml.getCharacterStream();
int read = -1; if (r == null) { r = xml.getCharacterStream(); case TEXT: if (r == null) { r = xml.getCharacterStream();
Reader reader; try { reader = xml.getCharacterStream(); } catch (SQLException e) { throw new TeiidComponentException(QueryPlugin.Event.TEIID30194, e);
@Test public void testInvokeXmlComment() throws Exception { CommandContext c = new CommandContext(); c.setBufferManager(BufferManagerFactory.getStandaloneBufferManager()); XMLType result = (XMLType)helpInvokeMethod("xmlcomment", new Class<?>[] {DataTypeManager.DefaultDataClasses.STRING}, new Object[] {"comment"}, c); String xml = ObjectConverterUtil.convertToString(result.getCharacterStream()); assertEquals("<!--comment-->", xml); }
InputStream is = null; if (!Charset.forName(value.getEncoding()).equals(encoding)) { is = new ReaderInputStream(value.getCharacterStream(), encoding); } else { is = value.getBinaryStream();
InputStream is = null; if (!Charset.forName(value.getEncoding()).equals(encoding)) { is = new ReaderInputStream(value.getCharacterStream(), encoding); } else { is = value.getBinaryStream();
InputStream is = null; if (!Charset.forName(value.getEncoding()).equals(encoding)) { is = new ReaderInputStream(value.getCharacterStream(), encoding); } else { is = value.getBinaryStream();
@Test public void testInvokeXmlConcat() throws Exception { CommandContext c = new CommandContext(); c.setBufferManager(BufferManagerFactory.getStandaloneBufferManager()); XMLType result = (XMLType)helpInvokeMethod("xmlconcat", new Class<?>[] {DataTypeManager.DefaultDataClasses.XML, DataTypeManager.DefaultDataClasses.XML}, new Object[] {DataTypeManager.transformValue("<bar/>", DataTypeManager.DefaultDataClasses.XML), DataTypeManager.transformValue("<Catalogs xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"><Catalog><Items><Item ItemID=\"001\"><Name>Lamp</Name><Quantity>5</Quantity></Item></Items></Catalog></Catalogs>", DataTypeManager.DefaultDataClasses.XML)}, c); String xml = ObjectConverterUtil.convertToString(result.getCharacterStream()); assertEquals("<bar/><Catalogs xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"><Catalog><Items><Item ItemID=\"001\"><Name>Lamp</Name><Quantity>5</Quantity></Item></Items></Catalog></Catalogs>", xml); }
private Object evaluateXMLSerialize(List<?> tuple, XMLSerialize xs) throws ExpressionEvaluationException, BlockedException, TeiidComponentException, FunctionExecutionException { XMLType value = (XMLType) internalEvaluate(xs.getExpression(), tuple); if (value == null) { return null; } try { if (!xs.isDocument()) { return XMLSystemFunctions.serialize(xs, value); } if (value.getType() == Type.UNKNOWN) { Type type = StringToSQLXMLTransform.isXml(value.getCharacterStream()); value.setType(type); } if (value.getType() == Type.DOCUMENT || value.getType() == Type.ELEMENT) { return XMLSystemFunctions.serialize(xs, value); } } catch (SQLException e) { throw new FunctionExecutionException(QueryPlugin.Event.TEIID30334, e); } catch (TransformationException e) { throw new FunctionExecutionException(QueryPlugin.Event.TEIID30335, e); } throw new FunctionExecutionException(QueryPlugin.Event.TEIID30336, QueryPlugin.Util.gs(QueryPlugin.Event.TEIID30336)); }
private Object evaluateXMLSerialize(List<?> tuple, XMLSerialize xs) throws ExpressionEvaluationException, BlockedException, TeiidComponentException, FunctionExecutionException { XMLType value = (XMLType) internalEvaluate(xs.getExpression(), tuple); if (value == null) { return null; } try { if (!xs.isDocument()) { return XMLSystemFunctions.serialize(xs, value); } if (value.getType() == Type.UNKNOWN) { Type type = StringToSQLXMLTransform.isXml(value.getCharacterStream()); value.setType(type); } if (value.getType() == Type.DOCUMENT || value.getType() == Type.ELEMENT) { return XMLSystemFunctions.serialize(xs, value); } } catch (SQLException e) { throw new FunctionExecutionException(QueryPlugin.Event.TEIID30334, e); } catch (TransformationException e) { throw new FunctionExecutionException(QueryPlugin.Event.TEIID30335, e); } throw new FunctionExecutionException(QueryPlugin.Event.TEIID30336, QueryPlugin.Util.gs(QueryPlugin.Event.TEIID30336)); }
private Object evaluateXMLSerialize(List<?> tuple, XMLSerialize xs) throws ExpressionEvaluationException, BlockedException, TeiidComponentException, FunctionExecutionException { XMLType value = (XMLType) internalEvaluate(xs.getExpression(), tuple); if (value == null) { return null; } try { if (!xs.isDocument()) { return XMLSystemFunctions.serialize(xs, value); } if (value.getType() == Type.UNKNOWN) { Type type = StringToSQLXMLTransform.isXml(value.getCharacterStream()); value.setType(type); } if (value.getType() == Type.DOCUMENT || value.getType() == Type.ELEMENT) { return XMLSystemFunctions.serialize(xs, value); } } catch (SQLException e) { throw new FunctionExecutionException(QueryPlugin.Event.TEIID30334, e); } catch (TransformationException e) { throw new FunctionExecutionException(QueryPlugin.Event.TEIID30335, e); } throw new FunctionExecutionException(QueryPlugin.Event.TEIID30336, QueryPlugin.Util.gs(QueryPlugin.Event.TEIID30336)); }