You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@directory.apache.org by ak...@apache.org on 2007/10/17 06:33:47 UTC
svn commit: r585363 - in
/directory/shared/branches/bigbang/ldap/src/main/java/org/apache/directory/shared/ldap/entry:
./ client/ server/
Author: akarasulu
Date: Tue Oct 16 21:33:45 2007
New Revision: 585363
URL: http://svn.apache.org/viewvc?rev=585363&view=rev
Log:
adding some interfaces to serve as the basis for server entries: incomplete and will move some things out of ldap-shared later
Added:
directory/shared/branches/bigbang/ldap/src/main/java/org/apache/directory/shared/ldap/entry/
directory/shared/branches/bigbang/ldap/src/main/java/org/apache/directory/shared/ldap/entry/BinaryValue.java
- copied, changed from r584853, directory/shared/branches/bigbang/ldap/src/main/java/org/apache/directory/shared/ldap/common/BinaryValue.java
directory/shared/branches/bigbang/ldap/src/main/java/org/apache/directory/shared/ldap/entry/Entry.java
directory/shared/branches/bigbang/ldap/src/main/java/org/apache/directory/shared/ldap/entry/EntryAttribute.java
directory/shared/branches/bigbang/ldap/src/main/java/org/apache/directory/shared/ldap/entry/StreamedValue.java
directory/shared/branches/bigbang/ldap/src/main/java/org/apache/directory/shared/ldap/entry/StringValue.java
- copied, changed from r584853, directory/shared/branches/bigbang/ldap/src/main/java/org/apache/directory/shared/ldap/common/StringValue.java
directory/shared/branches/bigbang/ldap/src/main/java/org/apache/directory/shared/ldap/entry/Value.java
directory/shared/branches/bigbang/ldap/src/main/java/org/apache/directory/shared/ldap/entry/client/
directory/shared/branches/bigbang/ldap/src/main/java/org/apache/directory/shared/ldap/entry/client/ClientAttribute.java
directory/shared/branches/bigbang/ldap/src/main/java/org/apache/directory/shared/ldap/entry/client/ClientEntry.java
directory/shared/branches/bigbang/ldap/src/main/java/org/apache/directory/shared/ldap/entry/client/ClientEntryFactory.java
directory/shared/branches/bigbang/ldap/src/main/java/org/apache/directory/shared/ldap/entry/server/
directory/shared/branches/bigbang/ldap/src/main/java/org/apache/directory/shared/ldap/entry/server/InvalidValueException.java
directory/shared/branches/bigbang/ldap/src/main/java/org/apache/directory/shared/ldap/entry/server/ServerAttribute.java
directory/shared/branches/bigbang/ldap/src/main/java/org/apache/directory/shared/ldap/entry/server/ServerEntry.java
directory/shared/branches/bigbang/ldap/src/main/java/org/apache/directory/shared/ldap/entry/server/ServerValue.java
Copied: directory/shared/branches/bigbang/ldap/src/main/java/org/apache/directory/shared/ldap/entry/BinaryValue.java (from r584853, directory/shared/branches/bigbang/ldap/src/main/java/org/apache/directory/shared/ldap/common/BinaryValue.java)
URL: http://svn.apache.org/viewvc/directory/shared/branches/bigbang/ldap/src/main/java/org/apache/directory/shared/ldap/entry/BinaryValue.java?p2=directory/shared/branches/bigbang/ldap/src/main/java/org/apache/directory/shared/ldap/entry/BinaryValue.java&p1=directory/shared/branches/bigbang/ldap/src/main/java/org/apache/directory/shared/ldap/common/BinaryValue.java&r1=584853&r2=585363&rev=585363&view=diff
==============================================================================
--- directory/shared/branches/bigbang/ldap/src/main/java/org/apache/directory/shared/ldap/common/BinaryValue.java (original)
+++ directory/shared/branches/bigbang/ldap/src/main/java/org/apache/directory/shared/ldap/entry/BinaryValue.java Tue Oct 16 21:33:45 2007
@@ -17,106 +17,129 @@
* under the License.
*
*/
-package org.apache.directory.shared.ldap.common;
+package org.apache.directory.shared.ldap.entry;
+
import java.util.Arrays;
import org.apache.directory.shared.ldap.util.StringTools;
+
/**
- * A class storing a byte[] value.
+ * A wrapper around byte[] values in entries.
*
* @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
* @version $Rev$, $Date$
*/
-public class BinaryValue extends AbstractValue<byte[]>
+public class BinaryValue implements Value<byte[]>
{
- /**
- * serialVersionUID
- */
- static final long serialVersionUID = 2L;
+ /** the wrapped binary value */
+ private byte[] wrapped;
+
-
/**
- * Creates a new instance of StringValue with no value
+ * Creates a new instance of BinaryValue with no initial wrapped value.
*/
public BinaryValue()
{
- super( null );
}
-
-
+
+
/**
- * Creates a new instance of StringValue with a value
+ * Creates a new instance of BinaryValue with a wrapped value.
+ *
+ * @param wrapped the binary value to wrap
*/
- public BinaryValue( byte[] value )
+ public BinaryValue( byte[] wrapped )
{
- super( value );
+ this.wrapped = wrapped;
}
-
-
+
+
/**
+ * Dumps binary in hex with label.
+ *
* @see Object#toString()
*/
public String toString()
{
- return "BinaryValue : " + StringTools.dumpBytes( value );
+ return "BinaryValue : " + StringTools.dumpBytes( wrapped );
}
-
+
/**
* @see Object#hashCode()
*/
public int hashCode()
{
- return Arrays.hashCode( value );
+ return Arrays.hashCode( wrapped );
+ }
+
+
+ public byte[] get()
+ {
+ return wrapped;
+ }
+
+
+ public void set( byte[] wrapped )
+ {
+ this.wrapped = wrapped;
}
-
+
/**
- * Makes a copy of the Value.
+ * Makes a deep copy of the BinaryValue.
*
- * @return A non-null copy of the Value.
+ * @return a deep copy of the Value.
*/
+ @SuppressWarnings ( { "CloneDoesntCallSuperClone" } )
public BinaryValue clone() throws CloneNotSupportedException
{
- // Clone the superclass
- BinaryValue cloned = (BinaryValue)super.clone();
-
- // Clone the byte[] value, if it's not null
- byte[] clonedValue = null;
-
- if ( value != null )
- {
- clonedValue = ( value == null ? null : (byte[])value.clone() );
-
- System.arraycopy( value, 0, clonedValue, 0, value.length );
- }
-
- cloned.value = clonedValue;
-
- // We can return the cloned result
- return cloned;
+ if ( wrapped == null )
+ {
+ return new BinaryValue();
+ }
+
+ byte[] clonedValue = new byte[wrapped.length];
+ System.arraycopy( wrapped, 0, clonedValue, 0, wrapped.length );
+ return new BinaryValue( clonedValue );
}
-
-
+
+
/**
* @see Object#equals(Object)
*/
public boolean equals( Object obj )
{
- if ( !super.equals( obj ) )
+ if ( this == obj )
+ {
+ return true;
+ }
+
+ if ( obj == null )
{
return false;
}
-
- BinaryValue value = (BinaryValue)obj;
-
- if ( this.value == null )
+
+ if ( obj.getClass() != this.getClass() )
{
- return value.value == null;
+ return false;
}
-
- return Arrays.equals( this.value, value.value );
+
+ BinaryValue binaryValue = ( BinaryValue ) obj;
+ if ( this.wrapped == null && binaryValue.wrapped == null )
+ {
+ return true;
+ }
+
+ //noinspection SimplifiableIfStatement
+ if ( this.wrapped == null && binaryValue.wrapped != null ||
+ this.wrapped != null && binaryValue.wrapped == null )
+ {
+ return false;
+ }
+
+ return Arrays.equals( this.wrapped, binaryValue.wrapped );
}
-}
+}
\ No newline at end of file
Added: directory/shared/branches/bigbang/ldap/src/main/java/org/apache/directory/shared/ldap/entry/Entry.java
URL: http://svn.apache.org/viewvc/directory/shared/branches/bigbang/ldap/src/main/java/org/apache/directory/shared/ldap/entry/Entry.java?rev=585363&view=auto
==============================================================================
--- directory/shared/branches/bigbang/ldap/src/main/java/org/apache/directory/shared/ldap/entry/Entry.java (added)
+++ directory/shared/branches/bigbang/ldap/src/main/java/org/apache/directory/shared/ldap/entry/Entry.java Tue Oct 16 21:33:45 2007
@@ -0,0 +1,97 @@
+/*
+ * 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 org.apache.directory.shared.ldap.name.LdapDN;
+
+import java.util.Iterator;
+
+
+/**
+ * Document me!
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev$, $Date$
+ */
+public interface Entry
+{
+ /**
+ * Removes all the attributes.
+ */
+ void clear();
+
+
+ /**
+ * Get this entry's DN.
+ *
+ * @return The entry DN
+ */
+ LdapDN getDn();
+
+
+ /**
+ * Set this entry's DN.
+ *
+ * @param dn The LdapdN associated with this entry
+ */
+ void setDn( LdapDN dn);
+
+
+ /**
+ * Returns an enumeration containing the zero or more attributes in the
+ * collection. The behaviour of the enumeration is not specified if the
+ * attribute collection is changed.
+ *
+ * @return an enumeration of all contained attributes
+ */
+ Iterator<? extends EntryAttribute> getAll();
+
+
+ /**
+ * Places a non-null attribute in the attribute collection. If there is
+ * already an attribute with the same OID as the new attribute, the old one
+ * is removed from the collection and is returned by this method. If there
+ * was no attribute with the same OID the return value is <code>null</code>.
+ *
+ * @param attribute the attribute to be put
+ * @return the old attribute with the same OID, if exists; otherwise
+ * <code>null</code>
+ */
+ EntryAttribute put( EntryAttribute attribute );
+
+
+ /**
+ * Removes the specified attribute. The removed attribute is
+ * returned by this method. If there were no attribute the return value
+ * is <code>null</code>.
+ *
+ * @param attribute the attribute to be removed
+ * @return the removed attribute, if exists; otherwise <code>null</code>
+ */
+ EntryAttribute remove( EntryAttribute attribute );
+
+
+ /**
+ * Returns the number of attributes.
+ *
+ * @return the number of attributes
+ */
+ int size();
+}
Added: directory/shared/branches/bigbang/ldap/src/main/java/org/apache/directory/shared/ldap/entry/EntryAttribute.java
URL: http://svn.apache.org/viewvc/directory/shared/branches/bigbang/ldap/src/main/java/org/apache/directory/shared/ldap/entry/EntryAttribute.java?rev=585363&view=auto
==============================================================================
--- directory/shared/branches/bigbang/ldap/src/main/java/org/apache/directory/shared/ldap/entry/EntryAttribute.java (added)
+++ directory/shared/branches/bigbang/ldap/src/main/java/org/apache/directory/shared/ldap/entry/EntryAttribute.java Tue Oct 16 21:33:45 2007
@@ -0,0 +1,197 @@
+/*
+ * 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.util.Iterator;
+
+
+/**
+ * Document me!
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev$, $Date$
+ */
+public interface EntryAttribute
+{
+ /**
+ * Adds a value to this attribute. If the new value is already present in
+ * the attribute values, the method has no effect.
+ * <p>
+ * The new value is added at the end of list of values.
+ * </p>
+ * <p>
+ * This method returns true or false to indicate whether a value was added.
+ * </p>
+ *
+ * @param val a new value to be added which may be null
+ * @return true if a value was added, otherwise false
+ */
+ boolean add( Value<?> val );
+
+
+ /**
+ * Adds a value to this attribute. If the new value is already present in
+ * the attribute values, the method has no effect.
+ * <p>
+ * The new value is added at the end of list of values.
+ * </p>
+ * <p>
+ * This method returns true or false to indicate whether a value was added.
+ * </p>
+ *
+ * @param val a new value to be added which may be null
+ * @return true if a value was added, otherwise false
+ */
+ boolean add( String val );
+
+
+ /**
+ * Adds a value to this attribute. If the new value is already present in
+ * the attribute values, the method has no effect.
+ * <p>
+ * The new value is added at the end of list of values.
+ * </p>
+ * <p>
+ * This method returns true or false to indicate whether a value was added.
+ * </p>
+ *
+ * @param val a new value to be added which may be null
+ * @return true if a value was added, otherwise false
+ */
+ boolean add( byte[] val );
+
+
+ /**
+ * Removes all values of this attribute.
+ */
+ void clear();
+
+
+ /**
+ * Returns a deep copy of the attribute containing all the same values. The
+ * values <b>are</b> cloned.
+ *
+ * @return a deep clone of this attribute
+ */
+ EntryAttribute clone();
+
+
+ /**
+ * Indicates whether the specified value is one of the attribute's values.
+ *
+ * @param val the value which may be null
+ * @return true if this attribute contains the value, otherwise false
+ */
+ boolean contains( Value<?> val );
+
+
+ /**
+ * Indicates whether the specified value is one of the attribute's values.
+ *
+ * @param val the value which may be null
+ * @return true if this attribute contains the value, otherwise false
+ */
+ boolean contains( String val );
+
+
+ /**
+ * Indicates whether the specified value is one of the attribute's values.
+ *
+ * @param val the value which may be null
+ * @return true if this attribute contains the value, otherwise false
+ */
+ boolean contains( byte[] val );
+
+
+ /**
+ * Gets the first value of this attribute. <code>null</code> is a valid value.
+ *
+ * <p>
+ * If the attribute has no values this method throws
+ * <code>NoSuchElementException</code>.
+ * </p>
+ *
+ * @return a value of 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();
+
+
+ /**
+ * 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();
+
+
+ /**
+ * Removes a value that is equal to the given value.
+ * <p>
+ * Returns true if a value is removed. If there is no value equal to <code>
+ * val</code> this method simply returns false.
+ * </p>
+ *
+ * @param val the value to be removed
+ * @return true if the value is removed, otherwise false
+ */
+ boolean remove( Value<?> val );
+
+
+ /**
+ * Removes a value that is equal to the given value.
+ * <p>
+ * Returns true if a value is removed. If there is no value equal to <code>
+ * val</code> this method simply returns false.
+ * </p>
+ *
+ * @param val the value to be removed
+ * @return true if the value is removed, otherwise false
+ */
+ boolean remove( byte[] val );
+
+
+ /**
+ * Removes a value that is equal to the given value.
+ * <p>
+ * Returns true if a value is removed. If there is no value equal to <code>
+ * val</code> this method simply returns false.
+ * </p>
+ *
+ * @param val the value to be removed
+ * @return true if the value is removed, otherwise false
+ */
+ boolean remove( String val );
+}
Added: directory/shared/branches/bigbang/ldap/src/main/java/org/apache/directory/shared/ldap/entry/StreamedValue.java
URL: http://svn.apache.org/viewvc/directory/shared/branches/bigbang/ldap/src/main/java/org/apache/directory/shared/ldap/entry/StreamedValue.java?rev=585363&view=auto
==============================================================================
--- directory/shared/branches/bigbang/ldap/src/main/java/org/apache/directory/shared/ldap/entry/StreamedValue.java (added)
+++ directory/shared/branches/bigbang/ldap/src/main/java/org/apache/directory/shared/ldap/entry/StreamedValue.java Tue Oct 16 21:33:45 2007
@@ -0,0 +1,114 @@
+/*
+ * 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 org.apache.directory.shared.ldap.NotImplementedException;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.net.URI;
+
+
+/**
+ * Document me!
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev$, $Date$
+ */
+public class StreamedValue implements Value<URI>
+{
+ private URI wrapped;
+
+
+ /**
+ * Creates a streamed value without a wrapped URI.
+ */
+ public StreamedValue()
+ {
+ }
+
+
+ /**
+ * Creates a streamed value with an initial wrapped URI.
+ *
+ * @param wrapped the URI to wrap
+ */
+ public StreamedValue( URI wrapped )
+ {
+ this.wrapped = wrapped;
+ }
+
+
+ /**
+ * Gets an input stream to read the streamed data.
+ *
+ * @return the streamed data
+ * @throws IOException if there are errors estabilishing the data channel
+ */
+ public InputStream getInputStream() throws IOException
+ {
+ /*
+ * Need some URI handlers to get the stream.
+ */
+ throw new NotImplementedException();
+ }
+
+
+ /**
+ * Gets an output stream to write streamed data for this value.
+ *
+ * @return the streamed data
+ * @throws IOException if there are errors establishing the data channel
+ */
+ public OutputStream getOutputStream() throws IOException
+ {
+ /*
+ * Need some URI handlers to get the stream.
+ */
+ throw new NotImplementedException();
+ }
+
+
+ public URI get()
+ {
+ return wrapped;
+ }
+
+
+ public void set( URI wrapped )
+ {
+ this.wrapped = wrapped;
+ }
+
+
+ /**
+ * A shallow clone however note this is the same as a deep clone since the
+ * URI is immutable.
+ *
+ * @return a copy of this StreamedValue
+ * @throws CloneNotSupportedException
+ */
+ @SuppressWarnings ( { "CloneDoesntCallSuperClone" } )
+ public StreamedValue clone() throws CloneNotSupportedException
+ {
+ return new StreamedValue( wrapped );
+ }
+}
Copied: directory/shared/branches/bigbang/ldap/src/main/java/org/apache/directory/shared/ldap/entry/StringValue.java (from r584853, directory/shared/branches/bigbang/ldap/src/main/java/org/apache/directory/shared/ldap/common/StringValue.java)
URL: http://svn.apache.org/viewvc/directory/shared/branches/bigbang/ldap/src/main/java/org/apache/directory/shared/ldap/entry/StringValue.java?p2=directory/shared/branches/bigbang/ldap/src/main/java/org/apache/directory/shared/ldap/entry/StringValue.java&p1=directory/shared/branches/bigbang/ldap/src/main/java/org/apache/directory/shared/ldap/common/StringValue.java&r1=584853&r2=585363&rev=585363&view=diff
==============================================================================
--- directory/shared/branches/bigbang/ldap/src/main/java/org/apache/directory/shared/ldap/common/StringValue.java (original)
+++ directory/shared/branches/bigbang/ldap/src/main/java/org/apache/directory/shared/ldap/entry/StringValue.java Tue Oct 16 21:33:45 2007
@@ -17,76 +17,125 @@
* under the License.
*
*/
-package org.apache.directory.shared.ldap.common;
+package org.apache.directory.shared.ldap.entry;
/**
- * A class storing a String value.
+ * A warpper around an EntryAttribute's String value.
*
* @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
* @version $Rev$, $Date$
*/
-public class StringValue extends AbstractValue<String>
+public class StringValue implements Value<String>
{
- /**
- * serialVersionUID
- */
+ @SuppressWarnings ( { "AnalyzingVariableNaming" } )
static final long serialVersionUID = 2L;
-
+ /** the wrapped string value */
+ private String wrapped;
+
+
/**
- * Creates a new instance of StringValue with no value
+ * Creates a new instance of StringValue with no value.
*/
public StringValue()
{
- super( null );
}
-
-
+
+
/**
- * Creates a new instance of StringValue with a value
+ * Creates a new instance of StringValue with a value.
+ *
+ * @param wrapped the actual String value to wrap
*/
- public StringValue( String value )
+ public StringValue( String wrapped )
{
- super( value );
+ this.wrapped = wrapped;
}
-
-
+
+
/**
* @see Object#toString()
*/
public String toString()
{
- return "StringValue : " + value;
+ return "StringValue : " + wrapped;
}
-
-
+
+
/**
* @see Object#hashCode()
*/
public int hashCode()
{
- return value.hashCode();
+ return wrapped.hashCode();
}
-
+
/**
* @see Object#equals(Object)
*/
public boolean equals( Object obj )
{
- if ( !super.equals( obj ) )
+ if ( this == obj )
+ {
+ return true;
+ }
+
+ if ( obj == null )
+ {
+ return false;
+ }
+
+ if ( ! ( obj instanceof StringValue ) )
{
return false;
}
-
- StringValue value = (StringValue)obj;
-
- if ( this.value == null )
+
+ StringValue stringValue = ( StringValue ) obj;
+ if ( this.wrapped == null && stringValue.wrapped == null )
{
- return value.value == null;
+ return true;
}
-
- return this.value.equals( value.value );
+
+ //noinspection SimplifiableIfStatement
+ if ( this.wrapped == null && stringValue.wrapped != null ||
+ this.wrapped != null && stringValue.wrapped == null )
+ {
+ return false;
+ }
+
+ //noinspection ConstantConditions
+ return this.wrapped.equals( stringValue.wrapped );
+ }
+
+
+ public String get()
+ {
+ return wrapped;
+ }
+
+
+ public void set( String wrapped )
+ {
+ this.wrapped = wrapped;
+ }
+
+
+ /**
+ * This is a shallow copy but in this case since the String is immutable
+ * and thus it makes no difference if the clone is shallow or deep.
+ *
+ * @return a shallow copy
+ */
+ @SuppressWarnings ( { "CloneDoesntCallSuperClone" } )
+ public Value<String> clone() throws CloneNotSupportedException
+ {
+ if ( wrapped == null )
+ {
+ return new StringValue();
+ }
+
+ return new StringValue( wrapped );
}
-}
+}
\ No newline at end of file
Added: directory/shared/branches/bigbang/ldap/src/main/java/org/apache/directory/shared/ldap/entry/Value.java
URL: http://svn.apache.org/viewvc/directory/shared/branches/bigbang/ldap/src/main/java/org/apache/directory/shared/ldap/entry/Value.java?rev=585363&view=auto
==============================================================================
--- directory/shared/branches/bigbang/ldap/src/main/java/org/apache/directory/shared/ldap/entry/Value.java (added)
+++ directory/shared/branches/bigbang/ldap/src/main/java/org/apache/directory/shared/ldap/entry/Value.java Tue Oct 16 21:33:45 2007
@@ -0,0 +1,58 @@
+/*
+ * 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.Serializable;
+
+
+/**
+ * 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 Serializable, Cloneable
+{
+ /**
+ * Get the wrapped value.
+ *
+ * @return the wrapped value, as its original type (String,byte[],URI)
+ */
+ T get();
+
+
+ /**
+ * Sets the wrapped value.
+ *
+ * @param wrapped the value to set. Should be either a String, URI, or a byte[]
+ */
+ void set( T wrapped );
+
+
+ /**
+ * Makes a deep copy of this Value.
+ *
+ * @return a deep copy of this Value
+ * @throws CloneNotSupportedException if the clone operation is not supported
+ */
+ Value<?> clone() throws CloneNotSupportedException;
+}
Added: directory/shared/branches/bigbang/ldap/src/main/java/org/apache/directory/shared/ldap/entry/client/ClientAttribute.java
URL: http://svn.apache.org/viewvc/directory/shared/branches/bigbang/ldap/src/main/java/org/apache/directory/shared/ldap/entry/client/ClientAttribute.java?rev=585363&view=auto
==============================================================================
--- directory/shared/branches/bigbang/ldap/src/main/java/org/apache/directory/shared/ldap/entry/client/ClientAttribute.java (added)
+++ directory/shared/branches/bigbang/ldap/src/main/java/org/apache/directory/shared/ldap/entry/client/ClientAttribute.java Tue Oct 16 21:33:45 2007
@@ -0,0 +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;
+
+
+/**
+ * Document me!
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev$, $Date$
+ */
+public interface ClientAttribute
+{
+ /**
+ * Gets the identifier for this client side entry attribute.
+ *
+ * @return the identifier for an entry
+ */
+ String getId();
+}
Added: directory/shared/branches/bigbang/ldap/src/main/java/org/apache/directory/shared/ldap/entry/client/ClientEntry.java
URL: http://svn.apache.org/viewvc/directory/shared/branches/bigbang/ldap/src/main/java/org/apache/directory/shared/ldap/entry/client/ClientEntry.java?rev=585363&view=auto
==============================================================================
--- directory/shared/branches/bigbang/ldap/src/main/java/org/apache/directory/shared/ldap/entry/client/ClientEntry.java (added)
+++ directory/shared/branches/bigbang/ldap/src/main/java/org/apache/directory/shared/ldap/entry/client/ClientEntry.java Tue Oct 16 21:33:45 2007
@@ -0,0 +1,118 @@
+/*
+ * 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;
+import org.apache.directory.shared.ldap.entry.Value;
+
+
+/**
+ * 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
+{
+ /**
+ * Returns the attribute with the specified alias. The return value
+ * is <code>null</code> if no match is found. An Attribute with an id
+ * different from the supplied alias may be returned: for example a call
+ * with 'cn' may in some implementations return a ClientAttribute whose
+ * getId() feild returns 'commonName'.
+ *
+ * @param alias an aliased name of the attribute identifier
+ * @return the attribute associated with the alias
+ */
+ ClientAttribute get( String alias );
+
+
+ /**
+ * Places a new attribute with the supplied alias and value into the
+ * attribute collection. If there is already an attribute associated with
+ * the alias, the old one is removed from the collection and is returned
+ * by this method. If there was no attribute associated with the alias the
+ * return value is <code>null</code>. An attribute with an id different
+ * from the supplied alias may be returned: for example a call with 'cn'
+ * may in some implementations return a ClientAttribute whose getId()
+ * feild returns 'commonName'.
+ *
+ * This method provides a mechanism to put an attribute with a <code>null
+ * </code> value: the value of <code>val</code> may be <code>null</code>.
+ *
+ * @param alias an aliased name of the new attribute to be put
+ * @param val the value of the new attribute to be put
+ * @return the old attribute with associated with the specified alias,
+ * if exists; otherwise <code>null</code>
+ */
+ ClientAttribute put( String alias, Value<?> val );
+
+
+ /**
+ * Places a new attribute with the supplied OID and value into the attribute
+ * collection. If there is already an attribute with the same OID, the old
+ * one is removed from the collection and is returned by this method. If
+ * there was no attribute with the same OID the return value is
+ * <code>null</code>.
+ *
+ * This method provides a mechanism to put an attribute with a
+ * <code>null</code> value: the value of <code>obj</code> may be
+ * <code>null</code>.
+ *
+ * @param alias an aliased name of the new attribute to be put
+ * @param val the value of the new attribute to be put
+ * @return the old attribute with the same identifier, if exists; otherwise
+ * <code>null</code>
+ */
+ ClientAttribute put( String alias, String val );
+
+
+ /**
+ * Places a new attribute with the supplied OID and value into the attribute
+ * collection. If there is already an attribute with the same OID, the old
+ * one is removed from the collection and is returned by this method. If
+ * there was no attribute with the same OID the return value is
+ * <code>null</code>.
+ *
+ * This method provides a mechanism to put an attribute with a
+ * <code>null</code> value: the value of <code>obj</code> may be
+ * <code>null</code>.
+ *
+ * @param alias an aliased of the new attribute to be put
+ * @param val the value of the new attribute to be put
+ * @return the old attribute with the same identifier, if exists; otherwise
+ * <code>null</code>
+ */
+ ClientAttribute put( String alias, byte[] val );
+
+
+ /**
+ * Removes the attribute with the specified alias. The removed attribute is
+ * returned by this method. If there is no attribute with the specified OID,
+ * the return value is <code>null</code>.
+ *
+ * @param alias an aliased name of the attribute to be removed
+ * @return the removed attribute, if exists; otherwise <code>null</code>
+ */
+ ClientAttribute remove( String alias );
+}
Added: directory/shared/branches/bigbang/ldap/src/main/java/org/apache/directory/shared/ldap/entry/client/ClientEntryFactory.java
URL: http://svn.apache.org/viewvc/directory/shared/branches/bigbang/ldap/src/main/java/org/apache/directory/shared/ldap/entry/client/ClientEntryFactory.java?rev=585363&view=auto
==============================================================================
--- directory/shared/branches/bigbang/ldap/src/main/java/org/apache/directory/shared/ldap/entry/client/ClientEntryFactory.java (added)
+++ directory/shared/branches/bigbang/ldap/src/main/java/org/apache/directory/shared/ldap/entry/client/ClientEntryFactory.java Tue Oct 16 21:33:45 2007
@@ -0,0 +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();
+}
Added: directory/shared/branches/bigbang/ldap/src/main/java/org/apache/directory/shared/ldap/entry/server/InvalidValueException.java
URL: http://svn.apache.org/viewvc/directory/shared/branches/bigbang/ldap/src/main/java/org/apache/directory/shared/ldap/entry/server/InvalidValueException.java?rev=585363&view=auto
==============================================================================
--- directory/shared/branches/bigbang/ldap/src/main/java/org/apache/directory/shared/ldap/entry/server/InvalidValueException.java (added)
+++ directory/shared/branches/bigbang/ldap/src/main/java/org/apache/directory/shared/ldap/entry/server/InvalidValueException.java Tue Oct 16 21:33:45 2007
@@ -0,0 +1,30 @@
+/*
+ * 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.server;
+
+
+/**
+ * Document me!
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev$, $Date$
+ */
+public class InvalidValueException extends Exception
+{
+}
Added: directory/shared/branches/bigbang/ldap/src/main/java/org/apache/directory/shared/ldap/entry/server/ServerAttribute.java
URL: http://svn.apache.org/viewvc/directory/shared/branches/bigbang/ldap/src/main/java/org/apache/directory/shared/ldap/entry/server/ServerAttribute.java?rev=585363&view=auto
==============================================================================
--- directory/shared/branches/bigbang/ldap/src/main/java/org/apache/directory/shared/ldap/entry/server/ServerAttribute.java (added)
+++ directory/shared/branches/bigbang/ldap/src/main/java/org/apache/directory/shared/ldap/entry/server/ServerAttribute.java Tue Oct 16 21:33:45 2007
@@ -0,0 +1,48 @@
+/*
+ * 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.server;
+
+
+import org.apache.directory.shared.ldap.entry.EntryAttribute;
+import org.apache.directory.shared.ldap.schema.AttributeType;
+
+
+/**
+ * Document me!
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev$, $Date$
+ */
+public interface ServerAttribute extends EntryAttribute
+{
+ /**
+ * Gets the attribute type associated with this ServerAttribute.
+ *
+ * @return the attributeType associated with this entry attribute
+ */
+ AttributeType getType();
+
+
+ /**
+ * Checks to see if this attribute is valid along with the values it contains.
+ *
+ * @return true if the attribute and it's values are valid, false otherwise
+ */
+ boolean isValid();
+}
Added: directory/shared/branches/bigbang/ldap/src/main/java/org/apache/directory/shared/ldap/entry/server/ServerEntry.java
URL: http://svn.apache.org/viewvc/directory/shared/branches/bigbang/ldap/src/main/java/org/apache/directory/shared/ldap/entry/server/ServerEntry.java?rev=585363&view=auto
==============================================================================
--- directory/shared/branches/bigbang/ldap/src/main/java/org/apache/directory/shared/ldap/entry/server/ServerEntry.java (added)
+++ directory/shared/branches/bigbang/ldap/src/main/java/org/apache/directory/shared/ldap/entry/server/ServerEntry.java Tue Oct 16 21:33:45 2007
@@ -0,0 +1,198 @@
+/*
+ * 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.server;
+
+
+import org.apache.directory.shared.asn1.primitives.OID;
+import org.apache.directory.shared.ldap.schema.ObjectClass;
+import org.apache.directory.shared.ldap.entry.Entry;
+import org.apache.directory.shared.ldap.entry.Value;
+import org.apache.directory.shared.ldap.entry.EntryAttribute;
+
+import java.util.Set;
+
+
+/**
+ * Document me!
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev$, $Date$
+ */
+public interface ServerEntry extends Entry
+{
+ // -----------------------------------------------------------------------
+ // Schema Related Methods
+ // -----------------------------------------------------------------------
+
+
+ /**
+ * Gets the first structural objectClass that it can find within the entry.
+ * If the entry is inconsistent and contains no objectClass attribute then
+ * null is returned. If the entry is inconsistent and contains more than
+ * one structural objectClass which is illegal, then the first to be found
+ * will be returned.
+ *
+ * @return the first structural objectClass found in this entry
+ */
+ ObjectClass getStructuralObjectClass();
+
+
+ /**
+ * Gets all the auxiliary objectClasses that it can find within the entry.
+ * If the entry is inconsistent and contains no objectClass attribute then
+ * the empty set is returned.
+ *
+ * @return the set of auxiliary objectClasses found in this entry
+ */
+ Set<ObjectClass> getAuxiliaryObjectClasses();
+
+
+ /**
+ * Gets the objectClasses associated with this entry. If there is no
+ * objectClass attribute contained within this entry then an empty set
+ * is returned.
+ *
+ * @return the objectClasses which govern the structure of this entry
+ */
+ Set<ObjectClass> getObjectClasses();
+
+
+ /**
+ * Gets the combinded set of all required attributes for this entry across
+ * all objectClasses.
+ *
+ * @return the combinded set of all required attributes
+ */
+ Set<ServerAttribute> getMustList();
+
+
+ /**
+ * Gets the combined set of all optional attributes for this entry across
+ * all objectClasses.
+ *
+ * @return the combined set of all optional attributes
+ */
+ Set<ServerAttribute> getMayList();
+
+
+ /**
+ * Fail fast check performed to determine entry consistency according to schema
+ * characteristics.
+ *
+ * @return true if the entry, it's attributes and their values are consistent
+ * with the schema
+ */
+ boolean isValid();
+
+
+ // -----------------------------------------------------------------------
+ // Container (get/put/remove) Methods
+ // -----------------------------------------------------------------------
+
+
+ /**
+ * Returns the attribute with the specified OID. The return value
+ * is <code>null</code> if no match is found.
+ *
+ * @param oid numeric attribute identifier
+ * @return the attribute with the specified OID
+ */
+ ServerAttribute get( OID oid );
+
+
+ /**
+ * Places a non-null attribute in the attribute collection. If there is
+ * already an attribute with the same OID as the new attribute, the old one
+ * is removed from the collection and is returned by this method. If there
+ * was no attribute with the same OID the return value is <code>null</code>.
+ *
+ * @param attribute the attribute to be put
+ * @return the old attribute with the same OID, if exists; otherwise
+ * <code>null</code>
+ */
+ ServerAttribute put( ServerAttribute attribute );
+
+
+ /**
+ * Places a new attribute with the supplied OID and value into the attribute
+ * collection. If there is already an attribute with the same OID, the old
+ * one is removed from the collection and is returned by this method. If
+ * there was no attribute with the same OID the return value is
+ * <code>null</code>.
+ *
+ * This method provides a mechanism to put an attribute with a
+ * <code>null</code> value: the value of <code>obj</code> may be
+ * <code>null</code>.
+ *
+ * @param oid the numeric object identifier of the new attribute to be put
+ * @param val the value of the new attribute to be put
+ * @return the old attribute with the same OID, if exists; otherwise
+ * <code>null</code>
+ */
+ ServerAttribute put( OID oid, Value<?> val );
+
+
+ /**
+ * Places a new attribute with the supplied OID and value into the attribute
+ * collection. If there is already an attribute with the same OID, the old
+ * one is removed from the collection and is returned by this method. If
+ * there was no attribute with the same OID the return value is
+ * <code>null</code>.
+ *
+ * This method provides a mechanism to put an attribute with a
+ * <code>null</code> value: the value of <code>obj</code> may be
+ * <code>null</code>.
+ *
+ * @param oid the numeric object identifier of the new attribute to be put
+ * @param val the value of the new attribute to be put
+ * @return the old attribute with the same identifier, if exists; otherwise
+ * <code>null</code>
+ */
+ ServerAttribute put( OID oid, String val );
+
+
+ /**
+ * Places a new attribute with the supplied OID and value into the attribute
+ * collection. If there is already an attribute with the same OID, the old
+ * one is removed from the collection and is returned by this method. If
+ * there was no attribute with the same OID the return value is
+ * <code>null</code>.
+ *
+ * This method provides a mechanism to put an attribute with a
+ * <code>null</code> value: the value of <code>obj</code> may be
+ * <code>null</code>.
+ *
+ * @param oid the numeric object identifier of the new attribute to be put
+ * @param val the value of the new attribute to be put
+ * @return the old attribute with the same identifier, if exists; otherwise
+ * <code>null</code>
+ */
+ ServerAttribute put( OID oid, byte[] val );
+
+
+ /**
+ * Removes the attribute with the specified alias. The removed attribute is
+ * returned by this method. If there is no attribute with the specified OID,
+ * the return value is <code>null</code>.
+ *
+ * @param oid the numeric object identifier of the attribute to be removed
+ * @return the removed attribute, if exists; otherwise <code>null</code>
+ */
+ ServerAttribute remove( OID oid );
+}
Added: directory/shared/branches/bigbang/ldap/src/main/java/org/apache/directory/shared/ldap/entry/server/ServerValue.java
URL: http://svn.apache.org/viewvc/directory/shared/branches/bigbang/ldap/src/main/java/org/apache/directory/shared/ldap/entry/server/ServerValue.java?rev=585363&view=auto
==============================================================================
--- directory/shared/branches/bigbang/ldap/src/main/java/org/apache/directory/shared/ldap/entry/server/ServerValue.java (added)
+++ directory/shared/branches/bigbang/ldap/src/main/java/org/apache/directory/shared/ldap/entry/server/ServerValue.java Tue Oct 16 21:33:45 2007
@@ -0,0 +1,43 @@
+/*
+ * 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.server;
+
+import org.apache.directory.shared.ldap.entry.Value;
+import org.apache.directory.shared.ldap.entry.server.InvalidValueException;
+
+
+/**
+ * Document me!
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev$, $Date$
+ */
+public interface ServerValue<T> extends Value
+{
+ /**
+ * Gets the normalized representation for the wrapped value of this ServerValue
+ * wrapper. Implementations
+ *
+ * @return the normalized wrapped value
+ * @throws InvalidValueException if the value is not valid
+ */
+ T getNormalizedValue() throws InvalidValueException;
+
+ boolean isValid();
+}