KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > enhydra > barracuda > core > view > ScriptingType


1 /*
2  * Copyright (C) 2003 Christian Cryder [christianc@granitepeaks.com]
3  *
4  * This library is free software; you can redistribute it and/or
5  * modify it under the terms of the GNU Lesser General Public
6  * License as published by the Free Software Foundation; either
7  * version 2.1 of the License, or (at your option) any later version.
8  *
9  * This library is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12  * Lesser General Public License for more details.
13  *
14  * You should have received a copy of the GNU Lesser General Public
15  * License along with this library; if not, write to the Free Software
16  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17  *
18  * $Id: ScriptingType.java,v 1.9 2004/02/01 05:16:28 christianc Exp $
19  */

20 package org.enhydra.barracuda.core.view;
21
22 import java.util.*;
23 import org.w3c.dom.*;
24 import org.w3c.dom.html.*;
25
26 /**
27  * <p>This class defines all valid ScriptingTypes.
28  *
29  * <p>We start by defining a series of basic interfaces to define all known scripting types
30  * and specify how they relate to one another. Please note that these are hierarchical in
31  * nature. Strongly typed ScriptingType interfaces include:
32  *
33  * <ul>
34  * <li>ScriptingSupport<ul>
35  * <li>JavaScript<ul>
36  * <li>JavaScript1x</li><ul>
37  * <li>JavaScript10</li><ul>
38  * <li>JavaScript11</li><ul>
39  * <li>JavaScript12</li><ul>
40  * <li>JavaScript13</li><ul>
41  * <li>JavaScript14</li><ul>
42  * <li>JavaScript15</li>
43  * </ul>
44  * </ul>
45  * </ul>
46  * </ul>
47  * </ul>
48  * </ul>
49  * </ul>
50  * </li>
51  * <li>WmlScript<ul>
52  * <li>WmlScript1x</li>
53  * <li>WmlScript10</li><ul>
54  * <li>WmlScript11</li><ul>
55  * <li>WmlScript12</li>
56  * </ul>
57  * </ul>
58  * </ul>
59  * </ul>
60  * </li>
61  * <li>None</li>
62  * </ul>
63  * </li>
64  * </ul>
65  *
66  * We can reference these interfaces to determine what kind of ScriptingType we're
67  * actually dealing with. We also define concrete scripting types to allow us to
68  * actually assign scripting type values.
69  *
70  * <p>Concrete scripting types include:
71  * <ul>
72  * <li>ScriptingType.JAVASCRIPT_1x</li>
73  * <li>ScriptingType.JAVASCRIPT_1_0</li>
74  * <li>ScriptingType.JAVASCRIPT_1_1</li>
75  * <li>ScriptingType.JAVASCRIPT_1_2</li>
76  * <li>ScriptingType.JAVASCRIPT_1_3</li>
77  * <li>ScriptingType.JAVASCRIPT_1_4</li>
78  * <li>ScriptingType.JAVASCRIPT_1_5</li>
79  * <li>ScriptingType.WMLSCRIPT_1x</li>
80  * <li>ScriptingType.WMLSCRIPT_1_0</li>
81  * <li>ScriptingType.WMLSCRIPT_1_1</li>
82  * <li>ScriptingType.WMLSCRIPT_1_2</li>
83  * <li>ScriptingType.NONE</li>
84  * </ul>
85  *
86  * <p> This all functions in a manner similar to the FormatType class. For more
87  * details, please refer to those Javadocs.
88  */

