ucar.ma2
Enum DataType

java.lang.Object
  extended by java.lang.Enum<DataType>
      extended by ucar.ma2.DataType
All Implemented Interfaces:
Serializable, Comparable<DataType>

public enum DataType
extends Enum<DataType>

Type-safe enumeration of data types.

Author:
john caron

Enum Constant Summary
BOOLEAN
           
BYTE
           
CHAR
           
DOUBLE
           
ENUM1
           
ENUM2
           
ENUM4
           
FLOAT
           
INT
           
LONG
           
OPAQUE
           
SEQUENCE
           
SHORT
           
STRING
           
STRUCTURE
           
 
Method Summary
 Class getClassType()
           
 Class getPrimitiveClassType()
          The primitive class type: char, byte, float, double, short, int, long, boolean, String, StructureData, StructureDataIterator, ByteBuffer.
 int getSize()
          Size in bytes of one element of this data type.
static DataType getType(Class c)
          Find the DataType that matches this class.
static DataType getType(String name)
          Find the DataType that matches this name.
 boolean isEnum()
          Is this an enumeration types?
 boolean isFloatingPoint()
          Is Float or Double
 boolean isIntegral()
          Is Byte, Int, Short, or Long
 boolean isNumeric()
          Is Byte, Float, Double, Int, Short, or Long
 boolean isString()
          Is String or Char
 String toString()
          The DataType name, eg "byte", "float", "String".
static short unsignedByteToShort(byte b)
          widen an unsigned byte to a short
static long unsignedIntToLong(int i)
          widen an unsigned int to a long
static int unsignedShortToInt(short s)
          widen an unsigned short to an int
static DataType valueOf(String name)
          Returns the enum constant of this type with the specified name.
static DataType[] values()
          Returns an array containing the constants of this enum type, in the order they are declared.
 
Methods inherited from class java.lang.Enum
clone, compareTo, equals, finalize, getDeclaringClass, hashCode, name, ordinal, valueOf
 
Methods inherited from class java.lang.Object
getClass, notify, notifyAll, wait, wait, wait
 

Enum Constant Detail

BOOLEAN

public static final DataType BOOLEAN

BYTE

public static final DataType BYTE

CHAR

public static final DataType CHAR

SHORT

public static final DataType SHORT

INT

public static final DataType INT

LONG

public static final DataType LONG

FLOAT

public static final DataType FLOAT

DOUBLE

public static final DataType DOUBLE

SEQUENCE

public static final DataType SEQUENCE

STRING

public static final DataType STRING

STRUCTURE

public static final DataType STRUCTURE

ENUM1

public static final DataType ENUM1

ENUM2

public static final DataType ENUM2

ENUM4

public static final DataType ENUM4

OPAQUE

public static final DataType OPAQUE
Method Detail

values

public static DataType[] values()
Returns an array containing the constants of this enum type, in the order they are declared. This method may be used to iterate over the constants as follows:
for (DataType c : DataType.values())
    System.out.println(c);

Returns:
an array containing the constants of this enum type, in the order they are declared

valueOf

public static DataType valueOf(String name)
Returns the enum constant of this type with the specified name. The string must match exactly an identifier used to declare an enum constant in this type. (Extraneous whitespace characters are not permitted.)

Parameters:
name - the name of the enum constant to be returned.
Returns:
the enum constant with the specified name
Throws:
IllegalArgumentException - if this enum type has no constant with the specified name
NullPointerException - if the argument is null

toString

public String toString()
The DataType name, eg "byte", "float", "String".

Overrides:
toString in class Enum<DataType>

getSize

public int getSize()
Size in bytes of one element of this data type. Strings dont know, so return 0. Structures return 1.

Returns:
Size in bytes of one element of this data type.

getClassType

public Class getClassType()

getPrimitiveClassType

public Class getPrimitiveClassType()
The primitive class type: char, byte, float, double, short, int, long, boolean, String, StructureData, StructureDataIterator, ByteBuffer.

Returns:
the primitive class type

isString

public boolean isString()
Is String or Char

Returns:
true if String or Char

isNumeric

public boolean isNumeric()
Is Byte, Float, Double, Int, Short, or Long

Returns:
true if numeric

isIntegral

public boolean isIntegral()
Is Byte, Int, Short, or Long

Returns:
true if integral

isFloatingPoint

public boolean isFloatingPoint()
Is Float or Double

Returns:
true if floating point type

isEnum

public boolean isEnum()
Is this an enumeration types?

Returns:
true if ENUM1, 2, or 4

getType

public static DataType getType(String name)
Find the DataType that matches this name.

Parameters:
name - find DataType with this name.
Returns:
DataType or null if no match.

getType

public static DataType getType(Class c)
Find the DataType that matches this class.

Parameters:
c - primitive or object class, eg float.class or Float.class
Returns:
DataType or null if no match.

unsignedIntToLong

public static long unsignedIntToLong(int i)
widen an unsigned int to a long

Parameters:
i - unsigned int
Returns:
equivilent long value

unsignedShortToInt

public static int unsignedShortToInt(short s)
widen an unsigned short to an int

Parameters:
s - unsigned short
Returns:
equivilent int value

unsignedByteToShort

public static short unsignedByteToShort(byte b)
widen an unsigned byte to a short

Parameters:
b - unsigned byte
Returns:
equivilent short value


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