ucar.grib
Class GribNumbers

java.lang.Object
  extended by ucar.grib.GribNumbers

public final class GribNumbers
extends Object

A class that contains several static methods for converting multiple bytes into one float or integer.

Version:
2.0
Author:
Robb Kambic 10/20/04

Field Summary
static int BIT_1
          Bit mask for bit 1 in an octet
static int BIT_2
          Bit mask for bit 1 in an octet
static int BIT_3
          Bit mask for bit 1 in an octet
static int BIT_4
          Bit mask for bit 1 in an octet
static int BIT_5
          Bit mask for bit 1 in an octet
static int BIT_6
          Bit mask for bit 1 in an octet
static int BIT_7
          Bit mask for bit 1 in an octet
static int BIT_8
          Bit mask for bit 1 in an octet
static int MISSING
          Grib uses this internal to mean missing
static int UNDEFINED
          if missing value is not defined use this value.
 
Constructor Summary
GribNumbers()
           
 
Method Summary
static boolean closeEnough(double v1, double v2)
           
static float float4(int a, int b, int c, int d)
          Convert 4 bytes to a float.
static float float4(RandomAccessFile raf)
          Convert 4 bytes into a float value.
static int int2(int a, int b)
          convert 2 bytes to a signed integer.
static int int2(RandomAccessFile raf)
          Convert 2 bytes into a signed integer.
static int int3(int a, int b, int c)
          Convert 3 bytes to signed integer.
static int int3(RandomAccessFile raf)
          Convert 3 bytes into a signed integer.
static int int4(int a, int b, int c, int d)
          Convert 4 bytes into a signed integer.
static int int4(RandomAccessFile raf)
          Convert 4 bytes into a signed integer.
static long int8(RandomAccessFile raf)
          Convert 8 bytes into a signed long.
static boolean isBitSet(int value, int bitMask)
          Is the bit set in this octet
static int uint2(int a, int b)
          convert 2 bytes to an unsigned integer.
static int uint2(RandomAccessFile raf)
          Convert 2 bytes into an unsigned integer.
static int uint3(int a, int b, int c)
          Convert 3 bytes into an unsigned int.
static int uint3(RandomAccessFile raf)
          Convert 3 bytes into an unsigned integer.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

UNDEFINED

public static final int UNDEFINED
if missing value is not defined use this value.

See Also:
Constant Field Values

MISSING

public static final int MISSING
Grib uses this internal to mean missing

See Also:
Constant Field Values

BIT_1

public static final int BIT_1
Bit mask for bit 1 in an octet

See Also:
Constant Field Values

BIT_2

public static final int BIT_2
Bit mask for bit 1 in an octet

See Also:
Constant Field Values

BIT_3

public static final int BIT_3
Bit mask for bit 1 in an octet

See Also:
Constant Field Values

BIT_4

public static final int BIT_4
Bit mask for bit 1 in an octet

See Also:
Constant Field Values

BIT_5

public static final int BIT_5
Bit mask for bit 1 in an octet

See Also:
Constant Field Values

BIT_6

public static final int BIT_6
Bit mask for bit 1 in an octet

See Also:
Constant Field Values

BIT_7

public static final int BIT_7
Bit mask for bit 1 in an octet

See Also:
Constant Field Values

BIT_8

public static final int BIT_8
Bit mask for bit 1 in an octet

See Also:
Constant Field Values
Constructor Detail

GribNumbers

public GribNumbers()
Method Detail

int2

public static int int2(RandomAccessFile raf)
                throws IOException
Convert 2 bytes into a signed integer.

Parameters:
raf -
Returns:
integer value
Throws:
IOException

int2

public static int int2(int a,
                       int b)
convert 2 bytes to a signed integer.

Parameters:
a -
b -
Returns:
int

int3

public static int int3(RandomAccessFile raf)
                throws IOException
Convert 3 bytes into a signed integer.

Parameters:
raf -
Returns:
integer value
Throws:
IOException

int3

public static int int3(int a,
                       int b,
                       int c)
Convert 3 bytes to signed integer.

Parameters:
a -
b -
c -
Returns:
int

int4

public static int int4(RandomAccessFile raf)
                throws IOException
Convert 4 bytes into a signed integer.

Parameters:
raf -
Returns:
integer value
Throws:
IOException

int4

public static int int4(int a,
                       int b,
                       int c,
                       int d)
Convert 4 bytes into a signed integer.

Parameters:
a -
b -
c -
d -
Returns:
int

uint2

public static int uint2(RandomAccessFile raf)
                 throws IOException
Convert 2 bytes into an unsigned integer.

Parameters:
raf -
Returns:
integer value
Throws:
IOException

uint2

public static int uint2(int a,
                        int b)
convert 2 bytes to an unsigned integer.

Parameters:
a -
b -
Returns:
unsigned int

uint3

public static int uint3(RandomAccessFile raf)
                 throws IOException
Convert 3 bytes into an unsigned integer.

Parameters:
raf -
Returns:
integer
Throws:
IOException

uint3

public static int uint3(int a,
                        int b,
                        int c)
Convert 3 bytes into an unsigned int.

Parameters:
a -
b -
c -
Returns:
unsigned integer

float4

public static float float4(RandomAccessFile raf)
                    throws IOException
Convert 4 bytes into a float value.

Parameters:
raf -
Returns:
float value
Throws:
IOException

float4

public static float float4(int a,
                           int b,
                           int c,
                           int d)
Convert 4 bytes to a float.

Parameters:
a -
b -
c -
d -
Returns:
float

int8

public static long int8(RandomAccessFile raf)
                 throws IOException
Convert 8 bytes into a signed long.

Parameters:
raf - RandomAccessFile
Returns:
long value
Throws:
IOException

isBitSet

public static boolean isBitSet(int value,
                               int bitMask)
Is the bit set in this octet

Parameters:
value - octet as an integer
bitMask - bit mask
Returns:
true if the bit is not 0

closeEnough

public static boolean closeEnough(double v1,
                                  double v2)


Copyright © 1999-2011 UCAR/Unidata. All Rights Reserved.