001    /*
002     * CDDL HEADER START
003     *
004     * The contents of this file are subject to the terms of the
005     * Common Development and Distribution License, Version 1.0 only
006     * (the "License").  You may not use this file except in compliance
007     * with the License.
008     *
009     * You can obtain a copy of the license at
010     * trunk/opends/resource/legal-notices/OpenDS.LICENSE
011     * or https://OpenDS.dev.java.net/OpenDS.LICENSE.
012     * See the License for the specific language governing permissions
013     * and limitations under the License.
014     *
015     * When distributing Covered Code, include this CDDL HEADER in each
016     * file and include the License file at
017     * trunk/opends/resource/legal-notices/OpenDS.LICENSE.  If applicable,
018     * add the following below this CDDL HEADER, with the fields enclosed
019     * by brackets "[]" replaced with your own identifying information:
020     *      Portions Copyright [yyyy] [name of copyright owner]
021     *
022     * CDDL HEADER END
023     *
024     *
025     *      Copyright 2008 Sun Microsystems, Inc.
026     */
027    package org.opends.admin.ads;
028    
029    import java.util.HashSet;
030    import java.util.Set;
031    
032    /**
033     * Class used to filter what we look for in the topology cache.
034     * This is done in particular to avoid problems of performance when we
035     * know what we are looking for.  It is particularly useful to avoid
036     * searching for monitoring information.
037     */
038    public class TopologyCacheFilter
039    {
040      private Set<String> baseDNs = new HashSet<String>();
041      private boolean searchMonitoringInformation = true;
042      private boolean searchBaseDNInformation = true;
043    
044      /**
045       * Returns whether we must search for base DN information or not.
046       * @return <CODE>true</CODE> if we must search base DN information and
047       * <CODE>false</CODE> otherwise.
048       */
049      public boolean searchBaseDNInformation()
050      {
051        return searchBaseDNInformation;
052      }
053    
054      /**
055       * Sets whether we must search for base DN information or not.
056       * @param searchBaseDNInformation whether we must search for base DN
057       * information or not.
058       */
059      public void setSearchBaseDNInformation(
060          boolean searchBaseDNInformation)
061      {
062        this.searchBaseDNInformation = searchBaseDNInformation;
063      }
064    
065    
066      /**
067       * Returns whether we must search for monitoring information or not.
068       * @return <CODE>true</CODE> if we must search monitoring information and
069       * <CODE>false</CODE> otherwise.
070       */
071      public boolean searchMonitoringInformation()
072      {
073        return searchMonitoringInformation;
074      }
075    
076      /**
077       * Sets whether we must search for monitoring information or not.
078       * @param searchMonitoringInformation whether we must search for monitoring
079       * information or not.
080       */
081      public void setSearchMonitoringInformation(
082          boolean searchMonitoringInformation)
083      {
084        this.searchMonitoringInformation = searchMonitoringInformation;
085      }
086    
087      /**
088       * Adds one of the base DNs we must search for.  If at least one baseDN
089       * is added using this method, only the added baseDNs are searched.  If no
090       * base DN is added, all the base DNs will be retrieved.
091       * @param dn the DN of the base DN to look for.
092       */
093      public void addBaseDNToSearch(String dn)
094      {
095        baseDNs.add(dn);
096      }
097    
098      /**
099       * Removes a base DN fom the list of baseDNs to search.
100       * @param dn the DN of the base DN to be removed.
101       */
102      public void removeBaseDNToSearch(String dn)
103      {
104        baseDNs.remove(dn);
105      }
106    
107      /**
108       * Returns the list of base DNs that will be searched for.  If the list is
109       * empty we will search for all the base DNs.
110       * @return the list of base DNs we will search for.
111       */
112      public Set<String> getBaseDNsToSearch()
113      {
114        return new HashSet<String>(baseDNs);
115      }
116    
117      /**
118       * Tells whether this filter specifies to search for all the base DNs or not.
119       * @return <CODE>true</CODE> if the filter specifies to search for all the
120       * base DNs and <CODE>false</CODE> otherwise.
121       */
122      public boolean searchAllBaseDNs()
123      {
124        return baseDNs.isEmpty();
125      }
126    }