org.inxar.jenesis
Interface ArrayInitializer
- All Superinterfaces:
- Codeable, Expression
- public interface ArrayInitializer
- extends Expression
Expression
subinterface for array initializers. The
array initialization expression has a few interesting features.
Notice, the argument is Object
. The contract is that
the Object
must be of runtime-type
Expression
or, more likely, Object[]
. If
the type is Object[]
, then each element of that array
will recursively be introspected, checking again to see if the type
is Expression
or Object[]
. In this
manner, one can arbitratily nest expressions. This is the only way
I know how to accomplish this behavior (ie not knowing the
dimensionality of an argument at compile-time).
For example, say we wanted to make the array:
int[][] aai = { {1, 2} , {3, 4} };
One could do this by:
Expression[] a1 = new Expression[2];
a1[0] = new IntLiteralImpl(1);
a1[1] = new IntLiteralImpl(2);
Expression[] a2 = new Expression[2];
a2[0] = new IntLiteralImpl(3);
a2[1] = new IntLiteralImpl(4);
Object[] a3 = new Object[2];
a3[0] = a1;
a3[1] = a2;
ArrayDeclarationStatement asd = new ArrayDeclarationStatementImpl(); // fictional implementation
asd.setInitialization(a3);
Method Summary |
java.lang.Object |
getArgs()
Gets the array initialization expressions. |
void |
setArgs(java.lang.Object o)
Sets the array initialization expressions as an arbitrarily
nested array of Expression[] or as a single
Expression . |
getArgs
public java.lang.Object getArgs()
- Gets the array initialization expressions.
setArgs
public void setArgs(java.lang.Object o)
- Sets the array initialization expressions as an arbitrarily
nested array of
Expression[]
or as a single
Expression
.