directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From seelm...@apache.org
Subject svn commit: r498419 - in /directory/ldapstudio/trunk/ldapstudio-browser-core/src/main/java/org/apache/directory/ldapstudio/browser/core: internal/model/Search.java model/ISearch.java model/SearchParameter.java
Date Sun, 21 Jan 2007 17:37:15 GMT
Author: seelmann
Date: Sun Jan 21 09:37:09 2007
New Revision: 498419

URL: http://svn.apache.org/viewvc?view=rev&rev=498419
Log:
Added Javadocs, code cleaning.

Modified:
    directory/ldapstudio/trunk/ldapstudio-browser-core/src/main/java/org/apache/directory/ldapstudio/browser/core/internal/model/Search.java
    directory/ldapstudio/trunk/ldapstudio-browser-core/src/main/java/org/apache/directory/ldapstudio/browser/core/model/ISearch.java
    directory/ldapstudio/trunk/ldapstudio-browser-core/src/main/java/org/apache/directory/ldapstudio/browser/core/model/SearchParameter.java

Modified: directory/ldapstudio/trunk/ldapstudio-browser-core/src/main/java/org/apache/directory/ldapstudio/browser/core/internal/model/Search.java
URL: http://svn.apache.org/viewvc/directory/ldapstudio/trunk/ldapstudio-browser-core/src/main/java/org/apache/directory/ldapstudio/browser/core/internal/model/Search.java?view=diff&rev=498419&r1=498418&r2=498419
==============================================================================
--- directory/ldapstudio/trunk/ldapstudio-browser-core/src/main/java/org/apache/directory/ldapstudio/browser/core/internal/model/Search.java
(original)
+++ directory/ldapstudio/trunk/ldapstudio-browser-core/src/main/java/org/apache/directory/ldapstudio/browser/core/internal/model/Search.java
Sun Jan 21 09:37:09 2007
@@ -37,41 +37,65 @@
 import org.eclipse.search.ui.ISearchPageScoreComputer;
 
 
