KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > webharvest > runtime > processors > ProcessorResolver


1 /* Copyright (c) 2006-2007, Vladimir Nikic
2     All rights reserved.
3
4     Redistribution and use of this software in source and binary forms,
5     with or without modification, are permitted provided that the following
6     conditions are met:
7
8     * Redistributions of source code must retain the above
9       copyright notice, this list of conditions and the
10       following disclaimer.
11
12     * Redistributions in binary form must reproduce the above
13       copyright notice, this list of conditions and the
14       following disclaimer in the documentation and/or other
15       materials provided with the distribution.
16
17     * The name of Web-Harvest may not be used to endorse or promote
18       products derived from this software without specific prior
19       written permission.
20
21     THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
22     AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
23     IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
24     ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
25     LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
26     CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
27     SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
28     INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
29     CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
30     ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
31     POSSIBILITY OF SUCH DAMAGE.
32
33     You can contact Vladimir Nikic by sending e-mail to
34     nikic_vladimir@yahoo.com. Please include the word "Web-Harvest" in the
35     subject line.
36 */

37 package org.webharvest.runtime.processors;
38
39 import org.webharvest.definition.*;
40
41 public class ProcessorResolver {
42     
43     public static BaseProcessor createProcessor(IElementDef elementDef) {
44         if (elementDef instanceof EmptyDef) {
45             return new EmptyProcessor( (EmptyDef)elementDef );
46         } else if (elementDef instanceof TextDef) {
47             return new TextProcessor( (TextDef)elementDef );
48         } else if (elementDef instanceof ConstantDef) {
49             return new ConstantProcessor( (ConstantDef)elementDef );
50         } else if (elementDef instanceof FileDef) {
51             return new FileProcessor( (FileDef)elementDef );
52         } else if (elementDef instanceof VarDefDef) {
53             return new VarDefProcessor( (VarDefDef)elementDef );
54         } else if (elementDef instanceof VarDef) {
55             return new VarProcessor( (VarDef)elementDef );
56         } else if (elementDef instanceof HttpDef) {
57             return new HttpProcessor( (HttpDef)elementDef );
58         } else if (elementDef instanceof HttpParamDef) {
59             return new HttpParamProcessor( (HttpParamDef)elementDef );
60         } else if (elementDef instanceof HttpHeaderDef) {
61             return new HttpHeaderProcessor( (HttpHeaderDef)elementDef );
62         } else if (elementDef instanceof XPathDef) {
63             return new XPathProcessor( (XPathDef)elementDef );
64         } else if (elementDef instanceof XQueryDef) {
65             return new XQueryProcessor( (XQueryDef)elementDef );
66         } else if (elementDef instanceof XsltDef) {
67             return new XsltProcessor( (XsltDef)elementDef );
68         } else if (elementDef instanceof TemplateDef) {
69             return new TemplateProcessor( (TemplateDef)elementDef );
70         } else if (elementDef instanceof RegexpDef) {
71             return new RegexpProcessor( (RegexpDef)elementDef );
72         } else if (elementDef instanceof HtmlToXmlDef) {
73             return new HtmlToXmlProcessor( (HtmlToXmlDef)elementDef );
74         } else if (elementDef instanceof CaseDef) {
75             return new CaseProcessor( (CaseDef)elementDef );
76         } else if (elementDef instanceof LoopDef) {
77             return new LoopProcessor( (LoopDef)elementDef );
78         } else if (elementDef instanceof WhileDef) {
79             return new WhileProcessor( (WhileDef)elementDef );
80         } else if (elementDef instanceof FunctionDef) {
81             return new FunctionProcessor( (FunctionDef)elementDef );
82         } else if (elementDef instanceof IncludeDef) {
83             return new IncludeProcessor( (IncludeDef)elementDef );
84         } else if (elementDef instanceof CallDef) {
85             return new CallProcessor( (CallDef)elementDef );
86         } else if (elementDef instanceof CallParamDef) {
87             return new CallParamProcessor( (CallParamDef)elementDef );
88         } else if (elementDef instanceof ReturnDef) {
89             return new ReturnProcessor( (ReturnDef)elementDef );
90         } else if (elementDef instanceof TryDef) {
91             return new TryProcessor( (TryDef)elementDef );
92         } else if (elementDef instanceof ScriptDef) {
93             return new ScriptProcessor( (ScriptDef)elementDef );
94         }
95
96         return null;
97     }
98     
99 }
Popular Tags