/** * Decodes an Object using the Base-N algorithm. This method is provided in order to satisfy the requirements of * the Decoder interface, and will throw a DecoderException if the supplied object is not of type byte[] or String. * * @param obj * Object to decode * @return An object (of type byte[]) containing the binary data which corresponds to the byte[] or String * supplied. * @throws DecoderException * if the parameter supplied is not of type byte[] */ @Override public Object decode(final Object obj) throws DecoderException { if (obj instanceof byte[]) { return decode((byte[]) obj); } else if (obj instanceof String) { return decode((String) obj); } else { throw new DecoderException("Parameter supplied to Base-N decode is not a byte[] or a String"); } }
/** * Decodes a String containing characters in the Base-N alphabet. * * @param pArray * A String containing Base-N character data * @return a byte array containing binary data */ public byte[] decode(final String pArray) { return decode(StringUtils.getBytesUtf8(pArray)); }
/** * Writes EOF. * * @throws IOException * if an I/O error occurs. * @since 1.11 */ public void eof() throws IOException { // Notify encoder of EOF (-1). if (doEncode) { baseNCodec.encode(singleByte, 0, EOF, context); } else { baseNCodec.decode(singleByte, 0, EOF, context); } }
/** * Decodes a byte[] containing characters in the Base-N alphabet. * * @param pArray * A byte array containing Base-N character data * @return a byte array containing binary data */ @Override public byte[] decode(final byte[] pArray) { if (pArray == null || pArray.length == 0) { return pArray; } final Context context = new Context(); decode(pArray, 0, pArray.length, context); decode(pArray, 0, EOF, context); // Notify decoder of EOF. final byte[] result = new byte[context.pos]; readResults(result, 0, result.length, context); return result; }
baseNCodec.encode(b, offset, len, context); } else { baseNCodec.decode(b, offset, len, context);
baseNCodec.encode(buf, 0, c, context); } else { baseNCodec.decode(buf, 0, c, context);
/** * Decodes an Object using the Base-N algorithm. This method is provided in order to satisfy the requirements of * the Decoder interface, and will throw a DecoderException if the supplied object is not of type byte[] or String. * * @param obj * Object to decode * @return An object (of type byte[]) containing the binary data which corresponds to the byte[] or String * supplied. * @throws DecoderException * if the parameter supplied is not of type byte[] */ @Override public Object decode(final Object obj) throws DecoderException { if (obj instanceof byte[]) { return decode((byte[]) obj); } else if (obj instanceof String) { return decode((String) obj); } else { throw new DecoderException("Parameter supplied to Base-N decode is not a byte[] or a String"); } }
/** * Decodes a String containing characters in the Base-N alphabet. * * @param pArray * A String containing Base-N character data * @return a byte array containing binary data */ public byte[] decode(final String pArray) { return decode(StringUtils.getBytesUtf8(pArray)); }
/** * Decodes a String containing characters in the Base-N alphabet. * * @param pArray * A String containing Base-N character data * @return a byte array containing binary data */ public byte[] decode(final String pArray) { return decode(StringUtils.getBytesUtf8(pArray)); }
/** * Decodes a String containing characters in the Base-N alphabet. * * @param pArray * A String containing Base-N character data * @return a byte array containing binary data */ public byte[] decode(final String pArray) { return decode(StringUtils.getBytesUtf8(pArray)); }
/** * Decodes a String containing characters in the Base-N alphabet. * * @param pArray * A String containing Base-N character data * @return a byte array containing binary data */ public byte[] decode(final String pArray) { return decode(StringUtils.getBytesUtf8(pArray)); }
/** * Decodes a String containing characters in the Base-N alphabet. * * @param pArray * A String containing Base-N character data * @return a byte array containing binary data */ public byte[] decode(final String pArray) { return decode(StringUtils.getBytesUtf8(pArray)); }
/** * Writes EOF. * * @throws IOException * if an I/O error occurs. * @since 1.11 */ public void eof() throws IOException { // Notify encoder of EOF (-1). if (doEncode) { baseNCodec.encode(singleByte, 0, EOF, context); } else { baseNCodec.decode(singleByte, 0, EOF, context); } }
/** * Decodes a byte[] containing characters in the Base-N alphabet. * * @param pArray * A byte array containing Base-N character data * @return a byte array containing binary data */ @Override public byte[] decode(final byte[] pArray) { if (pArray == null || pArray.length == 0) { return pArray; } final Context context = new Context(); decode(pArray, 0, pArray.length, context); decode(pArray, 0, EOF, context); // Notify decoder of EOF. final byte[] result = new byte[context.pos]; readResults(result, 0, result.length, context); return result; }
/** * Decodes a byte[] containing characters in the Base-N alphabet. * * @param pArray * A byte array containing Base-N character data * @return a byte array containing binary data */ @Override public byte[] decode(final byte[] pArray) { if (pArray == null || pArray.length == 0) { return pArray; } final Context context = new Context(); decode(pArray, 0, pArray.length, context); decode(pArray, 0, EOF, context); // Notify decoder of EOF. final byte[] result = new byte[context.pos]; readResults(result, 0, result.length, context); return result; }
/** * Decodes a byte[] containing characters in the Base-N alphabet. * * @param pArray * A byte array containing Base-N character data * @return a byte array containing binary data */ @Override public byte[] decode(final byte[] pArray) { if (pArray == null || pArray.length == 0) { return pArray; } final Context context = new Context(); decode(pArray, 0, pArray.length, context); decode(pArray, 0, EOF, context); // Notify decoder of EOF. final byte[] result = new byte[context.pos]; readResults(result, 0, result.length, context); return result; }
/** * Closes this output stream and releases any system resources associated with the stream. * * @throws IOException * if an I/O error occurs. */ @Override public void close() throws IOException { // Notify encoder of EOF (-1). if (doEncode) { baseNCodec.encode(singleByte, 0, EOF, context); } else { baseNCodec.decode(singleByte, 0, EOF, context); } flush(); out.close(); }
/** * Closes this output stream and releases any system resources associated with the stream. * * @throws IOException * if an I/O error occurs. */ @Override public void close() throws IOException { // Notify encoder of EOF (-1). if (doEncode) { baseNCodec.encode(singleByte, 0, EOF, context); } else { baseNCodec.decode(singleByte, 0, EOF, context); } flush(); out.close(); }
/** * Closes this output stream and releases any system resources associated with the stream. * * @throws IOException * if an I/O error occurs. */ @Override public void close() throws IOException { // Notify encoder of EOF (-1). if (doEncode) { baseNCodec.encode(singleByte, 0, EOF, context); } else { baseNCodec.decode(singleByte, 0, EOF, context); } flush(); out.close(); }
/** * Closes this output stream and releases any system resources associated with the stream. * * @throws IOException * if an I/O error occurs. */ @Override public void close() throws IOException { // Notify encoder of EOF (-1). if (doEncode) { baseNCodec.encode(singleByte, 0, EOF, context); } else { baseNCodec.decode(singleByte, 0, EOF, context); } flush(); out.close(); }