Save This Page
Home » openjdk-7 » javax » management » [javadoc | source]
    1   /*
    2    * JBoss, the OpenSource J2EE webOS
    3    *
    4    * Distributable under LGPL license.
    5    * See terms of license at gnu.org.
    6    */
    7   package javax.management;
    8   
    9   import java.io.Serializable;
   10   
   11   /**
   12    * A Final Substring Query Expression.<p>
   13    *
   14    * Returns true when an attribute value ends with the string expression.
   15    *
   16    * <p><b>20020317 Adrian Brock:</b>
   17    * <ul>
   18    * <li>Make queries thread safe
   19    * </ul>
   20    * 
   21    * @author  <a href="mailto:Adrian.Brock@HappeningTimes.com">Adrian Brock</a>.
   22    * @version $Revision: 1.2 $
   23    */
   24   /*package*/ class FinalSubStringQueryExp
   25      extends QueryExpSupport
   26   {
   27      // Constants ---------------------------------------------------
   28   
   29      // Attributes --------------------------------------------------
   30   
   31      /**
   32       * The attribute to test
   33       */
   34      AttributeValueExp attr;
   35   
   36      /**
   37       * The string to test
   38       */
   39      StringValueExp string;
   40   
   41      // Static ------------------------------------------------------
   42   
   43      // Constructors ------------------------------------------------
   44   
   45      /**
   46       * Construct a new Final Substring query expression
   47       *
   48       * @param attr the attribute to test
   49       * @param string the string to test
   50       */
   51      public FinalSubStringQueryExp(AttributeValueExp attr, StringValueExp string)
   52      {
   53         this.attr = attr;
   54         this.string = string;
   55      }
   56   
   57      // Public ------------------------------------------------------
   58   
   59      // QueryExp implementation -------------------------------------
   60   
   61      public boolean apply(ObjectName name)
   62         throws BadStringOperationException,
   63                BadBinaryOpValueExpException,
   64                BadAttributeValueExpException,
   65                InvalidApplicationException
   66      {
   67         ValueExp calcAttr = attr.apply(name);
   68         ValueExp calcString = string.apply(name);
   69         if (calcAttr instanceof StringValueExp)
   70         {
   71            return ((StringValueExp)calcAttr).toString().endsWith(
   72                   ((StringValueExp)calcString).toString());
   73         }
   74         // REVIEW: correct?
   75         return false;
   76      }
   77   
   78      // Object overrides --------------------------------------------
   79   
   80      public String toString()
   81      {
   82         return new String("(" + attr.toString() + " finalSubString " +
   83                           string.toString() + ")");
   84      }
   85   
   86      // Protected ---------------------------------------------------
   87   
   88      // Private -----------------------------------------------------
   89   
   90      // Inner classes -----------------------------------------------
   91   }

Save This Page
Home » openjdk-7 » javax » management » [javadoc | source]