Class 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 int INT4B_LEN
      Datentyp-Laenge in Byte.
      static int LONG5B_LEN
      Datentyp-Laenge in Byte.
      static int LONG6B_LEN
      Datentyp-Laenge in Byte.
      static int LONG8B_LEN
      Datentyp-Laenge in Byte.
      static byte[] SEPARATOR
      Trennzeichenfolge zwischen Datensaetzen.
    • Constructor Summary

      Constructors 
      Constructor Description
      ByteIO()  
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static 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.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • SEPARATOR

        public static final byte[] SEPARATOR
        Trennzeichenfolge zwischen Datensaetzen.
      • LONG8B_LEN

        public static final int LONG8B_LEN
        Datentyp-Laenge in Byte.
        See Also:
        Constant Field Values
      • LONG5B_LEN

        public static final int LONG5B_LEN
        Datentyp-Laenge in Byte.
        See Also:
        Constant Field Values
      • LONG6B_LEN

        public static final int LONG6B_LEN
        Datentyp-Laenge in Byte.
        See Also:
        Constant Field Values
    • Constructor Detail

      • ByteIO

        public ByteIO()
    • Method Detail

      • writeSeparator

        public static int writeSeparator​(byte[] buf,
                                         int pos)
        Schreibt den Seperator an die angegebene Stelle im uebergebenen Array.
        Parameters:
        buf - Byte-Array
        pos - 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-Array
        pos - Position
        val - 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-Array
        pos - Position
        val - 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-Array
        pos - Position
        val - 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-Array
        pos - Position
        val - 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-Array
        pos - Position
        b - 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-Array
        pos - 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-Array
        pos - 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-Array
        pos - Position
        Returns:
        Long (0-2^48)