Example usage for javax.naming.directory SearchResult setAttributes

List of usage examples for javax.naming.directory SearchResult setAttributes

Introduction

In this page you can find the example usage for javax.naming.directory SearchResult setAttributes.

Prototype

public void setAttributes(Attributes attrs) 

Source Link

Document

Sets the attributes of this search result to attrs.

Usage

From source file:org.openadaptor.auxil.connector.jndi.JNDISearch.java

/**
 * Retrieve the next match from the array of NamingEnumerations (the call to hasMore() will automagically bump it to
 * the next enumeration in the array if necessary.
 * /* www  .j a va  2s  .  com*/
 * @return Next Entry if available.
 * @throws NoSuchElementException
 *           if no more matches remain (i.e. hasMore() would have failed).
 * @throws NamingException
 *           if any other JNDI exception occurs.
 */
public Object next() throws NamingException {
    SearchResult result = null;
    if (hasMore()) { // Something to return!
        result = (SearchResult) searchResults[current].next();
        if (dnAttributeName != null) {// Stuff in the DN
            String rdn = result.getName(); // Get the relative dn for this match
            String dn = rdn + "," + executedSearch.getSearchBases()[current]; // Construct a full dn.
            Attributes attrs = result.getAttributes();
            attrs.put(dnAttributeName, dn);
            result.setAttributes(attrs);
        }
    } else {
        throw new NoSuchElementException();
    }
    return result;
}