1 11 package org.eclipse.core.internal.expressions; 12 13 import org.w3c.dom.Element ; 14 import org.w3c.dom.Node ; 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 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 element) throws CoreException { 75 String 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 child = element.getFirstChild(); 90 while (child != null) { 91 if (child.getNodeType() == Node.ELEMENT_NODE) { 92 return new NotExpression(converter.perform((Element )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 |