org.geotools.xml.Encoder.write()方法的使用及代码示例

x33g5p2x  于2022-01-19 转载在 其他  
字(1.7k)|赞(0)|评价(0)|浏览(121)

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

Encoder.write介绍

暂无

代码示例

代码示例来源:origin: org.geotools/gt2-xml-core

/**
 * Encodes an object, element name pair.
 *
 * @param object The object to encode.
 * @param element The name of the element to encode.
 *
 * @return The object encoded.
 * @throws Exception
 */
protected Document encode(Object object, QName element)
  throws Exception {
  Configuration configuration = createConfiguration();
  XSDSchema schema = configuration.getXSD().getSchema();
  Encoder encoder = new Encoder(configuration, schema);
  ByteArrayOutputStream output = new ByteArrayOutputStream();
  encoder.write(object, element, output);
  DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
  dbf.setNamespaceAware(true);
  return dbf.newDocumentBuilder().parse(new ByteArrayInputStream(output.toByteArray()));
}

代码示例来源:origin: org.geotools/gt2-xml-xsd

/**
 * Encodes an object, element name pair.
 * 
 * @param object The object to encode.
 * @param element The name of the element to encode.
 * 
 * @return The object encoded.
 * @throws Exception
 */
protected Document encode( Object object, QName element ) throws Exception {
  Configuration configuration = createConfiguration();
  XSDSchema schema = configuration.getSchemaLocator().locateSchema( 
    null, configuration.getNamespaceURI(), null, null
  );
  
  Encoder encoder = new Encoder( configuration, schema );
  ByteArrayOutputStream output = new ByteArrayOutputStream();
  encoder.write( object, element, output );

  DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
  dbf.setNamespaceAware( true );
  
  return dbf.newDocumentBuilder().parse( 
    new ByteArrayInputStream( output.toByteArray() )
  );
}

代码示例来源:origin: org.geotools.xsd/gt-core

encoder.write(object, element, output);

相关文章