KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > beehive > controls > runtime > generator > ControlBean


1 package org.apache.beehive.controls.runtime.generator;
2 /*
3  * Copyright 2004 The Apache Software Foundation.
4  *
5  * Licensed under the Apache License, Version 2.0 (the "License");
6  * you may not use this file except in compliance with the License.
7  * You may obtain a copy of the License at
8  *
9  * http://www.apache.org/licenses/LICENSE-2.0
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  *
17  * $Header:$
18  */

19
20 import com.sun.mirror.type.InterfaceType;
21
22 /**
23  * The ControlBean class is an class representing a generated JavaBean class that can host
24  * control implementation types associated with a particular control public or extension
25  * interface.
26  */

27 public class ControlBean
28 {
29     /**
30      * Constructs a new ControlBean class supporting a particular bean interface
31      * @param controlIntf the public interface associated with the bean
32      */

33     protected ControlBean(AptControlInterface controlIntf)
34     {
35         super();
36         _controlIntf = controlIntf;
37         if (_controlIntf != null)
38         {
39             _packageName = _controlIntf.getPackage();
40             _shortName = _controlIntf.getShortName() + "Bean";
41             _className = _packageName + "." + _shortName;
42             _superClass = new ControlBean(_controlIntf.getSuperClass());
43         }
44         else
45         {
46             Class JavaDoc c = org.apache.beehive.controls.runtime.bean.ControlBean.class;
47             _packageName = c.getPackage().getName();
48             _className = c.getName();
49             _shortName = _className.substring(_packageName.length() + 1);
50         }
51     }
52
53     /**
54      * Returns the fully qualified package name of the ControlBean
55      */

56     public String JavaDoc getPackage() { return _packageName; }
57
58     /**
59      * Returns the unqualified classname of the ControlBean
60      */

61     public String JavaDoc getShortName() { return _shortName; }
62
63     /**
64      * Returns the fully qualified classname of the ControlBean
65      */

66     public String JavaDoc getClassName() { return _className; }
67
68     /**
69      * Returns the class declaration for the ControlBean
70      */

71     public String JavaDoc getClassDeclaration()
72     {
73         StringBuffer JavaDoc sb = new StringBuffer JavaDoc(_shortName);
74         sb.append(_controlIntf.getFormalTypeParameters());
75         return sb.toString();
76     }
77
78     /**
79      * Returns the fully qualified classname of the ControlBean BeanInfo class. The
80      * standard JavaBean naming convention is used to enable automatic location by
81      * the JavaBean introspector.
82      */

83     public String JavaDoc getBeanInfoName() { return _className + "BeanInfo"; }
84
85
86     /**
87      * Returns the class as a Jar Manifest Name attribute
88      */

89     public String JavaDoc getManifestName() { return _className.replace('.','/') + ".class"; }
90
91     /**
92      * Returns the public or extension interface associated with the ControlBean
93      */

94     public AptControlInterface getControlInterface() { return _controlIntf; }
95
96     /**
97      * Returns the super class for this ControlBean
98      */

99     public ControlBean getSuperClass() { return _superClass; }
100
101     /**
102      * Returns any formal type parameters that should be bound for the bean's superclass,
103      * based upon any type bindings that occur on the original interface.
104      */

105     public String JavaDoc getSuperTypeBinding()
106     {
107         InterfaceType superType = _controlIntf.getSuperType();
108         if (superType != null)
109         {
110             String JavaDoc typeStr = superType.toString();
111             int paramIndex = typeStr.indexOf('<');
112             if (paramIndex > 0)
113                 return typeStr.substring(paramIndex);
114         }
115         return "";
116     }
117
118     String JavaDoc _packageName;
119     String JavaDoc _shortName;
120     String JavaDoc _className;
121     AptControlInterface _controlIntf;
122     ControlBean _superClass;
123 }
124
Popular Tags