org.apache.directory.server.core.entry
Class ServerEntryUtils

java.lang.Object
  extended by org.apache.directory.server.core.entry.ServerEntryUtils

public class ServerEntryUtils
extends java.lang.Object

A helper class used to manipulate Entries, Attributes and Values.

Version:
$Rev$, $Date$
Author:
Apache Directory Project

Constructor Summary
ServerEntryUtils()
           
 
Method Summary
static java.util.List<org.apache.directory.shared.ldap.entry.Modification> convertToServerModification(java.util.List<javax.naming.directory.ModificationItem> modificationItems, AttributeTypeRegistry atRegistry)
          Convert a list of ModificationItemImpl to a list of
static ServerAttribute getAttribute(java.util.List<org.apache.directory.shared.ldap.entry.Modification> mods, org.apache.directory.shared.ldap.schema.AttributeType type)
          Utility method to extract an attribute from a list of modifications.
static org.apache.directory.shared.ldap.entry.Modification getModificationItem(java.util.List<org.apache.directory.shared.ldap.entry.Modification> mods, org.apache.directory.shared.ldap.schema.AttributeType type)
          Utility method to extract a modification item from an array of modifications.
static ServerEntry getTargetEntry(org.apache.directory.shared.ldap.entry.Modification mod, ServerEntry entry, Registries registries)
          Gets the target entry as it would look after a modification operation was performed on it.
static ServerAttribute getUnion(ServerAttribute attr0, ServerAttribute attr1)
          Creates a new attribute which contains the values representing the union of two attributes.
static javax.naming.directory.Attribute toBasicAttribute(ServerAttribute entryAttribute)
          Convert a ServerAttribute into a BasicAttribute.
static javax.naming.directory.Attributes toBasicAttributes(ServerEntry entry)
          Convert a ServerEntry into a BasicAttributes.
static javax.naming.NamingEnumeration<javax.naming.directory.SearchResult> toSearchResultEnum(javax.naming.NamingEnumeration<ServerSearchResult> result)
          Encapsulate a ServerSearchResult enumeration into a SearchResult enumeration
static ServerAttribute toServerAttribute(javax.naming.directory.Attribute attribute, org.apache.directory.shared.ldap.schema.AttributeType attributeType)
          Convert a BasicAttribute or a AttributeImpl to a ServerAtribute
static ServerEntry toServerEntry(javax.naming.directory.Attributes attributes, org.apache.directory.shared.ldap.name.LdapDN dn, Registries registries)
          Convert a BasicAttributes or a AttributesImpl to a ServerEntry
static java.util.List<org.apache.directory.shared.ldap.entry.Modification> toServerModification(org.apache.directory.shared.ldap.entry.Modification[] modifications, AttributeTypeRegistry atRegistry)
           
static java.util.List<org.apache.directory.shared.ldap.entry.Modification> toServerModification(javax.naming.directory.ModificationItem[] modifications, AttributeTypeRegistry atRegistry)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ServerEntryUtils

public ServerEntryUtils()
Method Detail

toBasicAttribute

public static javax.naming.directory.Attribute toBasicAttribute(ServerAttribute entryAttribute)
Convert a ServerAttribute into a BasicAttribute. The DN is lost during this conversion, as the Attributes object does not store this element.

Returns:
An instance of a AttributesImpl() object

toBasicAttributes

public static javax.naming.directory.Attributes toBasicAttributes(ServerEntry entry)
Convert a ServerEntry into a BasicAttributes. The DN is lost during this conversion, as the Attributes object does not store this element.

Returns:
An instance of a AttributesImpl() object

toServerAttribute

public static ServerAttribute toServerAttribute(javax.naming.directory.Attribute attribute,
                                                org.apache.directory.shared.ldap.schema.AttributeType attributeType)
Convert a BasicAttribute or a AttributeImpl to a ServerAtribute

Parameters:
attribute - the BasicAttributes or AttributesImpl instance to convert
attributeType -
Returns:
An instance of a ServerEntry object
Throws:
javax.naming.directory.InvalidAttributeIdentifierException - If we had an incorrect attribute

