OpenCores
URL https://opencores.org/ocsvn/openrisc/openrisc/trunk

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [gnu-dev/] [or1k-gcc/] [libjava/] [classpath/] [gnu/] [java/] [beans/] [BeanInfoEmbryo.java] - Blame information for rev 769

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 769 jeremybenn
/* gnu.java.beans.BeanInfoEmbryo
2
   Copyright (C) 1998, 2002 Free Software Foundation, Inc.
3
 
4
This file is part of GNU Classpath.
5
 
6
GNU Classpath is free software; you can redistribute it and/or modify
7
it under the terms of the GNU General Public License as published by
8
the Free Software Foundation; either version 2, or (at your option)
9
any later version.
10
 
11
GNU Classpath is distributed in the hope that it will be useful, but
12
WITHOUT ANY WARRANTY; without even the implied warranty of
13
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14
General Public License for more details.
15
 
16
You should have received a copy of the GNU General Public License
17
along with GNU Classpath; see the file COPYING.  If not, write to the
18
Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
19
02110-1301 USA.
20
 
21
Linking this library statically or dynamically with other modules is
22
making a combined work based on this library.  Thus, the terms and
23
conditions of the GNU General Public License cover the whole
24
combination.
25
 
26
As a special exception, the copyright holders of this library give you
27
permission to link this library with independent modules to produce an
28
executable, regardless of the license terms of these independent
29
modules, and to copy and distribute the resulting executable under
30
terms of your choice, provided that you also meet, for each linked
31
independent module, the terms and conditions of the license of that
32
module.  An independent module is a module which is not derived from
33
or based on this library.  If you modify this library, you may extend
34
this exception to your version of the library, but you are not
35
obligated to do so.  If you do not wish to do so, delete this
36
exception statement from your version. */
37
 
38
 
39
package gnu.java.beans;
40
 
41
import java.beans.BeanDescriptor;
42
import java.beans.BeanInfo;
43
import java.beans.EventSetDescriptor;
44
import java.beans.IndexedPropertyDescriptor;
45
import java.beans.MethodDescriptor;
46
import java.beans.PropertyDescriptor;
47
import java.lang.reflect.Method;
48
import java.util.Arrays;
49
import java.util.Enumeration;
50
import java.util.Hashtable;
51
import java.util.Iterator;
52
import java.util.Map;
53
import java.util.TreeMap;
54
import java.util.Vector;
55
 
56
/**
57
 ** A BeanInfoEmbryo accumulates information about a Bean
58
 ** while it is in the process of being created, and then
59
 ** when you are done accumulating the information, the
60
 ** getBeanInfo() method may be called to create a BeanInfo
61
 ** object based on the information.<P>
62
 **
63
 ** This class is not well-synchronized.  (It can be, it
64
 ** just isn't yet.)
65
 **
66
 ** @author John Keiser
67
 ** @version 1.1.0, 30 Jul 1998
68
 ** @see java.beans.BeanInfo
69
 **/
70
 
71
public class BeanInfoEmbryo {
72
 
73
        // by using a TreeMap the properties will be sorted alphabetically by name
74
        // which matches the (undocumented) behavior of jdk
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
}

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.