KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > objectweb > jonas_ejb > deployment > api > FieldDesc


1 /**
2  * JOnAS: Java(TM) Open Application Server
3  * Copyright (C) 1999-2004 Bull S.A.
4  * Contact: jonas-team@objectweb.org
5  *
6  * This library is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU Lesser General Public
8  * License as published by the Free Software Foundation; either
9  * version 2.1 of the License, or any later version.
10  *
11  * This library is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14  * Lesser General Public License for more details.
15  *
16  * You should have received a copy of the GNU Lesser General Public
17  * License along with this library; if not, write to the Free Software
18  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
19  * USA
20  *
21  * --------------------------------------------------------------------------
22  * $Id: FieldDesc.java,v 1.7 2004/09/17 09:44:19 joaninh Exp $
23  * --------------------------------------------------------------------------
24  */

25
26
27 package org.objectweb.jonas_ejb.deployment.api;
28
29 /**
30  * Class to hold meta-information related to a cmp-field
31  * @author Christophe Ney [cney@batisseurs.com] : Initial developer
32  * @author Helene Joanin on May 2003: code cleanup
33  */

34 public class FieldDesc {
35
36     protected String JavaDoc fieldName = null;
37     protected boolean pkField = false;
38     protected Class JavaDoc fieldType = null;
39
40
41     /**
42      * Assessor method for primary key field
43      * @return true if field is a primary key
44      */

45     public boolean isPrimaryKey() {
46         return pkField;
47     }
48
49     /**
50      * Field name getter
51      * @return field name
52      */

53     public String JavaDoc getName() {
54         return fieldName;
55     }
56
57     /**
58      * field name setter
59      */

60     protected void setName(String JavaDoc fieldName) {
61         this.fieldName = fieldName;
62     }
63
64     /**
65      * primary key flag setter
66      */

67     protected void setPrimaryKey(boolean pkField) {
68         this.pkField = pkField;
69     }
70
71     /**
72      * field type getter
73      */

74     public Class JavaDoc getFieldType() {
75         return fieldType;
76     }
77
78     /**
79      * field type setter
80      */

81     protected void setFieldType(Class JavaDoc fieldType) {
82         this.fieldType = fieldType;
83     }
84
85     /**
86      * get the setter method name for a given field
87      */

88     public static String JavaDoc getSetterName(String JavaDoc fieldName) {
89         return "set" + Character.toUpperCase(fieldName.charAt(0)) + fieldName.substring(1);
90     }
91
92     /**
93      * get the getter method name for a given field
94      */

95     public static String JavaDoc getGetterName(String JavaDoc fieldName) {
96         return "get" + Character.toUpperCase(fieldName.charAt(0)) + fieldName.substring(1);
97     }
98
99     /**
100      * String representation of the object for test purpose
101      * @return String representation of this object
102      */

103     public String JavaDoc toString() {
104         StringBuffer JavaDoc ret = new StringBuffer JavaDoc();
105         ret.append("\ngetName() = " + getName());
106         ret.append("\ngetFieldType() = " + getFieldType());
107         ret.append("\nisPrimaryKey() = " + isPrimaryKey());
108         return ret.toString();
109     }
110
111 }
112
Popular Tags