directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From elecha...@apache.org
Subject svn commit: r801332 [3/5] - in /directory/shared/trunk: cursor/src/main/java/org/apache/directory/shared/ldap/cursor/ cursor/src/test/java/org/apache/directory/shared/ldap/cursor/ ldap-jndi/src/main/java/org/apache/directory/shared/ldap/jndi/ ldap/src/...
Date Wed, 05 Aug 2009 17:40:51 GMT
Modified: directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/entry/EntryAttribute.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/entry/EntryAttribute.java?rev=801332&r1=801331&r2=801332&view=diff
==============================================================================
--- directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/entry/EntryAttribute.java (original)
+++ directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/entry/EntryAttribute.java Wed Aug  5 17:40:50 2009
@@ -1,471 +1,471 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *  http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.directory.shared.ldap.entry;
-
-import java.io.Externalizable;
-import java.util.Iterator;
-import java.util.List;
-
-import javax.naming.directory.InvalidAttributeValueException;
-
-/**
- * A generic interface mocking the Attribute JNDI interface. This interface
- * will be the base interface for the ServerAttribute and ClientAttribute.
- *
- * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
- * @version $Rev$, $Date$
- */
-public interface EntryAttribute extends Iterable<Value<?>>, Cloneable, Externalizable
-{
-    /**
-     * Adds some values to this attribute. If the new values are already present in
-     * the attribute values, the method has no effect.
-     * <p>
-     * The new values are added at the end of list of values.
-     * </p>
-     * <p>
-     * This method returns the number of values that were added.
-     * </p>
-     * <p>
-     * If the value's type is different from the attribute's type,
-     * a conversion is done. For instance, if we try to set some String
-     * into a Binary attribute, we just store the UTF-8 byte array 
-     * encoding for this String.
-     * </p>
-     * <p>
-     * If we try to store some byte[] in a HR attribute, we try to 
-     * convert those byte[] assuming they represent an UTF-8 encoded
-     * String. Of course, if it's not the case, the stored value will
-     * be incorrect.
-     * </p>
-     * <p>
-     * It's the responsibility of the caller to check if the stored
-     * values are consistent with the attribute's type.
-     * </p>
-     * <p>
-     * The caller can set the HR flag in order to enforce a type for 
-     * the current attribute, otherwise this type will be set while
-     * adding the first value, using the value's type to set the flag.
-     * </p>
-     *
-     * @param vals some new values to be added which may be null
-     * @return the number of added values, or 0 if none has been added
-     */
-    int add( String... vals );
-
-
-    /**
-     * Adds some values to this attribute. If the new values are already present in
-     * the attribute values, the method has no effect.
-     * <p>
-     * The new values are added at the end of list of values.
-     * </p>
-     * <p>
-     * This method returns the number of values that were added.
-     * </p>
-     * If the value's type is different from the attribute's type,
-     * a conversion is done. For instance, if we try to set some String
-     * into a Binary attribute, we just store the UTF-8 byte array 
-     * encoding for this String.
-     * If we try to store some byte[] in a HR attribute, we try to 
-     * convert those byte[] assuming they represent an UTF-8 encoded
-     * String. Of course, if it's not the case, the stored value will
-     * be incorrect.
-     * <br>
-     * It's the responsibility of the caller to check if the stored
-     * values are consistent with the attribute's type.
-     * <br>
-     * The caller can set the HR flag in order to enforce a type for 
-     * the current attribute, otherwise this type will be set while
-     * adding the first value, using the value's type to set the flag.
-     *
-     * @param vals some new values to be added which may be null
-     * @return the number of added values, or 0 if none has been added
-     */
-    int add( byte[]... vals );
-
-
-    /**
-     * Adds some values to this attribute. If the new values are already present in
-     * the attribute values, the method has no effect.
-     * <p>
-     * The new values are added at the end of list of values.
-     * </p>
-     * <p>
-     * This method returns the number of values that were added.
-     * </p>
-     * <p>
-     * If the value's type is different from the attribute's type,
-     * a conversion is done. For instance, if we try to set some 
-     * StringValue into a Binary attribute, we just store the UTF-8 
-     * byte array encoding for this StringValue.
-     * </p>
-     * <p>
-     * If we try to store some BinaryValue in a HR attribute, we try to 
-     * convert those BinaryValue assuming they represent an UTF-8 encoded
-     * String. Of course, if it's not the case, the stored value will
-     * be incorrect.
-     * </p>
-     * <p>
-     * It's the responsibility of the caller to check if the stored
-     * values are consistent with the attribute's type.
-     * </p>
-     * <p>
-     * The caller can set the HR flag in order to enforce a type for 
-     * the current attribute, otherwise this type will be set while
-     * adding the first value, using the value's type to set the flag.
-     * </p>
-     * <p>
-     * <b>Note : </b>If the entry contains no value, and the unique added value
-     * is a null length value, then this value will be considered as
-     * a binary value.
-     * </p>
-     * @param vals some new values to be added which may be null
-     * @return the number of added values, or 0 if none has been added
-     */
-    int add( Value<?>... val );
-    
-    
-    /**
-     * Remove all the values from this attribute.
-     */
-    void clear();
-    
-    
-    /**
-     * @return A clone of the current object
-     */
-    EntryAttribute clone();
-
-
-    /**
-     * <p>
-     * Indicates whether the specified values are some of the attribute's values.
-     * </p>
-     * <p>
-     * If the Attribute is not HR, the values will be converted to byte[]
-     * </p>
-     *
-     * @param vals the values
-     * @return true if this attribute contains all the values, otherwise false
-     */
-    boolean contains( String... vals );
-
-
-    /**
-     * <p>
-     * Indicates whether the specified values are some of the attribute's values.
-     * </p>
-     * <p>
-     * If the Attribute is HR, the values will be converted to String
-     * </p>
-     *
-     * @param vals the values
-     * @return true if this attribute contains all the values, otherwise false
-     */
-    boolean contains( byte[]... vals );
-
-
-    /**
-     * <p>
-     * Indicates whether the specified values are some of the attribute's values.
-     * </p>
-     * <p>
-     * If the Attribute is HR, the binary values will be converted to String before
-     * being checked.
-     * </p>
-     *
-     * @param vals the values
-     * @return true if this attribute contains all the values, otherwise false
-     */
-    boolean contains( Value<?>... vals );
-
-
-    /**
-     * <p>
-     * Get the first value of this attribute. If there is none, 
-     * null is returned.
-     * </p>
-     * <p>
-     * Note : even if we are storing values into a Set, one can assume
-     * the values are ordered following the insertion order.
-     * </p>
-     * <p> 
-     * This method is meant to be used if the attribute hold only one value.
-     * </p>
-     * 
-     *  @return The first value for this attribute.
-     */
-    Value<?> get();
-
-
-    /**
-     * Returns an iterator over all the attribute's values.
-     * <p>
-     * The effect on the returned enumeration of adding or removing values of
-     * the attribute is not specified.
-     * </p>
-     * <p>
-     * This method will throw any <code>NamingException</code> that occurs.
-     * </p>
-     *
-     * @return an enumeration of all values of the attribute
-     */
-    Iterator<Value<?>> getAll();
-
-
-    /**
-     * <p>
-     * Get the nth value of this attribute. If there is none, 
-     * null is returned.
-     * </p>
-     * <p>
-     * Note : even if we are storing values into a Set, one can assume
-     * the values are ordered following the insertion order.
-     * </p>
-     * <p> 
-     * 
-     * @param i the index  of the value to get
-     *  @return The nth value for this attribute.
-     */
-    Value<?> get( int i );
-    
-    
-    /**
-     * <p>
-     * Get the byte[] value, if and only if the value is known to be Binary,
-     * otherwise a InvalidAttributeValueException will be thrown
-     * </p>
-     * <p>
-     * Note that this method returns the first value only.
-     * </p>
-     *
-     * @return The value as a byte[]
-     * @throws InvalidAttributeValueException If the value is a String
-     */
-    byte[] getBytes() throws InvalidAttributeValueException;
-    
-    
-    /**
-     * Get's the attribute identifier for this entry.  This is the value
-     * that will be used as the identifier for the attribute within the
-     * entry.  
-     *
-     * @return the identifier for this attribute
-     */
-    String getId();
-
-    
-    /**
-     * Get's the user provided identifier for this entry.  This is the value
-     * that will be used as the identifier for the attribute within the
-     * entry.  If this is a commonName attribute for example and the user
-     * provides "COMMONname" instead when adding the entry then this is
-     * the format the user will have that entry returned by the directory
-     * server.  To do so we store this value as it was given and track it
-     * in the attribute using this property.
-     *
-     * @return the user provided identifier for this attribute
-     */
-    String getUpId();
-    
-    
-    /**
-     * <p>
-     * Tells if the attribute is Human Readable. 
-     * </p>
-     * <p>This flag is set by the caller, or implicitly when adding String 
-     * values into an attribute which is not yet declared as Binary.
-     * </p> 
-     * @return
-     */
-    boolean isHR();
-
-    
-    /**
-     * <p>
-     * Get the String value, if and only if the value is known to be a String,
-     * otherwise a InvalidAttributeValueException will be thrown
-     * </p>
-     * <p>
-     * Note that this method returns the first value only.
-     * </p>
-     *
-     * @return The value as a String
-     * @throws InvalidAttributeValueException If the value is a byte[]
-     */
-    String getString() throws InvalidAttributeValueException;
-
-    
-    /**
-     * Puts some values to this attribute.
-     * <p>
-     * The new values will replace the previous values.
-     * </p>
-     * <p>
-     * This method returns the number of values that were put.
-     * </p>
-     *
-     * @param val some values to be put which may be null
-     * @return the number of added values, or 0 if none has been added
-     */
-    int put( String... vals );
-
-
-    /**
-     * Puts some values to this attribute.
-     * <p>
-     * The new values will replace the previous values.
-     * </p>
-     * <p>
-     * This method returns the number of values that were put.
-     * </p>
-     *
-     * @param val some values to be put which may be null
-     * @return the number of added values, or 0 if none has been added
-     */
-    int put( byte[]... vals );
-
-    
-    /**
-     * Puts some values to this attribute.
-     * <p>
-     * The new values are replace the previous values.
-     * </p>
-     * <p>
-     * This method returns the number of values that were put.
-     * </p>
-     *
-     * @param val some values to be put which may be null
-     * @return the number of added values, or 0 if none has been added
-     */
-    int put( Value<?>... vals );
-
-
-    /**
-     * <p>
-     * Puts a list of values into this attribute.
-     * </p>
-     * <p>
-     * The new values will replace the previous values.
-     * </p>
-     * <p>
-     * This method returns the number of values that were put.
-     * </p>
-     *
-     * @param vals the values to be put
-     * @return the number of added values, or 0 if none has been added
-     */
-    int put( List<Value<?>> vals );
-
-
-    /**
-     * <p>
-     * Removes all the  values that are equal to the given values.
-     * </p>
-     * <p>
-     * Returns true if all the values are removed.
-     * </p>
-     * <p>
-     * If the attribute type is not HR, then the values will be first converted
-     * to byte[]
-     * </p>
-     *
-     * @param vals the values to be removed
-     * @return true if all the values are removed, otherwise false
-     */
-    boolean remove( String... vals );
-    
-    
-    /**
-     * <p>
-     * Removes all the  values that are equal to the given values.
-     * </p>
-     * <p>
-     * Returns true if all the values are removed. 
-     * </p>
-     * <p>
-     * If the attribute type is HR, then the values will be first converted
-     * to String
-     * </p>
-     *
-     * @param vals the values to be removed
-     * @return true if all the values are removed, otherwise false
-     */
-    boolean remove( byte[]... val );
-
-
-    /**
-     * <p>
-     * Removes all the  values that are equal to the given values.
-     * </p>
-     * <p>
-     * Returns true if all the values are removed.
-     * </p>
-     * <p>
-     * If the attribute type is HR and some value which are not String, we
-     * will convert the values first (same thing for a non-HR attribute).
-     * </p>
-     *
-     * @param vals the values to be removed
-     * @return true if all the values are removed, otherwise false
-     */
-    boolean remove( Value<?>... vals );
-
-    
-    /**
-     * <p>
-     * Set the attribute to Human Readable or to Binary. 
-     * </p>
-     * @param isHR <code>true</code> for a Human Readable attribute, 
-     * <code>false</code> for a Binary attribute.
-     */
-    void setHR( boolean isHR );
-
-    
-    /**
-     * Set the normalized ID. The ID will be lowercased, and spaces
-     * will be trimmed. 
-     *
-     * @param id The attribute ID
-     * @throws IllegalArgumentException If the ID is empty or null or
-     * resolve to an empty value after being trimmed
-     */
-    public void setId( String id );
-
-    
-    /**
-     * Set the user provided ID. It will also set the ID, normalizing
-     * the upId (removing spaces before and after, and lowercasing it)
-     *
-     * @param upId The attribute ID
-     * @throws IllegalArgumentException If the ID is empty or null or
-     * resolve to an empty value after being trimmed
-     */
-    public void setUpId( String upId );
-
-    
-    /**
-      * Retrieves the number of values in this attribute.
-      *
-      * @return the number of values in this attribute, including any values
-      * wrapping a null value if there is one
-      */
-    int size();
-}
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.directory.shared.ldap.entry;
+
+import java.io.Externalizable;
+import java.util.Iterator;
+import java.util.List;
+
+import javax.naming.directory.InvalidAttributeValueException;
+
+/**
+ * A generic interface mocking the Attribute JNDI interface. This interface
+ * will be the base interface for the ServerAttribute and ClientAttribute.
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev$, $Date$
+ */
+public interface EntryAttribute extends Iterable<Value<?>>, Cloneable, Externalizable
+{
+    /**
+     * Adds some values to this attribute. If the new values are already present in
+     * the attribute values, the method has no effect.
+     * <p>
+     * The new values are added at the end of list of values.
+     * </p>
+     * <p>
+     * This method returns the number of values that were added.
+     * </p>
+     * <p>
+     * If the value's type is different from the attribute's type,
+     * a conversion is done. For instance, if we try to set some String
+     * into a Binary attribute, we just store the UTF-8 byte array 
+     * encoding for this String.
+     * </p>
+     * <p>
+     * If we try to store some byte[] in a HR attribute, we try to 
+     * convert those byte[] assuming they represent an UTF-8 encoded
+     * String. Of course, if it's not the case, the stored value will
+     * be incorrect.
+     * </p>
+     * <p>
+     * It's the responsibility of the caller to check if the stored
+     * values are consistent with the attribute's type.
+     * </p>
+     * <p>
+     * The caller can set the HR flag in order to enforce a type for 
+     * the current attribute, otherwise this type will be set while
+     * adding the first value, using the value's type to set the flag.
+     * </p>
+     *
+     * @param vals some new values to be added which may be null
+     * @return the number of added values, or 0 if none has been added
+     */
+    int add( String... vals );
+
+
+    /**
+     * Adds some values to this attribute. If the new values are already present in
+     * the attribute values, the method has no effect.
+     * <p>
+     * The new values are added at the end of list of values.
+     * </p>
+     * <p>
+     * This method returns the number of values that were added.
+     * </p>
+     * If the value's type is different from the attribute's type,
+     * a conversion is done. For instance, if we try to set some String
+     * into a Binary attribute, we just store the UTF-8 byte array 
+     * encoding for this String.
+     * If we try to store some byte[] in a HR attribute, we try to 
+     * convert those byte[] assuming they represent an UTF-8 encoded
+     * String. Of course, if it's not the case, the stored value will
+     * be incorrect.
+     * <br>
+     * It's the responsibility of the caller to check if the stored
+     * values are consistent with the attribute's type.
+     * <br>
+     * The caller can set the HR flag in order to enforce a type for 
+     * the current attribute, otherwise this type will be set while
+     * adding the first value, using the value's type to set the flag.
+     *
+     * @param vals some new values to be added which may be null
+     * @return the number of added values, or 0 if none has been added
+     */
+    int add( byte[]... vals );
+
+
+    /**
+     * Adds some values to this attribute. If the new values are already present in
+     * the attribute values, the method has no effect.
+     * <p>
+     * The new values are added at the end of list of values.
+     * </p>
+     * <p>
+     * This method returns the number of values that were added.
+     * </p>
+     * <p>
+     * If the value's type is different from the attribute's type,
+     * a conversion is done. For instance, if we try to set some 
+     * StringValue into a Binary attribute, we just store the UTF-8 
+     * byte array encoding for this StringValue.
+     * </p>
+     * <p>
+     * If we try to store some BinaryValue in a HR attribute, we try to 
+     * convert those BinaryValue assuming they represent an UTF-8 encoded
+     * String. Of course, if it's not the case, the stored value will
+     * be incorrect.
+     * </p>
+     * <p>
+     * It's the responsibility of the caller to check if the stored
+     * values are consistent with the attribute's type.
+     * </p>
+     * <p>
+     * The caller can set the HR flag in order to enforce a type for 
+     * the current attribute, otherwise this type will be set while
+     * adding the first value, using the value's type to set the flag.
+     * </p>
+     * <p>
+     * <b>Note : </b>If the entry contains no value, and the unique added value
+     * is a null length value, then this value will be considered as
+     * a binary value.
+     * </p>
+     * @param vals some new values to be added which may be null
+     * @return the number of added values, or 0 if none has been added
+     */
+    int add( Value<?>... val );
+    
+    
+    /**
+     * Remove all the values from this attribute.
+     */
+    void clear();
+    
+    
+    /**
+     * @return A clone of the current object
+     */
+    EntryAttribute clone();
+
+
+    /**
+     * <p>
+     * Indicates whether the specified values are some of the attribute's values.
+     * </p>
+     * <p>
+     * If the Attribute is not HR, the values will be converted to byte[]
+     * </p>
+     *
+     * @param vals the values
+     * @return true if this attribute contains all the values, otherwise false
+     */
+    boolean contains( String... vals );
+
+
+    /**
+     * <p>
+     * Indicates whether the specified values are some of the attribute's values.
+     * </p>
+     * <p>
+     * If the Attribute is HR, the values will be converted to String
+     * </p>
+     *
+     * @param vals the values
+     * @return true if this attribute contains all the values, otherwise false
+     */
+    boolean contains( byte[]... vals );
+
+
+    /**
+     * <p>
+     * Indicates whether the specified values are some of the attribute's values.
+     * </p>
+     * <p>
+     * If the Attribute is HR, the binary values will be converted to String before
+     * being checked.
+     * </p>
+     *
+     * @param vals the values
+     * @return true if this attribute contains all the values, otherwise false
+     */
+    boolean contains( Value<?>... vals );
+
+
+    /**
+     * <p>
+     * Get the first value of this attribute. If there is none, 
+     * null is returned.
+     * </p>
+     * <p>
+     * Note : even if we are storing values into a Set, one can assume
+     * the values are ordered following the insertion order.
+     * </p>
+     * <p> 
+     * This method is meant to be used if the attribute hold only one value.
+     * </p>
+     * 
+     *  @return The first value for this attribute.
+     */
+    Value<?> get();
+
+
+    /**
+     * Returns an iterator over all the attribute's values.
+     * <p>
+     * The effect on the returned enumeration of adding or removing values of
+     * the attribute is not specified.
+     * </p>
+     * <p>
+     * This method will throw any <code>NamingException</code> that occurs.
+     * </p>
+     *
+     * @return an enumeration of all values of the attribute
+     */
+    Iterator<Value<?>> getAll();
+
+
+    /**
+     * <p>
+     * Get the nth value of this attribute. If there is none, 
+     * null is returned.
+     * </p>
+     * <p>
+     * Note : even if we are storing values into a Set, one can assume
+     * the values are ordered following the insertion order.
+     * </p>
+     * <p> 
+     * 
+     * @param i the index  of the value to get
+     *  @return The nth value for this attribute.
+     */
+    Value<?> get( int i );
+    
+    
+    /**
+     * <p>
+     * Get the byte[] value, if and only if the value is known to be Binary,
+     * otherwise a InvalidAttributeValueException will be thrown
+     * </p>
+     * <p>
+     * Note that this method returns the first value only.
+     * </p>
+     *
+     * @return The value as a byte[]
+     * @throws InvalidAttributeValueException If the value is a String
+     */
+    byte[] getBytes() throws InvalidAttributeValueException;
+    
+    
+    /**
+     * Get's the attribute identifier for this entry.  This is the value
+     * that will be used as the identifier for the attribute within the
+     * entry.  
+     *
+     * @return the identifier for this attribute
+     */
+    String getId();
+
+    
+    /**
+     * Get's the user provided identifier for this entry.  This is the value
+     * that will be used as the identifier for the attribute within the
+     * entry.  If this is a commonName attribute for example and the user
+     * provides "COMMONname" instead when adding the entry then this is
+     * the format the user will have that entry returned by the directory
+     * server.  To do so we store this value as it was given and track it
+     * in the attribute using this property.
+     *
+     * @return the user provided identifier for this attribute
+     */
+    String getUpId();
+    
+    
+    /**
+     * <p>
+     * Tells if the attribute is Human Readable. 
+     * </p>
+     * <p>This flag is set by the caller, or implicitly when adding String 
+     * values into an attribute which is not yet declared as Binary.
+     * </p> 
+     * @return
+     */
+    boolean isHR();
+
+    
+    /**
+     * <p>
+     * Get the String value, if and only if the value is known to be a String,
+     * otherwise a InvalidAttributeValueException will be thrown
+     * </p>
+     * <p>
+     * Note that this method returns the first value only.
+     * </p>
+     *
+     * @return The value as a String
+     * @throws InvalidAttributeValueException If the value is a byte[]
+     */
+    String getString() throws InvalidAttributeValueException;
+
+    
+    /**
+     * Puts some values to this attribute.
+     * <p>
+     * The new values will replace the previous values.
+     * </p>
+     * <p>
+     * This method returns the number of values that were put.
+     * </p>
+     *
+     * @param val some values to be put which may be null
+     * @return the number of added values, or 0 if none has been added
+     */
+    int put( String... vals );
+
+
+    /**
+     * Puts some values to this attribute.
+     * <p>
+     * The new values will replace the previous values.
+     * </p>
+     * <p>
+     * This method returns the number of values that were put.
+     * </p>
+     *
+     * @param val some values to be put which may be null
+     * @return the number of added values, or 0 if none has been added
+     */
+    int put( byte[]... vals );
+
+    
+    /**
+     * Puts some values to this attribute.
+     * <p>
+     * The new values are replace the previous values.
+     * </p>
+     * <p>
+     * This method returns the number of values that were put.
+     * </p>
+     *
+     * @param val some values to be put which may be null
+     * @return the number of added values, or 0 if none has been added
+     */
+    int put( Value<?>... vals );
+
+
+    /**
+     * <p>
+     * Puts a list of values into this attribute.
+     * </p>
+     * <p>
+     * The new values will replace the previous values.
+     * </p>
+     * <p>
+     * This method returns the number of values that were put.
+     * </p>
+     *
+     * @param vals the values to be put
+     * @return the number of added values, or 0 if none has been added
+     */
+    int put( List<Value<?>> vals );
+
+
+    /**
+     * <p>
+     * Removes all the  values that are equal to the given values.
+     * </p>
+     * <p>
+     * Returns true if all the values are removed.
+     * </p>
+     * <p>
+     * If the attribute type is not HR, then the values will be first converted
+     * to byte[]
+     * </p>
+     *
+     * @param vals the values to be removed
+     * @return true if all the values are removed, otherwise false
+     */
+    boolean remove( String... vals );
+    
+    
+    /**
+     * <p>
+     * Removes all the  values that are equal to the given values.
+     * </p>
+     * <p>
+     * Returns true if all the values are removed. 
+     * </p>
+     * <p>
+     * If the attribute type is HR, then the values will be first converted
+     * to String
+     * </p>
+     *
+     * @param vals the values to be removed
+     * @return true if all the values are removed, otherwise false
+     */
+    boolean remove( byte[]... val );
+
+
+    /**
+     * <p>
+     * Removes all the  values that are equal to the given values.
+     * </p>
+     * <p>
+     * Returns true if all the values are removed.
+     * </p>
+     * <p>
+     * If the attribute type is HR and some value which are not String, we
+     * will convert the values first (same thing for a non-HR attribute).
+     * </p>
+     *
+     * @param vals the values to be removed
+     * @return true if all the values are removed, otherwise false
+     */
+    boolean remove( Value<?>... vals );
+
+    
+    /**
+     * <p>
+     * Set the attribute to Human Readable or to Binary. 
+     * </p>
+     * @param isHR <code>true</code> for a Human Readable attribute, 
+     * <code>false</code> for a Binary attribute.
+     */
+    void setHR( boolean isHR );
+
+    
+    /**
+     * Set the normalized ID. The ID will be lowercased, and spaces
+     * will be trimmed. 
+     *
+     * @param id The attribute ID
+     * @throws IllegalArgumentException If the ID is empty or null or
+     * resolve to an empty value after being trimmed
+     */
+    public void setId( String id );
+
+    
+    /**
+     * Set the user provided ID. It will also set the ID, normalizing
+     * the upId (removing spaces before and after, and lowercasing it)
+     *
+     * @param upId The attribute ID
+     * @throws IllegalArgumentException If the ID is empty or null or
+     * resolve to an empty value after being trimmed
+     */
+    public void setUpId( String upId );
+
+    
+    /**
+      * Retrieves the number of values in this attribute.
+      *
+      * @return the number of values in this attribute, including any values
+      * wrapping a null value if there is one
+      */
+    int size();
+}

