001: /*
002: * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
003: *
004: * Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved.
005: *
006: * The contents of this file are subject to the terms of either the GNU
007: * General Public License Version 2 only ("GPL") or the Common
008: * Development and Distribution License("CDDL") (collectively, the
009: * "License"). You may not use this file except in compliance with the
010: * License. You can obtain a copy of the License at
011: * http://www.netbeans.org/cddl-gplv2.html
012: * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
013: * specific language governing permissions and limitations under the
014: * License. When distributing the software, include this License Header
015: * Notice in each file and include the License file at
016: * nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this
017: * particular file as subject to the "Classpath" exception as provided
018: * by Sun in the GPL Version 2 section of the License file that
019: * accompanied this code. If applicable, add the following below the
020: * License Header, with the fields enclosed by brackets [] replaced by
021: * your own identifying information:
022: * "Portions Copyrighted [year] [name of copyright owner]"
023: *
024: * Contributor(s):
025: *
026: * The Original Software is NetBeans. The Initial Developer of the Original
027: * Software is Sun Microsystems, Inc. Portions Copyright 1997-2007 Sun
028: * Microsystems, Inc. All Rights Reserved.
029: *
030: * If you wish your version of this file to be governed by only the CDDL
031: * or only the GPL Version 2, indicate your decision by adding
032: * "[Contributor] elects to include this software in this distribution
033: * under the [CDDL or GPL Version 2] license." If you do not indicate a
034: * single choice of license, a recipient has the option to distribute
035: * your version of this file under either the CDDL, the GPL Version 2 or
036: * to extend the choice of license to its licensees as provided above.
037: * However, if you add GPL Version 2 code and therefore, elected the GPL
038: * Version 2 license, then the option applies only if the new code is
039: * made subject to such option by the copyright holder.
040: */
041:
042: /*
043: * File : StatementFactory.java
044: * Created on : Dec 10, 2003
045: * Author : Aztec
046: */
047: package org.netbeans.modules.uml.core.reverseengineering.parsingfacilities.translation.statehandlers;
048:
049: import org.netbeans.modules.uml.core.reverseengineering.parsingfacilities.IOpParserOptions;
050: import org.netbeans.modules.uml.core.reverseengineering.parsingfacilities.SymbolTable;
051:
052: /**
053: * @author Aztec
054: */
055: public class StatementFactory {
056: public static MethodDetailStateHandler retrieveStatementHandler(
057: String stateName, String language,
058: IOpParserOptions pOptions, SymbolTable symbolTable) {
059: MethodDetailStateHandler retVal = null;
060:
061: if ("Parameter".equals(stateName)) {
062: MethodParameterStateHandler pHandler = new MethodParameterStateHandler(
063: language);
064: pHandler.methodInitialize(pOptions, symbolTable);
065:
066: retVal = pHandler;
067: } else if ("Conditional".equals(stateName)) {
068: MethodConditionalStateHandler pHandler = new MethodConditionalStateHandler(
069: language, true);
070: pHandler.methodInitialize(pOptions, symbolTable);
071:
072: retVal = pHandler;
073: } else if ("Else Conditional".equals(stateName)) {
074: MethodConditionalStateHandler pHandler = new ElseConditionalStateHandler(
075: language);
076: pHandler.methodInitialize(pOptions, symbolTable);
077:
078: retVal = pHandler;
079: } else if ("Option Conditional".equals(stateName)) {
080: MethodSwitchStateHandler pHandler = new MethodSwitchStateHandler(
081: language);
082: pHandler.methodInitialize(pOptions, symbolTable);
083:
084: retVal = pHandler;
085: } else if ("Option".equals(stateName)) {
086: MethodSwitchStateHandler pHandler = new MethodSwitchStateHandler(
087: language);
088: pHandler.methodInitialize(pOptions, symbolTable);
089:
090: retVal = pHandler;
091: } else if (("Method Call".equals(stateName))
092: || ("Constructor Call".equals(stateName))
093: || ("Super Constructor Call".equals(stateName))) {
094: //MethodCallStateHandler pHandler = new MethodCallStateHandler(language);
095: MethodCallStateHandler pHandler = new MethodCallStateHandler(
096: stateName, language);
097: pHandler.methodInitialize(pOptions, symbolTable);
098:
099: retVal = pHandler;
100: } else if ("Assignment Expression".equals(stateName)) {
101: //MethodCallStateHandler pHandler = new MethodCallStateHandler(language);
102: AssignmentStateHandler pHandler = new AssignmentStateHandler(
103: stateName, language);
104: pHandler.methodInitialize(pOptions, symbolTable);
105:
106: retVal = pHandler;
107: } else if (("Plus Expression".equals(stateName))
108: || ("Multiply Expression".equals(stateName))
109: || ("Minus Expression".equals(stateName))
110: || ("Divide Expression".equals(stateName))
111: || ("Mod Expression".equals(stateName))
112: || ("LogicalOR Expression".equals(stateName))
113: || ("LogicalAND Expression".equals(stateName))
114: || ("BinaryOR Expression".equals(stateName))
115: || ("Not Equality Expression".equals(stateName))
116: || ("Equality Expression".equals(stateName))
117: || ("LT Relational Expression".equals(stateName))
118: || ("GT Relational Expression".equals(stateName))
119: || ("LE Relational Expression".equals(stateName))
120: || ("GE Relational Expression".equals(stateName))
121: || ("Type Check Expression".equals(stateName))
122: || ("ExclusiveOR Expression".equals(stateName))
123: || ("BinaryAND Expression".equals(stateName))
124: || ("Shift Left Expression".equals(stateName))
125: || ("Right Shift Expression".equals(stateName))
126: || ("Binary Shift Right Expression".equals(stateName))
127: || ("Logical Not Unary Expression".equals(stateName))
128: || ("Decrement Unary Expression".equals(stateName))
129: || ("Increment Post Unary Expression".equals(stateName))
130: || ("Increment Unary Expression".equals(stateName))
131: || ("Decrement Post Unary Expression".equals(stateName))
132: || ("Binary Not Unary Expression".equals(stateName))
133: || ("Minus Unary Expression".equals(stateName))
134: || ("Plus Unary Expression".equals(stateName))
135: ||
136:
137: ("Conditional Expression".equals(stateName))
138: || ("Plus Assignment Expression".equals(stateName))
139: || ("Minus Assignment Expression".equals(stateName))
140: || ("Binary XOR Assignment Expression"
141: .equals(stateName))
142: || ("Multiply Assignment Expression".equals(stateName))
143: || ("Divide Assignment Expression".equals(stateName))
144: || ("Mod Assignment Expression".equals(stateName))
145: || ("Shift Right Assignment Expression"
146: .equals(stateName))
147: || ("Shift Right Assignment Expression"
148: .equals(stateName))
149: || ("Shift Left Assignment Expression"
150: .equals(stateName))
151: || ("Binary And Assignment Expression"
152: .equals(stateName))
153: || ("Binary OR Assignment Expression".equals(stateName))
154: ||
155:
156: ("Pointer Indirection".equals(stateName))
157: || ("Pointer Access".equals(stateName))
158: || ("Address Of".equals(stateName))) {
159: //MethodCallStateHandler pHandler = new ExpressionStateHandler(language);
160: MethodExpressionStateHandler pHandler = new MethodExpressionStateHandler(
161: stateName, language);
162: pHandler.methodInitialize(pOptions, symbolTable);
163:
164: retVal = pHandler;
165: } else if ("Variable Definition".equals(stateName)) {
166: MethodDetailStateHandler pHandler = null;
167: if ("Visual Basic 6".equals(language)) {
168: pHandler = new VBVariableStateHandler(language, false);
169: } else {
170: pHandler = new MethodVariableStateHandler(language,
171: false);
172: }
173: pHandler.methodInitialize(pOptions, symbolTable);
174: retVal = pHandler;
175: } else if ("Loop".equals(stateName)) {
176: MethodLoopStateHandler pHandler = new MethodLoopStateHandler(
177: language);
178: pHandler.methodInitialize(pOptions, symbolTable);
179:
180: retVal = pHandler;
181: } else if ("Return".equals(stateName)) {
182: MethodReturnStateHandler pHandler = new MethodReturnStateHandler(
183: language);
184: pHandler.methodInitialize(pOptions, symbolTable);
185:
186: retVal = pHandler;
187: } else if ("CriticalSection".equals(stateName)) {
188: MethodCriticalSectionStateHandler pHandler = new MethodCriticalSectionStateHandler(
189: language);
190: pHandler.methodInitialize(pOptions, symbolTable);
191:
192: retVal = pHandler;
193: } else if ("Object Destruction".equals(stateName)) {
194: MethodDetroyStateHandler pHandler = new MethodDetroyStateHandler(
195: language);
196: pHandler.methodInitialize(pOptions, symbolTable);
197:
198: retVal = pHandler;
199: } else if (("Break".equals(stateName))
200: || ("Continue".equals(stateName))
201: || ("Goto".equals(stateName))) {
202: JumpStateHandler pHandler = new JumpStateHandler(language,
203: stateName);
204: pHandler.methodInitialize(pOptions, symbolTable);
205:
206: retVal = pHandler;
207: } else if ("RaisedException".equals(stateName)) {
208: MethodRaisedExceptionStateHandler pHandler = new MethodRaisedExceptionStateHandler(
209: language);
210: pHandler.methodInitialize(pOptions, symbolTable);
211:
212: retVal = pHandler;
213: } else if ("Exception Processing".equals(stateName)) {
214: MethodExceptionProcessingStateHandler pHandler = new MethodExceptionProcessingStateHandler(
215: language);
216: pHandler.methodInitialize(pOptions, symbolTable);
217:
218: retVal = pHandler;
219: } else if ("With Block".equals(stateName)) {
220: VBMethodWithStatement pHandler = new VBMethodWithStatement(
221: language);
222: pHandler.methodInitialize(pOptions, symbolTable);
223:
224: retVal = pHandler;
225: }
226: return retVal;
227: }
228:
229: }
|