use of org.n52.shetland.ogc.swe.encoding.SweTextEncoding in project arctic-sea by 52North.
the class SweHelper method createTextEncoding.
/**
* Create a TextEncoding object for token and tuple separators.
*
* @param tuple
* Token separator
* @param token
* Tuple separator
* @param decimal
* Decimal separator
*
* @return TextEncoding
*/
private SweAbstractEncoding createTextEncoding(String tuple, String token, String decimal) {
SweTextEncoding sosTextEncoding = new SweTextEncoding();
sosTextEncoding.setBlockSeparator(tuple);
sosTextEncoding.setTokenSeparator(token);
if (!Strings.isNullOrEmpty(decimal)) {
sosTextEncoding.setDecimalSeparator(decimal);
}
return sosTextEncoding;
}
use of org.n52.shetland.ogc.swe.encoding.SweTextEncoding in project arctic-sea by 52North.
the class InsertResultTemplateRequestDecoderTest method resultEncoding.
@Test
public void resultEncoding() throws IOException, DecodingException {
InsertResultTemplateRequest req = load();
assertThat(req.getResultEncoding(), is(notNullValue()));
assertThat(req.getResultEncoding().isDecoded(), is(true));
assertThat(req.getResultEncoding().isEncoded(), is(false));
assertThat(req.getResultEncoding().get().get(), is(instanceOf(SweTextEncoding.class)));
SweTextEncoding encoding = (SweTextEncoding) req.getResultEncoding().get().get();
errors.checkThat(encoding.getTokenSeparator(), is(","));
errors.checkThat(encoding.getBlockSeparator(), is("#"));
}
use of org.n52.shetland.ogc.swe.encoding.SweTextEncoding in project arctic-sea by 52North.
the class GetResultTemplateResponseEncoder method encodeSweTextEncoding.
private void encodeSweTextEncoding(SweAbstractEncoding encoding, ObjectNode node) {
SweTextEncoding sweTextEncoding = (SweTextEncoding) encoding;
String ts = sweTextEncoding.getTokenSeparator();
if (ts != null && !ts.isEmpty()) {
node.put(JSONConstants.TOKEN_SEPARATOR, ts);
}
String bs = sweTextEncoding.getBlockSeparator();
if (bs != null && !bs.isEmpty()) {
node.put(JSONConstants.BLOCK_SEPARATOR, bs);
}
String ds = sweTextEncoding.getDecimalSeparator();
if (ds != null && !ds.isEmpty()) {
node.put(JSONConstants.DECIMAL_SEPARATOR, ds);
}
}
use of org.n52.shetland.ogc.swe.encoding.SweTextEncoding in project arctic-sea by 52North.
the class InsertResultTemplateRequestDecoder method parseResultEncoding.
private SosResultEncoding parseResultEncoding(JsonNode node) {
SweTextEncoding textEncoding = new SweTextEncoding();
textEncoding.setTokenSeparator(node.path(JSONConstants.TOKEN_SEPARATOR).textValue());
textEncoding.setBlockSeparator(node.path(JSONConstants.BLOCK_SEPARATOR).textValue());
if (!node.path(JSONConstants.DECIMAL_SEPARATOR).isMissingNode()) {
textEncoding.setDecimalSeparator(node.path(JSONConstants.DECIMAL_SEPARATOR).textValue());
}
return new SosResultEncoding(textEncoding);
}
use of org.n52.shetland.ogc.swe.encoding.SweTextEncoding in project arctic-sea by 52North.
the class SweCommonDecoderV101 method parseTextEncoding.
private SweTextEncoding parseTextEncoding(TextBlock textEncoding) {
final SweTextEncoding sosTextEncoding = new SweTextEncoding();
sosTextEncoding.setBlockSeparator(textEncoding.getBlockSeparator());
sosTextEncoding.setTokenSeparator(textEncoding.getTokenSeparator());
sosTextEncoding.setDecimalSeparator(textEncoding.getDecimalSeparator());
return sosTextEncoding;
}
Aggregations