java.sql.SQLXML.getSource()方法的使用及代码示例

x33g5p2x  于2022-01-30 转载在 其他  
字(6.2k)|赞(0)|评价(0)|浏览(132)

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

SQLXML.getSource介绍

[英]Returns a Source for reading this object's data.
[中]返回用于读取此对象数据的源。

代码示例

代码示例来源:origin: spring-projects/spring-framework

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

代码示例来源:origin: spring-projects/spring-framework

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

代码示例来源:origin: co.paralleluniverse/comsat-jdbc

@Override
  public T call() throws SQLException {
    return sqlXML.getSource(sourceClass);
  }
});

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

public <T extends Source> T getSource(Class<T> sourceClass) throws SQLException {
  return this.reference.getSource(sourceClass);
}

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

public <T extends Source> T getSource(Class<T> sourceClass) throws SQLException {
  return this.reference.getSource(sourceClass);
}

代码示例来源:origin: apache/servicemix-bundles

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

代码示例来源:origin: org.springframework/org.springframework.jdbc

@SuppressWarnings("unchecked")
public Source getXmlAsSource(ResultSet rs, int columnIndex, Class sourceClass) throws SQLException {
  return rs.getSQLXML(columnIndex).getSource(sourceClass != null ? sourceClass : DOMSource.class);
}

代码示例来源:origin: org.springframework/org.springframework.jdbc

@SuppressWarnings("unchecked")
public Source getXmlAsSource(ResultSet rs, String columnName, Class sourceClass) throws SQLException {
  return rs.getSQLXML(columnName).getSource(sourceClass != null ? sourceClass : DOMSource.class);
}

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

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

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

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

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

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

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

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

代码示例来源:origin: ModeShape/modeshape

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

相关文章