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 2007/12/26 23:14:17 UTC
svn commit: r606960 -
/directory/apacheds/branches/bigbang/core-entry/src/main/java/org/apache/directory/server/core/entry/
Author: elecharny
Date: Wed Dec 26 14:14:15 2007
New Revision: 606960
URL: http://svn.apache.org/viewvc?rev=606960&view=rev
Log:
Removed all the needless generics, as we want to simplify the API, not making it more complex ...
Modified:
directory/apacheds/branches/bigbang/core-entry/src/main/java/org/apache/directory/server/core/entry/AbstractServerAttribute.java
directory/apacheds/branches/bigbang/core-entry/src/main/java/org/apache/directory/server/core/entry/DefaultServerEntry.java
directory/apacheds/branches/bigbang/core-entry/src/main/java/org/apache/directory/server/core/entry/ServerAttribute.java
directory/apacheds/branches/bigbang/core-entry/src/main/java/org/apache/directory/server/core/entry/ServerEntry.java
directory/apacheds/branches/bigbang/core-entry/src/main/java/org/apache/directory/server/core/entry/ServerEntryUtils.java
directory/apacheds/branches/bigbang/core-entry/src/main/java/org/apache/directory/server/core/entry/ServerModification.java
Modified: directory/apacheds/branches/bigbang/core-entry/src/main/java/org/apache/directory/server/core/entry/AbstractServerAttribute.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/bigbang/core-entry/src/main/java/org/apache/directory/server/core/entry/AbstractServerAttribute.java?rev=606960&r1=606959&r2=606960&view=diff
==============================================================================
--- directory/apacheds/branches/bigbang/core-entry/src/main/java/org/apache/directory/server/core/entry/AbstractServerAttribute.java (original)
+++ directory/apacheds/branches/bigbang/core-entry/src/main/java/org/apache/directory/server/core/entry/AbstractServerAttribute.java Wed Dec 26 14:14:15 2007
@@ -41,7 +41,7 @@
* @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
* @version $Rev$, $Date$
*/
-public abstract class AbstractServerAttribute implements ServerAttribute<ServerValue<?>>
+public abstract class AbstractServerAttribute implements ServerAttribute
{
/** logger for reporting errors that might not be handled properly upstream */
private static final Logger LOG = LoggerFactory.getLogger( AbstractServerAttribute.class );
Modified: directory/apacheds/branches/bigbang/core-entry/src/main/java/org/apache/directory/server/core/entry/DefaultServerEntry.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/bigbang/core-entry/src/main/java/org/apache/directory/server/core/entry/DefaultServerEntry.java?rev=606960&r1=606959&r2=606960&view=diff
==============================================================================
--- directory/apacheds/branches/bigbang/core-entry/src/main/java/org/apache/directory/server/core/entry/DefaultServerEntry.java (original)
+++ directory/apacheds/branches/bigbang/core-entry/src/main/java/org/apache/directory/server/core/entry/DefaultServerEntry.java Wed Dec 26 14:14:15 2007
@@ -27,6 +27,7 @@
import java.util.Map;
import java.util.Set;
+import org.apache.directory.server.schema.registries.AttributeTypeRegistry;
import org.apache.directory.server.schema.registries.Registries;
import org.apache.directory.shared.ldap.NotImplementedException;
import org.apache.directory.shared.ldap.constants.SchemaConstants;
@@ -42,18 +43,33 @@
/**
* A default implementation of a ServerEntry which should suite most
* use cases.
+ *
+ * This class is final, it should not be extended.
*
* @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
* @version $Rev$, $Date$
*/
-public class DefaultServerEntry implements ServerEntry<ServerAttribute<ServerValue<?>>>
+public final class DefaultServerEntry implements ServerEntry
{
+ /** The logger for this class */
private static final Logger LOG = LoggerFactory.getLogger( DefaultServerEntry.class );
- private Map<AttributeType, ServerAttribute<ServerValue<?>>> serverAttributeMap = new HashMap<AttributeType, ServerAttribute<ServerValue<?>>>();
+ /** A map containing all the attributes for this entry */
+ private Map<AttributeType, ServerAttribute> serverAttributeMap = new HashMap<AttributeType, ServerAttribute>();
+
+ /** The objectClass container */
private ObjectClassAttribute objectClassAttribute;
+
+ /** The registries */
private final transient Registries registries;
+
+ /** The AttributeType registry */
+ private final transient AttributeTypeRegistry atRegistry;
+
+ /** A speedup to get the ObjectClass attribute */
private transient AttributeType objectClassAT;
+
+ /** The DN for this entry */
private LdapDN dn;
@@ -61,20 +77,21 @@
{
this.dn = dn;
this.registries = registries;
+ atRegistry = registries.getAttributeTypeRegistry();
- objectClassAT = registries.getAttributeTypeRegistry().lookup( SchemaConstants.OBJECT_CLASS_AT );
+ objectClassAT = atRegistry.lookup( SchemaConstants.OBJECT_CLASS_AT );
setObjectClassAttribute( new ObjectClassAttribute( registries ) );
}
- private ServerAttribute<ServerValue<?>> setObjectClassAttribute( ServerAttribute<ServerValue<?>> objectClassAttribute ) throws NamingException
+ private ServerAttribute setObjectClassAttribute( ServerAttribute objectClassAttribute ) throws NamingException
{
this.objectClassAttribute = (ObjectClassAttribute)objectClassAttribute;
return serverAttributeMap.put( objectClassAT, objectClassAttribute );
}
- private ServerAttribute<ServerValue<?>> removeObjectClassAttribute( ServerAttribute<ServerValue<?>> objectClassAttribute ) throws NamingException
+ private ServerAttribute removeObjectClassAttribute( ServerAttribute objectClassAttribute ) throws NamingException
{
this.objectClassAttribute = (ObjectClassAttribute)objectClassAttribute;
@@ -160,17 +177,35 @@
}
- public ServerAttribute<ServerValue<?>> get( AttributeType attributeType )
+ /**
+ * Returns the attribute associated with an AttributeType
+ *
+ * @param the AttributeType we are looking for
+ * @return the associated attribute
+ */
+ public ServerAttribute get( AttributeType attributeType )
{
return serverAttributeMap.get( attributeType );
}
- public List<ServerAttribute<ServerValue<?>>> put( ServerAttribute<ServerValue<?>>... serverAttributes ) throws NamingException
+ /**
+ * Returns the attribute associated with a String
+ *
+ * @param the Attribute ID we are looking for
+ * @return the associated attribute
+ */
+ public ServerAttribute get( String attributeType ) throws NamingException
+ {
+ return get( atRegistry.lookup( attributeType ) );
+ }
+
+
+ public List<ServerAttribute> put( ServerAttribute... serverAttributes ) throws NamingException
{
- List<ServerAttribute<ServerValue<?>>> duplicatedAttributes = new ArrayList<ServerAttribute<ServerValue<?>>>();
+ List<ServerAttribute> duplicatedAttributes = new ArrayList<ServerAttribute>();
- for ( ServerAttribute<ServerValue<?>> serverAttribute:serverAttributes )
+ for ( ServerAttribute serverAttribute:serverAttributes )
{
if ( serverAttribute.getType().equals( objectClassAT ) )
{
@@ -205,7 +240,7 @@
}
- public ServerAttribute<ServerValue<?>> put( String upId, AttributeType attributeType ) throws NamingException
+ public ServerAttribute put( String upId, AttributeType attributeType ) throws NamingException
{
throw new NotImplementedException();
}
@@ -221,10 +256,10 @@
* @return The replaced attribute
* @throws NamingException If the attribute does not exist
*/
- public ServerAttribute<ServerValue<?>> put( String upId, String... values ) throws NamingException
+ public ServerAttribute put( String upId, String... values ) throws NamingException
{
- AttributeType attributeType = registries.getAttributeTypeRegistry().lookup( upId );
- ServerAttribute<ServerValue<?>> existing = serverAttributeMap.get( attributeType );
+ AttributeType attributeType = atRegistry.lookup( upId );
+ ServerAttribute existing = serverAttributeMap.get( attributeType );
for ( String value:values )
{
@@ -245,10 +280,10 @@
* @return The replaced attribute
* @throws NamingException If the attribute does not exist
*/
- public ServerAttribute<ServerValue<?>> put( String upId, byte[]... values ) throws NamingException
+ public ServerAttribute put( String upId, byte[]... values ) throws NamingException
{
- AttributeType attributeType = registries.getAttributeTypeRegistry().lookup( upId );
- ServerAttribute<ServerValue<?>> existing = serverAttributeMap.get( attributeType );
+ AttributeType attributeType = atRegistry.lookup( upId );
+ ServerAttribute existing = serverAttributeMap.get( attributeType );
for ( byte[] value:values )
{
@@ -259,17 +294,17 @@
}
- public ServerAttribute<ServerValue<?>> put( AttributeType attributeType ) throws NamingException
+ public ServerAttribute put( AttributeType attributeType ) throws NamingException
{
throw new NotImplementedException();
}
- public List<ServerAttribute<ServerValue<?>>> remove( ServerAttribute<ServerValue<?>>... serverAttributes ) throws NamingException
+ public List<ServerAttribute> remove( ServerAttribute... serverAttributes ) throws NamingException
{
- List<ServerAttribute<ServerValue<?>>> removedAttributes = new ArrayList<ServerAttribute<ServerValue<?>>>();
+ List<ServerAttribute> removedAttributes = new ArrayList<ServerAttribute>();
- for ( ServerAttribute<ServerValue<?>> serverAttribute:serverAttributes )
+ for ( ServerAttribute serverAttribute:serverAttributes )
{
if ( serverAttribute.getType().equals( objectClassAT ) )
{
@@ -287,9 +322,9 @@
}
- public ServerAttribute<ServerValue<?>> put( AttributeType attributeType, ServerValue<?> val ) throws NamingException
+ public ServerAttribute put( AttributeType attributeType, ServerValue<?> val ) throws NamingException
{
- ServerAttribute<ServerValue<?>> existing = serverAttributeMap.get( attributeType );
+ ServerAttribute existing = serverAttributeMap.get( attributeType );
if ( existing != null )
{
@@ -302,7 +337,7 @@
}
- public ServerAttribute<ServerValue<?>> put( String upId, AttributeType attributeType, ServerValue<?> val ) throws NamingException
+ public ServerAttribute put( String upId, AttributeType attributeType, ServerValue<?> val ) throws NamingException
{
if ( attributeType.equals( objectClassAT ) )
{
@@ -313,9 +348,9 @@
}
- public ServerAttribute<ServerValue<?>> put( AttributeType attributeType, String val ) throws NamingException
+ public ServerAttribute put( AttributeType attributeType, String val ) throws NamingException
{
- ServerAttribute<ServerValue<?>> existing = serverAttributeMap.get( attributeType );
+ ServerAttribute existing = serverAttributeMap.get( attributeType );
if ( attributeType.equals( objectClassAT ) )
{
@@ -338,7 +373,7 @@
}
- public ServerAttribute<ServerValue<?>> put( String upId, AttributeType attributeType, String val ) throws NamingException
+ public ServerAttribute put( String upId, AttributeType attributeType, String val ) throws NamingException
{
if ( attributeType.equals( objectClassAT ) )
{
@@ -349,14 +384,14 @@
}
- public ServerAttribute<ServerValue<?>> put( AttributeType attributeType, byte[] val ) throws NamingException
+ public ServerAttribute put( AttributeType attributeType, byte[] val ) throws NamingException
{
if ( attributeType.equals( objectClassAT ) )
{
throw new UnsupportedOperationException( "Only String values supported for objectClass attribute" );
}
- ServerAttribute<ServerValue<?>> existing = serverAttributeMap.get( attributeType );
+ ServerAttribute existing = serverAttributeMap.get( attributeType );
if ( existing != null )
{
@@ -369,7 +404,7 @@
}
- public ServerAttribute<ServerValue<?>> put( String upId, AttributeType attributeType, byte[] val ) throws NamingException
+ public ServerAttribute put( String upId, AttributeType attributeType, byte[] val ) throws NamingException
{
if ( attributeType.equals( objectClassAT ) )
{
@@ -380,7 +415,7 @@
}
- public ServerAttribute<ServerValue<?>> remove( AttributeType attributeType ) throws NamingException
+ public ServerAttribute remove( AttributeType attributeType ) throws NamingException
{
if ( attributeType.equals( objectClassAT ) )
{
@@ -422,7 +457,7 @@
}
- public Iterator<ServerAttribute<ServerValue<?>>> iterator()
+ public Iterator<ServerAttribute> iterator()
{
return Collections.unmodifiableMap( serverAttributeMap ).values().iterator();
}
Modified: directory/apacheds/branches/bigbang/core-entry/src/main/java/org/apache/directory/server/core/entry/ServerAttribute.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/bigbang/core-entry/src/main/java/org/apache/directory/server/core/entry/ServerAttribute.java?rev=606960&r1=606959&r2=606960&view=diff
==============================================================================
--- directory/apacheds/branches/bigbang/core-entry/src/main/java/org/apache/directory/server/core/entry/ServerAttribute.java (original)
+++ directory/apacheds/branches/bigbang/core-entry/src/main/java/org/apache/directory/server/core/entry/ServerAttribute.java Wed Dec 26 14:14:15 2007
@@ -32,7 +32,7 @@
* @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
* @version $Rev$, $Date$
*/
-public interface ServerAttribute<T extends ServerValue<?>> extends EntryAttribute<T>, Iterable<ServerValue<?>>
+public interface ServerAttribute extends EntryAttribute<ServerValue<?>>, Iterable<ServerValue<?>>
{
/**
* Gets the attribute type associated with this ServerAttribute.
Modified: directory/apacheds/branches/bigbang/core-entry/src/main/java/org/apache/directory/server/core/entry/ServerEntry.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/bigbang/core-entry/src/main/java/org/apache/directory/server/core/entry/ServerEntry.java?rev=606960&r1=606959&r2=606960&view=diff
==============================================================================
--- directory/apacheds/branches/bigbang/core-entry/src/main/java/org/apache/directory/server/core/entry/ServerEntry.java (original)
+++ directory/apacheds/branches/bigbang/core-entry/src/main/java/org/apache/directory/server/core/entry/ServerEntry.java Wed Dec 26 14:14:15 2007
@@ -35,7 +35,7 @@
* @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
* @version $Rev$, $Date$
*/
-public interface ServerEntry<T extends ServerAttribute<ServerValue<?>>> extends Entry<T>, Iterable<T>
+public interface ServerEntry extends Entry<ServerAttribute>, Iterable<ServerAttribute>
{
// -----------------------------------------------------------------------
// Schema Related Methods
@@ -192,7 +192,7 @@
* @param attributeType the type of the attribute
* @return the attribute of the specified type
*/
- T get( AttributeType attributeType );
+ ServerAttribute get( AttributeType attributeType );
/**
@@ -206,13 +206,13 @@
* @return the old attributes with the same OID, if exist; otherwise
* <code>null</code>
*/
- List<T> put( T... attributes ) throws NamingException;
+ List<ServerAttribute> put( ServerAttribute... attributes ) throws NamingException;
// no value put'ters
- T put( String upId, AttributeType attributeType ) throws NamingException;
+ ServerAttribute put( String upId, AttributeType attributeType ) throws NamingException;
- T put( AttributeType attributeType ) throws NamingException;
+ ServerAttribute put( AttributeType attributeType ) throws NamingException;
/**
@@ -234,7 +234,7 @@
* <code>null</code>
* @throws NamingException if there are resolution issues
*/
- T put( AttributeType attributeType, ServerValue<?> val ) throws NamingException;
+ ServerAttribute put( AttributeType attributeType, ServerValue<?> val ) throws NamingException;
/**
* Places a new attribute with the supplied attributeType and value into this
@@ -252,7 +252,7 @@
* <code>null</code>
* @throws NamingException if there are failures
*/
- T put( String upId, AttributeType attributeType, ServerValue<?> val ) throws NamingException;
+ ServerAttribute put( String upId, AttributeType attributeType, ServerValue<?> val ) throws NamingException;
/**
@@ -272,10 +272,10 @@
* <code>null</code>
* @throws NamingException if there are failures
*/
- T put( AttributeType attributeType, String val ) throws NamingException;
+ ServerAttribute put( AttributeType attributeType, String val ) throws NamingException;
- T put( String upId, AttributeType attributeType, String val ) throws NamingException;
+ ServerAttribute put( String upId, AttributeType attributeType, String val ) throws NamingException;
/**
@@ -295,10 +295,10 @@
* <code>null</code>
* @throws NamingException if there are failures
*/
- T put( AttributeType attributeType, byte[] val ) throws NamingException;
+ ServerAttribute put( AttributeType attributeType, byte[] val ) throws NamingException;
- T put( String upId, AttributeType attributeType, byte[] val ) throws NamingException;
+ ServerAttribute put( String upId, AttributeType attributeType, byte[] val ) throws NamingException;
/**
@@ -310,7 +310,7 @@
* @return the removed attribute, if exists; otherwise <code>null</code>
* @throws NamingException if there are failures
*/
- T remove( AttributeType attributeType ) throws NamingException;
+ ServerAttribute remove( AttributeType attributeType ) throws NamingException;
/**
@@ -321,5 +321,5 @@
* @param attributes the attributes to be removed
* @return the removed attribute, if exists; otherwise <code>null</code>
*/
- List<T> remove( T... attributes ) throws NamingException;
+ List<ServerAttribute> remove( ServerAttribute... attributes ) throws NamingException;
}
Modified: directory/apacheds/branches/bigbang/core-entry/src/main/java/org/apache/directory/server/core/entry/ServerEntryUtils.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/bigbang/core-entry/src/main/java/org/apache/directory/server/core/entry/ServerEntryUtils.java?rev=606960&r1=606959&r2=606960&view=diff
==============================================================================
--- directory/apacheds/branches/bigbang/core-entry/src/main/java/org/apache/directory/server/core/entry/ServerEntryUtils.java (original)
+++ directory/apacheds/branches/bigbang/core-entry/src/main/java/org/apache/directory/server/core/entry/ServerEntryUtils.java Wed Dec 26 14:14:15 2007
@@ -29,7 +29,6 @@
import javax.naming.directory.InvalidAttributeIdentifierException;
import org.apache.directory.server.schema.registries.Registries;
-import org.apache.directory.shared.ldap.entry.EntryAttribute;
import org.apache.directory.shared.ldap.entry.Value;
import org.apache.directory.shared.ldap.message.AttributeImpl;
import org.apache.directory.shared.ldap.message.AttributesImpl;
@@ -51,7 +50,7 @@
*
* @return An instance of a AttributesImpl() object
*/
- public static Attributes toAttributesImpl( ServerEntry<?> entry )
+ public static Attributes toAttributesImpl( ServerEntry entry )
{
Attributes attributes = new AttributesImpl();
@@ -59,7 +58,7 @@
{
Attribute attribute = new AttributeImpl( attributeType.getName() );
- ServerAttribute<?> attr = entry.get( attributeType );
+ ServerAttribute attr = entry.get( attributeType );
for ( Iterator<ServerValue<?>> iter = attr.iterator(); iter.hasNext();)
{
@@ -171,7 +170,7 @@
*
* @return An instance of a BasicAttributes() object
*/
- public static Attributes toBasicAttributes( ServerEntry<?> entry )
+ public static Attributes toBasicAttributes( ServerEntry entry )
{
Attributes attributes = new BasicAttributes( true );
@@ -179,7 +178,7 @@
{
Attribute attribute = new BasicAttribute( attributeType.getName(), true );
- ServerAttribute<?> attr = entry.get( attributeType );
+ ServerAttribute attr = entry.get( attributeType );
for ( Iterator<ServerValue<?>> iter = attr.iterator(); iter.hasNext();)
{
@@ -199,7 +198,7 @@
*
* @return An instance of a BasicAttribute() object
*/
- public static Attribute toBasicAttribute( ServerAttribute<ServerValue<?>> attr )
+ public static Attribute toBasicAttribute( ServerAttribute attr )
{
Attribute attribute = new BasicAttribute( attr.getUpId(), false );
@@ -219,7 +218,7 @@
*
* @return An instance of a BasicAttribute() object
*/
- public static Attribute toAttributeImpl( ServerAttribute<ServerValue<?>> attr )
+ public static Attribute toAttributeImpl( ServerAttribute attr )
{
Attribute attribute = new AttributeImpl( attr.getUpId(), false );
Modified: directory/apacheds/branches/bigbang/core-entry/src/main/java/org/apache/directory/server/core/entry/ServerModification.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/bigbang/core-entry/src/main/java/org/apache/directory/server/core/entry/ServerModification.java?rev=606960&r1=606959&r2=606960&view=diff
==============================================================================
--- directory/apacheds/branches/bigbang/core-entry/src/main/java/org/apache/directory/server/core/entry/ServerModification.java (original)
+++ directory/apacheds/branches/bigbang/core-entry/src/main/java/org/apache/directory/server/core/entry/ServerModification.java Wed Dec 26 14:14:15 2007
@@ -33,7 +33,7 @@
* @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
* @version $Rev$, $Date$
*/
-public class ServerModification<T extends ServerAttribute<?>> implements Modification<T>, Serializable
+public class ServerModification<T extends ServerAttribute> implements Modification<T>, Serializable
{
public static final long serialVersionUID = 1L;