You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@directory.apache.org by el...@apache.org on 2012/05/01 02:22:15 UTC
svn commit: r1332480 -
/directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/shared/ldap/model/entry/StringValue.java
Author: elecharny
Date: Tue May 1 00:22:15 2012
New Revision: 1332480
URL: http://svn.apache.org/viewvc?rev=1332480&view=rev
Log:
Keep a byte[] version of the value, to avoid doing the conversion when writing back the entry to the client
Modified:
directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/shared/ldap/model/entry/StringValue.java
Modified: directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/shared/ldap/model/entry/StringValue.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/shared/ldap/model/entry/StringValue.java?rev=1332480&r1=1332479&r2=1332480&view=diff
==============================================================================
--- directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/shared/ldap/model/entry/StringValue.java (original)
+++ directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/shared/ldap/model/entry/StringValue.java Tue May 1 00:22:15 2012
@@ -45,6 +45,9 @@ public class StringValue extends Abstrac
{
/** Used for serialization */
private static final long serialVersionUID = 2L;
+
+ /** The UTF-8 bytes for this value */
+ private byte[] bytes;
// -----------------------------------------------------------------------
@@ -85,6 +88,7 @@ public class StringValue extends Abstrac
{
this.wrappedValue = value;
this.normalizedValue = value;
+ bytes = Strings.getBytesUtf8( value );
}
@@ -93,7 +97,7 @@ public class StringValue extends Abstrac
*
* @param attributeType the schema type associated with this StringValue
* @param value the value to wrap
- * @throws LdapInvalidAttributeValueException If the added value is invalid accordingly
+ * @throws LdapInvalidAttributeValueException If the added value is invalid accordingly
* to the schema
*/
public StringValue( AttributeType attributeType, String value ) throws LdapInvalidAttributeValueException
@@ -115,8 +119,8 @@ public class StringValue extends Abstrac
// object without copying it.
return wrappedValue;
}
-
-
+
+
/**
* {@inheritDoc}
*/
@@ -212,14 +216,14 @@ public class StringValue extends Abstrac
// -----------------------------------------------------------------------
/**
* @see Object#hashCode()
- * @return the instance's hashcode
+ * @return the instance's hashcode
*/
public int hashCode()
{
if ( h == 0 )
{
// return zero if the value is null so only one null value can be
- // stored in an attribute - the binary version does the same
+ // stored in an attribute - the binary version does the same
if ( isNull() )
{
return 0;
@@ -306,7 +310,7 @@ public class StringValue extends Abstrac
// Shortcut : compare the values without normalization
// If they are equal, we may avoid a normalization.
// Note : if two values are equal, then their normalized
- // value are equal too if their attributeType are equal.
+ // value are equal too if their attributeType are equal.
if ( getReference().equals( other.getReference() ) )
{
return true;
@@ -373,7 +377,7 @@ public class StringValue extends Abstrac
*/
public byte[] getBytes()
{
- return Strings.getBytesUtf8( wrappedValue );
+ return bytes;
}
@@ -441,6 +445,7 @@ public class StringValue extends Abstrac
if ( in.readBoolean() )
{
wrappedValue = in.readUTF();
+ bytes = Strings.getBytesUtf8( wrappedValue );
}
// Read the isNormalized flag
@@ -486,7 +491,7 @@ public class StringValue extends Abstrac
// Write the isNormalized flag
if ( attributeType != null )
{
- // This flag is present to tell that we have a normalized value different
+ // This flag is present to tell that we have a normalized value different
// from the upValue
out.writeBoolean( true );