org.identityconnectors.ldap.search
Class LdapFilter

java.lang.Object
  extended by org.identityconnectors.ldap.search.LdapFilter

public final class LdapFilter
extends Object

Encapsulates an LDAP filter. An instance of this class is consists of an optional entry DN and an optional native LDAP filter. The semantics of such an instance is "an LDAP entry with this entry DN (if specified) and matching this native filter (if specified)".

The problem this class solves is the following. When an attribute, for instance Name, is mapped to an entry's DN, and the user constructs an EqualsFilter for that attribute, the connector needs to translate that Filter into a native LDAP filter. The connector could use the entryDN attribute in the native filter, but some servers might not support that attribute. Instead, such a Filter is translated to an LdapFilter with that entry DN. A composed filter, for instance:

 Name name = new Name("uid=foo,dc=example,dc=com");
 Attribute attr = AttributeBuilder.build("foo", "bar");
 FilterBuilder.and(
     FilterBuilder.equalTo(name),
     FilterBuilder.equalTo(attr));
 

can be translated to a single LdapFilter whose entry DN corresponds to aName and whose filter string is (foo=bar).


Method Summary
 LdapFilter and(LdapFilter other)
          Logically "ANDs" together this filter with another filter.
 boolean equals(Object o)
           
static LdapFilter forEntryDN(String entryDN)
           
static LdapFilter forNativeFilter(String nativeFilter)
           
 String getEntryDN()
           
 String getNativeFilter()
           
 int hashCode()
           
 LdapFilter or(LdapFilter other)
          Logically "ORs" together this filter with another filter.
 String toString()
           
 LdapFilter withNativeFilter(String nativeFilter)
           
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Method Detail

forEntryDN

public static LdapFilter forEntryDN(String entryDN)

forNativeFilter

public static LdapFilter forNativeFilter(String nativeFilter)

withNativeFilter

public LdapFilter withNativeFilter(String nativeFilter)

getNativeFilter

public String getNativeFilter()

getEntryDN

public String getEntryDN()

and

public LdapFilter and(LdapFilter other)
Logically "ANDs" together this filter with another filter.

If at most one of the two filters has an entry DN, the result is a filter with that entry DN (if any) and a native filter whose value is the native filters of the two filters "ANDed" together using the LDAP & operator.

Otherwise, the method returns null.

Parameters:
other - the other filter.
Returns:
the two filters "ANDed" together or null.

or

public LdapFilter or(LdapFilter other)
Logically "ORs" together this filter with another filter.

If none of the two filters has an entry DN, the result is a filter with no entry DN and a native filter whose value is the native filters of the two filters "ORed" together using the LDAP | filter operator.

Otherwise, the method returns null.

Parameters:
other - the other filter.
Returns:
the two filters "ORed" together or null.

equals

public boolean equals(Object o)
Overrides:
equals in class Object

hashCode

public int hashCode()
Overrides:
hashCode in class Object

toString

public String toString()
Overrides:
toString in class Object


Copyright © 2012. All Rights Reserved.