KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > google > gwt > dev > js > ast > JsForIn


1 /*
2  * Copyright 2007 Google Inc.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License"); you may not
5  * use this file except in compliance with the License. You may obtain a copy of
6  * the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
12  * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
13  * License for the specific language governing permissions and limitations under
14  * the License.
15  */

16 package com.google.gwt.dev.js.ast;
17
18 /**
19  * Represents a JavaScript for..in statement.
20  */

21 public class JsForIn extends JsStatement {
22
23   private JsStatement body;
24
25   private JsExpression iterExpr;
26
27   // Optional: the name of a new iterator variable to introduce
28
private final JsName iterVarName;
29
30   private JsExpression objExpr;
31
32   public JsForIn() {
33     this(null);
34   }
35
36   public JsForIn(JsName iterVarName) {
37     this.iterVarName = iterVarName;
38   }
39
40   public JsStatement getBody() {
41     return body;
42   }
43
44   public JsExpression getIterExpr() {
45     return iterExpr;
46   }
47
48   public JsName getIterVarName() {
49     return iterVarName;
50   }
51
52   public JsExpression getObjExpr() {
53     return objExpr;
54   }
55
56   public void setBody(JsStatement body) {
57     this.body = body;
58   }
59
60   public void setIterExpr(JsExpression iterExpr) {
61     this.iterExpr = iterExpr;
62   }
63
64   public void setObjExpr(JsExpression objExpr) {
65     this.objExpr = objExpr;
66   }
67
68   public void traverse(JsVisitor v, JsContext ctx) {
69     if (v.visit(this, ctx)) {
70       if (iterExpr != null) {
71         iterExpr = v.accept(iterExpr);
72       }
73       objExpr = v.accept(objExpr);
74       body = v.accept(body);
75     }
76     v.endVisit(this, ctx);
77   }
78 }
79
Popular Tags