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 2006-2008 Sun Microsystems, Inc.
026     */
027    package org.opends.server.api;
028    
029    
030    
031    import org.opends.server.types.Entry;
032    
033    
034    
035    /**
036     * Generic subtree specification interface.
037     */
038    @org.opends.server.types.PublicAPI(
039         stability=org.opends.server.types.StabilityLevel.VOLATILE,
040         mayInstantiate=false,
041         mayExtend=true,
042         mayInvoke=false)
043    public abstract class SubtreeSpecification
044    {
045      /**
046       * Create a new subtree specification.
047       */
048      protected SubtreeSpecification()
049      {
050        // No implementation required.
051      }
052    
053    
054    
055      /**
056       * Determine if an entry is within the scope of the subtree
057       * specification.
058       *
059       * @param  entry  The entry.
060       *
061       * @return  {@code true} if the entry is within the scope of the
062       *          subtree specification, or {@code false} if not.
063       */
064      public abstract boolean isWithinScope(Entry entry);
065    
066    
067    
068      /**
069       * Indicates whether the provided object is logically equal to this
070       * subtree specification object.
071       *
072       * @param  obj  The object for which to make the determination.
073       *
074       * @return  {@code true} if the provided object is logically equal
075       *          to this subtree specification object, or {@code false}
076       *          if not.
077       */
078      @Override
079      public abstract boolean equals(Object obj);
080    
081    
082    
083      /**
084       * Retrieves the hash code for this subtree specification object.
085       *
086       * @return  The hash code for this subtree specification object.
087       */
088      @Override
089      public abstract int hashCode();
090    
091    
092    
093      /**
094       * Append the string representation of the subtree specification to
095       * the provided string builder.
096       *
097       * @param  builder  The string builder.
098       * @return  The string builder.
099       */
100      public abstract StringBuilder toString(StringBuilder builder);
101    
102    
103    
104      /**
105       * Retrieves a string representation of this subtree specification
106       * object.
107       *
108       * @return  A string representation of this subtree specification
109       *          object.
110       */
111      @Override
112      public final String toString()
113      {
114        StringBuilder builder = new StringBuilder();
115        return toString(builder).toString();
116      }
117    }
118