/** * Decodes the HEX input data producing a output stream. * * @param data Input data to be decoded. * @return A byte array representing the decoded input data. */ public static byte[] decode(final String data) { try { final ByteArrayOutputStream out = new ByteArrayOutputStream(); decode(data, out); out.close(); return out.toByteArray(); } catch (IOException e) { e.printStackTrace(); throw new RuntimeException(e.getMessage(), e); } }
/** * Decode binary data and return decoded value. * * @param descriptor {@link XMLFieldDescriptor} instance for the field whose value requires * decoding. * @param binaryData The binary data value to be decoded * @return Decode data. */ byte[] decodeBinaryData(final XMLFieldDescriptor descriptor, final String binaryData) { // -- Base64/HexBinary decoding byte[] decodedValue; if ((descriptor.isMultivalued() && HexDecoder.DATA_TYPE.equals(descriptor.getComponentType())) || HexDecoder.DATA_TYPE.equals(descriptor.getSchemaType())) { decodedValue = HexDecoder.decode(binaryData); } else { decodedValue = Base64Decoder.decode(binaryData); } return decodedValue; }
value = HexDecoder.decode(attValue); } else { value = Base64Decoder.decode(attValue);