netscape.ldap.util
Class LDAPFilterDescriptor

java.lang.Object
  extended by netscape.ldap.util.LDAPFilterDescriptor

public class LDAPFilterDescriptor
extends java.lang.Object

Represents an LDAP filter configuration file read into memory.

Once you read in a filter file to create an object of this class, you can access the filter information through the methods that create LDAPFilterList and LDAPFilter objects. (You do not need to manually construct these objects yourself.)

This class (along with the other LDAP filter classes) provide functionality equivalent to the LDAP filter functions in the LDAP C API.

The format of the file/URL/buffer must be that as defined in the ldapfilter.conf(5) man page from the University of Michigan LDAP-3.3 distribution.

The LDAP filter classes provide a powerful way to configure LDAP clients by modifying a configuration file.

The following is a short example for how to use the LDAP filter classes.


 // ... Setup LDAPConnection up here ...
 

LDAPFilterDescriptor filterDescriptor;

// Create the LDAPFilterDescriptor given the file // "ldapfilter.conf". try { filterDescriptor = new LDAPFilterDescriptor ( "ldapfilter.conf" );

// Now retrieve the Filters in the form of an // LDAPFilterList LDAPFilterList filterList = new filterDescriptor.getFilters("match_tag", "string_user_typed");

// For each filter, do the search. Normally, you wouldn't // do the search if the first filter matched, but this is // just showing the enumeration type aspects of // LDAPFilterList LDAPFilter filter; while ( filterList.hasMoreElements() ) { filter = filterList.next(); LDAPResults results = LDAPConnection.search ( strBase, // base DN filter.getScope(), // scope filter.getFilter(), // completed filter null, // all attribs false ); // attrsOnly? }

// ...more processing here... } catch ( BadFilterException e ) { System.out.println ( e.toString() ); System.exit ( 0 ); } catch ( IOException e ) { // ...handle exception here... }

See Also:
LDAPFilterList, LDAPFilter

Constructor Summary
LDAPFilterDescriptor(java.lang.String strFile)
          Creates an LDAPFilterDescriptor object from an existing filter configuration file.
LDAPFilterDescriptor(java.lang.StringBuffer strBuffer)
          Creates an LDAPFilterDescriptor object from an existing StringBuffer.
LDAPFilterDescriptor(java.net.URL url)
          Creates an LDAPFilterDescriptor object from a URL.
 
Method Summary
 LDAPFilterList getFilters(java.lang.String strTagPat, java.lang.String strValue)
          Return all the filters which match the strTagPat (regular expression), and the user input (strValue)
 void setFilterAffixes(java.lang.String strPrefix, java.lang.String strAffix)
          Prepend the parameter (strPrefix) and append the second parameter (strAffix) to every filter that is returned by the getFilters() method.
 java.lang.String toString()
          Output a text dump of this filter descriptor.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

LDAPFilterDescriptor

public LDAPFilterDescriptor(java.lang.String strFile)
                     throws java.io.FileNotFoundException,
                            BadFilterException
Creates an LDAPFilterDescriptor object from an existing filter configuration file. This file has the format as defined in the ldapfilter.conf(5) man page.

Throws:
BadFilterException - One of the filters was not generated properly. Most likely this is due to an improperly formatted ldapfilter.conf file.
java.io.FileNotFoundException

LDAPFilterDescriptor

public LDAPFilterDescriptor(java.lang.StringBuffer strBuffer)
                     throws BadFilterException
Creates an LDAPFilterDescriptor object from an existing StringBuffer. This file has the format as defined in the ldapfilter.conf(5) man page.

Throws:
BadFilterException - One of the filters was not generated properly. Most likely this is due to an improperly formatted ldapfilter.conf file.

LDAPFilterDescriptor

public LDAPFilterDescriptor(java.net.URL url)
                     throws java.io.IOException,
                            BadFilterException
Creates an LDAPFilterDescriptor object from a URL. This file has the format as defined in the ldapfilter.conf(5) man page.

Throws:
BadFilterException - One of the filters was not generated properly. Most likely this is due to an improperly formatted ldapfilter.conf file.
java.io.IOException
Method Detail

toString

public java.lang.String toString()
Output a text dump of this filter descriptor. It cycles through all of the internal LDAPIntFilterSet objects and calls their toString() methods.

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

getFilters

public LDAPFilterList getFilters(java.lang.String strTagPat,
                                 java.lang.String strValue)
                          throws java.lang.IllegalArgumentException
Return all the filters which match the strTagPat (regular expression), and the user input (strValue)

Throws:
java.lang.IllegalArgumentException

setFilterAffixes

public void setFilterAffixes(java.lang.String strPrefix,
                             java.lang.String strAffix)
Prepend the parameter (strPrefix) and append the second parameter (strAffix) to every filter that is returned by the getFilters() method.