Modified: directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/entry/Value.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/entry/Value.java?rev=801332&r1=801331&r2=801332&view=diff
==============================================================================
--- directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/entry/Value.java (original)
+++ directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/entry/Value.java Wed Aug  5 17:40:50 2009
@@ -1,214 +1,214 @@
-/*
- *  Licensed to the Apache Software Foundation (ASF) under one
- *  or more contributor license agreements.  See the NOTICE file
- *  distributed with this work for additional information
- *  regarding copyright ownership.  The ASF licenses this file
- *  to you under the Apache License, Version 2.0 (the
- *  "License"); you may not use this file except in compliance
- *  with the License.  You may obtain a copy of the License at
- *
- *    http://www.apache.org/licenses/LICENSE-2.0
- *
- *  Unless required by applicable law or agreed to in writing,
- *  software distributed under the License is distributed on an
- *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- *  KIND, either express or implied.  See the License for the
- *  specific language governing permissions and limitations
- *  under the License.
- *
- */
-package org.apache.directory.shared.ldap.entry;
-
-
-import java.io.Externalizable;
-
-import javax.naming.NamingException;
-
-import org.apache.directory.shared.ldap.schema.Normalizer;
-import org.apache.directory.shared.ldap.schema.SyntaxChecker;
-
-
-/**
- * A interface for wrapping attribute values stored into an EntryAttribute. These
- * values can be a String or a byte[].
- *
- * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
- * @version $Rev$, $Date$
- */
-public interface Value<T> extends Cloneable, Externalizable, Comparable<Value<T>>
-{
-    
-    Value<T> clone();
-    
-    
-    /**
-     * Check if the contained value is null or not
-     * 
-     * @return <code>true</code> if the inner value is null.
-     */
-    boolean isNull();
-    
-    
-    /**
-     * @return Tells if the wrapped value and the normalized value are the same 
-     */
-    boolean isSame();
-
-    
-    /**
-     * Sets the wrapped value.
-     *
-     * @param wrapped the value to set: either a String, URI, or a byte[]
-     */
-    void set( T wrapped );
-    
-
-    /**
-     * Get the wrapped value.
-     *
-     * @return the wrapped value
-     */
-    T get();
-    
-    
-    /**
-     * Get the wrapped value as a byte[]. If the original value
-     * is binary, this method will return a copy of the wrapped byte[]
-     *
-     * @return the wrapped value as a byte[]
-     */
-    byte[] getBytes();
-    
-    
-    /**
-     * Get the wrapped value as a String. If the original value
-     * is binary, this method will return the value as if it was 
-     * an UTF-8 encoded String.
-     *
-     * @return the wrapped value as a String
-     */
-    String getString();
-    
-    
-    /**
-     * Get a reference on the stored value.
-     *
-     * @return a reference on the wrapped value.
-     */
-    T getReference();
-    
-    
-    /**
-     * Get a copy of the stored value.
-     *
-     * @return a copy of the stored value.
-     */
-    T getCopy();
-    
-    
-    /**
-     * Reset the value
-     */
-    void clear();
-    
-    
-    /**
-     * Tells if the value has already be normalized or not.
-     *
-     * @return <code>true</code> if the value has already been normalized.
-     */
-    boolean isNormalized();
-    
-    
-    /**
-     * Tells if the value is valid. The value must have already been
-     * validated at least once through a call to isValid( SyntaxChecker ).  
-     * 
-     * @return <code>true</code> if the value is valid
-     */
-    boolean isValid();
-
-    
-    /**
-     * Tells if the value is valid wrt a Syntax checker
-     * 
-     * @param checker the SyntaxChecker to use to validate the value
-     * @return <code>true</code> if the value is valid
-     * @exception NamingException if the value cannot be validated
-     */
-    boolean isValid( SyntaxChecker checker ) throws NamingException;
-
-    
-    /**
-     * Set the normalized flag.
-     * 
-     * @param normalized the value : true or false
-     */
-    void setNormalized( boolean normalized );
-
-    
-    /**
-     * Gets the normalized (canonical) representation for the wrapped string.
-     * If the wrapped String is null, null is returned, otherwise the normalized
-     * form is returned.  If the normalizedValue is null, then this method
-     * will attempt to generate it from the wrapped value: repeated calls to
-     * this method do not unnecessarily normalize the wrapped value.  Only changes
-     * to the wrapped value result in attempts to normalize the wrapped value.
-     *
-     * @return gets the normalized value
-     */
-    T getNormalizedValue();
-    
-    
-    /**
-     * Gets a reference to the the normalized (canonical) representation 
-     * for the wrapped value.
-     *
-     * @return gets a reference to the normalized value
-     */
-    T getNormalizedValueReference();
-
-    
-    /**
-     * Gets a copy of the the normalized (canonical) representation 
-     * for the wrapped value.
-     *
-     * @return gets a copy of the normalized value
-     */
-    T getNormalizedValueCopy();
-
-    
-    /**
-     * Normalize the value. In order to use this method, the Value
-     * must be schema aware.
-     * 
-     * @exception NamingException if the value cannot be normalized
-     */
-    void normalize() throws NamingException;
-
-    
-    /**
-     * Normalize the value. For a client String value, applies the given normalizer.
-     * 
-     * It supposes that the client has access to the schema in order to select the
-     * appropriate normalizer.
-     * 
-     * @param normalizer the normalizer to apply to the value
-     * @exception NamingException if the value cannot be normalized
-     */
-    void normalize( Normalizer normalizer ) throws NamingException;
-    
-    
-    /**
-     * Tells if the current value is Binary or String
-     * 
-     * @return <code>true</code> if the value is Binary, <code>false</code> otherwise
-     */
-    boolean isBinary();
-    
-    
-    /**
-     * @return The length of the interned value
-     */
-    int length();
-}
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License.
+ *
+ */
+package org.apache.directory.shared.ldap.entry;
+
+
+import java.io.Externalizable;
+
+import javax.naming.NamingException;
+
+import org.apache.directory.shared.ldap.schema.Normalizer;
+import org.apache.directory.shared.ldap.schema.SyntaxChecker;
+
+
+/**
+ * A interface for wrapping attribute values stored into an EntryAttribute. These
+ * values can be a String or a byte[].
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev$, $Date$
+ */
+public interface Value<T> extends Cloneable, Externalizable, Comparable<Value<T>>
+{
+    
+    Value<T> clone();
+    
+    
+    /**
+     * Check if the contained value is null or not
+     * 
+     * @return <code>true</code> if the inner value is null.
+     */
+    boolean isNull();
+    
+    
+    /**
+     * @return Tells if the wrapped value and the normalized value are the same 
+     */
+    boolean isSame();
+
+    
+    /**
+     * Sets the wrapped value.
+     *
+     * @param wrapped the value to set: either a String, URI, or a byte[]
+     */
+    void set( T wrapped );
+    
+
+    /**
+     * Get the wrapped value.
+     *
+     * @return the wrapped value
+     */
+    T get();
+    
+    
+    /**
+     * Get the wrapped value as a byte[]. If the original value
+     * is binary, this method will return a copy of the wrapped byte[]
+     *
+     * @return the wrapped value as a byte[]
+     */
+    byte[] getBytes();
+    
+    
+    /**
+     * Get the wrapped value as a String. If the original value
+     * is binary, this method will return the value as if it was 
+     * an UTF-8 encoded String.
+     *
+     * @return the wrapped value as a String
+     */
+    String getString();
+    
+    
+    /**
+     * Get a reference on the stored value.
+     *
+     * @return a reference on the wrapped value.
+     */
+    T getReference();
+    
+    
+    /**
+     * Get a copy of the stored value.
+     *
+     * @return a copy of the stored value.
+     */
+    T getCopy();
+    
+    
+    /**
+     * Reset the value
+     */
+    void clear();
+    
+    
+    /**
+     * Tells if the value has already be normalized or not.
+     *
+     * @return <code>true</code> if the value has already been normalized.
+     */
+    boolean isNormalized();
+    
+    
+    /**
+     * Tells if the value is valid. The value must have already been
+     * validated at least once through a call to isValid( SyntaxChecker ).  
+     * 
+     * @return <code>true</code> if the value is valid
+     */
+    boolean isValid();
+
+    
+    /**
+     * Tells if the value is valid wrt a Syntax checker
+     * 
+     * @param checker the SyntaxChecker to use to validate the value
+     * @return <code>true</code> if the value is valid
+     * @exception NamingException if the value cannot be validated
+     */
+    boolean isValid( SyntaxChecker checker ) throws NamingException;
+
+    
+    /**
+     * Set the normalized flag.
+     * 
+     * @param normalized the value : true or false
+     */
+    void setNormalized( boolean normalized );
+
+    
+    /**
+     * Gets the normalized (canonical) representation for the wrapped string.
+     * If the wrapped String is null, null is returned, otherwise the normalized
+     * form is returned.  If the normalizedValue is null, then this method
+     * will attempt to generate it from the wrapped value: repeated calls to
+     * this method do not unnecessarily normalize the wrapped value.  Only changes
+     * to the wrapped value result in attempts to normalize the wrapped value.
+     *
+     * @return gets the normalized value
+     */
+    T getNormalizedValue();
+    
+    
+    /**
+     * Gets a reference to the the normalized (canonical) representation 
+     * for the wrapped value.
+     *
+     * @return gets a reference to the normalized value
+     */
+    T getNormalizedValueReference();
+
+    
+    /**
+     * Gets a copy of the the normalized (canonical) representation 
+     * for the wrapped value.
+     *
+     * @return gets a copy of the normalized value
+     */
+    T getNormalizedValueCopy();
+
+    
+    /**
+     * Normalize the value. In order to use this method, the Value
+     * must be schema aware.
+     * 
+     * @exception NamingException if the value cannot be normalized
+     */
+    void normalize() throws NamingException;
+
+    
+    /**
+     * Normalize the value. For a client String value, applies the given normalizer.
+     * 
+     * It supposes that the client has access to the schema in order to select the
+     * appropriate normalizer.
+     * 
+     * @param normalizer the normalizer to apply to the value
+     * @exception NamingException if the value cannot be normalized
+     */
+    void normalize( Normalizer normalizer ) throws NamingException;
+    
+    
+    /**
+     * Tells if the current value is Binary or String
+     * 
+     * @return <code>true</code> if the value is Binary, <code>false</code> otherwise
+     */
+    boolean isBinary();
+    
+    
+    /**
+     * @return The length of the interned value
+     */
+    int length();
+}

