本文整理了Java中org.geotools.xml.Encoder.setEncoding()
方法的一些代码示例,展示了Encoder.setEncoding()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Encoder.setEncoding()
方法的具体详情如下:
包路径:org.geotools.xml.Encoder
类名称:Encoder
方法名:setEncoding
[英]Sets the charset encoding scheme to be used in encoding XML content.
This encoding will determine the resulting character encoding for the XML content generated by this Encoder and will be reflected in the XML declaration tag.
[中]设置用于编码XML内容的字符集编码方案。
此编码将确定此编码器生成的XML内容的结果字符编码,并将反映在XML声明标记中。
代码示例来源:origin: org.geotools/gt-wfs
public void writeBody(final OutputStream out) throws IOException {
final Charset charset = defaultEncoding == null ? Charset.forName("UTF-8")
: defaultEncoding;
encoder.setEncoding(charset);
// if (LOGGER.isLoggable(Level.FINEST)) {
// System.err.println("Sending POST request: ");
// WFS_1_1_0_Protocol.encode(request, wfsConfig, System.err, charset);
// }
WFS_1_1_0_Protocol.encode(request, encoder, out);
}
};
代码示例来源:origin: org.geotools/gt-wfs
/**
* Returns a single-line string containing the xml representation of the given filter, as
* appropriate for the {@code FILTER} parameter in a GetFeature request.
*/
protected String encodeGetFeatureGetFilter(final Filter filter) throws IOException {
Configuration filterConfig = getFilterConfiguration();
Encoder encoder = new Encoder(filterConfig);
// do not write the xml declaration
encoder.setOmitXMLDeclaration(true);
encoder.setEncoding(Charset.forName("UTF-8"));
OutputStream out = new ByteArrayOutputStream();
encoder.encode(filter, OGC.Filter, out);
String encoded = out.toString();
encoded = encoded.replaceAll("\n", "");
return encoded;
}
代码示例来源:origin: org.geotools/gt-wfs
/**
* Encodes a WFS request into {@code out}
*
* @param request
* one of {@link GetCapabilitiesType}, {@link GetFeatureType}, etc
* @param configuration
* the wfs configuration to use for encoding the request into the output stream
* @param out
* the output stream where to encode the request into
* @param charset
* the charset to use to encode the request in
* @throws IOException
*/
public static void encode(final EObject request, final Configuration configuration,
final OutputStream out, final Charset charset) throws IOException {
Encoder encoder = new Encoder(configuration);
encoder.setEncoding(charset);
encode(request, encoder, out);
}
代码示例来源:origin: org.geotools/gt-wfs-ng
/**
* Returns a single-line string containing the xml representation of the given filter, as
* appropriate for the {@code FILTER} parameter in a GetFeature request.
*/
protected String encodeGetFeatureGetFilter(final Filter filter) throws IOException {
final Configuration filterConfig = getFilterConfiguration();
final QName encName;
if (filterConfig instanceof org.geotools.filter.v1_0.OGCConfiguration
|| filterConfig instanceof org.geotools.filter.v1_1.OGCConfiguration) {
encName = org.geotools.filter.v1_0.OGC.Filter;
} else {
encName = org.geotools.filter.v2_0.FES.Filter;
}
Encoder encoder = new Encoder(filterConfig);
// do not write the xml declaration
encoder.setOmitXMLDeclaration(true);
encoder.setEncoding(Charset.forName("UTF-8"));
String encoded = encoder.encodeAsString(filter, encName);
encoded = encoded.replaceAll("\n", "");
return encoded;
}
代码示例来源:origin: org.geotools/gt-wfs-ng
encoder.setEncoding(charset);
encoder.setIndentSize(1);
代码示例来源:origin: org.geoserver/gs-wfs
void write1_1(LockFeatureResponseType lockResponse, OutputStream output, Operation operation)
throws IOException {
Encoder encoder = new Encoder(configuration, configuration.schema());
encoder.setEncoding(Charset.forName(getInfo().getGeoServer().getSettings().getCharset()));
LockFeatureType req = (LockFeatureType) operation.getParameters()[0];
encoder.setSchemaLocation(
org.geoserver.wfs.xml.v1_1_0.WFS.NAMESPACE,
buildSchemaURL(req.getBaseUrl(), "schemas/wfs/1.1.0/wfs.xsd"));
encoder.encode(lockResponse, org.geoserver.wfs.xml.v1_1_0.WFS.LOCKFEATURERESPONSE, output);
output.flush();
}
}
代码示例来源:origin: org.geoserver/gs-wfs
@Override
protected void encode(FeatureCollectionResponse hits, OutputStream output, WFSInfo wfs)
throws IOException {
hits.setNumberOfFeatures(BigInteger.valueOf(0));
Encoder e = new Encoder(new WFSConfiguration());
e.setEncoding(Charset.forName(wfs.getGeoServer().getSettings().getCharset()));
e.setSchemaLocation(
WFS.NAMESPACE, ResponseUtils.appendPath(wfs.getSchemaBaseURL(), "wfs/2.0/wfs.xsd"));
e.encode(hits.getAdaptee(), WFS.FeatureCollection, output);
}
}
代码示例来源:origin: org.geoserver/gs-wfs
public void write(Object value, OutputStream output, Operation operation)
throws IOException, ServiceException {
// get the feature
SimpleFeature feature = (SimpleFeature) value;
SimpleFeatureType featureType = feature.getType();
// grab the metadata
FeatureTypeInfo meta = catalog.getFeatureTypeByName(featureType.getName());
// create teh encoder
Encoder encoder = new Encoder(configuration);
encoder.setEncoding(Charset.forName(getInfo().getGeoServer().getSettings().getCharset()));
encoder.encode(feature, new QName(meta.getNamespace().getURI(), meta.getName()), output);
}
}
代码示例来源:origin: org.geoserver/gs-wfs
protected void encode(FeatureCollectionResponse hits, OutputStream output, WFSInfo wfs)
throws IOException {
Encoder encoder = new Encoder(configuration, configuration.schema());
encoder.setEncoding(Charset.forName(wfs.getGeoServer().getSettings().getCharset()));
encoder.setSchemaLocation(
org.geoserver.wfs.xml.v1_1_0.WFS.NAMESPACE,
ResponseUtils.appendPath(wfs.getSchemaBaseURL(), "wfs/1.1.0/wfs.xsd"));
encoder.encode(
hits.getAdaptee(), org.geoserver.wfs.xml.v1_1_0.WFS.FEATURECOLLECTION, output);
}
}
代码示例来源:origin: org.geoserver/gs-wfs
@Override
public void write(Object value, OutputStream output, Operation operation)
throws IOException, ServiceException {
Encoder encoder = new Encoder(new WFSConfiguration());
encoder.setEncoding(Charset.forName(getInfo().getGeoServer().getSettings().getCharset()));
encoder.setOmitXMLDeclaration(Dispatcher.REQUEST.get().isSOAP());
String baseURL = (String) EMFUtils.get((EObject) operation.getParameters()[0], "baseUrl");
encoder.setSchemaLocation(WFS.NAMESPACE, buildSchemaURL(baseURL, "wfs/2.0/wfs.xsd"));
encode(encoder, value, output, operation);
}
代码示例来源:origin: org.geoserver.community/gs-nsg-wfs-profile
@Override
protected void encode(FeatureCollectionResponse hits, OutputStream output, WFSInfo wfs)
throws IOException {
hits.setNumberOfFeatures(BigInteger.ZERO);
// instantiate the XML encoder
Encoder encoder = new Encoder(new WFSConfiguration());
encoder.setEncoding(Charset.forName(wfs.getGeoServer().getSettings().getCharset()));
encoder.setSchemaLocation(
WFS.NAMESPACE, ResponseUtils.appendPath(wfs.getSchemaBaseURL(), "wfs/2.0/wfs.xsd"));
Document document;
try {
// encode the HITS result using FeatureCollection as the root XML element
document = encoder.encodeAsDOM(hits.getAdaptee(), WFS.FeatureCollection);
} catch (Exception exception) {
throw new RuntimeException("Error encoding INDEX result.", exception);
}
// add the resultSetID attribute to the result
addResultSetIdElement(document, resultSetId);
// write the XML document to response output stream
writeDocument(document, output);
}
代码示例来源:origin: org.geoserver/gs-wfs
public void write(Object value, OutputStream output, Operation operation)
throws IOException, ServiceException {
Encoder encoder = new Encoder(new GMLConfiguration());
encoder.setEncoding(Charset.forName(getInfo().getGeoServer().getSettings().getCharset()));
if (value instanceof Point) {
encoder.encode(value, GML.Point, output);
} else if (value instanceof MultiPoint) {
encoder.encode(value, GML.MultiPoint, output);
} else if (value instanceof LineString) {
encoder.encode(value, GML.LineString, output);
} else if (value instanceof MultiLineString) {
encoder.encode(value, GML.MultiLineString, output);
} else if (value instanceof Polygon) {
encoder.encode(value, GML.Polygon, output);
} else if (value instanceof MultiPolygon) {
encoder.encode(value, GML.MultiPolygon, output);
} else {
throw new WFSException("Cannot encode geometry of type: " + value.getClass());
}
}
}
代码示例来源:origin: org.geoserver/gs-wfs
Encoder encoder = createEncoder(configuration, ns2metas, gft);
encoder.setEncoding(Charset.forName(geoServer.getSettings().getCharset()));
Request dispatcherRequest = Dispatcher.REQUEST.get();
if (dispatcherRequest != null) {
代码示例来源:origin: org.geoserver/gs-wfs
public void v_1_1(TransactionResponseType response, OutputStream output, Operation operation)
throws IOException, ServiceException {
if (!response.getTransactionResults().getAction().isEmpty()) {
// since we do atomic transactions, an action failure means all we rolled back
// spec says to throw exception
ActionType action =
(ActionType) response.getTransactionResults().getAction().iterator().next();
throw new WFSException(action.getMessage(), action.getCode(), action.getLocator());
}
Encoder encoder = new Encoder(configuration, configuration.schema());
encoder.setEncoding(Charset.forName(getInfo().getGeoServer().getSettings().getCharset()));
TransactionType req = (TransactionType) operation.getParameters()[0];
encoder.setSchemaLocation(
org.geoserver.wfs.xml.v1_1_0.WFS.NAMESPACE,
buildSchemaURL(req.getBaseUrl(), "wfs/1.1.0/wfs.xsd"));
encoder.encode(response, org.geoserver.wfs.xml.v1_1_0.WFS.TRANSACTIONRESPONSE, output);
}
}
内容来源于网络,如有侵权,请联系作者删除!