View Javadoc

1   /*
2    * ASForEachInStatement.java
3    * 
4    * Copyright (c) 2007-2008 David Holroyd
5    *
6    * Licensed under the Apache License, Version 2.0 (the "License");
7    * you may not use this file except in compliance with the License.
8    * You may obtain a copy of the License at
9    *
10   *     http://www.apache.org/licenses/LICENSE-2.0
11   *
12   * Unless required by applicable law or agreed to in writing, software
13   * distributed under the License is distributed on an "AS IS" BASIS,
14   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15   * See the License for the specific language governing permissions and
16   * limitations under the License.
17   */
18  
19  package uk.co.badgersinfoil.metaas.dom;
20  
21  /**
22   * A for-each-in statement, such as <code>for each(v in a) { }</code>.
23   * 
24   * <p>e.g. The Java code</p>
25   * <pre class="eg">ASForEachInStatement forEachIn = method.newForEachIn("var v", "arr");
26   *forEachIn.addStmt("trace(v)");</pre>
27   *
28   * <p>Will create ActionScript code like,</p>
29   * <pre class="eg">for each(var v in arr) {
30   *	trace(v);
31   *}</pre>
32   *
33   * @see StatementContainer#newForEachIn(Expression, Expression)
34   */
35  public interface ASForEachInStatement extends Statement, StatementContainer {
36  
37  	/**
38  	 * Returns a string representation of the loop-variable declaration
39  	 * for this loop.
40  	 * 
41  	 * e.g. given the loop <code>for each(v in a) { }</code>, this method
42  	 * will return the string <code>"v"</code>.
43  	 */
44  	public String getVarString();
45  
46  	/**
47  	 * Returns a string representation of the expression whose value will
48  	 * iterated over.
49  	 * 
50  	 * e.g. given the loop <code>for each(v in a) { }</code>, this method
51  	 * will return the string <code>"a"</code>.
52  	 */
53  	public String getIteratedString();
54  
55  	public Expression getIterated();
56  
57  	/**
58  	 * Specifies the loop-variable declaration for this loop.
59  	 * 
60  	 * @throws uk.co.badgersinfoil.metaas.SyntaxException if the given
61  	 * string is not a valid ActionScript expression.
62  	 */
63  	public void setVar(String expr);
64  
65  	/**
66  	 * Changes the expression whose value will be iterated over by this
67  	 * loop.
68  	 * 
69  	 * @throws uk.co.badgersinfoil.metaas.SyntaxException if the given
70  	 * string is not a valid ActionScript expression.
71  	 */
72  	public void setIterated(String expr);
73  
74  	public void setIterated(Expression expr);
75  }