Package de.bsvrz.sys.funclib.losb.util
Class ByteIO
java.lang.Object
de.bsvrz.sys.funclib.losb.util.ByteIO
public final class ByteIO
extends java.lang.Object
Diese Klasse enthaelt die Funktionalitaet fuer das Handling von Ganzzahlen in Byte-Arrays.
-
Field Summary
Fields Modifier and Type Field Description static intINT4B_LENDatentyp-Laenge in Byte.static intLONG5B_LENDatentyp-Laenge in Byte.static intLONG6B_LENDatentyp-Laenge in Byte.static intLONG8B_LENDatentyp-Laenge in Byte.static byte[]SEPARATORTrennzeichenfolge zwischen Datensaetzen. -
Constructor Summary
Constructors Constructor Description ByteIO() -
Method Summary
Modifier and Type Method Description static intreadSignedInt4Bytes(byte[] buf, int pos)Liest 4 Bytes im Byte-Array buf ab Stelle pos und liefert sie als Integer.static longreadSignedLong8Byte(byte[] buf, int pos)Liest 8 Bytes im Byte-Array buf ab Stelle pos und liefert sie als Long.static longreadUnsignedLong5Byte(byte[] buf, int pos)Liest 5 Bytes im Byte-Array buf ab Stelle pos und liefert sie als Long.static longreadUnsignedLong6Byte(byte[] buf, int pos)Liest 6 Bytes im Byte-Array buf ab Stelle pos und liefert sie als Long.static intwriteBytes(byte[] buf, int pos, byte[] b)Schreibt das Quell-Byte-Array b in das Ziel-Byte-Array buf an die Stelle pos.static intwriteSeparator(byte[] buf, int pos)Schreibt den Seperator an die angegebene Stelle im uebergebenen Array.static intwriteSignedInt4Bytes(byte[] buf, int pos, int val)Schreibt den Integer val in das Byte-Array buf an die Stelle pos.static intwriteSignedLong8Byte(byte[] buf, int pos, long val)Schreibt den Long val in das Byte-Array buf an die Stelle pos.static intwriteUnsignedLong5Byte(byte[] buf, int pos, long val)Schreibt die untersten 5 Byte des Long val in das Byte-Array buf an die Stelle pos.static intwriteUnsignedLong6Byte(byte[] buf, int pos, long val)Schreibt die untersten 6 Byte des Long val in das Byte-Array buf an die Stelle pos.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Field Details
-
SEPARATOR
public static final byte[] SEPARATORTrennzeichenfolge zwischen Datensaetzen. -
INT4B_LEN
public static final int INT4B_LENDatentyp-Laenge in Byte.- See Also:
- Constant Field Values
-
LONG8B_LEN
public static final int LONG8B_LENDatentyp-Laenge in Byte.- See Also:
- Constant Field Values
-
LONG5B_LEN
public static final int LONG5B_LENDatentyp-Laenge in Byte.- See Also:
- Constant Field Values
-
LONG6B_LEN
public static final int LONG6B_LENDatentyp-Laenge in Byte.- See Also:
- Constant Field Values
-
-
Constructor Details
-
ByteIO
public ByteIO()
-
-
Method Details
-
writeSeparator
public static int writeSeparator(byte[] buf, int pos)Schreibt den Seperator an die angegebene Stelle im uebergebenen Array.- Parameters:
buf- Byte-Arraypos- Position- Returns:
- Laenge des Seperators in Byte.
-
writeSignedInt4Bytes
public static int writeSignedInt4Bytes(byte[] buf, int pos, int val)Schreibt den Integer val in das Byte-Array buf an die Stelle pos. Val kann eine positive oder negative Zahl sein.- Parameters:
buf- Byte-Arraypos- Positionval- Integer-Wert- Returns:
- Laenge des Integer in Byte.
-
writeSignedLong8Byte
public static int writeSignedLong8Byte(byte[] buf, int pos, long val)Schreibt den Long val in das Byte-Array buf an die Stelle pos. Val kann eine positive oder negative Zahl sein.- Parameters:
buf- Byte-Arraypos- Positionval- Long-Wert.- Returns:
- Laenge des Long in Byte.
-
writeUnsignedLong5Byte
public static int writeUnsignedLong5Byte(byte[] buf, int pos, long val)Schreibt die untersten 5 Byte des Long val in das Byte-Array buf an die Stelle pos. Der geschriebene Wert ist stets ≥ 0.- Parameters:
buf- Byte-Arraypos- Positionval- Long-Wert, nur die untersten 5 Byte werden beruecksichtigt- Returns:
- Laenge des 5-Byte-Long in Byte
-
writeUnsignedLong6Byte
public static int writeUnsignedLong6Byte(byte[] buf, int pos, long val)Schreibt die untersten 6 Byte des Long val in das Byte-Array buf an die Stelle pos. Der geschriebene Wert ist stets ≥ 0.- Parameters:
buf- Byte-Arraypos- Positionval- Long-Wert, nur die untersten 6 Byte werden beruecksichtigt (also auch nur positive Zahlen)- Returns:
- Laenge des 6-Byte-Long in Byte
-
writeBytes
public static int writeBytes(byte[] buf, int pos, byte[] b)Schreibt das Quell-Byte-Array b in das Ziel-Byte-Array buf an die Stelle pos.- Parameters:
buf- Ziel-Byte-Arraypos- Positionb- Quell-Byte-Array- Returns:
- Laenge des Quell-Byte-Array b.
-
readSignedInt4Bytes
public static int readSignedInt4Bytes(byte[] buf, int pos)Liest 4 Bytes im Byte-Array buf ab Stelle pos und liefert sie als Integer. Das erste Bit wird als Vorzeichenbit interpretiert.- Parameters:
buf- Byte-Array.pos- Position.- Returns:
- Integer.
-
readSignedLong8Byte
public static long readSignedLong8Byte(byte[] buf, int pos)Liest 8 Bytes im Byte-Array buf ab Stelle pos und liefert sie als Long. Das erste Bit wird als Vorzeichenbit interpretiert.- Parameters:
buf- Byte-Arraypos- Position- Returns:
- Long
-
readUnsignedLong5Byte
public static long readUnsignedLong5Byte(byte[] buf, int pos)Liest 5 Bytes im Byte-Array buf ab Stelle pos und liefert sie als Long. Das erste Bit wird nicht als Vorzeichenbit interpretiert.- Parameters:
buf- Byte-Arraypos- Position- Returns:
- Long (0-2^40)
-
readUnsignedLong6Byte
public static long readUnsignedLong6Byte(byte[] buf, int pos)Liest 6 Bytes im Byte-Array buf ab Stelle pos und liefert sie als Long. Das erste Bit wird nicht als Vorzeichenbit interpretiert.- Parameters:
buf- Byte-Arraypos- Position- Returns:
- Long (0-2^48)
-