1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21 package org.onemind.commons.relabean;
22
23 import java.beans.FeatureDescriptor;
24 import java.io.IOException;
25 import java.io.Writer;
26 import java.lang.reflect.Method;
27 /***
28 * Describe relation between a bean and another bean
29 *
30 * @author TiongHiang Lee (thlee@onemindsoft.org)
31 * @version $Id: RelationDescriptor.java,v 1.2 2004/08/26 16:28:58 thlee Exp $ $Name: $
32 */
33 public class RelationDescriptor extends FeatureDescriptor
34 {
35
36 /*** name * */
37 private String _name;
38
39 /*** the relation type * */
40 private Class _relationType;
41
42 /*** the set method * */
43 private Method _writeMethod;
44
45 /*** the get method * */
46 private Method _readMethod;
47
48 /*** the add method * */
49 private Method _addMethod;
50
51 /*** the remove method * */
52 private Method _removeMethod;
53
54 /*** the member type * */
55 private Class _memberType;
56
57 /***
58 * Constructor {@inheritDoc}
59 */
60 public RelationDescriptor(String name, Class type, Method readMethod,
61 Method writeMethod)
62 {
63 _name = name;
64 _relationType = type;
65 _readMethod = readMethod;
66 _writeMethod = writeMethod;
67 }
68
69 /***
70 * Constructor {@inheritDoc}
71 */
72 public RelationDescriptor(String name, Class type, Method readMethod,
73 Method writeMethod, Class memberType, Method addMethod,
74 Method removeMethod)
75 {
76 this(name, type, readMethod, writeMethod);
77 _memberType = memberType;
78 _addMethod = addMethod;
79 _removeMethod = removeMethod;
80 }
81
82 /***
83 * Returns the getMethod.
84 *
85 * @return the getMethod.
86 */
87 public Method getReadMethod()
88 {
89 return _readMethod;
90 }
91
92 /***
93 * Returns the name.
94 *
95 * @return the name
96 */
97 public String getName()
98 {
99 return _name;
100 }
101
102 /***
103 * Returns the removeMethod.
104 *
105 * @return the remove method
106 */
107 public Method getRemoveMethod()
108 {
109 return _removeMethod;
110 }
111
112 /***
113 * Returns the writeMethod.
114 *
115 * @return the writeMethod
116 */
117 public Method getWriteMethod()
118 {
119 return _writeMethod;
120 }
121
122 /***
123 * Get the add method
124 *
125 * @return the add method
126 */
127 public Method getAddMethod()
128 {
129 return _addMethod;
130 }
131
132 /***
133 * Set the method
134 *
135 * @param method the set method
136 */
137 public void setAddMethod(Method method)
138 {
139 _addMethod = method;
140 }
141
142 /***
143 * Return relation type
144 *
145 * @return the relation type
146 */
147 public Class getRelationType()
148 {
149 return _relationType;
150 }
151
152 /***
153 * Dump the property
154 *
155 * @param prefix the prefix
156 * @param writer the writer
157 * @throws IOException if there's IO problem
158 */
159 public void dump(String prefix, Writer writer) throws IOException
160 {
161 writer.write(prefix + "Relation name: " + getName() + "\n");
162 writer.write(prefix + "\ttype: " + getRelationType() + "\n");
163 writer.write(prefix + "\tmember type: " + getMemberType() + "\n");
164 writer.write(prefix + "\treadMethod: " + getReadMethod() + "\n");
165 writer.write(prefix + "\twriteMethod: " + getWriteMethod() + "\n");
166 writer.write(prefix + "\taddMethod: " + getAddMethod() + "\n");
167 writer.write(prefix + "\tremoveMethod: " + getRemoveMethod() + "\n");
168 }
169
170 /***
171 * Get the member type
172 *
173 * @return the member type
174 */
175 public Class getMemberType()
176 {
177 return _memberType;
178 }
179
180 /***
181 * Set the member type
182 *
183 * @param c the member type to set
184 */
185 public void setMemberType(Class c)
186 {
187 _memberType = c;
188 }
189
190 /***
191 * Set the read method
192 *
193 * @param method the read method
194 */
195 public void setReadMethod(Method method)
196 {
197 _readMethod = method;
198 }
199
200 /***
201 * Set the relation type
202 *
203 * @param class1 the type
204 */
205 public void setRelationType(Class class1)
206 {
207 _relationType = class1;
208 }
209
210 /***
211 * Set the remove method
212 *
213 * @param method the method
214 */
215 public void setRemoveMethod(Method method)
216 {
217 _removeMethod = method;
218 }
219
220 /***
221 * Set the write method
222 *
223 * @param method the method
224 */
225 public void setWriteMethod(Method method)
226 {
227 _writeMethod = method;
228 }
229 }