org.apache.directory.shared.ldap.entry.client
Class DefaultClientEntry

java.lang.Object
  extended by org.apache.directory.shared.ldap.entry.AbstractEntry<java.lang.String>
      extended by org.apache.directory.shared.ldap.entry.client.DefaultClientEntry
All Implemented Interfaces:
java.io.Externalizable, java.io.Serializable, java.lang.Cloneable, java.lang.Iterable<EntryAttribute>, Entry

public final class DefaultClientEntry
extends AbstractEntry<java.lang.String>

A default implementation of a ServerEntry which should suite most use cases. This class is final, it should not be extended.

Version:
$Rev$, $Date$
Author:
Apache Directory Project
See Also:
Serialized Form

Field Summary
 
Fields inherited from class org.apache.directory.shared.ldap.entry.AbstractEntry
attributes, dn
 
Constructor Summary
DefaultClientEntry()
          Creates a new instance of DefaultClientEntry.
DefaultClientEntry(DN dn)
          Creates a new instance of DefaultServerEntry, with a DN.
DefaultClientEntry(DN dn, EntryAttribute... attributes)
           Creates a new instance of DefaultClientEntry, with a DN and a list of EntryAttributes.
DefaultClientEntry(DN dn, java.lang.String... upIds)
          Creates a new instance of DefaultServerEntry, with a DN and a list of IDs.
 
Method Summary
 void add(EntryAttribute... attributes)
          Add some Attributes to the current Entry.
 void add(java.lang.String upId, byte[]... values)
          Add an attribute (represented by its ID and binary values) into an entry.
 void add(java.lang.String upId, java.lang.String... values)
          Add some String values to the current Entry.
 void add(java.lang.String upId, Value<?>... values)
          Add an attribute (represented by its ID and Value values) into an entry.
 Entry clone()
          Clone an entry.
 boolean contains(EntryAttribute... attributes)
           Checks if an entry contains a list of attributes.
 boolean contains(java.lang.String upId)
          Checks if an entry contains a specific attribute
 boolean contains(java.lang.String upId, byte[]... values)
          Checks if an entry contains an attribute with some binary values.
 boolean contains(java.lang.String upId, java.lang.String... values)
          Checks if an entry contains an attribute with some String values.
 boolean contains(java.lang.String upId, Value<?>... values)
          Checks if an entry contains an attribute with some values.
 boolean containsAttribute(java.lang.String... attributes)
          Checks if an entry contains some specific attributes.
 boolean equals(java.lang.Object o)
           
 EntryAttribute get(java.lang.String alias)
           Returns the attribute with the specified alias.
 int hashCode()
          Get the hash code of this ClientEntry.
 boolean hasObjectClass(java.lang.String objectClass)
          Tells if an entry has a specific ObjectClass value
 java.util.Iterator<EntryAttribute> iterator()
          Returns an enumeration containing the zero or more attributes in the collection.
 java.util.List<EntryAttribute> put(EntryAttribute... attributes)
           Places attributes in the attribute collection.
 EntryAttribute put(java.lang.String upId, byte[]... values)
           Put an attribute (represented by its ID and some binary values) into an entry.
 EntryAttribute put(java.lang.String upId, java.lang.String... values)
           Put an attribute (represented by its ID and some String values) into an entry.
 EntryAttribute put(java.lang.String upId, Value<?>... values)
           Put an attribute (represented by its ID and some values) into an entry.
 void readExternal(java.io.ObjectInput in)
           
 java.util.List<EntryAttribute> remove(EntryAttribute... attributes)
          Removes the specified attributes.
 boolean remove(java.lang.String upId, byte[]... values)
           Removes the specified binary values from an attribute.
 boolean remove(java.lang.String upId, java.lang.String... values)
           Removes the specified String values from an attribute.
 boolean remove(java.lang.String upId, Value<?>... values)
           Removes the specified values from an attribute.
 java.util.List<EntryAttribute> removeAttributes(java.lang.String... attributes)
           Removes the attribute with the specified alias.
 java.util.List<EntryAttribute> set(java.lang.String... upIds)
           Put some new ClientAttribute using the User Provided ID.
 java.lang.String toString()
           
 void writeExternal(java.io.ObjectOutput out)
           
 
Methods inherited from class org.apache.directory.shared.ldap.entry.AbstractEntry
clear, getDn, setDn, size
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

DefaultClientEntry

public DefaultClientEntry()
Creates a new instance of DefaultClientEntry.

This entry must be initialized before being used !


DefaultClientEntry

public DefaultClientEntry(DN dn)
Creates a new instance of DefaultServerEntry, with a DN.

Parameters:
dn - The DN for this serverEntry. Can be null.

DefaultClientEntry

public DefaultClientEntry(DN dn,
                          java.lang.String... upIds)
