KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > core > internal > expressions > StandardElementHandler


1 /*******************************************************************************
2  * Copyright (c) 2000, 2007 IBM Corporation and others.
3  * All rights reserved. This program and the accompanying materials
4  * are made available under the terms of the Eclipse Public License v1.0
5  * which accompanies this distribution, and is available at
6  * http://www.eclipse.org/legal/epl-v10.html
7  *
8  * Contributors:
9  * IBM Corporation - initial API and implementation
10  *******************************************************************************/

11 package org.eclipse.core.internal.expressions;
12
13 import org.w3c.dom.Element JavaDoc;
14 import org.w3c.dom.Node JavaDoc;
15
16 import org.eclipse.core.runtime.CoreException;
17 import org.eclipse.core.runtime.IConfigurationElement;
18
19 import org.eclipse.core.expressions.ElementHandler;
20 import org.eclipse.core.expressions.Expression;
21 import org.eclipse.core.expressions.ExpressionConverter;
22 import org.eclipse.core.expressions.ExpressionTagNames;
23
24 public class StandardElementHandler extends ElementHandler {
25     
26     public Expression create(ExpressionConverter converter, IConfigurationElement element) throws CoreException {
27         String JavaDoc name= element.getName();
28         if (ExpressionTagNames.INSTANCEOF.equals(name)) {
29             return new InstanceofExpression(element);
30         } else if (ExpressionTagNames.TEST.equals(name)) {
31             return new TestExpression(element);
32         } else if (ExpressionTagNames.OR.equals(name)) {
33             OrExpression result= new OrExpression();
34             processChildren(converter, element, result);
35             return result;
36         } else if (ExpressionTagNames.AND.equals(name)) {
37             AndExpression result= new AndExpression();
38             processChildren(converter, element, result);
39             return result;
40         } else if (ExpressionTagNames.NOT.equals(name)) {
41             return new NotExpression(converter.perform(element.getChildren()[0]));
42         } else if (ExpressionTagNames.WITH.equals(name)) {
43             WithExpression result= new WithExpression(element);
44             processChildren(converter, element, result);
45             return result;
46         } else if (ExpressionTagNames.ADAPT.equals(name)) {
47             AdaptExpression result= new AdaptExpression(element);
48             processChildren(converter, element, result);
49             return result;
50         } else if (ExpressionTagNames.ITERATE.equals(name)) {
51             IterateExpression result= new IterateExpression(element);
52             processChildren(converter, element, result);
53             return result;
54         } else if (ExpressionTagNames.COUNT.equals(name)) {
55             return new CountExpression(element);
56         } else if (ExpressionTagNames.SYSTEM_TEST.equals(name)) {
57             return new SystemTestExpression(element);
58         } else if (ExpressionTagNames.RESOLVE.equals(name)) {
59             ResolveExpression result= new ResolveExpression(element);
60             processChildren(converter, element, result);
61             return result;
62         } else if (ExpressionTagNames.ENABLEMENT.equals(name)) {
63             EnablementExpression result= new EnablementExpression(element);
64             processChildren(converter, element, result);
65             return result;
66         } else if (ExpressionTagNames.EQUALS.equals(name)) {
67             return new EqualsExpression(element);
68         } else if (ExpressionTagNames.REFERENCE.equals(name)) {
69             return new ReferenceExpression(element);
70         }
71         return null;
72     }
73
74     public Expression create(ExpressionConverter converter, Element JavaDoc element) throws CoreException {
75         String JavaDoc name= element.getNodeName();
76         if (ExpressionTagNames.INSTANCEOF.equals(name)) {
77             return new InstanceofExpression(element);
78         } else if (ExpressionTagNames.TEST.equals(name)) {
79             return new TestExpression(element);
80         } else if (ExpressionTagNames.OR.equals(name)) {
81             OrExpression result= new OrExpression();
82             processChildren(converter, element, result);
83             return result;
84         } else if (ExpressionTagNames.AND.equals(name)) {
85             AndExpression result= new AndExpression();
86             processChildren(converter, element, result);
87             return result;
88         } else if (ExpressionTagNames.NOT.equals(name)) {
89             Node JavaDoc child = element.getFirstChild();
90             while (child != null) {
91                 if (child.getNodeType() == Node.ELEMENT_NODE) {
92                     return new NotExpression(converter.perform((Element JavaDoc)child));
93                 }
94                 child = child.getNextSibling();
95             }
96         } else if (ExpressionTagNames.WITH.equals(name)) {
97             WithExpression result= new WithExpression(element);
98             processChildren(converter, element, result);
99             return result;
100         } else if (ExpressionTagNames.ADAPT.equals(name)) {
101             AdaptExpression result= new AdaptExpression(element);
102             processChildren(converter, element, result);
103             return result;
104         } else if (ExpressionTagNames.ITERATE.equals(name)) {
105             IterateExpression result= new IterateExpression(element);
106             processChildren(converter, element, result);
107             return result;
108         } else if (ExpressionTagNames.COUNT.equals(name)) {
109             return new CountExpression(element);
110         } else if (ExpressionTagNames.SYSTEM_TEST.equals(name)) {
111             return new SystemTestExpression(element);
112         } else if (ExpressionTagNames.RESOLVE.equals(name)) {
113             ResolveExpression result= new ResolveExpression(element);
114             processChildren(converter, element, result);
115             return result;
116         } else if (ExpressionTagNames.ENABLEMENT.equals(name)) {
117             EnablementExpression result= new EnablementExpression(element);
118             processChildren(converter, element, result);
119             return result;
120         } else if (ExpressionTagNames.EQUALS.equals(name)) {
121             return new EqualsExpression(element);
122         } else if (ExpressionTagNames.REFERENCE.equals(name)) {
123             return new ReferenceExpression(element);
124         }
125         return null;
126     }
127 }
128
Popular Tags