KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > columba > core > context > base > AttributeType


1 package org.columba.core.context.base;
2
3 import org.columba.core.context.base.api.IAttributeType;
4
5 public class AttributeType implements IAttributeType {
6
7     private String JavaDoc name;
8
9     private String JavaDoc namespace;
10
11     private BASETYPE baseType;
12
13     private Object JavaDoc defaultValue;
14
15     private boolean optional;
16
17     public AttributeType(final String JavaDoc theName, final String JavaDoc theNamespace) {
18         this.name = theName;
19         this.namespace = theNamespace;
20
21         this.baseType = BASETYPE.STRING;
22         optional = true;
23     }
24
25     public BASETYPE getBaseType() {
26         return baseType;
27     }
28
29     public Object JavaDoc getDefaultValue() {
30         return defaultValue;
31     }
32
33     public void setDefaultValue(final Object JavaDoc theDefaultValue) {
34         this.defaultValue = theDefaultValue;
35     }
36
37     public void setBaseType(final BASETYPE type) {
38         this.baseType = type;
39     }
40
41     public String JavaDoc getName() {
42         return name;
43     }
44
45     public String JavaDoc getNamespace() {
46         return namespace;
47     }
48
49     @Override JavaDoc
50     public boolean equals(final Object JavaDoc obj) {
51         final AttributeType t = (AttributeType) obj;
52
53         if (!t.getBaseType().equals(getBaseType())) {
54             return false;
55         }
56
57         if ((t.getDefaultValue() != null) && (getDefaultValue() != null)) {
58             if (!t.getDefaultValue().equals(getDefaultValue())) {
59                 return false;
60             }
61         }
62
63         return true;
64     }
65
66     @Override JavaDoc
67     public String JavaDoc toString() {
68         final StringBuilder JavaDoc buf = new StringBuilder JavaDoc();
69         buf.append("AttributeType["); //$NON-NLS-1$
70
buf.append("name=" + getName()); //$NON-NLS-1$
71
buf.append("namespace=" + getNamespace()); //$NON-NLS-1$
72
buf.append("basetype=" + getBaseType()); //$NON-NLS-1$
73
buf.append(']');
74         return buf.toString();
75     }
76
77     public boolean isOptional() {
78         return optional;
79     }
80
81     public void setOptional(final boolean isOptional) {
82         this.optional = isOptional;
83     }
84
85 }
86
Popular Tags