89 public abstract class ScriptingType {
90
91     //concrete instances of scripting types
92
public static final ScriptingType JAVASCRIPT_1x = new JavaScript1xImpl();
93     public static final ScriptingType JAVASCRIPT_1_0 = new JavaScript1_0Impl();
94     public static final ScriptingType JAVASCRIPT_1_1 = new JavaScript1_1Impl();
95     public static final ScriptingType JAVASCRIPT_1_2 = new JavaScript1_2Impl();
96     public static final ScriptingType JAVASCRIPT_1_3 = new JavaScript1_3Impl();
97     public static final ScriptingType JAVASCRIPT_1_4 = new JavaScript1_4Impl();
98     public static final ScriptingType JAVASCRIPT_1_5 = new JavaScript1_5Impl();
99     public static final ScriptingType WMLSCRIPT_1x = new WmlScript1xImpl();
100     public static final ScriptingType WMLSCRIPT_1_0 = new WmlScript1_0Impl();
101     public static final ScriptingType WMLSCRIPT_1_1 = new WmlScript1_1Impl();
102     public static final ScriptingType WMLSCRIPT_1_2 = new WmlScript1_2Impl();
103     public static final ScriptingType NONE = new NoneImpl();
104
105     //base scripting types (hierarchical defs)
106
public interface ScriptingSupport {};
107     public interface JavaScript extends ScriptingSupport {};
108     public interface JavaScript1x extends JavaScript {};
109     public interface JavaScript10 extends JavaScript1x {};
110     public interface JavaScript11 extends JavaScript10 {};
111     public interface JavaScript12 extends JavaScript11 {};
112     public interface JavaScript13 extends JavaScript12 {};
113     public interface JavaScript14 extends JavaScript13 {};
114     public interface JavaScript15 extends JavaScript14 {};
115     public interface WmlScript extends ScriptingSupport {};
116     public interface WmlScript1x extends WmlScript {};
117     public interface WmlScript10 extends WmlScript1x {};
118     public interface WmlScript11 extends WmlScript10 {};
119     public interface WmlScript12 extends WmlScript11 {};
120     public interface None extends ScriptingSupport {};
121     
122     //private implementations (while the concrete implementations above are final
123
//so they can't be changed, the specific implementations are left merely protected,
124
//allowing developers to extend for custom types if needed).
125

126     //scripting types
127
protected static class ScriptingSupportImpl extends ScriptingType implements ScriptingSupport {
128         public String JavaDoc toString() {
129             String JavaDoc s = this.getClass().getName();
130             int spos = s.indexOf("$");
131             int epos = s.indexOf("Impl");
132             return s.substring(spos+1, epos);
133         }
134     };
135     protected static class JavaScriptImpl extends ScriptingSupportImpl implements JavaScript {};
136     protected static class JavaScript1xImpl extends JavaScriptImpl implements JavaScript1x {};
137     protected static class JavaScript1_0Impl extends JavaScript1xImpl implements JavaScript10 {};
138     protected static class JavaScript1_1Impl extends JavaScript1_0Impl implements JavaScript11 {};
139     protected static class JavaScript1_2Impl extends JavaScript1_1Impl implements JavaScript12 {};
140     protected static class JavaScript1_3Impl extends JavaScript1_2Impl implements JavaScript13 {};
141     protected static class JavaScript1_4Impl extends JavaScript1_3Impl implements JavaScript14 {};
142     protected static class JavaScript1_5Impl extends JavaScript1_4Impl implements JavaScript15 {};
143     protected static class WmlScriptImpl extends ScriptingSupportImpl implements WmlScript {};
144     protected static class WmlScript1xImpl extends WmlScriptImpl implements WmlScript1x {};
145     protected static class WmlScript1_0Impl extends WmlScript1xImpl implements WmlScript10 {};
146     protected static class WmlScript1_1Impl extends WmlScript1_0Impl implements WmlScript11 {};
147     protected static class WmlScript1_2Impl extends WmlScript1_1Impl implements WmlScript12 {};
148     protected static class NoneImpl extends ScriptingSupportImpl implements None {};
149
150
151
152     /**
153      * Private constructor to prevent external instantiation
154      */

155     protected ScriptingType() {}
156
157     public static void main(String JavaDoc args[]) {
158         System.out.println ("Testing...");
159         System.out.println ("JAVASCRIPT_1_3 instanceof ScriptingType.JavaScript1x:"+(ScriptingType.JAVASCRIPT_1_3 instanceof ScriptingType.JavaScript1x));
160     }
161 }
162
Popular Tags