JET

edu.utep.cs.et.rat.val
Class ArrayValue

java.lang.Object
  extended by edu.utep.cs.et.rat.val.CompositeValue
      extended by edu.utep.cs.et.rat.val.ArrayValue
All Implemented Interfaces:
Denotable

public class ArrayValue
extends CompositeValue

A class to represent an array value. An array value is represented as a tuple of a type, (Class) and the elements (an array of Denotables). An element may be another array value. If the type is null, the array is assumed to be an element of another array.

Version:
$Revision: 1.7 $
Author:
Yoonsik Cheon

Nested Class Summary
 
Nested classes/interfaces inherited from class edu.utep.cs.et.rat.val.CompositeValue
CompositeValue.SimpleVarGenerator
 
Field Summary
private  Object array
          The Java array object represented by this array value.
 
Constructor Summary
ArrayValue(Class type, Denotable[] elems)
          Creates an array of the given type and elements.
 
Method Summary
static void assign(Object array, int i, Denotable elem)
          Retrieves the Java value represented by the given Denotable, elem, and assigns it to the i-th element of the given array, array.
private  Object buildJavaArray(Denotable[] values)
          Builds and returns a Java array denoted by the given array of Denotable's.
 String code()
          Returns a textual representation of the object denoted by this constructor call.
 String[] code(VarGenerator varGen)
          Returns Java source code that, if evaluated, constructs a Java array object represented by this value.
 String toString()
          Returns a string representation of this array.
 Class type()
          Returns the type of this array.
 Object value()
          Returns the Java array represented by this array.
 
Methods inherited from class edu.utep.cs.et.rat.val.CompositeValue
elems, getTypeName, hasEquals, isEquivalentTo, isNull
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

array

private Object array
The Java array object represented by this array value. Each element of the array object is represented by the corresponding element of the array of Denotables.

Constructor Detail

ArrayValue

public ArrayValue(Class type,
                  Denotable[] elems)
Creates an array of the given type and elements. If the type is null, the created array is assumed to be an element of another array.

Method Detail

buildJavaArray

private Object buildJavaArray(Denotable[] values)
Builds and returns a Java array denoted by the given array of Denotable's.


assign

public static void assign(Object array,
                          int i,
                          Denotable elem)
Retrieves the Java value represented by the given Denotable, elem, and assigns it to the i-th element of the given array, array.


type

public Class type()
Returns the type of this array.

Specified by:
type in interface Denotable
Overrides:
type in class CompositeValue

value

public Object value()
Returns the Java array represented by this array.


toString

public String toString()
Returns a string representation of this array.

Specified by:
toString in interface Denotable
Overrides:
toString in class Object

code

public String code()
Returns a textual representation of the object denoted by this constructor call. The returned string has the following general form:
  x where:
  T1 x1 = ...;
  ...
  Tn xn = ...;
  T x = new T[] {x1, ..., xn}
 

See Also:
code(VarGenerator)

code

public String[] code(VarGenerator varGen)
Returns Java source code that, if evaluated, constructs a Java array object represented by this value. The given argument is used to generate unique temporary variables to store intermediate values and the constructed object. The first element of the returned array contains Java source code of the following general form:
  T1 x1 = ...;
  ...
  Tn xn = ...;
  T x = new T[] {x1, ..., xn}
 
The second element gives the name of the variable (e.g., x) that contains the constructed array object.

Specified by:
code in class CompositeValue
See Also:
code(VarGenerator)

JET

JET is Copyright (C) 2005-2007 by The University of Texas at El Paso and is distributed under the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.