Modified: directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/entry/client/ClientAttribute.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/entry/client/ClientAttribute.java?rev=801332&r1=801331&r2=801332&view=diff
==============================================================================
--- directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/entry/client/ClientAttribute.java (original)
+++ directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/entry/client/ClientAttribute.java Wed Aug  5 17:40:50 2009
@@ -1,45 +1,45 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *  http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.directory.shared.ldap.entry.client;
-
-
-import javax.naming.NamingException;
-
-import org.apache.directory.shared.ldap.entry.EntryAttribute;
-import org.apache.directory.shared.ldap.schema.SyntaxChecker;
-
-
-/**
- * The server specific interface extending the EntryAttribute interface. It adds
- * three more methods which are Server side.
- *
- * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
- * @version $Rev$, $Date$
- */
-public interface ClientAttribute extends EntryAttribute
-{
-    /**
-     * Checks to see if this attribute is valid along with the values it contains.
-     *
-     * @param checker The syntax checker
-     * @return true if the attribute and it's values are valid, false otherwise
-     * @throws NamingException if there is a failure to check syntaxes of values
-     */
-    boolean isValid( SyntaxChecker checker) throws NamingException;
-}
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.directory.shared.ldap.entry.client;
+
+
+import javax.naming.NamingException;
+
+import org.apache.directory.shared.ldap.entry.EntryAttribute;
+import org.apache.directory.shared.ldap.schema.SyntaxChecker;
+
+
+/**
+ * The server specific interface extending the EntryAttribute interface. It adds
+ * three more methods which are Server side.
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev$, $Date$
+ */
+public interface ClientAttribute extends EntryAttribute
+{
+    /**
+     * Checks to see if this attribute is valid along with the values it contains.
+     *
+     * @param checker The syntax checker
+     * @return true if the attribute and it's values are valid, false otherwise
+     * @throws NamingException if there is a failure to check syntaxes of values
+     */
+    boolean isValid( SyntaxChecker checker) throws NamingException;
+}

