source: trunk/gcc/libjava/gnu/java/beans/BeanInfoEmbryo.java

Last change on this file was 2, checked in by bird, 22 years ago

Initial revision

  • Property cvs2svn:cvs-rev set to 1.1
  • Property svn:eol-style set to native
  • Property svn:executable set to *
File size: 5.0 KB
Line 
1/* gnu.java.beans.BeanInfoEmbryo
2 Copyright (C) 1998, 2002 Free Software Foundation, Inc.
3
4This file is part of GNU Classpath.
5
6GNU Classpath is free software; you can redistribute it and/or modify
7it under the terms of the GNU General Public License as published by
8the Free Software Foundation; either version 2, or (at your option)
9any later version.
10
11GNU Classpath is distributed in the hope that it will be useful, but
12WITHOUT ANY WARRANTY; without even the implied warranty of
13MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14General Public License for more details.
15
16You should have received a copy of the GNU General Public License
17along with GNU Classpath; see the file COPYING. If not, write to the
18Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
1902111-1307 USA.
20
21Linking this library statically or dynamically with other modules is
22making a combined work based on this library. Thus, the terms and
23conditions of the GNU General Public License cover the whole
24combination.
25
26As a special exception, the copyright holders of this library give you
27permission to link this library with independent modules to produce an
28executable, regardless of the license terms of these independent
29modules, and to copy and distribute the resulting executable under
30terms of your choice, provided that you also meet, for each linked
31independent module, the terms and conditions of the license of that
32module. An independent module is a module which is not derived from
33or based on this library. If you modify this library, you may extend
34this exception to your version of the library, but you are not
35obligated to do so. If you do not wish to do so, delete this
36exception statement from your version. */
37
38
39package gnu.java.beans;
40
41import java.beans.*;
42import java.util.*;
43import gnu.java.lang.*;
44import java.lang.reflect.*;
45
46/**
47 ** A BeanInfoEmbryo accumulates information about a Bean
48 ** while it is in the process of being created, and then
49 ** when you are done accumulating the information, the
50 ** getBeanInfo() method may be called to create a BeanInfo
51 ** object based on the information.<P>
52 **
53 ** This class is not well-synchronized. (It can be, it
54 ** just isn't yet.)
55 **
56 ** @author John Keiser
57 ** @version 1.1.0, 30 Jul 1998
58 ** @see java.beans.BeanInfo
59 **/
60
61public class BeanInfoEmbryo {
62 Hashtable properties = new Hashtable();
63 Hashtable events = new Hashtable();
64 Vector methods = new Vector();
65
66 BeanDescriptor beanDescriptor;
67 BeanInfo[] additionalBeanInfo;
68 java.awt.Image[] im;
69 String defaultPropertyName;
70 String defaultEventName;
71
72 public BeanInfoEmbryo() {
73 }
74
75 public BeanInfo getBeanInfo() {
76 int defaultProperty = -1;
77 int defaultEvent = -1;
78
79 PropertyDescriptor[] Aproperties = new PropertyDescriptor[properties.size()];
80 int i = 0;
81 Enumeration enum = properties.elements();
82 while(enum.hasMoreElements()) {
83 Aproperties[i] = (PropertyDescriptor)enum.nextElement();
84 if(defaultPropertyName != null && Aproperties[i].getName().equals(defaultPropertyName)) {
85 defaultProperty = i;
86 }
87 i++;
88 }
89
90 EventSetDescriptor[] Aevents = new EventSetDescriptor[events.size()];
91 i = 0;
92 enum = events.elements();
93 while(enum.hasMoreElements()) {
94 Aevents[i] = (EventSetDescriptor)enum.nextElement();
95 if(defaultEventName != null && Aevents[i].getName().equals(defaultEventName)) {
96 defaultEvent = i;
97 }
98 i++;
99 }
100
101 MethodDescriptor[] Amethods = new MethodDescriptor[methods.size()];
102 methods.copyInto(Amethods);
103
104 return new ExplicitBeanInfo(beanDescriptor,additionalBeanInfo,Aproperties,defaultProperty,Aevents,defaultEvent,Amethods,im);
105 }
106
107 public void setBeanDescriptor(BeanDescriptor b) {
108 beanDescriptor = b;
109 }
110
111 public void setAdditionalBeanInfo(BeanInfo[] b) {
112 additionalBeanInfo = b;
113 }
114
115 public boolean hasProperty(PropertyDescriptor p) {
116 return properties.get(p.getName()) != null;
117 }
118 public void addProperty(PropertyDescriptor p) {
119 properties.put(p.getName(),p);
120 }
121 public void addIndexedProperty(IndexedPropertyDescriptor p) {
122 properties.put(p.getName(),p);
123 }
124
125 public boolean hasEvent(EventSetDescriptor e) {
126 return events.get(e.getName()) != null;
127 }
128 public void addEvent(EventSetDescriptor e) {
129 events.put(e.getName(),e);
130 }
131
132 public boolean hasMethod(MethodDescriptor m) {
133 for(int i=0;i<methods.size();i++) {
134 Method thisMethod = ((MethodDescriptor)methods.elementAt(i)).getMethod();
135 if(m.getMethod().getName().equals(thisMethod.getName())
136 && Arrays.equals(m.getMethod().getParameterTypes(),
137 thisMethod.getParameterTypes())) {
138 return true;
139 }
140 }
141 return false;
142 }
143 public void addMethod(MethodDescriptor m) {
144 methods.addElement(m);
145 }
146
147 public void setDefaultPropertyName(String defaultPropertyName) {
148 this.defaultPropertyName = defaultPropertyName;
149 }
150
151 public void setDefaultEventName(String defaultEventName) {
152 this.defaultEventName = defaultEventName;
153 }
154
155 public void setIcons(java.awt.Image[] im) {
156 this.im = im;
157 }
158}
Note: See TracBrowser for help on using the repository browser.