Package com.actelion.research.util
Class BinaryEncoder
- java.lang.Object
-
- com.actelion.research.util.BinaryEncoder
-
public class BinaryEncoder extends java.lang.Object
-
-
Constructor Summary
Constructors Constructor Description BinaryEncoder(java.io.BufferedWriter writer)Creates an encoder to make a BufferedWriter write byte/int arrays as Strings.BinaryEncoder(java.io.BufferedWriter writer, int bitsPerCharacter, int baseCharacter, int lineLength)Instantiates an encoder for byte/int arrays to String.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description voidfinalize()Writes remaining bits from buffer, if there are any and possibly adds final NL/LF.voidinitialize(int dataBitCount, int totalByteCount)Initializes encoder for writing one binary arraystatic java.lang.StringtoString(byte[] data, int dataBitCount)Convenience method to directly encode a byte array into a String Uses 6 bits per character using 64 characters from '@' (ASCII 64).static java.lang.StringtoString(int[] data, int dataBitCount)Convenience method to directly encode an int array into a String Uses 6 bits per character using 64 characters from '@' (ASCII 64).voidwrite(int data)Encodes and writes one data value
-
-
-
Constructor Detail
-
BinaryEncoder
public BinaryEncoder(java.io.BufferedWriter writer)
Creates an encoder to make a BufferedWriter write byte/int arrays as Strings. This version uses 6 bits per character using 64 characters from '@' (ASCII 64). It inserts a platform specific newline/linefeed after every 80 characters.- Parameters:
writer-
-
BinaryEncoder
public BinaryEncoder(java.io.BufferedWriter writer, int bitsPerCharacter, int baseCharacter, int lineLength)Instantiates an encoder for byte/int arrays to String.- Parameters:
writer-bitsPerCharacter- no of bits to be used per characterbaseCharacter- lowest character, which encodes value '0'lineLength- -1 (no LF/NL) or count of character after which a NL/LF is inserted
-
-
Method Detail
-
toString
public static java.lang.String toString(int[] data, int dataBitCount)Convenience method to directly encode an int array into a String Uses 6 bits per character using 64 characters from '@' (ASCII 64).- Parameters:
data-dataBitCount-- Returns:
-
toString
public static java.lang.String toString(byte[] data, int dataBitCount)Convenience method to directly encode a byte array into a String Uses 6 bits per character using 64 characters from '@' (ASCII 64).- Parameters:
data-dataBitCount-- Returns:
-
initialize
public void initialize(int dataBitCount, int totalByteCount) throws java.io.IOExceptionInitializes encoder for writing one binary array- Parameters:
dataBitCount- count of bits to be written per data valuetotalByteCount- count of data values to be encoded- Throws:
java.io.IOException
-
write
public void write(int data) throws java.io.IOExceptionEncodes and writes one data value- Parameters:
data-- Throws:
java.io.IOException
-
finalize
public void finalize() throws java.io.IOExceptionWrites remaining bits from buffer, if there are any and possibly adds final NL/LF.- Overrides:
finalizein classjava.lang.Object- Throws:
java.io.IOException
-
-