Modified: directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/entry/client/ClientEntry.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/entry/client/ClientEntry.java?rev=801332&r1=801331&r2=801332&view=diff
==============================================================================
--- directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/entry/client/ClientEntry.java (original)
+++ directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/entry/client/ClientEntry.java Wed Aug  5 17:40:50 2009
@@ -1,36 +1,36 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *  http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.directory.shared.ldap.entry.client;
-
-
-import org.apache.directory.shared.ldap.entry.Entry;
-
-
-/**
- * An entry implementation intended for use by clients. Implementations of
- * this interface may treat attributes with different aliases of the same
- * attributeType as the same attribute or may treat them as separate
- * attributes.
- *
- * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
- * @version $Rev$, $Date$
- */
-public interface ClientEntry extends Entry
-{
-}
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.directory.shared.ldap.entry.client;
+
+
+import org.apache.directory.shared.ldap.entry.Entry;
+
+
+/**
+ * An entry implementation intended for use by clients. Implementations of
+ * this interface may treat attributes with different aliases of the same
+ * attributeType as the same attribute or may treat them as separate
+ * attributes.
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev$, $Date$
+ */
+public interface ClientEntry extends Entry
+{
+}

Modified: directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/entry/client/ClientEntryFactory.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/entry/client/ClientEntryFactory.java?rev=801332&r1=801331&r2=801332&view=diff
==============================================================================
--- directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/entry/client/ClientEntryFactory.java (original)
+++ directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/entry/client/ClientEntryFactory.java Wed Aug  5 17:40:50 2009
@@ -1,31 +1,31 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *  http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.directory.shared.ldap.entry.client;
-
-
-/**
- * Document me!
- *
- * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
- * @version $Rev$, $Date$
- */
-public interface ClientEntryFactory
-{
-    ClientEntry newEntry();
-}
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.directory.shared.ldap.entry.client;
+
+
+/**
+ * Document me!
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev$, $Date$
+ */
+public interface ClientEntryFactory
+{
+    ClientEntry newEntry();
+}

