1:
37:
38:
39: package ;
40:
41: import ;
42: import ;
43: import ;
44: import ;
45: import ;
46: import ;
47: import ;
48: import ;
49: import ;
50: import ;
51: import ;
52: import ;
53: import ;
54: import ;
55:
56:
70:
71: public class BeanInfoEmbryo {
72:
73:
74:
75: TreeMap properties = new TreeMap();
76: Hashtable events = new Hashtable();
77: Vector methods = new Vector();
78:
79: BeanDescriptor beanDescriptor;
80: BeanInfo[] additionalBeanInfo;
81: java.awt.Image[] im;
82: String defaultPropertyName;
83: String defaultEventName;
84:
85: public BeanInfoEmbryo() {
86: }
87:
88: public BeanInfo getBeanInfo() {
89: int defaultProperty = -1;
90: int defaultEvent = -1;
91:
92: PropertyDescriptor[] Aproperties = new PropertyDescriptor[properties.size()];
93: int i = 0;
94: Iterator it = properties.entrySet().iterator();
95: while (it.hasNext()) {
96: Aproperties[i] = (PropertyDescriptor) (((Map.Entry)it.next()).getValue());
97: if(defaultPropertyName != null && Aproperties[i].getName().equals(defaultPropertyName)) {
98: defaultProperty = i;
99: }
100: i++;
101: }
102:
103: EventSetDescriptor[] Aevents = new EventSetDescriptor[events.size()];
104: i = 0;
105: Enumeration e = events.elements();
106: while (e.hasMoreElements()) {
107: Aevents[i] = (EventSetDescriptor) e.nextElement();
108: if(defaultEventName != null && Aevents[i].getName().equals(defaultEventName)) {
109: defaultEvent = i;
110: }
111: i++;
112: }
113:
114: MethodDescriptor[] Amethods = new MethodDescriptor[methods.size()];
115: methods.copyInto(Amethods);
116:
117: return new ExplicitBeanInfo(beanDescriptor,additionalBeanInfo,Aproperties,defaultProperty,Aevents,defaultEvent,Amethods,im);
118: }
119:
120: public void setBeanDescriptor(BeanDescriptor b) {
121: beanDescriptor = b;
122: }
123:
124: public void setAdditionalBeanInfo(BeanInfo[] b) {
125: additionalBeanInfo = b;
126: }
127:
128: public boolean hasProperty(PropertyDescriptor p) {
129: return properties.get(p.getName()) != null;
130: }
131: public void addProperty(PropertyDescriptor p) {
132: properties.put(p.getName(),p);
133: }
134: public void addIndexedProperty(IndexedPropertyDescriptor p) {
135: properties.put(p.getName(),p);
136: }
137:
138: public boolean hasEvent(EventSetDescriptor e) {
139: return events.get(e.getName()) != null;
140: }
141: public void addEvent(EventSetDescriptor e) {
142: events.put(e.getName(),e);
143: }
144:
145: public boolean hasMethod(MethodDescriptor m) {
146: for(int i=0;i<methods.size();i++) {
147: Method thisMethod = ((MethodDescriptor)methods.elementAt(i)).getMethod();
148: if(m.getMethod().getName().equals(thisMethod.getName())
149: && Arrays.equals(m.getMethod().getParameterTypes(),
150: thisMethod.getParameterTypes())) {
151: return true;
152: }
153: }
154: return false;
155: }
156: public void addMethod(MethodDescriptor m) {
157: methods.addElement(m);
158: }
159:
160: public void setDefaultPropertyName(String defaultPropertyName) {
161: this.defaultPropertyName = defaultPropertyName;
162: }
163:
164: public void setDefaultEventName(String defaultEventName) {
165: this.defaultEventName = defaultEventName;
166: }
167:
168: public void setIcons(java.awt.Image[] im) {
169: this.im = im;
170: }
171: }