/** * Encodes the input data producing a Hex output stream. * * @param data Input data to encode. * @return the number of bytes produced. */ public static String encode(final byte[] data) { try { final ByteArrayOutputStream out = new ByteArrayOutputStream(); encode(data, 0, data.length, out); out.close(); return new String(out.toByteArray()); } catch (IOException e) { e.printStackTrace(); throw new RuntimeException(e.getMessage(), e); } }
/** * Encode binary data. * * @param valueToEncode The binary data to encode. * @param componentType The XML schema component type. * @return Encoded binary data in {@link String} form. */ private Object encodeBinaryData(final Object valueToEncode, final String componentType) { String encodedValue; if (HexDecoder.DATA_TYPE.equals(componentType)) { encodedValue = HexDecoder.encode((byte[]) valueToEncode); } else { encodedValue = new String(Base64Encoder.encode((byte[]) valueToEncode)); } return encodedValue; }
chars = new String(HexDecoder.encode((byte[]) obj)).toCharArray(); } else { chars = Base64Encoder.encode((byte[]) obj); if ((descriptor.isMultivalued() && HexDecoder.DATA_TYPE.equals(componentType)) || HexDecoder.DATA_TYPE.equals(schemaType)) { chars = new String(HexDecoder.encode((byte[]) object)).toCharArray(); } else { chars = Base64Encoder.encode((byte[]) object);