Modified: directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/entry/client/ClientStringValue.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/entry/client/ClientStringValue.java?rev=801332&r1=801331&r2=801332&view=diff
==============================================================================
--- directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/entry/client/ClientStringValue.java (original)
+++ directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/entry/client/ClientStringValue.java Wed Aug  5 17:40:50 2009
@@ -1,401 +1,401 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *  http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.directory.shared.ldap.entry.client;
-
-
-import java.io.Externalizable;
-import java.io.IOException;
-import java.io.ObjectInput;
-import java.io.ObjectOutput;
-
-import javax.naming.NamingException;
-
-import org.apache.directory.shared.ldap.NotImplementedException;
-import org.apache.directory.shared.ldap.entry.AbstractValue;
-import org.apache.directory.shared.ldap.entry.Value;
-import org.apache.directory.shared.ldap.schema.Normalizer;
-import org.apache.directory.shared.ldap.util.StringTools;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-
-/**
- * A server side schema aware wrapper around a String attribute value.
- * This value wrapper uses schema information to syntax check values,
- * and to compare them for equality and ordering.  It caches results
- * and invalidates them when the wrapped value changes.
- *
- * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
- * @version $Rev$, $Date$
- */
-public class ClientStringValue extends AbstractValue<String>
-{
-    /** Used for serialization */
-    private static final long serialVersionUID = 2L;
-    
-    
-    /** logger for reporting errors that might not be handled properly upstream */
-    private static final Logger LOG = LoggerFactory.getLogger( ClientStringValue.class );
-
-    
-    // -----------------------------------------------------------------------
-    // Constructors
-    // -----------------------------------------------------------------------
-    /**
-     * Creates a ServerStringValue without an initial wrapped value.
-     */
-    public ClientStringValue()
-    {
-        normalized = false;
-        valid = null;
-    }
-
-
-    /**
-     * Creates a ServerStringValue with an initial wrapped String value.
-     *
-     * @param wrapped the value to wrap which can be null
-     */
-    public ClientStringValue( String wrapped )
-    {
-        this.wrapped = wrapped;
-        normalized = false;
-        valid = null;
-    }
-
-
-    // -----------------------------------------------------------------------
-    // Value<String> Methods
-    // -----------------------------------------------------------------------
-    /**
-     * Get a copy of the stored value.
-     *
-     * @return A copy of the stored value.
-     */
-    public String getCopy()
-    {
-        // The String is immutable, we can safely return the internal
-        // object without copying it.
-        return wrapped;
-    }
-    
-    
-    /**
-     * Sets the wrapped String value.  Has the side effect of setting the
-     * normalizedValue and the valid flags to null if the wrapped value is
-     * different than what is already set.  These cached values must be
-     * recomputed to be correct with different values.
-     *
-     * @see ServerValue#set(Object)
-     */
-    public final void set( String wrapped )
-    {
-        // Why should we invalidate the normalized value if it's we're setting the
-        // wrapper to it's current value?
-        if ( !StringTools.isEmpty( wrapped ) && wrapped.equals( getString() ) )
-        {
-            return;
-        }
-
-        normalizedValue = null;
-        normalized = false;
-        valid = null;
-        this.wrapped = wrapped;
-    }
-
-
-    /**
-     * Gets the normalized (canonical) representation for the wrapped string.
-     * If the wrapped String is null, null is returned, otherwise the normalized
-     * form is returned.  If the normalizedValue is null, then this method
-     * will attempt to generate it from the wrapped value: repeated calls to
-     * this method do not unnecessarily normalize the wrapped value.  Only changes
-     * to the wrapped value result in attempts to normalize the wrapped value.
-     *
-     * @return gets the normalized value
-     */
-    public String getNormalizedValue()
-    {
-        if ( isNull() )
-        {
-            return null;
-        }
-
-        if ( normalizedValue == null )
-        {
-            return wrapped;
-        }
-
-        return normalizedValue;
-    }
-
-
-    /**
-     * Gets a copy of the the normalized (canonical) representation 
-     * for the wrapped value.
-     *
-     * @return gets a copy of the normalized value
-     */
-    public String getNormalizedValueCopy()
-    {
-        return getNormalizedValue();
-    }
-
-
-    /**
-     * Normalize the value. For a client String value, applies the given normalizer.
-     * 
-     * It supposes that the client has access to the schema in order to select the
-     * appropriate normalizer.
-     * 
-     * @param Normalizer The normalizer to apply to the value
-     * @exception NamingException If the value cannot be normalized
-     */
-    public final void normalize( Normalizer normalizer ) throws NamingException
-    {
-        if ( normalizer != null )
-        {
-            normalizedValue = (String)normalizer.normalize( wrapped );
-            normalized = true;
-        }
-    }
-
-    
-    // -----------------------------------------------------------------------
-    // Comparable<String> Methods
-    // -----------------------------------------------------------------------
-    /**
-     * @see ServerValue#compareTo(ServerValue)
-     * @throws IllegalStateException on failures to extract the comparator, or the
-     * normalizers needed to perform the required comparisons based on the schema
-     */
-    public int compareTo( Value<String> value )
-    {
-        if ( isNull() )
-        {
-            if ( ( value == null ) || value.isNull() )
-            {
-                return 0;
-            }
-            else
-            {
-                return -1;
-            }
-        }
-        else if ( ( value == null ) || value.isNull() )
-        {
-            return 1;
-        }
-
-        if ( value instanceof ClientStringValue )
-        {
-            ClientStringValue stringValue = ( ClientStringValue ) value;
-            
-            return getNormalizedValue().compareTo( stringValue.getNormalizedValue() );
-        }
-        else 
-        {
-            String message = "Cannot compare " + toString() + " with the unknown value " + value.getClass();
-            LOG.error( message );
-            throw new NotImplementedException( message );
-        }
-    }
-
-
-    // -----------------------------------------------------------------------
-    // Cloneable methods
-    // -----------------------------------------------------------------------
-    /**
-     * Get a clone of the Client Value
-     * 
-     * @return a copy of the current value
-     */
-    public ClientStringValue clone()
-    {
-        return (ClientStringValue)super.clone();
-    }
-
-
-    // -----------------------------------------------------------------------
-    // Object Methods
-    // -----------------------------------------------------------------------
-    /**
-     * @see Object#hashCode()
-     * @return the instance's hashcode 
-     */
-    public int hashCode()
-    {
-        // return zero if the value is null so only one null value can be
-        // stored in an attribute - the binary version does the same 
-        if ( isNull() )
-        {
-            return 0;
-        }
-
-        // If the normalized value is null, will default to wrapped
-        // which cannot be null at this point.
-        return getNormalizedValue().hashCode();
-    }
-
-
-    /**
-     * @see Object#equals(Object)
-     * 
-     * Two ClientStringValue are equals if their normalized values are equal
-     */
-    public boolean equals( Object obj )
-    {
-        if ( this == obj )
-        {
-            return true;
-        }
-
-        if ( ! ( obj instanceof ClientStringValue ) )
-        {
-            return false;
-        }
-
-        ClientStringValue other = ( ClientStringValue ) obj;
-        
-        if ( this.isNull() )
-        {
-            return other.isNull();
-        }
-        
-        // Test the normalized values
-        return this.getNormalizedValue().equals( other.getNormalizedValue() );
-    }
-    
-    
-    /**
-     * Tells if the current value is Binary or String
-     * 
-     * @return <code>true</code> if the value is Binary, <code>false</code> otherwise
-     */
-    public boolean isBinary()
-    {
-        return false;
-    }
-    
-    
-    /**
-     * @return The length of the interned value
-     */
-    public int length()
-    {
-        return wrapped != null ? wrapped.length() : 0;
-    }
-    
-    
-    /**
-     * Get the wrapped value as a byte[].
-     * @return the wrapped value as a byte[]
-     */
-    public byte[] getBytes()
-    {
-        return StringTools.getBytesUtf8( wrapped );
-    }
-    
-    
-    /**
-     * Get the wrapped value as a String.
-     *
-     * @return the wrapped value as a String
-     */
-    public String getString()
-    {
-        return wrapped != null ? wrapped : "";
-    }
-    
-    
-    /**
-     * @see Externalizable#readExternal(ObjectInput)
-     */
-    public void readExternal( ObjectInput in ) throws IOException, ClassNotFoundException
-    {
-        // Read the wrapped value, if it's not null
-        if ( in.readBoolean() )
-        {
-            wrapped = in.readUTF();
-        }
-        
-        // Read the isNormalized flag
-        normalized = in.readBoolean();
-        
-        if ( normalized )
-        {
-            // Read the normalized value, if not null
-            if ( in.readBoolean() )
-            {
-                normalizedValue = in.readUTF();
-            }
-        }
-    }
-
-    
-    /**
-     * @see Externalizable#writeExternal(ObjectOutput)
-     */
-    public void writeExternal( ObjectOutput out ) throws IOException
-    {
-        // Write the wrapped value, if it's not null
-        if ( wrapped != null )
-        {
-            out.writeBoolean( true );
-            out.writeUTF( wrapped );
-        }
-        else
-        {
-            out.writeBoolean( false );
-        }
-        
-        // Write the isNormalized flag
-        if ( normalized )
-        {
-            out.writeBoolean( true );
-            
-            // Write the normalized value, if not null
-            if ( normalizedValue != null )
-            {
-                out.writeBoolean( true );
-                out.writeUTF( normalizedValue );
-            }
-            else
-            {
-                out.writeBoolean( false );
-            }
-        }
-        else
-        {
-            out.writeBoolean( false );
-        }
-        
-        // and flush the data
-        out.flush();
-    }
-    
-    
-    /**
-     * @see Object#toString()
-     */
-    public String toString()
-    {
-        return wrapped == null ? "null": wrapped;
-    }
-}
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.directory.shared.ldap.entry.client;
+
+
+import java.io.Externalizable;
+import java.io.IOException;
+import java.io.ObjectInput;
+import java.io.ObjectOutput;
+
+import javax.naming.NamingException;
+
+import org.apache.directory.shared.ldap.NotImplementedException;
+import org.apache.directory.shared.ldap.entry.AbstractValue;
+import org.apache.directory.shared.ldap.entry.Value;
+import org.apache.directory.shared.ldap.schema.Normalizer;
+import org.apache.directory.shared.ldap.util.StringTools;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+
+/**
+ * A server side schema aware wrapper around a String attribute value.
+ * This value wrapper uses schema information to syntax check values,
+ * and to compare them for equality and ordering.  It caches results
+ * and invalidates them when the wrapped value changes.
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev$, $Date$
+ */
+public class ClientStringValue extends AbstractValue<String>
+{
+    /** Used for serialization */
+    private static final long serialVersionUID = 2L;
+    
+    
+    /** logger for reporting errors that might not be handled properly upstream */
+    private static final Logger LOG = LoggerFactory.getLogger( ClientStringValue.class );
+
+    
+    // -----------------------------------------------------------------------
+    // Constructors
+    // -----------------------------------------------------------------------
+    /**
+     * Creates a ServerStringValue without an initial wrapped value.
+     */
+    public ClientStringValue()
+    {
+        normalized = false;
+        valid = null;
+    }
+
+
+    /**
+     * Creates a ServerStringValue with an initial wrapped String value.
+     *
+     * @param wrapped the value to wrap which can be null
+     */
+    public ClientStringValue( String wrapped )
+    {
+        this.wrapped = wrapped;
+        normalized = false;
+        valid = null;
+    }
+
+
+    // -----------------------------------------------------------------------
+    // Value<String> Methods
+    // -----------------------------------------------------------------------
+    /**
+     * Get a copy of the stored value.
+     *
+     * @return A copy of the stored value.
+     */
+    public String getCopy()
+    {
+        // The String is immutable, we can safely return the internal
+        // object without copying it.
+        return wrapped;
+    }
+    
+    
+    /**
+     * Sets the wrapped String value.  Has the side effect of setting the
+     * normalizedValue and the valid flags to null if the wrapped value is
+     * different than what is already set.  These cached values must be
+     * recomputed to be correct with different values.
+     *
+     * @see ServerValue#set(Object)
+     */
+    public final void set( String wrapped )
+    {
+        // Why should we invalidate the normalized value if it's we're setting the
+        // wrapper to it's current value?
+        if ( !StringTools.isEmpty( wrapped ) && wrapped.equals( getString() ) )
+        {
+            return;
+        }
+
+        normalizedValue = null;
+        normalized = false;
+        valid = null;
+        this.wrapped = wrapped;
+    }
+
+
+    /**
+     * Gets the normalized (canonical) representation for the wrapped string.
+     * If the wrapped String is null, null is returned, otherwise the normalized
+     * form is returned.  If the normalizedValue is null, then this method
+     * will attempt to generate it from the wrapped value: repeated calls to
+     * this method do not unnecessarily normalize the wrapped value.  Only changes
+     * to the wrapped value result in attempts to normalize the wrapped value.
+     *
+     * @return gets the normalized value
+     */
+    public String getNormalizedValue()
+    {
+        if ( isNull() )
+        {
+            return null;
+        }
+
+        if ( normalizedValue == null )
+        {
+            return wrapped;
+        }
+
+        return normalizedValue;
+    }
+
+
+    /**
+     * Gets a copy of the the normalized (canonical) representation 
+     * for the wrapped value.
+     *
+     * @return gets a copy of the normalized value
+     */
+    public String getNormalizedValueCopy()
+    {
+        return getNormalizedValue();
+    }
+
+
+    /**
+     * Normalize the value. For a client String value, applies the given normalizer.
+     * 
+     * It supposes that the client has access to the schema in order to select the
+     * appropriate normalizer.
+     * 
+     * @param Normalizer The normalizer to apply to the value
+     * @exception NamingException If the value cannot be normalized
+     */
+    public final void normalize( Normalizer normalizer ) throws NamingException
+    {
+        if ( normalizer != null )
+        {
+            normalizedValue = (String)normalizer.normalize( wrapped );
+            normalized = true;
+        }
+    }
+
+    
+    // -----------------------------------------------------------------------
+    // Comparable<String> Methods
+    // -----------------------------------------------------------------------
+    /**
+     * @see ServerValue#compareTo(ServerValue)
+     * @throws IllegalStateException on failures to extract the comparator, or the
+     * normalizers needed to perform the required comparisons based on the schema
+     */
+    public int compareTo( Value<String> value )
+    {
+        if ( isNull() )
+        {
+            if ( ( value == null ) || value.isNull() )
+            {
+                return 0;
+            }
+            else
+            {
+                return -1;
+            }
+        }
+        else if ( ( value == null ) || value.isNull() )
+        {
+            return 1;
+        }
+
+        if ( value instanceof ClientStringValue )
+        {
+            ClientStringValue stringValue = ( ClientStringValue ) value;
+            
+            return getNormalizedValue().compareTo( stringValue.getNormalizedValue() );
+        }
+        else 
+        {
+            String message = "Cannot compare " + toString() + " with the unknown value " + value.getClass();
+            LOG.error( message );
+            throw new NotImplementedException( message );
+        }
+    }
+
+
+    // -----------------------------------------------------------------------
+    // Cloneable methods
+    // -----------------------------------------------------------------------
+    /**
+     * Get a clone of the Client Value
+     * 
+     * @return a copy of the current value
+     */
+    public ClientStringValue clone()
+    {
+        return (ClientStringValue)super.clone();
+    }
+
+
+    // -----------------------------------------------------------------------
+    // Object Methods
+    // -----------------------------------------------------------------------
+    /**
+     * @see Object#hashCode()
+     * @return the instance's hashcode 
+     */
+    public int hashCode()
+    {
+        // return zero if the value is null so only one null value can be
+        // stored in an attribute - the binary version does the same 
+        if ( isNull() )
+        {
+            return 0;
+        }
+
+        // If the normalized value is null, will default to wrapped
+        // which cannot be null at this point.
+        return getNormalizedValue().hashCode();
+    }
+
+
+    /**
+     * @see Object#equals(Object)
+     * 
+     * Two ClientStringValue are equals if their normalized values are equal
+     */
+    public boolean equals( Object obj )
+    {
+        if ( this == obj )
+        {
+            return true;
+        }
+
+        if ( ! ( obj instanceof ClientStringValue ) )
+        {
+            return false;
+        }
+
+        ClientStringValue other = ( ClientStringValue ) obj;
+        
+        if ( this.isNull() )
+        {
+            return other.isNull();
+        }
+        
+        // Test the normalized values
+        return this.getNormalizedValue().equals( other.getNormalizedValue() );
+    }
+    
+    
+    /**
+     * Tells if the current value is Binary or String
+     * 
+     * @return <code>true</code> if the value is Binary, <code>false</code> otherwise
+     */
+    public boolean isBinary()
+    {
+        return false;
+    }
+    
+    
+    /**
+     * @return The length of the interned value
+     */
+    public int length()
+    {
+        return wrapped != null ? wrapped.length() : 0;
+    }
+    
+    
+    /**
+     * Get the wrapped value as a byte[].
+     * @return the wrapped value as a byte[]
+     */
+    public byte[] getBytes()
+    {
+        return StringTools.getBytesUtf8( wrapped );
+    }
+    
+    
+    /**
+     * Get the wrapped value as a String.
+     *
+     * @return the wrapped value as a String
+     */
+    public String getString()
+    {
+        return wrapped != null ? wrapped : "";
+    }
+    
+    
+    /**
+     * @see Externalizable#readExternal(ObjectInput)
+     */
+    public void readExternal( ObjectInput in ) throws IOException, ClassNotFoundException
+    {
+        // Read the wrapped value, if it's not null
+        if ( in.readBoolean() )
+        {
+            wrapped = in.readUTF();
+        }
+        
+        // Read the isNormalized flag
+        normalized = in.readBoolean();
+        
+        if ( normalized )
+        {
+            // Read the normalized value, if not null
+            if ( in.readBoolean() )
+            {
+                normalizedValue = in.readUTF();
+            }
+        }
+    }
+
+    
+    /**
+     * @see Externalizable#writeExternal(ObjectOutput)
+     */
+    public void writeExternal( ObjectOutput out ) throws IOException
+    {
+        // Write the wrapped value, if it's not null
+        if ( wrapped != null )
+        {
+            out.writeBoolean( true );
+            out.writeUTF( wrapped );
+        }
+        else
+        {
+            out.writeBoolean( false );
+        }
+        
+        // Write the isNormalized flag
+        if ( normalized )
+        {
+            out.writeBoolean( true );
+            
+            // Write the normalized value, if not null
+            if ( normalizedValue != null )
+            {
+                out.writeBoolean( true );
+                out.writeUTF( normalizedValue );
+            }
+            else
+            {
+                out.writeBoolean( false );
+            }
+        }
+        else
+        {
+            out.writeBoolean( false );
+        }
+        
+        // and flush the data
+        out.flush();
+    }
+    
+    
+    /**
+     * @see Object#toString()
+     */
+    public String toString()
+    {
+        return wrapped == null ? "null": wrapped;
+    }
+}



Mime
View raw message