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, org.apache.directory.shared.ldap.schema.SchemaManager schemaManager)
          Convert a list of ModificationItemImpl to a list of
static org.apache.directory.shared.ldap.entry.EntryAttribute 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 org.apache.directory.shared.ldap.entry.ServerEntry getTargetEntry(org.apache.directory.shared.ldap.entry.Modification mod, org.apache.directory.shared.ldap.entry.ServerEntry entry, org.apache.directory.shared.ldap.schema.SchemaManager schemaManager)
          Gets the target entry as it would look after a modification operation was performed on it.
static org.apache.directory.shared.ldap.entry.EntryAttribute getUnion(org.apache.directory.shared.ldap.entry.EntryAttribute attr0, org.apache.directory.shared.ldap.entry.EntryAttribute attr1)
          Creates a new attribute which contains the values representing the union of two attributes.
static javax.naming.directory.Attribute toBasicAttribute(org.apache.directory.shared.ldap.entry.EntryAttribute entryAttribute)
          Convert a ServerAttribute into a BasicAttribute.
static javax.naming.directory.Attributes toBasicAttributes(org.apache.directory.shared.ldap.entry.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 org.apache.directory.shared.ldap.entry.EntryAttribute toServerAttribute(javax.naming.directory.Attribute attribute, org.apache.directory.shared.ldap.schema.AttributeType attributeType)
          Convert a BasicAttribute or a AttributeImpl to a ServerAtribute
static org.apache.directory.shared.ldap.entry.ServerEntry toServerEntry(javax.naming.directory.Attributes attributes, org.apache.directory.shared.ldap.name.DN dn, org.apache.directory.shared.ldap.schema.SchemaManager schemaManager)
          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, org.apache.directory.shared.ldap.schema.SchemaManager schemaManager)
           
static java.util.List<org.apache.directory.shared.ldap.entry.Modification> toServerModification(javax.naming.directory.ModificationItem[] modifications, org.apache.directory.shared.ldap.schema.SchemaManager schemaManager)
           
 
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(org.apache.directory.shared.ldap.entry.EntryAttribute 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(org.apache.directory.shared.ldap.entry.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 org.apache.directory.shared.ldap.entry.EntryAttribute 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 org.apache.directory.shared.ldap.entry.ServerEntry toServerEntry(javax.naming.directory.Attributes attributes,
                                                                               org.apache.directory.shared.ldap.name.DN dn,
                                                                               org.apache.directory.shared.ldap.schema.SchemaManager schemaManager)
                                                                        throws org.apache.directory.shared.ldap.exception.LdapInvalidAttributeTypeException
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:
org.apache.directory.shared.ldap.exception.LdapInvalidAttributeTypeException - If we get an invalid attribute

getTargetEntry

public static org.apache.directory.shared.ldap.entry.ServerEntry getTargetEntry(org.apache.directory.shared.ldap.entry.Modification mod,
                                                                                org.apache.directory.shared.ldap.entry.ServerEntry entry,
                                                                                org.apache.directory.shared.ldap.schema.SchemaManager schemaManager)
                                                                         throws org.apache.directory.shared.ldap.exception.LdapException
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:
org.apache.directory.shared.ldap.exception.LdapException - if there are problems accessing attributes

getUnion

public static org.apache.directory.shared.ldap.entry.EntryAttribute getUnion(org.apache.directory.shared.ldap.entry.EntryAttribute attr0,
                                                                             org.apache.directory.shared.ldap.entry.EntryAttribute 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:
org.apache.directory.shared.ldap.exception.LdapException - 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,
                                                                                                              org.apache.directory.shared.ldap.schema.SchemaManager schemaManager)
                                                                                                       throws org.apache.directory.shared.ldap.exception.LdapException
Convert a list of ModificationItemImpl to a list of

Parameters:
modificationImpls -
atRegistry -
Returns:
Throws:
org.apache.directory.shared.ldap.exception.LdapException

toServerModification

public static java.util.List<org.apache.directory.shared.ldap.entry.Modification> toServerModification(org.apache.directory.shared.ldap.entry.Modification[] modifications,
                                                                                                       org.apache.directory.shared.ldap.schema.SchemaManager schemaManager)
                                                                                                throws org.apache.directory.shared.ldap.exception.LdapException
Throws:
org.apache.directory.shared.ldap.exception.LdapException

toServerModification

public static java.util.List<org.apache.directory.shared.ldap.entry.Modification> toServerModification(javax.naming.directory.ModificationItem[] modifications,
                                                                                                       org.apache.directory.shared.ldap.schema.SchemaManager schemaManager)
                                                                                                throws org.apache.directory.shared.ldap.exception.LdapException
Throws:
org.apache.directory.shared.ldap.exception.LdapException

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 org.apache.directory.shared.ldap.entry.EntryAttribute 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-2011 Apache Software Foundation. All Rights Reserved.