use of com.adaptris.util.text.SimpleByteTranslator in project interlok by adaptris.
the class HexSequenceConfiguredReplacementSource method obtainValue.
public String obtainValue(AdaptrisMessage msg) throws ServiceException {
String result = null;
ByteTranslator hexToBytes = new HexStringByteTranslator();
ByteTranslator bytesToString = new SimpleByteTranslator();
if (!isEmpty(charset)) {
bytesToString = new CharsetByteTranslator(charset);
}
try {
result = bytesToString.translate(hexToBytes.translate(this.getValue()));
} catch (Exception e) {
throw new ServiceException(e);
}
return result;
}
use of com.adaptris.util.text.SimpleByteTranslator in project interlok by adaptris.
the class ByteArrayMetadataTest method testWrapString.
@Test
public void testWrapString() throws Exception {
AdaptrisMessage msg = AdaptrisMessageFactory.getDefaultInstance().newMessage();
msg.addMetadata(KEY, HELLO_WORLD);
byte[] wrapped = new ByteArrayFromMetadata().withTranslator(new SimpleByteTranslator()).withKey(KEY).wrap(msg);
assertTrue(MessageDigest.isEqual(BYTE_ARRAY, wrapped));
}
Aggregations