KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > go > teaservlet > TeaToolsContext


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

52
53 package com.go.teaservlet;
54
55 import com.go.teatools.*;
56
57 import java.beans.*;
58 import java.lang.reflect.*;
59
60 /******************************************************************************
61  * A Tea Tool's best friend. This class has several useful methods for writing
62  * tools that work with Tea. Many of these methods were taken from Kettle
63  * 3.0.x so that they could be reused in future versions and in other
64  * applications.
65  * <p>
66  * This class was written with the intent that it could be used as a tea
67  * context class. It provides a collection of functions to make introspection
68  * possible from Tea.
69  *
70  * @author Mark Masse
71  * @version
72  * <!--$$Revision:--> 3 <!-- $-->, <!--$$JustDate:--> 12/06/00 <!-- $-->
73  */

74 public interface TeaToolsContext {
75
76     /**
77      * Returns a bean full of handy information about the specified class.
78      */

79     public HandyClassInfo getHandyClassInfo(Class JavaDoc clazz);
80
81     /**
82      * Returns a bean full of handy information about the specified class.
83      */

84     public HandyClassInfo getHandyClassInfo(String JavaDoc className);
85
86     /**
87      * Returns the first sentence of the specified paragraph. Uses
88      * <code>java.text.BreakIterator.getSentenceInstance()</code>
89      */

90     public String JavaDoc getFirstSentence(String JavaDoc paragraph);
91
92     /**
93      * Creates a String with the specified pattern repeated length
94      * times.
95      */

96     public String JavaDoc createPatternString(String JavaDoc pattern, int length);
97
98     /**
99      * Creates a String of spaces with the specified length.
100      */

101     public String JavaDoc createWhitespaceString(int length);
102
103     /**
104      * provides a bean to contain an assortment of methods to handle class
105      * names and properties.
106      */

107     interface HandyClassInfo {
108     
109          /**
110           * Returns the class name of the specified class. This method
111           * provides special formatting for array and inner classes.
112           */

113          public String JavaDoc getFullName();
114         
115         
116         /**
117          * Returns the class name of the specified class. The class name returned
118          * does not include the package. This method provides special formatting
119          * for array and inner classes.
120          */

121         public String JavaDoc getName();
122
123         /**
124          * Returns the package name of the specified class. Returns null if the
125          * class has no package.
126          */

127         public String JavaDoc getPackage();
128
129         /**
130          * Returns the type.
131          */

132         public Class JavaDoc getType();
133         
134         /**
135          * Returns the name of the type of the Class described by this
136          * TypeDescription.
137          * <p>
138          * <UL>
139          * <LI>A Class returns "class"
140          * <LI>An Interface returns "interface"
141          * <LI>An array returns null
142          * <LI>A primitive returns null
143          * </UL>
144          */

145         public String JavaDoc getTypeName();
146    
147         /**
148          * Returns the array type. Returns the specified class if it is
149          * not an array.
150          */

151         public TypeDescription getArrayType();
152
153         /**
154          * Returns the array dimensions.
155          * Returns 0 if the specified class is not an array.
156          */

157         public int getArrayDimensions();
158
159         /**
160          * Returns the array dimensions String (i.e. "[][][]").
161          * Returns "" (empty string) if the specified class is not an array.
162          */

163         public String JavaDoc getArrayDimensionsString();
164
165         /**
166          * Returns the shortDescription or "" if the
167          * shortDescription is the same as the displayName.
168          */

169         public String JavaDoc getDescription();
170         
171         /**
172          * Returns the first sentence of the
173          * shortDescription. Returns "" if the shortDescription is the same as
174          * the displayName (the default for reflection-generated
175          * FeatureDescriptors).
176          */

177         public String JavaDoc getDescriptionFirstSentence();
178         
179         /**
180          * Create a version information string based on what the build process
181          * provided. The string is of the form "M.m.r" or
182          * "M.m.r.bbbb" (i.e. 1.1.0.0004) if the build number can be retrieved.
183          * Returns <code>null</code> if the version string cannot be retrieved.
184          */

185         public String JavaDoc getVersion();
186
187         /**
188          * Introspects a Java bean to learn about all its properties,
189          * exposed methods, and events.
190          *
191          * @param beanClass the bean class to be analyzed
192          */

193         public BeanInfo getBeanInfo();
194         
195         /**
196          * Returns the type's MethodDescriptions.
197          */

198         public MethodDescription[] getMethodDescriptions();
199         
200         /**
201          * Returns the type's PropertyDescriptions.
202          */

203         public PropertyDescription[] getPropertyDescriptions();
204         
205         /**
206          * A function that returns an array of all the available properties on
207          * a given class.
208          * <p>
209          * <b>NOTE:</b> If possible, the results of this method should be cached
210          * by the caller.
211          *
212          * @param beanClass the bean class to introspect
213          *
214          * @return an array of all the available properties on the specified class.
215          */

216         public PropertyDescriptor[] getTeaBeanPropertyDescriptors();
217                                                         
218         /**
219          * Gets the MethodDescriptors of the specified context class including
220          * all of the MethodDescriptors for methods declared in the class's
221          * superclass and interfaces
222          *
223          * @param contextClass the Tea context Class to introspect (any class will
224          * work fine)
225          */

226         public MethodDescriptor[] getTeaContextMethodDescriptors();
227
228     }
229 }
230
Popular Tags