Search in sources :

Example 1 with ByteTranslator

use of com.adaptris.util.text.ByteTranslator 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;
}
Also used : ServiceException(com.adaptris.core.ServiceException) ByteTranslator(com.adaptris.util.text.ByteTranslator) HexStringByteTranslator(com.adaptris.util.text.HexStringByteTranslator) SimpleByteTranslator(com.adaptris.util.text.SimpleByteTranslator) CharsetByteTranslator(com.adaptris.util.text.CharsetByteTranslator) CharsetByteTranslator(com.adaptris.util.text.CharsetByteTranslator) HexStringByteTranslator(com.adaptris.util.text.HexStringByteTranslator) SimpleByteTranslator(com.adaptris.util.text.SimpleByteTranslator) ServiceException(com.adaptris.core.ServiceException)

Example 2 with ByteTranslator

use of com.adaptris.util.text.ByteTranslator in project interlok by adaptris.

the class StringToHexService method reformat.

@Override
public String reformat(String s, String msgCharset) throws Exception {
    ByteTranslator bytesToHex = new HexStringByteTranslator();
    ByteTranslator stringToBytes = new CharsetByteTranslator(getCharacterEncoding());
    return bytesToHex.translate(stringToBytes.translate(s));
}
Also used : ByteTranslator(com.adaptris.util.text.ByteTranslator) HexStringByteTranslator(com.adaptris.util.text.HexStringByteTranslator) CharsetByteTranslator(com.adaptris.util.text.CharsetByteTranslator) CharsetByteTranslator(com.adaptris.util.text.CharsetByteTranslator) HexStringByteTranslator(com.adaptris.util.text.HexStringByteTranslator)

Example 3 with ByteTranslator

use of com.adaptris.util.text.ByteTranslator in project interlok by adaptris.

the class HexToStringService method reformat.

@Override
public String reformat(String s, String msgCharset) throws Exception {
    ByteTranslator hexToBytes = new HexStringByteTranslator();
    ByteTranslator bytesToString = new CharsetByteTranslator(getCharacterEncoding());
    return bytesToString.translate(hexToBytes.translate(s));
}
Also used : ByteTranslator(com.adaptris.util.text.ByteTranslator) HexStringByteTranslator(com.adaptris.util.text.HexStringByteTranslator) CharsetByteTranslator(com.adaptris.util.text.CharsetByteTranslator) CharsetByteTranslator(com.adaptris.util.text.CharsetByteTranslator) HexStringByteTranslator(com.adaptris.util.text.HexStringByteTranslator)

Aggregations

ByteTranslator (com.adaptris.util.text.ByteTranslator)3 CharsetByteTranslator (com.adaptris.util.text.CharsetByteTranslator)3 HexStringByteTranslator (com.adaptris.util.text.HexStringByteTranslator)3 ServiceException (com.adaptris.core.ServiceException)1 SimpleByteTranslator (com.adaptris.util.text.SimpleByteTranslator)1