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;
021
022
023 /**
024 * An abstract Syntax class.
025 *
026 * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
027 * @version $Rev: 664290 $
028 */
029 public abstract class AbstractSyntax extends AbstractSchemaObject implements Syntax
030 {
031 /** the human readable flag */
032 private boolean isHumanReadable = false;
033
034
035 // ------------------------------------------------------------------------
036 // C O N S T R U C T O R S
037 // ------------------------------------------------------------------------
038
039 /**
040 * Creates a Syntax object using a unique OID.
041 *
042 * @param oid
043 * the OID for this Syntax
044 */
045 protected AbstractSyntax(String oid)
046 {
047 super( oid );
048 }
049
050
051 /**
052 * Creates a Syntax object using a unique OID.
053 *
054 * @param oid
055 * the OID for this Syntax
056 * @param isHumanReadable
057 * whether or not Syntax is human readable
058 */
059 protected AbstractSyntax(String oid, boolean isHumanReadable)
060 {
061 super( oid );
062 this.isHumanReadable = isHumanReadable;
063 }
064
065
066 /**
067 * Creates a Syntax object using a unique OID.
068 *
069 * @param oid
070 * the OID for this Syntax
071 * @param description
072 * the description for this Syntax
073 */
074 protected AbstractSyntax(String oid, String description)
075 {
076 super( oid, description );
077 }
078
079
080 /**
081 * Creates a Syntax object using a unique OID.
082 *
083 * @param oid
084 * the OID for this Syntax
085 * @param isHumanReadable
086 * whether or not Syntax is human readable
087 * @param description
088 * the description for this Syntax
089 */
090 protected AbstractSyntax(String oid, String description, boolean isHumanReadable)
091 {
092 super( oid, description );
093 this.isHumanReadable = isHumanReadable;
094 }
095
096
097 // ------------------------------------------------------------------------
098 // Syntax interface methods
099 // ------------------------------------------------------------------------
100
101 /**
102 * @see org.apache.directory.shared.ldap.schema.Syntax#isHumanReadable()
103 * @return true if the syntax can be interpreted by humans, false otherwise
104 */
105 public final boolean isHumanReadable()
106 {
107 return isHumanReadable;
108 }
109
110
111 // ------------------------------------------------------------------------
112 // Protected setters
113 // ------------------------------------------------------------------------
114
115 /**
116 * Sets the human readable flag value.
117 *
118 * @param isHumanReadable
119 * the human readable flag value to set
120 */
121 protected void setHumanReadable( boolean isHumanReadable )
122 {
123 this.isHumanReadable = isHumanReadable;
124 }
125
126
127 // ------------------------------------------------------------------------
128 // Object overloads
129 // ------------------------------------------------------------------------
130
131 /**
132 * Based on the hashCode of the oid property.
133 *
134 * @return the hashCode of the oid String
135 */
136 public int hashCode()
137 {
138 return oid.hashCode();
139 }
140
141
142 /**
143 * If the object implements Syntax and has the same OID as this Syntax then
144 * they are equal.
145 *
146 * @param obj
147 * the object to test for equality
148 * @return true if obj is a Syntax and OID's match
149 */
150 public boolean equals( Object obj )
151 {
152 if ( !super.equals( obj ) )
153 {
154 return false;
155 }
156
157 if ( obj instanceof Syntax )
158 {
159 return true;
160 }
161
162 return false;
163 }
164 }