netscape.ldap.util

Class 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(String strFile)
Creates an LDAPFilterDescriptor object from an existing filter configuration file.
LDAPFilterDescriptor(StringBuffer strBuffer)
Creates an LDAPFilterDescriptor object from an existing StringBuffer.
LDAPFilterDescriptor(URL url)
Creates an LDAPFilterDescriptor object from a URL.

Method Summary

LDAPFilterList
getFilters(String strTagPat, String strValue)
Return all the filters which match the strTagPat (regular expression), and the user input (strValue)
void
setFilterAffixes(String strPrefix, String strAffix)
Prepend the parameter (strPrefix) and append the second parameter (strAffix) to every filter that is returned by the getFilters() method.
String
toString()
Output a text dump of this filter descriptor.

Constructor Details

LDAPFilterDescriptor

public LDAPFilterDescriptor(String strFile)
            throws 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.


LDAPFilterDescriptor

public LDAPFilterDescriptor(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(URL url)
            throws 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.

Method Details

getFilters

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


setFilterAffixes

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


toString

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

See Also:
LDAPIntFilterSet.toString()