KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jboss > beans > info > plugins > AbstractPropertyInfo


1 /*
2 * JBoss, Home of Professional Open Source
3 * Copyright 2005, JBoss Inc., and individual contributors as indicated
4 * by the @authors tag. See the copyright.txt in the distribution for a
5 * full listing of individual contributors.
6 *
7 * This is free software; you can redistribute it and/or modify it
8 * under the terms of the GNU Lesser General Public License as
9 * published by the Free Software Foundation; either version 2.1 of
10 * the License, or (at your option) any later version.
11 *
12 * This software is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Lesser General Public License for more details.
16 *
17 * You should have received a copy of the GNU Lesser General Public
18 * License along with this software; if not, write to the Free
19 * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
20 * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
21 */

22 package org.jboss.beans.info.plugins;
23
24 import org.jboss.beans.info.spi.BeanInfo;
25 import org.jboss.beans.info.spi.PropertyInfo;
26 import org.jboss.reflect.spi.MethodInfo;
27 import org.jboss.reflect.spi.TypeInfo;
28 import org.jboss.util.JBossObject;
29 import org.jboss.util.JBossStringBuilder;
30
31 /**
32  * Property info.
33  *
34  * @author <a HREF="adrian@jboss.com">Adrian Brock</a>
35  * @version $Revision: 57133 $
36  */

37 public class AbstractPropertyInfo extends JBossObject implements PropertyInfo
38 {
39    /** The bean info */
40    protected BeanInfo beanInfo;
41    
42    /** The property name */
43    protected String JavaDoc name;
44
45    /** The upper property name */
46    protected String JavaDoc upperName;
47    
48    /** The type */
49    protected TypeInfo type;
50    
51    /** The getter */
52    protected MethodInfo getter;
53    
54    /** The setter */
55    protected MethodInfo setter;
56
57    /**
58     * Create a new property info
59     */

60    public AbstractPropertyInfo()
61    {
62       this(null, null, null, null, null);
63    }
64
65    /**
66     * Create a new property info
67     *
68     * @param name the name
69     */

70    public AbstractPropertyInfo(String JavaDoc name)
71    {
72       this(name, name, null, null, null);
73    }
74
75    /**
76     * Create a new property info
77     *
78     * @param name the name
79     * @param upperName the upper case version of the name
80     * @param type the type
81     * @param getter the getter
82     * @param setter the setter
83     */

84    public AbstractPropertyInfo(String JavaDoc name, String JavaDoc upperName, TypeInfo type, MethodInfo getter, MethodInfo setter)
85    {
86       this.name = name;
87       this.upperName = upperName;
88       this.type = type;
89       this.getter = getter;
90       this.setter = setter;
91    }
92    
93    public BeanInfo getBeanInfo()
94    {
95       return beanInfo;
96    }
97    
98    public String JavaDoc getName()
99    {
100       return name;
101    }
102    
103    public String JavaDoc getUpperName()
104    {
105       return upperName;
106    }
107    
108    public TypeInfo getType()
109    {
110       return type;
111    }
112
113    public void setType(TypeInfo type)
114    {
115       this.type = type;
116    }
117    
118    public MethodInfo getGetter()
119    {
120       return getter;
121    }
122
123    public void setGetter(MethodInfo getter)
124    {
125       this.getter = getter;
126    }
127    
128    public MethodInfo getSetter()
129    {
130       return setter;
131    }
132
133    public void setSetter(MethodInfo setter)
134    {
135       this.setter = setter;
136    }
137    
138    public boolean equals(Object JavaDoc object)
139    {
140       if (object == null || object instanceof AbstractPropertyInfo == false)
141          return false;
142       
143       AbstractPropertyInfo other = (AbstractPropertyInfo) object;
144       if (notEqual(name, other.name))
145          return false;
146       else if (notEqual(getter, other.getter))
147          return false;
148       else if (notEqual(setter, other.setter))
149          return false;
150       return true;
151    }
152    
153    public void toString(JBossStringBuilder buffer)
154    {
155       buffer.append("name=").append(name);
156       buffer.append(" getter=").append(getter);
157       buffer.append(" setter=").append(setter);
158    }
159    
160    public void toShortString(JBossStringBuilder buffer)
161    {
162       buffer.append(name);
163    }
164
165    public int getHashCode()
166    {
167       return name.hashCode();
168    }
169 }
170
Popular Tags