Package de.bsvrz.sys.funclib.losb.util
Class ByteIO
java.lang.Object
de.bsvrz.sys.funclib.losb.util.ByteIO
Diese Klasse enthaelt die Funktionalitaet fuer das Handling von Ganzzahlen in Byte-Arrays.
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final int
Datentyp-Laenge in Byte.static final int
Datentyp-Laenge in Byte.static final int
Datentyp-Laenge in Byte.static final int
Datentyp-Laenge in Byte.static final byte[]
Trennzeichenfolge zwischen Datensaetzen. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic int
readSignedInt4Bytes
(byte[] buf, int pos) Liest 4 Bytes im Byte-Array buf ab Stelle pos und liefert sie als Integer.static long
readSignedLong8Byte
(byte[] buf, int pos) Liest 8 Bytes im Byte-Array buf ab Stelle pos und liefert sie als Long.static long
readUnsignedLong5Byte
(byte[] buf, int pos) Liest 5 Bytes im Byte-Array buf ab Stelle pos und liefert sie als Long.static long
readUnsignedLong6Byte
(byte[] buf, int pos) Liest 6 Bytes im Byte-Array buf ab Stelle pos und liefert sie als Long.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.static int
writeSeparator
(byte[] buf, int pos) Schreibt den Seperator an die angegebene Stelle im uebergebenen Array.static int
writeSignedInt4Bytes
(byte[] buf, int pos, int val) Schreibt den Integer val in das Byte-Array buf an die Stelle pos.static int
writeSignedLong8Byte
(byte[] buf, int pos, long val) Schreibt den Long val in das Byte-Array buf an die Stelle pos.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.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.
-
Field Details
-
SEPARATOR
public static final byte[] SEPARATORTrennzeichenfolge zwischen Datensaetzen. -
INT4B_LEN
public static final int INT4B_LENDatentyp-Laenge in Byte.- See Also:
-
LONG8B_LEN
public static final int LONG8B_LENDatentyp-Laenge in Byte.- See Also:
-
LONG5B_LEN
public static final int LONG5B_LENDatentyp-Laenge in Byte.- See Also:
-
LONG6B_LEN
public static final int LONG6B_LENDatentyp-Laenge in Byte.- See Also:
-
-
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)
-