org.teiid.core.types.XMLType.getCharacterStream()方法的使用及代码示例

x33g5p2x  于2022-02-03 转载在 其他  
字(7.9k)|赞(0)|评价(0)|浏览(110)

本文整理了Java中org.teiid.core.types.XMLType.getCharacterStream()方法的一些代码示例,展示了XMLType.getCharacterStream()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。XMLType.getCharacterStream()方法的具体详情如下:
包路径:org.teiid.core.types.XMLType
类名称:XMLType
方法名:getCharacterStream

XMLType.getCharacterStream介绍

暂无

代码示例

代码示例来源:origin: teiid/teiid

/**
 * 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) {
    }
  }
}

代码示例来源:origin: org.teiid/teiid-common-core

/**
 * 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) {
    }
  }
}

代码示例来源:origin: org.jboss.teiid/teiid-engine

int read = -1;
  if (r == null) {
    r = xml.getCharacterStream();
case TEXT:
  if (r == null) {
    r = xml.getCharacterStream();

代码示例来源:origin: org.teiid/teiid-engine

int read = -1;
  if (r == null) {
    r = xml.getCharacterStream();
case TEXT:
  if (r == null) {
    r = xml.getCharacterStream();

代码示例来源:origin: teiid/teiid

int read = -1;
  if (r == null) {
    r = xml.getCharacterStream();
case TEXT:
  if (r == null) {
    r = xml.getCharacterStream();

代码示例来源:origin: org.jboss.teiid/teiid-engine

Reader reader;
try {
  reader = xml.getCharacterStream();
} catch (SQLException e) {
   throw new TeiidComponentException(QueryPlugin.Event.TEIID30194, e);

代码示例来源:origin: teiid/teiid

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

代码示例来源:origin: org.jboss.teiid/teiid-engine

InputStream is = null;
if (!Charset.forName(value.getEncoding()).equals(encoding)) {
  is = new ReaderInputStream(value.getCharacterStream(), encoding);
} else {
  is = value.getBinaryStream();

代码示例来源:origin: org.teiid/teiid-engine

InputStream is = null;
if (!Charset.forName(value.getEncoding()).equals(encoding)) {
  is = new ReaderInputStream(value.getCharacterStream(), encoding);
} else {
  is = value.getBinaryStream();

代码示例来源:origin: teiid/teiid

InputStream is = null;
if (!Charset.forName(value.getEncoding()).equals(encoding)) {
  is = new ReaderInputStream(value.getCharacterStream(), encoding);
} else {
  is = value.getBinaryStream();

代码示例来源:origin: teiid/teiid

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

代码示例来源:origin: teiid/teiid

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

代码示例来源:origin: org.jboss.teiid/teiid-engine

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

代码示例来源:origin: org.teiid/teiid-engine

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

相关文章