edu.rit.classfile
Class PrimitiveReference

java.lang.Object
  extended by edu.rit.classfile.TypeReference
      extended by edu.rit.classfile.PrimitiveReference

public class PrimitiveReference
extends TypeReference

Class PrimitiveReference encapsulates a reference to a primitive type. Singleton objects are defined for all the Java primitive types.

An instance of class PrimitiveReference can be written to a data output stream using the write() method below, and an instance of class PrimitiveReference can be read from a data input stream using the static TypeReference.read() method.


Field Summary
static PrimitiveReference BOOLEAN
          The primitive reference object for type boolean.
static PrimitiveReference BYTE
          The primitive reference object for type byte.
static PrimitiveReference CHAR
          The primitive reference object for type char.
static PrimitiveReference DOUBLE
          The primitive reference object for type double.
static PrimitiveReference FLOAT
          The primitive reference object for type float.
static PrimitiveReference INT
          The primitive reference object for type int.
static PrimitiveReference LONG
          The primitive reference object for type long.
static PrimitiveReference SHORT
          The primitive reference object for type short.
 
Method Summary
static PrimitiveReference forClassName(String theClassName)
          Returns the primitive reference corresponding to the given class name.
static PrimitiveReference forDescriptor(char theDescriptor)
          Returns the primitive reference corresponding to the given type descriptor character.
static PrimitiveReference forDescriptor(String theDescriptor)
          Returns the primitive reference corresponding to the given type descriptor.
 void write(DataOutput theDataOutput)
          Write this primitive reference to the given data output stream.
 
Methods inherited from class edu.rit.classfile.TypeReference
equals, getTypeDescriptor, getWordCount, hashCode, read, toString
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

BYTE

public static final PrimitiveReference BYTE
The primitive reference object for type byte.


CHAR

public static final PrimitiveReference CHAR
The primitive reference object for type char.


DOUBLE

public static final PrimitiveReference DOUBLE
The primitive reference object for type double.


FLOAT

public static final PrimitiveReference FLOAT
The primitive reference object for type float.


INT

public static final PrimitiveReference INT
The primitive reference object for type int.


LONG

public static final PrimitiveReference LONG
The primitive reference object for type long.


SHORT

public static final PrimitiveReference SHORT
The primitive reference object for type short.


BOOLEAN

public static final PrimitiveReference BOOLEAN
The primitive reference object for type boolean.

Method Detail

forClassName

public static PrimitiveReference forClassName(String theClassName)
Returns the primitive reference corresponding to the given class name. The class name is assumed to be in the format returned by Class.getName(). The mapping is:

Class Name     PrimitiveReference
"byte"BYTE
"char"CHAR
"double"DOUBLE
"float"FLOAT
"int"INT
"long"LONG
"short"SHORT
"boolean"BOOLEAN

Parameters:
theClassName - Class name as returned by Class.getName().
Returns:
Primitive reference corresponding to theClassName, or null if theClassName does not refer to one of the above primitive types.

forDescriptor

public static PrimitiveReference forDescriptor(String theDescriptor)
Returns the primitive reference corresponding to the given type descriptor. The mapping is:

Type Descriptor     PrimitiveReference
"B"BYTE
"C"CHAR
"D"DOUBLE
"F"FLOAT
"I"INT
"J"LONG
"S"SHORT
"Z"BOOLEAN

Parameters:
theDescriptor - Type descriptor.
Returns:
Primitive reference corresponding to theDescriptor, or null if theDescriptor does not refer to one of the above primitive types.

forDescriptor

public static PrimitiveReference forDescriptor(char theDescriptor)
Returns the primitive reference corresponding to the given type descriptor character. The mapping is:

Type Descriptor     PrimitiveReference
'B'BYTE
'C'CHAR
'D'DOUBLE
'F'FLOAT
'I'INT
'J'LONG
'S'SHORT
'Z'BOOLEAN

Parameters:
theDescriptor - Type descriptor character.
Returns:
Primitive reference corresponding to theDescriptor, or null if theDescriptor does not refer to one of the above primitive types.

write

public void write(DataOutput theDataOutput)
           throws IOException
Write this primitive reference to the given data output stream.

Overrides:
write in class TypeReference
Parameters:
theDataOutput - Data output stream to write.
Throws:
IOException - Thrown if an I/O error occurred.


Copyright © 2001-2006 by Alan Kaminsky. All rights reserved. Send comments to ark­@­cs.rit.edu.