KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > enhydra > dods > trans > Referrer


1 /*
2  * Enhydra Java Application Server Project
3  *
4  * The contents of this file are subject to the Enhydra Public License
5  * Version 1.1 (the "License"); you may not use this file except in
6  * compliance with the License. You may obtain a copy of the License on
7  * the Enhydra web site ( http://www.enhydra.org/ ).
8  *
9  * Software distributed under the License is distributed on an "AS IS"
10  * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
11  * the License for the specific terms governing rights and limitations
12  * under the License.
13  *
14  * The Initial Developer of the Enhydra Application Server is Lutris
15  * Technologies, Inc. The Enhydra Application Server and portions created
16  * by Lutris Technologies, Inc. are Copyright Lutris Technologies, Inc.
17  * All Rights Reserved.
18  *
19  * Contributor(s):
20  *
21  * $Id: Referrer.java,v 1.1 2004/09/03 13:43:13 sinisa Exp $
22  */

23
24 /*
25  *
26  * @author Nenad Vico
27  * @since LBS1.8
28  * @version $Revision: 1.1 $
29  *
30  */

31 package org.enhydra.dods.trans;
32
33 import java.util.ArrayList JavaDoc;
34
35 /**
36  * This class represents referrer object. When one table references another table, information about referrer table
37  * is saved in this class.
38  */

39 public class Referrer {
40     
41     /**
42      * List of referrer attributes.
43      */

44     protected ArrayList JavaDoc refAttr = new ArrayList JavaDoc();
45
46     /**
47      * referrer name
48      */

49     protected String JavaDoc name = null;
50
51     /**
52      * referrer package
53      */

54     protected String JavaDoc pckg = null;
55
56     /**
57      * referrer security
58      */

59     protected boolean do_secure = DefaultTagValues.DO_SECURITY;
60
61     /**
62      * constructor (String, String)
63      *
64      * @param pckg Referrer package.
65      * @param name Referrer package.
66      */

67     public Referrer(String JavaDoc pckg, String JavaDoc name) {
68         this.name = name;
69         this.pckg = pckg;
70     }
71
72     /**
73      * Add referrer attribute.
74      *
75      * @param name Name of attribute.
76      * @param do_name Name of DO class which references current table.
77      */

78     public void addAttribute(String JavaDoc name, String JavaDoc do_name, boolean isSecure) {
79         refAttr.add(new RefAttr(name, do_name, isSecure));
80     }
81
82     /**
83      * Add referrer attribute.
84      *
85      * @param attr Referrer attribute.
86      */

87     public void addAttribute(RefAttr attr) {
88         refAttr.add(attr);
89     }
90
91     /**
92      * Get number of referrer attributes.
93      *
94      * @return Number of referrer attributes.
95      */

96     public int size() {
97         return refAttr.size();
98     }
99
100     /**
101      * Get referrer name.
102      *
103      * @return Referrer name.
104      */

105     public String JavaDoc name() {
106         return name;
107     }
108
109     /**
110      * Set referrer security.
111      *
112      * @param is_secure true/false
113      */

114     public void secure(boolean is_secure) {
115         do_secure = is_secure;
116     }
117     
118     /**
119      * Get referrer secyrity.
120      *
121      * @return if Referrer is security based.
122      */

123     public boolean isSecure() {
124         return do_secure;
125     }
126     
127     /**
128      * Get referrer package.
129      *
130      * @return Referrer package.
131      */

132     public String JavaDoc pckg() {
133         return pckg;
134     }
135
136     /**
137      * Get referrer attributes.
138      *
139      * @return Referrer attributes.
140      */

141     public ArrayList JavaDoc referrerAttributes() {
142         return refAttr;
143     }
144
145     /**
146      * Get referrer attribute with appropriate index.
147      *
148      * @param index Index of referrer attribute.
149      *
150      * @return Attribute with appropriate index.
151      */

152     public RefAttr attribute(int index) {
153         return (RefAttr) refAttr.get(index);
154     }
155
156     /**
157      * Get referrer attribute name with appropriate index.
158      *
159      * @param index Index of referrer attribute.
160      *
161      * @return Attribute name with appropriate index.
162      */

163     public String JavaDoc attributeName(int index) {
164         return ((RefAttr) refAttr.get(index)).name();
165     }
166
167     /**
168      * Get referrer attribute DO name with appropriate index.
169      *
170      * @param index Index of referrer attribute.
171      *
172      * @return Attribute DO name with appropriate index.
173      */

174     public String JavaDoc attributeDoName(int index) {
175         return ((RefAttr) refAttr.get(index)).doName();
176     }
177
178     /**
179      * Get referrer generateSecure parameter with appropriate index.
180      *
181      * @param index Index of referrer attribute.
182      *
183      * @return Is column secure based.
184      */

185     public boolean attributeSecurity(int index) {
186         return ((RefAttr) refAttr.get(index)).isSecure();
187     }
188
189     /**
190      * Get String representation.
191      *
192      * @return String representation.
193      */

194     public String JavaDoc toString() {
195         StringBuffer JavaDoc ret = new StringBuffer JavaDoc("name=").append(name).append(" package=").append(pckg).append(" attributes: ");
196
197         for (int i = 0; i < refAttr.size(); i++) {
198             ret.append(refAttr.get(i)).append(" ");
199         }
200         return ret.toString();
201     }
202
203     public static void main(String JavaDoc[] args) {
204         Referrer referrer = new Referrer("package0.package1", "Person");
205
206         referrer.addAttribute("Manager", "package0.package1.Manager", false);
207         referrer.addAttribute("Employee", "package0.package1.Employee", false);
208         System.out.println("Refferer: \n" + referrer);
209     }
210
211     /**
212      * This class represent referrer attribute object.
213      */

214     public class RefAttr {
215
216         /**
217          * referrer attribute name
218          */

219         protected String JavaDoc name = null;
220        
221         /**
222          * referrer attribute DO class name (class which reference current table)
223          */

224         protected String JavaDoc do_name = null;
225         
226         /**
227          * referrer security
228          */

229         protected boolean do_secure = DefaultTagValues.DO_SECURITY;
230
231         /**
232          * Constructor (String, String)
233          *
234          * @param name Referrer attribute name.
235          * @param do_name Attribute do_name.
236          * @param isSecure Attribute isSecure.
237          */

238         public RefAttr(String JavaDoc name, String JavaDoc do_name, boolean isSecure) {
239             this.name = name;
240             this.do_name = do_name;
241             this.do_secure = isSecure;
242         }
243
244         /**
245          * Get referrer attribute name.
246          *
247          * @return Referrer name.
248          */

249         public String JavaDoc name() {
250             return name;
251         }
252     
253         /**
254          * Get referrer attribute DO class name.
255          *
256          * @return Referrer DO class name.
257          */

258         public String JavaDoc doName() {
259             return do_name;
260         }
261     
262         /**
263          * Get referrer secyrity.
264          *
265          * @return if Referrer is security based.
266          */

267         public boolean isSecure() {
268             return do_secure;
269         }
270     
271         /**
272          * Get String representation.
273          *
274          * @return String representation.
275          */

276         public String JavaDoc toString() {
277             return new StringBuffer JavaDoc("name=").append(name).append(" do_name=").append(do_name).toString();
278         }
279     }
280 }
281
Popular Tags