edu.rit.classfile
Class ArrayReference

java.lang.Object
  extended by edu.rit.classfile.TypeReference
      extended by edu.rit.classfile.ArrayOrClassReference
          extended by edu.rit.classfile.ArrayReference

public class ArrayReference
extends ArrayOrClassReference

Class ArrayReference encapsulates the information needed to refer to an array type. This includes the array's component type and number of dimensions. In the documentation below, the term "referenced type" means "the array type referred to by this type reference object."

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


Constructor Summary
ArrayReference(TypeReference theComponentType, int theDimensions)
          Construct a new array reference with the given component type and dimensions.
 
Method Summary
static ArrayReference forClassName(String theClassName)
          Returns an array reference corresponding to the given class name.
 TypeReference getComponentType()
          Returns the referenced type's component type.
 int getDimensions()
          Returns the referenced type's number of dimensions.
 void write(DataOutput theDataOutput)
          Write this array reference to the given data output stream.
 
Methods inherited from class edu.rit.classfile.ArrayOrClassReference
getClassInternalName
 
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
 

Constructor Detail

ArrayReference

public ArrayReference(TypeReference theComponentType,
                      int theDimensions)
               throws OutOfRangeException
Construct a new array reference with the given component type and dimensions.

Parameters:
theComponentType - Component type.
theDimensions - Number of dimensions.
Throws:
NullPointerException - (unchecked exception) Thrown if theComponentType is null.
OutOfRangeException - Thrown if theDimensions is not in the range 1 .. 255.
Method Detail

getComponentType

public TypeReference getComponentType()
Returns the referenced type's component type.


getDimensions

public int getDimensions()
Returns the referenced type's number of dimensions.


forClassName

public static ArrayReference forClassName(String theClassName)
Returns an array reference corresponding to the given class name. The class name is assumed to be in the format returned by Class.getName() for an array class, namely (i) from 1 to 255 left brackets "[" denoting the number of dimensions, followed by the array's component type, either (ii) a single letter denoting one of the Java primitive types or (iii) an "L", the fully-qualified name of a class (with periods), and a semicolon ";".

Parameters:
theClassName - Class name as returned by Class.getName().
Returns:
Array reference corresponding to theClassName, or null if theClassName does not obey the format described above.

write

public void write(DataOutput theDataOutput)
           throws IOException
Write this array 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. In particular, a NotSerializableException is thrown if this array reference's component type reference is not an instance of one of the subclasses that can be written.


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