Class Swap

java.lang.Object
ucar.unidata.io.Swap

@Deprecated public class Swap extends Object
Deprecated.
do not use
The Swap class provides static methods for swapping the bytes of chars, shorts, ints, longs, floats, and doubles.
  • Constructor Summary

    Constructors
    Constructor
    Description
    Deprecated.
     
  • Method Summary

    Modifier and Type
    Method
    Description
    static byte[]
    intToBytes(int v)
    Deprecated.
    Convert an int to an array of 4 bytes.
    static byte[]
    longToBytes(long v)
    Deprecated.
    Convert a long to an array of 8 bytes.
    static byte[]
    shortToBytes(short v)
    Deprecated.
    Convert a short to an array of 2 bytes.
    static char
    swapChar(byte[] b, int offset)
    Deprecated.
    Returns the char resulting from swapping 2 bytes at a specified offset in a byte array.
    static double
    swapDouble(byte[] b, int offset)
    Deprecated.
    Returns the double resulting from reversing 8 bytes at a specified offset in a byte array.
    static double
    swapDouble(double v)
    Deprecated.
    Returns the double resulting from reversing 8 bytes of a specified double.
    static float
    swapFloat(byte[] b, int offset)
    Deprecated.
    Returns the float resulting from reversing 4 bytes at a specified offset in a byte array.
    static float
    swapFloat(float v)
    Deprecated.
    Returns the float resulting from reversing 4 bytes of a specified float.
    static int
    swapInt(byte[] b, int offset)
    Deprecated.
    Returns the int resulting from reversing 4 bytes at a specified offset in a byte array.
    static int
    swapInt(int v)
    Deprecated.
    Returns the int resulting from reversing 4 bytes of a specified int.
    static long
    swapLong(byte[] b, int offset)
    Deprecated.
    Returns the long resulting from reversing 8 bytes at a specified offset in a byte array.
    static long
    swapLong(long l)
    Deprecated.
    Returns the long resulting from reversing 8 bytes of a specified long.
    static short
    swapShort(byte[] b, int offset)
    Deprecated.
    Returns the short resulting from swapping 2 bytes at a specified offset in a byte array.
    static short
    swapShort(short s)
    Deprecated.
    Returns the short resulting from swapping 2 bytes of a specified short.

    Methods inherited from class java.lang.Object

    equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • Swap

      public Swap()
      Deprecated.
  • Method Details

    • swapShort

      public static short swapShort(byte[] b, int offset)
      Deprecated.
      Returns the short resulting from swapping 2 bytes at a specified offset in a byte array.
      Parameters:
      b - the byte array
      offset - the offset of the first byte
      Returns:
      the short represented by the bytes b[offset+1], b[offset]
    • swapInt

      public static int swapInt(byte[] b, int offset)
      Deprecated.
      Returns the int resulting from reversing 4 bytes at a specified offset in a byte array.
      Parameters:
      b - the byte array
      offset - the offset of the first byte
      Returns:
      the int represented by the bytes b[offset+3], b[offset+2], ..., b[offset]
    • swapLong

      public static long swapLong(byte[] b, int offset)
      Deprecated.
      Returns the long resulting from reversing 8 bytes at a specified offset in a byte array.
      Parameters:
      b - the byte array
      offset - the offset of the first byte
      Returns:
      the long represented by the bytes b[offset+7], b[offset+6], ..., b[offset]
    • swapFloat

      public static float swapFloat(byte[] b, int offset)
      Deprecated.
      Returns the float resulting from reversing 4 bytes at a specified offset in a byte array.
      Parameters:
      b - the byte array
      offset - the offset of the first byte
      Returns:
      the float represented by the bytes b[offset+3], b[offset+2], ..., b[offset]
    • swapDouble

      public static double swapDouble(byte[] b, int offset)
      Deprecated.
      Returns the double resulting from reversing 8 bytes at a specified offset in a byte array.
      Parameters:
      b - the byte array
      offset - the offset of the first byte
      Returns:
      the double represented by the bytes b[offset+7], b[offset+6], ..., b[offset]
    • swapChar

      public static char swapChar(byte[] b, int offset)
      Deprecated.
      Returns the char resulting from swapping 2 bytes at a specified offset in a byte array.
      Parameters:
      b - the byte array
      offset - the offset of the first byte
      Returns:
      the char represented by the bytes b[offset+1], b[offset]
    • swapShort

      public static short swapShort(short s)
      Deprecated.
      Returns the short resulting from swapping 2 bytes of a specified short.
      Parameters:
      s - input value for which byte reversal is desired
      Returns:
      the value represented by the bytes of s reversed
    • swapInt

      public static int swapInt(int v)
      Deprecated.
      Returns the int resulting from reversing 4 bytes of a specified int.
      Parameters:
      v - input value for which byte reversal is desired
      Returns:
      the value represented by the bytes of v reversed
    • swapLong

      public static long swapLong(long l)
      Deprecated.
      Returns the long resulting from reversing 8 bytes of a specified long.
      Parameters:
      l - input value for which byte reversal is desired
      Returns:
      the value represented by the bytes of l reversed
    • swapFloat

      public static float swapFloat(float v)
      Deprecated.
      Returns the float resulting from reversing 4 bytes of a specified float.
      Parameters:
      v - input value for which byte reversal is desired
      Returns:
      the value represented by the bytes of v reversed
    • swapDouble

      public static double swapDouble(double v)
      Deprecated.
      Returns the double resulting from reversing 8 bytes of a specified double.
      Parameters:
      v - input value for which byte reversal is desired
      Returns:
      the value represented by the bytes of v reversed
    • shortToBytes

      public static byte[] shortToBytes(short v)
      Deprecated.
      Convert a short to an array of 2 bytes.
      Parameters:
      v - input value
      Returns:
      the corresponding array of bytes
    • intToBytes

      public static byte[] intToBytes(int v)
      Deprecated.
      Convert an int to an array of 4 bytes.
      Parameters:
      v - input value
      Returns:
      the corresponding array of bytes
    • longToBytes

      public static byte[] longToBytes(long v)
      Deprecated.
      Convert a long to an array of 8 bytes.
      Parameters:
      v - input value
      Returns:
      the corresponding array of bytes