Mercurial > dive4elements > http-client
changeset 90:8bd13f10d555
issue1494: Prepare HttpClient to use a specified encoding for collectionOut. Doc.
author | Felix Wolfsteller <felix.wolfsteller@intevation.de> |
---|---|
date | Wed, 25 Sep 2013 10:30:12 +0200 |
parents | 1866aa3a3bfc |
children | f5eb5131aef0 |
files | src/main/java/org/dive4elements/artifacts/httpclient/http/HttpClientImpl.java |
diffstat | 1 files changed, 28 insertions(+), 3 deletions(-) [+] |
line wrap: on
line diff
--- a/src/main/java/org/dive4elements/artifacts/httpclient/http/HttpClientImpl.java Mon Sep 16 17:11:21 2013 +0200 +++ b/src/main/java/org/dive4elements/artifacts/httpclient/http/HttpClientImpl.java Wed Sep 25 10:30:12 2013 +0200 @@ -10,6 +10,10 @@ import java.io.InputStream; import java.io.IOException; import java.io.OutputStream; +import java.io.OutputStreamWriter; + +import java.nio.charset.Charset; + import java.util.ArrayList; import java.util.List; @@ -41,6 +45,7 @@ /** + * Client to artifact-server. * @author <a href="mailto:ingo.weinzierl@intevation.de">Ingo Weinzierl</a> */ public class HttpClientImpl implements HttpClient { @@ -76,6 +81,12 @@ private String localeString; + /** + * The Charset used for encoding the collectionOut output. + * If not set, the system/java default will be used (UTF-8). + */ + private Charset charset; + private static final ThreadLocal<Client> CLIENT = new ThreadLocal<Client>() { @Override @@ -87,6 +98,22 @@ public HttpClientImpl(String serverUrl) { this.serverUrl = serverUrl; + setEncoding(null); + } + + + /** + * Sets the encoding. + * + * Currently the encoding is only + * respected in the collectionOut-method! + * + * It was implemented to allow csv export to be in another than the + * sensible default (UTF-8) and allow easier integration + * e.g. in proprietary products. + */ + public void setEncoding(Charset charset) { + this.charset = charset; } @@ -409,9 +436,7 @@ /** - * This method triggers the out() operation of a Collection. The result of - * this operation is written to <i>out</i> directly - there is no return - * value. + * Write out() operation of a Collection to <i>out</i>. * * @param doc The request document for the out() operation. * @param uuid The identifier of the Collection.