KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > net > sf > invicta > type > BasicDefinedProperty


1 package net.sf.invicta.type;
2
3 import net.sf.invicta.api.DefinedProperty;
4
5 /**
6  *
7  */

8 public class BasicDefinedProperty {
9     protected String JavaDoc type;
10     protected String JavaDoc name;
11     protected String JavaDoc valueTemplate = null;
12     protected String JavaDoc defaultValue = null;
13     protected String JavaDoc description;
14
15     /**
16      *
17      *
18      */

19     public BasicDefinedProperty() {
20         
21     }
22     
23     /**
24      *
25      */

26     public BasicDefinedProperty(String JavaDoc name, String JavaDoc type, String JavaDoc defaultValue,
27                                 String JavaDoc valueTemplate, String JavaDoc description) {
28         this.name = name;
29         this.type = type;
30         this.valueTemplate = valueTemplate;
31         this.defaultValue = defaultValue;
32         this.description = description;
33     }
34     
35     /**
36      *
37      */

38     public BasicDefinedProperty(BasicDefinedProperty other) {
39         this.name = other.getName();
40         this.type = other.getType();
41         this.valueTemplate = other.getValueTemplate();
42         this.defaultValue = other.getDefaultValue();
43         this.description = other.getDescription();
44     }
45
46     /**
47      *
48      */

49     public void checkRequiredAttributes() throws InvictaTypeException {
50         if ((this.defaultValue == null) &&
51             (this.isLocalType() || this.isGeneralType()))
52             throw InvictaTypeException.missingPropertyAttribute(name, "defaultValue");
53     }
54             
55     /**
56      * Returns the name of the defined property.
57      * @return String. Property name. For example: src.dir
58      */

59     public String JavaDoc getName() {
60         return name;
61     }
62
63     /**
64      * Returns the type of the defined type.
65      * @return String. Property type. One of the following: general, component, project and local.
66      */

67     public String JavaDoc getType() {
68         return type;
69     }
70
71     /**
72      * Sets the name.
73      * @param name The name to set
74      */

75     public void setName(String JavaDoc name) {
76         this.name = name;
77     }
78
79     /**
80      * Sets the type.
81      * @param type The type to set
82      */

83     public void setType(String JavaDoc type) {
84         this.type = type;
85     }
86     
87     /**
88      *
89      * @return boolean. true if this is a general property.
90      */

91     public boolean isGeneralType() {
92         return this.type.equalsIgnoreCase(DefinedProperty.TYPE_GENERAL);
93     }
94     
95     /**
96      *
97      * @return boolean. true if this is a component property.
98      */

99     public boolean isComponentType() {
100         return this.type.equalsIgnoreCase(DefinedProperty.TYPE_COMPONENT);
101     }
102     
103     /**
104      *
105      * @return boolean. true if this is a project property.
106      */

107     public boolean isProjectType() {
108         return this.type.equalsIgnoreCase(DefinedProperty.TYPE_PROJECT);
109     }
110     
111     /**
112      *
113      * @return boolean. true if this is a local property.
114      */

115     public boolean isLocalType() {
116         return this.type.equalsIgnoreCase(DefinedProperty.TYPE_LOCAL);
117     }
118     /**
119      * Returns the value.
120      * @return String
121      */

122     public String JavaDoc getValueTemplate() {
123         return valueTemplate;
124     }
125
126     /**
127      * Sets the value.
128      * @param value The value to set
129      */

130     public void setValueTemplate(String JavaDoc value) {
131         this.valueTemplate = value;
132     }
133
134     
135     /**
136      * Returns the defaultValue.
137      * @return String
138      */

139     public String JavaDoc getDefaultValue() {
140         return defaultValue;
141     }
142
143     /**
144      * Sets the defaultValue.
145      * @param defaultValue The defaultValue to set
146      */

147     public void setDefaultValue(String JavaDoc defaultValue) {
148         this.defaultValue = defaultValue;
149     }
150
151     /**
152      *
153      */

154     public boolean equals(BasicDefinedProperty other) {
155                 
156         return equals(this.type, other.getType()) &&
157                 equals(this.name, other.getName()) &&
158                 equals(this.valueTemplate, other.getValueTemplate()) &&
159                 equals(this.defaultValue, other.getDefaultValue());
160     }
161
162     /**
163      *
164      */

165     private boolean equals(Object JavaDoc o1, Object JavaDoc o2) {
166         if ((o1 == null) && (o2 == null))
167             return true;
168         if ((o1 == null) || (o2 == null))
169             return false;
170         return o1.equals(o2);
171     }
172
173     /**
174      *
175      */

176     public String JavaDoc getDescription() {
177         return description;
178     }
179
180     /**
181      *
182      */

183     public void setDescription(String JavaDoc description) {
184         this.description = description;
185     }
186
187 }
188
Popular Tags