Creates a new instance of DefaultServerEntry, with a DN and a list of IDs.

Parameters:
dn - The DN for this serverEntry. Can be null.
upIds - The list of attributes to create.

DefaultClientEntry

public DefaultClientEntry(DN dn,
                          EntryAttribute... attributes)

Creates a new instance of DefaultClientEntry, with a DN and a list of EntryAttributes.

Parameters:
dn - The DN for this serverEntry. Can be null
attributes - The list of attributes to create
Method Detail

add

public void add(EntryAttribute... attributes)
         throws LdapException
Add some Attributes to the current Entry.

Parameters:
attributes - The attributes to add
Throws:
LdapException - If we can't add any of the attributes

add

public void add(java.lang.String upId,
                byte[]... values)
         throws LdapException
Add an attribute (represented by its ID and binary values) into an entry.

Parameters:
upId - The attribute ID
values - The list of binary values to inject. It can be empty
Throws:
LdapException - If the attribute does not exist

add

public void add(java.lang.String upId,
                java.lang.String... values)
         throws LdapException
Add some String values to the current Entry.

Parameters:
upId - The user provided ID of the attribute we want to add some values to
values - The list of String values to add
Throws:
LdapException - If we can't add any of the values

add

public void add(java.lang.String upId,
                Value<?>... values)
         throws LdapException
Add an attribute (represented by its ID and Value values) into an entry.

Parameters:
upId - The attribute ID
values - The list of Value values to inject. It can be empty
Throws:
LdapException - If the attribute does not exist

clone

public Entry clone()
Clone an entry. All the element are duplicated, so a modification on the original object won't affect the cloned object, as a modification on the cloned object has no impact on the original object

Specified by:
clone in interface Entry
Overrides:
clone in class AbstractEntry<java.lang.String>

contains

public boolean contains(EntryAttribute... attributes)
                 throws LdapException

Checks if an entry contains a list of attributes.

If the list is null or empty, this method will return true if the entry has no attribute, false otherwise.

Parameters:
attributes - The Attributes to look for
Returns:
true if all the attributes are found within the entry, false if at least one of them is not present.
Throws:
LdapException - If the attribute does not exist

contains

public boolean contains(java.lang.String upId)
                 throws LdapException
Checks if an entry contains a specific attribute

Parameters:
attributes - The Attributes to look for
Returns:
true if the attributes are found within the entry
Throws:
LdapException - If the attribute does not exist

contains

public boolean contains(java.lang.String upId,
                        byte[]... values)
Checks if an entry contains an attribute with some binary values.

Parameters:
id - The Attribute we are looking for.
values - The searched values.
Returns:
true if all the values are found within the attribute, false if at least one value is not present or if the ID is not valid.

contains

public boolean contains(java.lang.String upId,
                        java.lang.String... values)
Checks if an entry contains an attribute with some String values.

Parameters:
id - The Attribute we are looking for.
values - The searched values.
Returns:
true if all the values are found within the attribute, false if at least one value is not present or if the ID is not valid.

contains

public boolean contains(java.lang.String upId,
                        Value<?>... values)
Checks if an entry contains an attribute with some values.

Parameters:
id - The Attribute we are looking for.
values - The searched values.
Returns:
true if all the values are found within the attribute, false if at least one value is not present or if the ID is not valid.

containsAttribute

public boolean containsAttribute(java.lang.String... attributes)
Checks if an entry contains some specific attributes.

Parameters:
attributes - The Attributes to look for.
Returns:
true if the attributes are all found within the entry.

get

public EntryAttribute get(java.lang.String alias)

Returns the attribute with the specified alias. The return value is null 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 an Attribute whose getId() field returns 'commonName'.

Parameters:
alias - an aliased name of the attribute identifier
Returns:
the attribute associated with the alias

put

public EntryAttribute put(java.lang.String upId,
                          byte[]... values)

Put an attribute (represented by its ID and some binary values) into an entry.

If the attribute already exists, the previous attribute will be replaced and returned.

Parameters:
upId - The attribute ID
values - The list of binary values to put. It can be empty.
Returns:
The replaced attribute

put

public EntryAttribute put(java.lang.String upId,
                          java.lang.String... values)

Put an attribute (represented by its ID and some String values) into an entry.

If the attribute already exists, the previous attribute will be replaced and returned.

Parameters:
upId - The attribute ID
values - The list of String values to put. It can be empty.
Returns:
The replaced attribute

put

public EntryAttribute put(java.lang.String upId,
                          Value<?>... values)

Put an attribute (represented by its ID and some values) into an entry.

If the attribute already exists, the previous attribute will be replaced and returned.

Parameters:
upId - The attribute ID
values - The list of values to put. It can be empty.
Returns:
The replaced attribute

set

public java.util.List<EntryAttribute> set(java.lang.String... upIds)