+/**
+ * Default implementation of ISearch.
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev$, $Date$
+ */
 public class Search implements ISearch
 {
 
+    /** The serialVersionUID. */
     private static final long serialVersionUID = -3482673086666351174L;
 
+    /** The connection. */
     private IConnection connection;
 
+    /** The search results. */
     private ISearchResult[] searchResults;
 
+    /** The search parameter. */
     private SearchParameter searchParameter;
 
+    /** The count limit exceeded flag. */
     private boolean countLimitExceeded;
 
 
     /**
      * Creates a new search with the following parameters:
-     * 
+     * <ul>
      * <li>searchName: current date
      * <li>connection: null
-     * <li>searchBase: empty
-     * <li>filter: empty (objectClass=*)
-     * <li>returningAttributea: none
-     * <li>scope: one level
-     * <li>countLimit: preference value
-     * <li>timeLimit: preference value
+     * <li>empty search base
+     * <li>default filter (objectClass=*)
+     * <li>no returning attributes
+     * <li>search scope one level
+     * <li>no count limit
+     * <li>no time limit
+     * <li>never dereference aliases
+     * <li>ignore referrals
+     * <li>no initialization of hasChildren flag
+     * <li>no initialization of isAlias and isReferral flag
+     * <li>no controls  
+     * <li>
+     * </ul>
      */
     public Search()
     {
         this(
             new SimpleDateFormat( "yyyy-MM-dd HH-mm-ss" ).format( new Date() ), //$NON-NLS-1$

-            null, new DN(), FILTER_TRUE, NO_ATTRIBUTES, ISearch.SCOPE_ONELEVEL, 0, 0,
+            null, EMPTY_SEARCH_BASE, FILTER_TRUE, NO_ATTRIBUTES, ISearch.SCOPE_ONELEVEL,
0, 0,
             IConnection.DEREFERENCE_ALIASES_NEVER, IConnection.HANDLE_REFERRALS_IGNORE, false,
false, null );
     }
 
 
+    /**
+     * Creates a new Search with the given connection and search parameters.
+     *
+     * @param conn the connection
+     * @param searchParameter the search parameters
+     */
     public Search( IConnection conn, SearchParameter searchParameter )
     {
         this.connection = conn;
@@ -85,74 +109,75 @@
      * Creates a new search with the given search parameters
      * 
      * @param searchName
-     *                The name of the search
+     *                the name of the search
      * @param conn
-     *                The connection of the search
+     *                the connection of the search
      * @param searchBase
-     *                The base DN of the search
+     *                the base DN of the search, a null search base will be
+     *                transformed to an empty DN.
      * @param filter
-     *                The filter to use, null or empty filters will be
+     *                the filter to use, null or empty filters will be
      *                transformed to (objectClass=*)
      * @param returningAttributes
-     *                The attributes to return, empty array indicates none,
-     *                null indicates all
+     *                the attributes to return, an empty array indicates none,
+     *                null will be transformed to '*' (all user attributes)
      * @param scope
      *                the search scope, one of SCOPE_OBJECT, SCOPE_ONELEVEL,
      *                SCOPE_SUBTREE
      * @param countLimit
-     *                The count limit, 0 indicates no limit
+     *                the count limit, 0 indicates no limit
      * @param timeLimit
-     *                The time limit in ms, 0 indicats no limit
+     *                the time limit in ms, 0 indicates no limit
      * @param aliasesDereferencingMethod
+     *                the aliases dereferencing method, one of IConnection.DEREFERENCE_ALIASES_NEVER,

+     *                IConnection.DEREFERENCE_ALIASES_ALWAYS, IConnection.DEREFERENCE_ALIASES_FINDING
+     *                or IConnection.DEREFERENCE_ALIASES_SEARCH
      * @param referralsHandlingMethod
-     * @param initChildrenFlag
-     * @param initAliasFlag
-     * @param initObjectClasses
+     *                the referrals handling method, one of IConnection.HANDLE_REFERRALS_IGNORE

+     *                or IConnection.HANDLE_REFERRALS_FOLLOW 
+     * @param initHasChildrenFlag
+     *                the init hasChildren flag
+     * @param initAliasAndReferralsFlag
+     *                the init isAlias and isReferral flag
      */
     public Search( String searchName, IConnection conn, DN searchBase, String filter, String[]
returningAttributes,
         int scope, int countLimit, int timeLimit, int aliasesDereferencingMethod, int referralsHandlingMethod,
-        boolean initChildrenFlag, boolean initAliasAndReferralsFlag, Control[] controls )
+        boolean initHasChildrenFlag, boolean initAliasAndReferralsFlag, Control[] controls
)
     {
         this.connection = conn;
         this.searchResults = null;
+        this.countLimitExceeded = false;
 
         this.searchParameter = new SearchParameter();
         this.searchParameter.setName( searchName );
         this.searchParameter.setSearchBase( searchBase );
-        if ( filter == null || "".equals( filter ) ) { //$NON-NLS-1$
-            this.searchParameter.setFilter( FILTER_TRUE );
-        }
-        else
-        {
-            this.searchParameter.setFilter( filter );
-        }
-        if ( returningAttributes == null )
-        {
-            this.searchParameter.setReturningAttributes( new String[]
-                { ALL_USER_ATTRIBUTES } );
-        }
-        else
-        {
-            this.searchParameter.setReturningAttributes( returningAttributes );
-        }
+        this.searchParameter.setFilter( filter );
+        this.searchParameter.setReturningAttributes( returningAttributes );
         this.searchParameter.setScope( scope );
         this.searchParameter.setTimeLimit( timeLimit );
         this.searchParameter.setCountLimit( countLimit );
         this.searchParameter.setAliasesDereferencingMethod( aliasesDereferencingMethod );
         this.searchParameter.setReferralsHandlingMethod( referralsHandlingMethod );
-        this.searchParameter.setInitChildrenFlag( initChildrenFlag );
+        this.searchParameter.setInitChildrenFlag( initHasChildrenFlag );
         this.searchParameter.setInitAliasAndReferralFlag( initAliasAndReferralsFlag );
         this.searchParameter.setControls( controls );
-        this.countLimitExceeded = false;
     }
 
 
+    /**
+     * {@inheritDoc}
+     */
     public URL getUrl()
     {
         return new URL( this );
     }
 
 
+    /**
+     * Fires a search update event if the search name is set.
+     *
+     * @param detail the SearchUpdateEvent detail
+     */
     private void fireSearchUpdated( int detail )
     {
         if ( this.getName() != null && !"".equals( this.getName() ) ) { //$NON-NLS-1$
@@ -161,30 +186,45 @@
     }
 
 
+    /**
+     * {@inheritDoc}
+     */
     public boolean isInitChildrenFlag()
     {
         return this.searchParameter.isInitChildrenFlag();
     }
 
 
+    /**
+     * {@inheritDoc}
+     */
     public boolean isInitAliasAndReferralFlag()
     {
         return this.searchParameter.isInitAliasAndReferralFlag();
     }
 
 
+    /**
+     * {@inheritDoc}
+     */
     public Control[] getControls()
     {
         return this.searchParameter.getControls();
     }
 
 
+    /**
+     * {@inheritDoc}
+     */
     public int getCountLimit()
     {
         return this.searchParameter.getCountLimit();
     }
 
 
+    /**
+     * {@inheritDoc}
+     */
     public void setCountLimit( int countLimit )
     {
         this.searchParameter.setCountLimit( countLimit );
@@ -192,31 +232,37 @@
     }
 
 
+    /**
+     * {@inheritDoc}
+     */
     public String getFilter()
     {
         return this.searchParameter.getFilter();
     }
 
 
+    /**
+     * {@inheritDoc}
+     */
     public void setFilter( String filter )
     {
-        if ( filter == null || "".equals( filter ) ) { //$NON-NLS-1$
-            this.searchParameter.setFilter( FILTER_TRUE );
-        }
-        else
-        {
-            this.searchParameter.setFilter( filter );
-        }
+        this.searchParameter.setFilter( filter );
         this.fireSearchUpdated( SearchUpdateEvent.SEARCH_PARAMETER_UPDATED );
     }
 
 
+    /**
+     * {@inheritDoc}
+     */
     public String[] getReturningAttributes()
     {
         return this.searchParameter.getReturningAttributes();
     }
 
 
+    /**
+     * {@inheritDoc}
+     */
     public void setReturningAttributes( String[] returningAttributes )
     {
         this.searchParameter.setReturningAttributes( returningAttributes );
@@ -224,12 +270,18 @@
     }
 
 
+    /**
+     * {@inheritDoc}
+     */
     public int getScope()
     {
         return this.searchParameter.getScope();
     }
 
 
+    /**
+     * {@inheritDoc}
+     */
     public void setScope( int scope )
     {
         this.searchParameter.setScope( scope );
@@ -237,12 +289,18 @@
     }
 
 
+    /**
+     * {@inheritDoc}
+     */
     public int getAliasesDereferencingMethod()
     {
         return this.searchParameter.getAliasesDereferencingMethod();
     }
 
 
+    /**
+     * {@inheritDoc}
+     */
     public void setAliasesDereferencingMethod( int aliasesDereferencingMethod )
     {
         this.searchParameter.setAliasesDereferencingMethod( aliasesDereferencingMethod );
@@ -250,12 +308,18 @@
     }
 
 
+    /**
+     * {@inheritDoc}
+     */
     public int getReferralsHandlingMethod()
     {
         return this.searchParameter.getReferralsHandlingMethod();
     }
 
 
+    /**
+     * {@inheritDoc}
+     */
     public void setReferralsHandlingMethod( int referralsHandlingMethod )
     {
         this.searchParameter.setReferralsHandlingMethod( referralsHandlingMethod );
@@ -263,12 +327,18 @@
     }
 
 
+    /**
+     * {@inheritDoc}
+     */
     public DN getSearchBase()
     {
         return this.searchParameter.getSearchBase();
     }
 
 
+    /**
+     * {@inheritDoc}
+     */
     public void setSearchBase( DN searchBase )
     {
         this.searchParameter.setSearchBase( searchBase );
@@ -276,12 +346,18 @@
     }
 
 
+    /**
+     * {@inheritDoc}
+     */
     public int getTimeLimit()
     {
         return this.searchParameter.getTimeLimit();
     }
 
 
+    /**
+     * {@inheritDoc}
+     */
     public void setTimeLimit( int timeLimit )
     {
         this.searchParameter.setTimeLimit( timeLimit );
@@ -289,12 +365,18 @@
     }
 
 
+    /**
+     * {@inheritDoc}
+     */
     public String getName()
     {
         return this.searchParameter.getName();
     }
 
 
+    /**
+     * {@inheritDoc}
+     */
     public void setName( String searchName )
     {
         this.searchParameter.setName( searchName );
@@ -302,12 +384,18 @@
     }
 
 
+    /**
+     * {@inheritDoc}
+     */
     public ISearchResult[] getSearchResults()
     {
         return searchResults;
     }
 
 
+    /**
+     * {@inheritDoc}
+     */
     public void setSearchResults( ISearchResult[] searchResults )
     {
         this.searchResults = searchResults;
@@ -318,12 +406,18 @@
     }
 
 
+    /**
+     * {@inheritDoc}
+     */
     public boolean isCountLimitExceeded()
     {
         return this.countLimitExceeded;
     }
 
 
+    /**
+     * {@inheritDoc}
+     */
     public void setCountLimitExceeded( boolean countLimitExceeded )
     {
         this.countLimitExceeded = countLimitExceeded;
@@ -331,12 +425,18 @@
     }
 
 
+    /**
+     * {@inheritDoc}
+     */
     public IConnection getConnection()
     {
         return connection;
     }
 
 
+    /**
+     * {@inheritDoc}
+     */
     public void setConnection( IConnection connection )
     {
         this.connection = connection;
@@ -348,14 +448,18 @@
     }
 
 
+    /**
+     * {@inheritDoc}
+     */
     public String toString()
     {
-        // return this.searchParameter.getFilter() +
-        // Integer.toString(this.searchResults!=null?this.searchResults.length:0);
         return this.getName() + " (" + this.connection + ")"; //$NON-NLS-1$ //$NON-NLS-2$
     }
 
 
+    /**
+     * {@inheritDoc}
+     */
     public Object clone()
     {
         return new Search( this.getName(), this.getConnection(), this.getSearchBase(), this.getFilter(),
this
@@ -365,32 +469,44 @@
     }
 
 
+    /**
+     * {@inheritDoc}
+     */
     public SearchParameter getSearchParameter()
     {
         return searchParameter;
     }
 
 
+    /**
+     * {@inheritDoc}
+     */
     public void setSearchParameter( SearchParameter searchParameter )
     {
         this.searchParameter = searchParameter;
     }
 
 
+    /**
+     * {@inheritDoc}
+     */
     public Object getAdapter( Class adapter )
     {
-        if ( adapter.isAssignableFrom( ISearchPageScoreComputer.class ) )
+
+        Class<?> clazz = ( Class<?> ) adapter;
+        if ( clazz.isAssignableFrom( ISearchPageScoreComputer.class ) )
         {
             return new LdapSearchPageScoreComputer();
         }
-        if ( adapter == IConnection.class )
+        if ( clazz.isAssignableFrom( IConnection.class ) )
         {
-            return this.connection;
+            return getConnection();
         }
-        if ( adapter == ISearch.class )
+        if ( clazz.isAssignableFrom( ISearch.class ) )
         {
             return this;
         }
+
         return null;
     }
 

Modified: directory/ldapstudio/trunk/ldapstudio-browser-core/src/main/java/org/apache/directory/ldapstudio/browser/core/model/ISearch.java
URL: http://svn.apache.org/viewvc/directory/ldapstudio/trunk/ldapstudio-browser-core/src/main/java/org/apache/directory/ldapstudio/browser/core/model/ISearch.java?view=diff&rev=498419&r1=498418&r2=498419
==============================================================================
--- directory/ldapstudio/trunk/ldapstudio-browser-core/src/main/java/org/apache/directory/ldapstudio/browser/core/model/ISearch.java
(original)
+++ directory/ldapstudio/trunk/ldapstudio-browser-core/src/main/java/org/apache/directory/ldapstudio/browser/core/model/ISearch.java
Sun Jan 21 09:37:09 2007
@@ -28,116 +28,324 @@
 import org.eclipse.core.runtime.IAdaptable;
 
 
+/**
+ * An ISearch holds all search parameters and search results of an
+ * LDAP search.
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev$, $Date$
+ */
 public interface ISearch extends Serializable, IAdaptable, SearchPropertyPageProvider, ConnectionPropertyPageProvider
 {
 
+    /** Constant for empty search base */
+    public static final DN EMPTY_SEARCH_BASE = new DN(); //$NON-NLS-1$
+
+    /** The returning attribute shortcut for all user attributes '*' */
     public static final String ALL_USER_ATTRIBUTES = "*"; //$NON-NLS-1$
 
+    /** The returning attribute shortcut for all operational attributes '+' */
     public static final String ALL_OPERATIONAL_ATTRIBUTES = "+"; //$NON-NLS-1$
 
+    /** Constant for no returning attributes, an empty array */
     public static final String[] NO_ATTRIBUTES = new String[0];
 
+    /** True filter (objectClass=*) */
     public static final String FILTER_TRUE = "(objectClass=*)"; //$NON-NLS-1$
 
+    /** False filter (!(objectClass=*)) */
     public static final String FILTER_FALSE = "(!(objectClass=*))"; //$NON-NLS-1$
 
+    /** Search scope object */
     public static final int SCOPE_OBJECT = 0;
 
+    /** Search scope one level */
     public static final int SCOPE_ONELEVEL = 1;
 
+    /** Search scope subtree */
     public static final int SCOPE_SUBTREE = 2;
 
 
+    /**
+     * Gets the LDAP URL of this search.
+     * 
+     * @return the LDAP URL of this search
+     */
     public abstract URL getUrl();
 
 
+    /**
+     * Checks if the hasChildren flag should be initialized.
+     * 
+     * @return true, if the hasChildren flag should be initialized
+     */
     public abstract boolean isInitChildrenFlag();
 
 
+    /**
+     * Checks if the isAlias and isReferral flags should be initialized.
+     * 
+     * @return true, if the isAlias and isReferral flags should be initialized
+     */
     public abstract boolean isInitAliasAndReferralFlag();
 
 
+    /**
+     * Gets the controls.
+     * 
+     * @return the controls
+     */
     public abstract Control[] getControls();
 
 
+    /**
+     * Gets the count limit, 0 means no limit.
+     * 
+     * @return the count limit
+     */
     public abstract int getCountLimit();
 
 
+    /**
+     * Sets the count limit, 0 means no limit.
+     * 
+     * @param countLimit the count limit
+     */
     public abstract void setCountLimit( int countLimit );
 
 
+    /**
+     * Gets the filter.
+     * 
+     * @return the filter
+     */
     public abstract String getFilter();
 
 
+    /**
+     * Sets the filter, a null or empty filter will be
+     * transformed to (objectClass=*).
+     * 
+     * Calling this method causes firing a search update event.
+     * 
+     * @param filter the filter
+     */
     public abstract void setFilter( String filter );
 
 
+    /**
+     * Gets the returning attributes.
+     * 
+     * @return the returning attributes
+     */
     public abstract String[] getReturningAttributes();
 
 
+    /**
+     * Sets the returning attributes, an empty array indicates none,
+     * null will be transformed to '*' (all user attributes).
+     * 
+     * Calling this method causes firing a search update event.
+     * 
+     * @param returningAttributes the returning attributes
+     */
     public abstract void setReturningAttributes( String[] returningAttributes );
 
 
+    /**
+     * Gets the search scope, one of ISearch.SCOPE_OBJECT, 
+     * ISearch.SCOPE_ONELEVEL or ISearch.SCOPE_SUBTREE.
+     * 
+     * @return the search scope
+     */
     public abstract int getScope();
 
 
+    /**
+     * Sets the search scope, one of ISearch.SCOPE_OBJECT, 
+     * ISearch.SCOPE_ONELEVEL or ISearch.SCOPE_SUBTREE.
+     * 
+     * Calling this method causes firing a search update event.
+     * 
+     * @param scope the search scope
+     */
     public abstract void setScope( int scope );
 
 
+    /**
+     * Gets the aliases dereferencing method, one of IConnection.DEREFERENCE_ALIASES_NEVER,

+     * IConnection.DEREFERENCE_ALIASES_ALWAYS, IConnection.DEREFERENCE_ALIASES_FINDING 
+     * or IConnection.DEREFERENCE_ALIASES_SEARCH.
+     * 
+     * 
+     * @return the aliases dereferencing method
+     */
     public abstract int getAliasesDereferencingMethod();
 
 
+    /**
+     * Sets the aliases dereferencing method, one of IConnection.DEREFERENCE_ALIASES_NEVER,

+     * IConnection.DEREFERENCE_ALIASES_ALWAYS, IConnection.DEREFERENCE_ALIASES_FINDING 
+     * or IConnection.DEREFERENCE_ALIASES_SEARCH.
+     * 
+     * Calling this method causes firing a search update event.
+     * 
+     * @param aliasesDereferencingMethod the aliases dereferencing method
+     */
     public abstract void setAliasesDereferencingMethod( int aliasesDereferencingMethod );
 
 
+    /**
+     * Gets the referrals handling method, one of IConnection.HANDLE_REFERRALS_IGNORE
+     * or IConnection.HANDLE_REFERRALS_FOLLOW.
+     *  
+     * @return the referrals handling method
+     */
     public abstract int getReferralsHandlingMethod();
 
 
+    /**
+     * Sets the referrals handling method, one of IConnection.HANDLE_REFERRALS_IGNORE or

+     * IConnection.HANDLE_REFERRALS_FOLLOW.
+     * 
+     * Calling this method causes firing a search update event.
+     * 
+     * @param referralsHandlingMethod the referrals handling method
+     */
     public abstract void setReferralsHandlingMethod( int referralsHandlingMethod );
 
 
+    /**
+     * Gets the search base.
+     * 
+     * @return the search base
+     */
     public abstract DN getSearchBase();
 
 
+    /**
+     * Sets the search base, a null search base will be
+     * transformed to an empty DN.
+     * 
+     * Calling this method causes firing a search update event.
+     * 
+     * @param searchBase the search base
+     */
     public abstract void setSearchBase( DN searchBase );
 
 
+    /**
+     * Gets the time limit in milliseconds, 0 means no limit.
+     * 
+     * @return the time limit
+     */
     public abstract int getTimeLimit();
 
 
+    /**
+     * Sets the time limit in milliseconds, 0 means no limit.
+     * 
+     * Calling this method causes firing a search update event.
+     * 
+     * @param timeLimit the time limit
+     */
     public abstract void setTimeLimit( int timeLimit );
 
 
+    /**
+     * Gets the symbolic name.
+     * 
+     * @return the name
+     */
     public abstract String getName();
 
 
+    /**
+     * Sets the symbolic name.
+     * 
+     * Calling this method causes firing a search update event.
+     * 
+     * @param name the name
+     */
     public abstract void setName( String searchName );
 
 
+    /**
+     * Gets the search results, null indicates that the
+     * search wasn't performed yet.
+     * 
+     * @return the search results
+     */
     public abstract ISearchResult[] getSearchResults();
 
 
+    /**
+     * Sets the search results.
+     * 
+     * Calling this method causes firing a search update event.
+     * 
+     * @param searchResults the search results
+     */
     public abstract void setSearchResults( ISearchResult[] searchResults );
 
 
+    /**
+     * Checks if the count limit exceeded.
+     * 
+     * @return true, if the count limit exceeded
+     */
     public abstract boolean isCountLimitExceeded();
 
 
+    /**
+     * Sets the count limit exceeded flag.
+     * 
+     * Calling this method causes firing a search update event.
+     * 
+     * @param countLimitExceeded the count limit exceeded flag
+     */
     public abstract void setCountLimitExceeded( boolean countLimitExceeded );
 
 
+    /**
+     * Gets the connection.
+     * 
+     * @return the connection
+     */
     public abstract IConnection getConnection();
 
 
+    /**
+     * Sets the connection.
+     * 
+     * Calling this method causes firing a search update event.
+     * 
+     * @param connection the connection
+     */
     public abstract void setConnection( IConnection connection );
 
 
+    /**
+     * Clones this search.
+     * 
+     * @return the cloned search
+     */
     public abstract Object clone();
 
 
+    /**
+     * Gets the search parameter.
+     * 
+     * @return the search parameter
+     */
     public abstract SearchParameter getSearchParameter();
 
 
+    /**
+     * Sets the search parameter.
+     * 
+     * @param searchParameter the search parameter
+     */
     public abstract void setSearchParameter( SearchParameter searchParameter );
 
 }

Modified: directory/ldapstudio/trunk/ldapstudio-browser-core/src/main/java/org/apache/directory/ldapstudio/browser/core/model/SearchParameter.java
URL: http://svn.apache.org/viewvc/directory/ldapstudio/trunk/ldapstudio-browser-core/src/main/java/org/apache/directory/ldapstudio/browser/core/model/SearchParameter.java?view=diff&rev=498419&r1=498418&r2=498419
==============================================================================
--- directory/ldapstudio/trunk/ldapstudio-browser-core/src/main/java/org/apache/directory/ldapstudio/browser/core/model/SearchParameter.java
(original)
+++ directory/ldapstudio/trunk/ldapstudio-browser-core/src/main/java/org/apache/directory/ldapstudio/browser/core/model/SearchParameter.java
Sun Jan 21 09:37:09 2007
@@ -28,8 +28,6 @@
  * A Bean class to hold the search parameters.
  * It is used to make searches persistent.
  * 
- * TODO: check problems with null searchBase, filter and returningAttributes!
- * 
  * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
  * @version $Rev$, $Date$
  */
@@ -70,7 +68,7 @@
     private Control[] controls;
 
     /** Flag indicating wether the hasChildren flag of IEntry should be initialized */
-    private boolean initChildrenFlag;
+    private boolean initHasChildrenFlag;
 
     /** Flag indicating wether the isAlias and isReferral flag of IEntry should be initialized
*/
     private boolean initAliasAndReferralFlag;
@@ -79,27 +77,33 @@
     /**
      * Creates a new instance of SearchParameter with default search parameters:
      * <ul>
-     * <li>Filter (objectClass=*)
-     * <li>Object scope
-     * <li>No time limit
-     * <li<No count limit
-     * <li>Never dereference aliases
-     * <li>Ignore referrals
-     * <li>No controls
-     * <li>Don't initialize hasChildren flag
-     * <li>Don't initialize isAlias and isReferral flag
+     * <li>null search name
+     * <li>empty search base
+     * <li>default filter (objectClass=*)
+     * <li>no returning attributes
+     * <li>search scope one level
+     * <li>no count limit
+     * <li>no time limit
+     * <li>never dereference aliases
+     * <li>ignore referrals
+     * <li>no initialization of hasChildren flag
+     * <li>no initialization of isAlias and isReferral flag
+     * <li>no controls 
      * </ul>
      */
     public SearchParameter()
     {
+        name = null;
+        searchBase = ISearch.EMPTY_SEARCH_BASE;
         filter = ISearch.FILTER_TRUE;
-        scope = ISearch.SCOPE_OBJECT;
+        returningAttributes = ISearch.NO_ATTRIBUTES;
+        scope = ISearch.SCOPE_ONELEVEL;
         timeLimit = 0;
         countLimit = 0;
         aliasesDereferencingMethod = IConnection.DEREFERENCE_ALIASES_NEVER;
         referralsHandlingMethod = IConnection.HANDLE_REFERRALS_IGNORE;
         controls = null;
-        initChildrenFlag = false;
+        initHasChildrenFlag = false;
         initAliasAndReferralFlag = false;
     }
 
@@ -138,12 +142,17 @@
 
 
     /**
-     * Sets the filter.
+     * Sets the filter, a null or empty filter will be
+     * transformed to (objectClass=*).
      * 
      * @param filter the filter
      */
     public void setFilter( String filter )
     {
+        if ( filter == null || "".equals( filter ) ) //$NON-NLS-1$
+        {
+            filter = ISearch.FILTER_TRUE;
+        }
         this.filter = filter;
     }
 
@@ -182,7 +191,8 @@
 
 
     /**
-     * Sets the returning attributes.
+     * Sets the returning attributes, an empty array indicates none,
+     * null will be transformed to '*' (all user attributes).
      * 
      * @param returningAttributes the returning attributes
      */
@@ -190,9 +200,8 @@
     {
         if ( returningAttributes == null )
         {
-            IllegalArgumentException e = new IllegalArgumentException( "Argument returningAttributes
is null" ); //$NON-NLS-1$
-            e.printStackTrace();
-            throw e;
+            returningAttributes = new String[]
+                { ISearch.ALL_USER_ATTRIBUTES };
         }
         this.returningAttributes = returningAttributes;
     }
@@ -284,12 +293,17 @@
 
 
     /**
-     * Sets the search base.
+     * Sets the search base, a null search base will be
+     * transformed to an empty DN.
      * 
      * @param searchBase the search base
      */
     public void setSearchBase( DN searchBase )
     {
+        if ( searchBase == null )
+        {
+            searchBase = ISearch.EMPTY_SEARCH_BASE;
+        }
         this.searchBase = searchBase;
     }
 
@@ -339,9 +353,9 @@
 
 
     /**
-     * Checks if the hasChildren flag of IEntry should be initialized.
+     * Checks if the isAlias and isReferral flags of IEntry should be initialized.
      * 
-     * @return true, if the hasChildren flag of IEntry should be initialized
+     * @return true, if the isAlias and isReferral flags of IEntry should be initialized
      */
     public boolean isInitAliasAndReferralFlag()
     {
@@ -352,7 +366,7 @@
     /**
      * Sets if the hasChildren flag of IEntry should be initialized.
      * 
-     * @param initAliasAndReferralFlag the init alias and referral flag
+     * @param initAliasAndReferralFlag the init isAlias and isReferral flag
      */
     public void setInitAliasAndReferralFlag( boolean initAliasAndReferralFlag )
     {
@@ -367,18 +381,18 @@
      */
     public boolean isInitChildrenFlag()
     {
-        return initChildrenFlag;
+        return initHasChildrenFlag;
     }
 
 
     /**
      * Sets if the hasChildren flag of IEntry should be initialized.
      * 
-     * @param initChildrenFlag the init children flag
+     * @param initHasChildrenFlag the init hasChildren flag
      */
-    public void setInitChildrenFlag( boolean initChildrenFlag )
+    public void setInitChildrenFlag( boolean initHasChildrenFlag )
     {
-        this.initChildrenFlag = initChildrenFlag;
+        this.initHasChildrenFlag = initHasChildrenFlag;
     }
 
 



Mime
View raw message