KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > jetspeed > portlet > Capability


1 /* ====================================================================
2  * The Apache Software License, Version 1.1
3  *
4  * Copyright (c) 2000-2001 The Apache Software Foundation. All rights
5  * reserved.
6  *
7  * Redistribution and use in source and binary forms, with or without
8  * modification, are permitted provided that the following conditions
9  * are met:
10  *
11  * 1. Redistributions of source code must retain the above copyright
12  * notice, this list of conditions and the following disclaimer.
13  *
14  * 2. Redistributions in binary form must reproduce the above copyright
15  * notice, this list of conditions and the following disclaimer in
16  * the documentation and/or other materials provided with the
17  * distribution.
18  *
19  * 3. The end-user documentation included with the redistribution,
20  * if any, must include the following acknowledgment:
21  * "This product includes software developed by the
22  * Apache Software Foundation (http://www.apache.org/)."
23  * Alternately, this acknowledgment may appear in the software itself,
24  * if and wherever such third-party acknowledgments normally appear.
25  *
26  * 4. The names "Apache" and "Apache Software Foundation" and
27  * "Apache Jetspeed" must not be used to endorse or promote products
28  * derived from this software without prior written permission. For
29  * written permission, please contact apache@apache.org.
30  *
31  * 5. Products derived from this software may not be called "Apache" or
32  * "Apache Jetspeed", nor may "Apache" appear in their name, without
33  * prior written permission of the Apache Software Foundation.
34  *
35  * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
36  * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
37  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
38  * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
39  * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
40  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
41  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
42  * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
43  * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
44  * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
45  * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
46  * SUCH DAMAGE.
47  * ====================================================================
48  *
49  * This software consists of voluntary contributions made by many
50  * individuals on behalf of the Apache Software Foundation. For more
51  * information on the Apache Software Foundation, please see
52  * <http://www.apache.org/>.
53  */

54
55 package org.apache.jetspeed.portlet;
56
57 import java.util.AbstractList JavaDoc;
58 import java.util.LinkedList JavaDoc;
59
60 /**
61  ** Instances of the <CODE>Capability</CODE> class correspond to particular
62  ** properties which can be assigned to the client devices.
63  **
64  ** <P>
65  ** The class has only a private constructor, so that it is not possible
66  ** to dynamically create objects of this class from outside the class. A set
67  ** of predefined isntances (ie. capabilities) is provided.
68  **
69  ** @see Client
70  **
71  ** @author <A HREF="mailto:tboehme@us.ibm.com">Thomas F. Boehme</A>
72  **/

73
74 public class Capability
75 {
76     private AbstractList JavaDoc impliedCapabilities = new LinkedList JavaDoc ();
77
78     private static AbstractList JavaDoc capabilities = new LinkedList JavaDoc ();
79
80     public final static Capability HTML_JAVA = new Capability ("HTML Java", 0);
81     public final static Capability HTML_JAVA_1_0 = new Capability ("HMTL Java 1.0", 1);
82     public final static Capability HTML_JAVA_1_1 = new Capability ("HTML Java 1.1", 2);
83     public final static Capability HTML_JAVA_1_2 = new Capability ("HTML Java 1.2", 3);
84
85     public final static Capability HTML_JAVASCRIPT = new Capability ("HTML JavaScript", 4);
86     public final static Capability HTML_JAVASCRIPT_1_0 = new Capability ("HTML JavaScript 1.0", 5);
87     public final static Capability HTML_JAVASCRIPT_1_1 = new Capability ("HTML JavaScript 1.1", 6);
88     public final static Capability HTML_JAVASCRIPT_1_2 = new Capability ("HTML JavaScript 1.2", 7);
89
90     public final static Capability HTML_TABLE = new Capability ("HTML Table Support", 8);
91     public final static Capability HTML_NESTED_TABLE = new Capability ("HTML Nested Table Support", 9);
92
93     public final static Capability HTML_FORM = new Capability ("HTML Forms Support", 10);
94
95     public final static Capability HTML_FRAME = new Capability ("HTML Frames Support", 11);
96
97     public final static Capability HTML_IMAGE = new Capability ("HTML Images Support", 12);
98
99     public final static Capability HTML_ACTIVE_X = new Capability ("HTML Active X", 13);
100
101     public final static Capability HTML_CSS1 = new Capability ("HTML CSS1 Support", 14);
102     public final static Capability HTML_CSS2 = new Capability ("HTML CSS2 Support", 15);
103     public final static Capability HTML_CSSP = new Capability ("HTML CSSP Support", 16);
104
105     public final static Capability WML_TABLE = new Capability ("WML Table Support", 17);
106
107     public final static Capability HTTP_COOKIE = new Capability ("HTTP Cookie Support", 18);
108
109     static
110     {
111         HTML_JAVASCRIPT_1_0.implies (HTML_JAVASCRIPT);
112         HTML_JAVASCRIPT_1_1.implies (HTML_JAVASCRIPT);
113         HTML_JAVASCRIPT_1_2.implies (HTML_JAVASCRIPT);
114
115         HTML_JAVA_1_0.implies (HTML_JAVA);
116         HTML_JAVA_1_1.implies (HTML_JAVA);
117         HTML_JAVA_1_2.implies (HTML_JAVA);
118
119         // need many more...
120
}
121
122     /**
123      ** Returns a hash code for this capability.
124      **
125      ** @return the hash code
126      **/

127
128     public int hashCode ()
129     {
130         return (value);
131     }
132
133     /**
134      ** Returns whether this and the given object represent the same
135      ** capability.
136      **
137      ** @param object
138      ** the object to compare with
139      **
140      ** @return <CODE>true</CODE> if the objects represent the same capability, <BR>
141      ** <CODE>false</CODE> otherwise
142      **/

143
144     public boolean equals (Object JavaDoc object)
145     {
146         boolean result = false;
147
148         if (object instanceof Capability)
149         {
150             result = (this.getClass () == object.getClass () &&
151                       this.getValue () == ((Capability) object).getValue ());
152         }
153
154         return (result);
155     }
156
157     /**
158      ** Returns the capability as a displayable string.
159      **
160      ** @return the displayable string
161      **/

162
163     public String JavaDoc toString ()
164     {
165         return (identifier);
166     }
167
168     /**
169      ** Returns the identifier of this capability.
170      **
171      ** @return the capability
172      **/

173
174     public String JavaDoc getIdentifier ()
175     {
176         return (identifier);
177     }
178
179     /**
180      ** Returns the integer value of this capability.
181      **
182      ** @return the integer value
183      **/

184
185     protected int getValue ()
186     {
187         return (value);
188     }
189
190     private String JavaDoc identifier;
191
192     private int value;
193
194     /**
195      ** Constructs a capability.
196      **
197      ** @param identifier
198      ** the identifier of the capability
199      ** @param value
200      ** the integer value of the capability
201      **/

202
203     private Capability (String JavaDoc identifier, int value)
204     {
205         this.identifier = identifier;
206         this.value = value;
207
208         capabilities.add (this);
209     }
210
211     /**
212      ** Registers an implied capability with this capability.
213      **
214      ** @param capability
215      ** the implied capability
216      **/

217
218     private void implies (Capability capability)
219     {
220         impliedCapabilities.add (capability);
221     }
222 }
223
224
Popular Tags