KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > objectweb > medor > lib > BasicField


1 /**
2  * MEDOR: Middleware Enabling Distributed Object Requests
3  *
4  * Copyright (C) 2001-2003 France Telecom R&D
5  * Contact: alexandre.lefebvre@rd.francetelecom.com
6  *
7  * This library is free software; you can redistribute it and/or
8  * modify it under the terms of the GNU Lesser General Public
9  * License as published by the Free Software Foundation; either
10  * version 2.1 of the License, or (at your option) any later version.
11  *
12  * This library 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 library; if not, write to the Free Software
19  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20  *
21  * Initial developers: M. Alia, A. Lefebvre, S. Chassande-Barrioz
22  */

23
24 package org.objectweb.medor.lib;
25
26 import org.objectweb.medor.api.Field;
27 import org.objectweb.medor.api.MedorException;
28 import org.objectweb.medor.clone.lib.BasicCloneable;
29 import org.objectweb.jorm.type.api.PType;
30 import org.objectweb.util.monolog.api.Logger;
31
32 import java.util.Map JavaDoc;
33
34 public class BasicField extends BasicCloneable implements Field {
35     protected String JavaDoc name;
36     protected PType type;
37     protected short valueState;
38     transient protected Logger logger;
39
40     public BasicField() {
41         logger = Log.getLoggerFactory().getLogger(getClass().getName());
42     }
43
44     public BasicField(String JavaDoc name) {
45         this();
46         this.name = name;
47     }
48
49     public BasicField(String JavaDoc name, PType type) {
50         this(name);
51         this.type = type;
52     }
53
54     public BasicField(String JavaDoc name, PType type, short valueState)
55         throws MedorException {
56         this(name, type);
57         if ((valueState != Field.NONULLS) &&
58             (valueState != Field.NULLABLE) &&
59             (valueState != Field.NULLABLEUNKNOWN)) {
60             throw new MedorException("invalid nulStatus Field Error: " + valueState);
61         }
62         this.valueState = valueState;
63     }
64
65     public Object JavaDoc clone(Object JavaDoc clone,
66                         Map JavaDoc obj2clone) throws CloneNotSupportedException JavaDoc {
67         clone = super.clone(clone, obj2clone);
68         ((BasicField) clone).name = name;
69         ((BasicField) clone).type = type;
70         ((BasicField) clone).valueState = valueState;
71         return clone;
72     }
73
74     public String JavaDoc getName() {
75         return name;
76     }
77
78     public PType getType() {
79         return type;
80     }
81
82     public short getNullStatus() {
83         return valueState;
84     }
85
86     public String JavaDoc toString() {
87         return name;
88     }
89
90     public int compareTo(Object JavaDoc o) {
91         BasicField bf = (BasicField) o;
92         return name.compareTo(bf.name);
93     }
94 }
95
Popular Tags