View Javadoc
1   package net.sourceforge.jenesis4java;
2   
3   /*
4    * #%L
5    * Jenesis 4 Java Code Generator
6    * %%
7    * Copyright (C) 2000 - 2015 jenesis4java
8    * %%
9    * This program is free software: you can redistribute it and/or modify
10   * it under the terms of the GNU Lesser General Public License as
11   * published by the Free Software Foundation, either version 3 of the
12   * License, or (at your option) any later version.
13   * 
14   * This program is distributed in the hope that it will be useful,
15   * but WITHOUT ANY WARRANTY; without even the implied warranty of
16   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17   * GNU General Lesser Public License for more details.
18   * 
19   * You should have received a copy of the GNU General Lesser Public
20   * License along with this program.  If not, see
21   * <http://www.gnu.org/licenses/lgpl-3.0.html>.
22   * #L%
23   */
24  
25  /**
26   * Copyright (C) 2008, 2010 Richard van Nieuwenhoven - ritchie [at] gmx [dot] at
27   * Copyright (C) 2000, 2001 Paul Cody Johnston - pcj@inxar.org <br>
28   * This file is part of Jenesis4java. Jenesis4java is free software: you can
29   * redistribute it and/or modify it under the terms of the GNU Lesser General
30   * Public License as published by the Free Software Foundation, either version 3
31   * of the License, or (at your option) any later version.<br>
32   * Jenesis4java is distributed in the hope that it will be useful, but WITHOUT
33   * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
34   * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
35   * details.<br>
36   * You should have received a copy of the GNU Lesser General Public License
37   * along with Jenesis4java. If not, see <http://www.gnu.org/licenses/>.
38   */
39  /**
40   * {@code Expression} subinterface for array initializers. The array
41   * initialization expression has a few interesting features. Notice, the
42   * argument is {@code Object}. The contract is that the {@code Object} must be
43   * of runtime-type {@code Expression} or, more likely, {@code Object[]}. If the
44   * type is {@code Object[]}, then each element of that array will recursively be
45   * introspected, checking again to see if the type is {@code Expression} or
46   * {@code Object[]}. In this manner, one can arbitrarily nest expressions. This
47   * is the only way I know how to accomplish this behavior (ie not knowing the
48   * dimensionality of an argument at compile-time).
49   * <P>
50   * For example, say we wanted to make the array: {@code int[][] aai = 1, 2}, {
51   * 3, 4 }}; } One could do this by:
52   * 
53   * <PRE>
54   * Expression[] a1 = new Expression[2];
55   * a1[0] = new IntLiteralImpl(1);
56   * a1[1] = new IntLiteralImpl(2);
57   * Expression[] a2 = new Expression[2];
58   * a2[0] = new IntLiteralImpl(3);
59   * a2[1] = new IntLiteralImpl(4);
60   * Object[] a3 = new Object[2];
61   * a3[0] = a1;
62   * a3[1] = a2;
63   * ArrayDeclarationStatement asd = new ArrayDeclarationStatementImpl(); // fictional
64   * // implementation
65   * asd.setInitialization(a3);
66   * </PRE>
67   */
68  public interface ArrayInitializer extends Expression {
69  
70      /**
71       * Gets the array initialization expressions.
72       */
73      Object getArgs();
74  
75      /**
76       * Sets the array initialization expressions as an arbitrarily nested array
77       * of {@code Expression[]} <i>or</i> as a single {@code Expression}.
78       */
79      ArrayInitializer setArgs(Object o);
80  }