KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > core > expressions > ElementHandler


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.expressions;
12
13 import org.w3c.dom.Element JavaDoc;
14
15 import org.eclipse.core.runtime.CoreException;
16 import org.eclipse.core.runtime.IConfigurationElement;
17 import org.eclipse.core.runtime.IStatus;
18 import org.eclipse.core.runtime.Status;
19
20 import org.eclipse.core.internal.expressions.CompositeExpression;
21 import org.eclipse.core.internal.expressions.ExpressionMessages;
22 import org.eclipse.core.internal.expressions.ExpressionPlugin;
23 import org.eclipse.core.internal.expressions.StandardElementHandler;
24
25
26 /**
27  * An element handler converts an {@link IConfigurationElement} into a
28  * corresponding expression object.
29  * <p>
30  * The class should be subclassed by clients wishing to provide an element
31  * handler for special expressions.
32  * </p>
33  * @since 3.0
34  */

35 public abstract class ElementHandler {
36     
37     private static final ElementHandler INSTANCE= new StandardElementHandler();
38     
39     /**
40      * The default element handler which can cope with all XML expression elements
41      * defined by the common expression language.
42      *
43      * @return the default element handler
44      */

45     public static ElementHandler getDefault() {
46         return INSTANCE;
47     }
48     
49     /**
50      * Creates the corresponding expression for the given configuration element.
51      *
52      * @param converter the expression converter used to initiate the
53      * conversion process
54      *
55      * @param config the configuration element to convert
56      *
57      * @return the corresponding expression
58      *
59      * @throws CoreException if the conversion failed
60      */

61     public abstract Expression create(ExpressionConverter converter, IConfigurationElement config) throws CoreException;
62     
63     /**
64      * Creates the corresponding expression for the given DOM element. This is
65      * an optional operation that is only required if the handler supports conversion
66      * of DOM elements.
67      *
68      * @param converter the expression converter used to initiate the
69      * conversion process
70      *
71      * @param element the DOM element to convert
72      *
73      * @return the corresponding expression
74      *
75      * @throws CoreException if the conversion failed
76      *
77      * @since 3.3
78      */

79     public Expression create(ExpressionConverter converter, Element JavaDoc element) throws CoreException {
80         throw new CoreException(new Status(IStatus.ERROR, ExpressionPlugin.getPluginId(),
81                 IStatus.ERROR,
82                 ExpressionMessages.ElementHandler_unsupported_element,
83                 null));
84     }
85
86     /**
87      * Converts the children of the given configuration element and adds them
88      * to the given composite expression.
89      * <p>
90      * Note this is an internal method and should not be called by clients.
91      * </p>
92      * @param converter the converter used to do the actual conversion
93      * @param element the configuration element for which the children
94      * are to be processed
95      * @param expression the composite expression representing the result
96      * of the conversion
97      *
98      * @throws CoreException if the conversion failed
99      */

100     protected void processChildren(ExpressionConverter converter, IConfigurationElement element, CompositeExpression expression) throws CoreException {
101         converter.processChildren(element, expression);
102     }
103
104     /**
105      * Converts the children of the given DOM element and adds them to the
106      * given composite expression.
107      * <p>
108      * Note this is an internal method and should not be called by clients.
109      * </p>
110      * @param converter the converter used to do the actual conversion
111      * @param element the DOM element for which the children are to be processed
112      * @param expression the composite expression representing the result
113      * of the conversion
114      *
115      * @throws CoreException if the conversion failed
116      *
117      * @since 3.3
118      */

119     protected void processChildren(ExpressionConverter converter, Element JavaDoc element, CompositeExpression expression) throws CoreException {
120         converter.processChildren(element, expression);
121     }
122 }
123
Popular Tags