toServerEntry

public static ServerEntry toServerEntry(javax.naming.directory.Attributes attributes,
                                        org.apache.directory.shared.ldap.name.LdapDN dn,
                                        Registries registries)
                                 throws javax.naming.directory.InvalidAttributeIdentifierException
Convert a BasicAttributes or a AttributesImpl to a ServerEntry

Parameters:
attributes - the BasicAttributes or AttributesImpl instance to convert
registries - The registries, needed ro build a ServerEntry
dn - The DN which is needed by the ServerEntry
Returns:
An instance of a ServerEntry object
Throws:
javax.naming.directory.InvalidAttributeIdentifierException - If we get an invalid attribute

getTargetEntry

public static ServerEntry getTargetEntry(org.apache.directory.shared.ldap.entry.Modification mod,
                                         ServerEntry entry,
                                         Registries registries)
                                  throws javax.naming.NamingException
Gets the target entry as it would look after a modification operation was performed on it.

Parameters:
mod - the modification
entry - the source entry that is modified
Returns:
the resultant entry after the modification has taken place
Throws:
javax.naming.NamingException - if there are problems accessing attributes

getUnion

public static ServerAttribute getUnion(ServerAttribute attr0,
                                       ServerAttribute attr1)
Creates a new attribute which contains the values representing the union of two attributes. If one attribute is null then the resultant attribute returned is a copy of the non-null attribute. If both are null then we cannot determine the attribute ID and an IllegalArgumentException is raised.

Parameters:
attr0 - the first attribute
attr1 - the second attribute
Returns:
a new attribute with the union of values from both attribute arguments
Throws:
javax.naming.NamingException - if there are problems accessing attribute values

convertToServerModification

public static java.util.List<org.apache.directory.shared.ldap.entry.Modification> convertToServerModification(java.util.List<javax.naming.directory.ModificationItem> modificationItems,
                                                                                                              AttributeTypeRegistry atRegistry)
                                                                                                       throws javax.naming.NamingException
Convert a list of ModificationItemImpl to a list of

Parameters:
modificationImpls -
atRegistry -
Returns:
Throws:
javax.naming.NamingException

toServerModification

public static java.util.List<org.apache.directory.shared.ldap.entry.Modification> toServerModification(org.apache.directory.shared.ldap.entry.Modification[] modifications,
                                                                                                       AttributeTypeRegistry atRegistry)
                                                                                                throws javax.naming.NamingException
Throws:
javax.naming.NamingException

toServerModification

public static java.util.List<org.apache.directory.shared.ldap.entry.Modification> toServerModification(javax.naming.directory.ModificationItem[] modifications,
                                                                                                       AttributeTypeRegistry atRegistry)
                                                                                                throws javax.naming.NamingException
Throws:
javax.naming.NamingException

getModificationItem

public static final org.apache.directory.shared.ldap.entry.Modification getModificationItem(java.util.List<org.apache.directory.shared.ldap.entry.Modification> mods,
                                                                                            org.apache.directory.shared.ldap.schema.AttributeType type)
Utility method to extract a modification item from an array of modifications.

Parameters:
mods - the array of ModificationItems to extract the Attribute from.
type - the attributeType spec of the Attribute to extract
Returns:
the modification item on the attributeType specified

getAttribute

public static ServerAttribute getAttribute(java.util.List<org.apache.directory.shared.ldap.entry.Modification> mods,
                                           org.apache.directory.shared.ldap.schema.AttributeType type)
Utility method to extract an attribute from a list of modifications.

Parameters:
mods - the list of ModificationItems to extract the Attribute from.
type - the attributeType spec of the Attribute to extract
Returns:
the extract Attribute or null if no such attribute exists

toSearchResultEnum

public static javax.naming.NamingEnumeration<javax.naming.directory.SearchResult> toSearchResultEnum(javax.naming.NamingEnumeration<ServerSearchResult> result)
Encapsulate a ServerSearchResult enumeration into a SearchResult enumeration

Parameters:
result - The ServerSearchResult enumeration
Returns:
A SearchResultEnumeration


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