001 /*
002 * Licensed to the Apache Software Foundation (ASF) under one
003 * or more contributor license agreements. See the NOTICE file
004 * distributed with this work for additional information
005 * regarding copyright ownership. The ASF licenses this file
006 * to you under the Apache License, Version 2.0 (the
007 * "License"); you may not use this file except in compliance
008 * with the License. You may obtain a copy of the License at
009 *
010 * http://www.apache.org/licenses/LICENSE-2.0
011 *
012 * Unless required by applicable law or agreed to in writing,
013 * software distributed under the License is distributed on an
014 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
015 * KIND, either express or implied. See the License for the
016 * specific language governing permissions and limitations
017 * under the License.
018 *
019 */
020 package org.apache.directory.shared.ldap.schema.parsers;
021
022
023 import org.apache.directory.shared.ldap.schema.UsageEnum;
024 import org.apache.directory.shared.ldap.util.ArrayUtils;
025
026
027 /**
028 * A bean used to hold the literal values of an AttributeType parsed out of an
029 * OpenLDAP schema configuration file.
030 *
031 * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
032 * @version $Rev: 504954 $
033 */
034 public class AttributeTypeLiteral
035 {
036 private boolean obsolete = false;
037 private boolean singleValue = false;
038 private boolean collective = false;
039 private boolean noUserModification = false;
040
041 private String oid;
042 private String description;
043 private String superior;
044 private String equality;
045 private String ordering;
046 private String substr;
047 private String syntax;
048
049 private UsageEnum usage = UsageEnum.USER_APPLICATIONS;
050
051 private String[] names = ArrayUtils.EMPTY_STRING_ARRAY;
052
053 private int length = -1;
054
055
056 // ------------------------------------------------------------------------
057 // C O N S T R U C T O R S
058 // ------------------------------------------------------------------------
059
060 public AttributeTypeLiteral(String oid)
061 {
062 this.oid = oid;
063 }
064
065
066 // ------------------------------------------------------------------------
067 // Accessors and mutators
068 // ------------------------------------------------------------------------
069
070 public boolean isObsolete()
071 {
072 return obsolete;
073 }
074
075
076 public void setObsolete( boolean obsolete )
077 {
078 this.obsolete = obsolete;
079 }
080
081
082 public boolean isSingleValue()
083 {
084 return singleValue;
085 }
086
087
088 public void setSingleValue( boolean singleValue )
089 {
090 this.singleValue = singleValue;
091 }
092
093
094 public boolean isCollective()
095 {
096 return collective;
097 }
098
099
100 public void setCollective( boolean collective )
101 {
102 this.collective = collective;
103 }
104
105
106 public boolean isNoUserModification()
107 {
108 return noUserModification;
109 }
110
111
112 public void setNoUserModification( boolean noUserModification )
113 {
114 this.noUserModification = noUserModification;
115 }
116
117
118 public String getOid()
119 {
120 return oid;
121 }
122
123
124 public String getDescription()
125 {
126 return description;
127 }
128
129
130 public void setDescription( String description )
131 {
132 this.description = description;
133 }
134
135
136 public String getSuperior()
137 {
138 return superior;
139 }
140
141
142 public void setSuperior( String superior )
143 {
144 this.superior = superior;
145 }
146
147
148 public String getEquality()
149 {
150 return equality;
151 }
152
153
154 public void setEquality( String equality )
155 {
156 this.equality = equality;
157 }
158
159
160 public String getOrdering()
161 {
162 return ordering;
163 }
164
165
166 public void setOrdering( String ordering )
167 {
168 this.ordering = ordering;
169 }
170
171
172 public String getSubstr()
173 {
174 return substr;
175 }
176
177
178 public void setSubstr( String substr )
179 {
180 this.substr = substr;
181 }
182
183
184 public String getSyntax()
185 {
186 return syntax;
187 }
188
189
190 public void setSyntax( String syntax )
191 {
192 this.syntax = syntax;
193 }
194
195
196 public UsageEnum getUsage()
197 {
198 return usage;
199 }
200
201
202 public void setUsage( UsageEnum usage )
203 {
204 this.usage = usage;
205 }
206
207
208 public String[] getNames()
209 {
210 return names;
211 }
212
213
214 public void setNames( String[] names )
215 {
216 this.names = names;
217 }
218
219
220 public int getLength()
221 {
222 return length;
223 }
224
225
226 public void setLength( int length )
227 {
228 this.length = length;
229 }
230
231
232 // ------------------------------------------------------------------------
233 // Object overrides
234 // ------------------------------------------------------------------------
235
236 /**
237 * Compute the instance's hash code
238 * @return the instance's hash code
239 */
240 public int hashCode()
241 {
242 return getOid().hashCode();
243 }
244
245
246 public boolean equals( Object obj )
247 {
248 if ( this == obj )
249 {
250 return true;
251 }
252
253 if ( !( obj instanceof AttributeTypeLiteral ) )
254 {
255 return false;
256 }
257
258 return getOid().equals( ( ( AttributeTypeLiteral ) obj ).getOid() );
259 }
260
261
262 public String toString()
263 {
264 return getOid();
265 }
266
267 /**
268 * Method used to modify the AttributeType OID if it is edited.
269 */
270 public void setOid( String oid )
271 {
272 this.oid = oid;
273 }
274 }