Put some new ClientAttribute using the User Provided ID. No value is inserted.

If an existing Attribute is found, it will be replaced by an empty attribute, and returned to the caller.

Parameters:
upIds - The user provided IDs of the AttributeTypes to add.
Returns:
A list of replaced Attributes.

put

public java.util.List<EntryAttribute> put(EntryAttribute... attributes)
                                   throws LdapException

Places attributes in the attribute collection.

If there is already an attribute with the same ID as any of the new attributes, the old ones are removed from the collection and are returned by this method. If there was no attribute with the same ID the return value is null.

Parameters:
attributes - the attributes to be put
Returns:
the old attributes with the same OID, if exist; otherwise null
Throws:
LdapException - if the operation fails

remove

public java.util.List<EntryAttribute> remove(EntryAttribute... attributes)
                                      throws LdapException
Description copied from interface: Entry
Removes the specified attributes. The removed attributes are returned by this method. If there were no attribute the return value is null.

Parameters:
attributes - the attributes to be removed
Returns:
the removed attribute, if exists; otherwise null
Throws:
LdapException

removeAttributes

public java.util.List<EntryAttribute> removeAttributes(java.lang.String... attributes)

Removes the attribute with the specified alias.

The removed attribute are returned by this method.

If there is no attribute with the specified alias, the return value is null.

Parameters:
attributes - an aliased name of the attribute to be removed
Returns:
the removed attributes, if any, as a list; otherwise null

remove

public boolean remove(java.lang.String upId,
                      byte[]... values)
               throws LdapException

Removes the specified binary values from an attribute.

If at least one value is removed, this method returns true.

If there is no more value after having removed the values, the attribute will be removed too.

If the attribute does not exist, nothing is done and the method returns false

Parameters:
upId - The attribute ID
values - the values to be removed
Returns:
true if at least a value is removed, false if not all the values have been removed or if the attribute does not exist.
Throws:
LdapException

remove

public boolean remove(java.lang.String upId,
                      java.lang.String... values)
               throws LdapException

Removes the specified String values from an attribute.

If at least one value is removed, this method returns true.

If there is no more value after having removed the values, the attribute will be removed too.

If the attribute does not exist, nothing is done and the method returns false

Parameters:
upId - The attribute ID
attributes - the attributes to be removed
Returns:
true if at least a value is removed, false if not all the values have been removed or if the attribute does not exist.
Throws:
LdapException

remove

public boolean remove(java.lang.String upId,
                      Value<?>... values)
               throws LdapException

Removes the specified values from an attribute.

If at least one value is removed, this method returns true.

If there is no more value after having removed the values, the attribute will be removed too.

If the attribute does not exist, nothing is done and the method returns false

Parameters:
upId - The attribute ID
attributes - the attributes to be removed
Returns:
true if at least a value is removed, false if not all the values have been removed or if the attribute does not exist.
Throws:
LdapException

iterator

public java.util.Iterator<EntryAttribute> iterator()
Description copied from class: AbstractEntry
Returns an enumeration containing the zero or more attributes in the collection. The behavior of the enumeration is not specified if the attribute collection is changed.

Specified by:
iterator in interface java.lang.Iterable<EntryAttribute>
Specified by:
iterator in interface Entry
Overrides:
iterator in class AbstractEntry<java.lang.String>
Returns:
an enumeration of all contained attributes

writeExternal

public void writeExternal(java.io.ObjectOutput out)
                   throws java.io.IOException
Throws:
java.io.IOException
See Also:
This is the place where we serialize entries, and all theirs elements.

The structure used to store the entry is the following :

  • [DN] : If it's null, stores an empty DN
  • [attributes number] : the number of attributes.
  • [attribute]* : each attribute, if we have some

  • readExternal

    public void readExternal(java.io.ObjectInput in)
                      throws java.io.IOException,
                             java.lang.ClassNotFoundException
    Throws:
    java.io.IOException
    java.lang.ClassNotFoundException
    See Also:
    Externalizable#readExternal(ObjectInput)

    hashCode

    public int hashCode()
    Get the hash code of this ClientEntry.

    Overrides:
    hashCode in class java.lang.Object
    Returns:
    the instance's hash code
    See Also:
    Object.hashCode()

    hasObjectClass

    public boolean hasObjectClass(java.lang.String objectClass)
    Tells if an entry has a specific ObjectClass value

    Parameters:
    objectClass - The ObjectClass we want to check
    Returns:
    true if the ObjectClass value is present in the ObjectClass attribute

    equals

    public boolean equals(java.lang.Object o)
    Overrides:
    equals in class java.lang.Object
    See Also:
    Object.equals(Object)

    toString

    public java.lang.String toString()
    Overrides:
    toString in class java.lang.Object
    See Also:
    Object.toString()


    Copyright © 2003-2011 Apache Software Foundation. All Rights Reserved.