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    * An Any Substring Query Expression.<p>
   13    *
   14    * Returns true when an attribute value contains the string expression.
   15    *
   16    * <p><b>Revisions:</b>
   17    * <p><b>20020317 Adrian Brock:</b>
   18    * <ul>
   19    * <li>Make queries thread safe
   20    * </ul>
   21    * 
   22    * @author  <a href="mailto:Adrian.Brock@HappeningTimes.com">Adrian Brock</a>.
   23    * @version $Revision: 1.2 $
   24    */
   25   /*package*/ class AnySubStringQueryExp
   26      extends QueryExpSupport
   27   {
   28      // Constants ---------------------------------------------------
   29   
   30      // Attributes --------------------------------------------------
   31   
   32      /**
   33       * The attribute to test
   34       */
   35      AttributeValueExp attr;
   36   
   37      /**
   38       * The string to test
   39       */
   40      StringValueExp string;
   41   
   42      // Static ------------------------------------------------------
   43   
   44      // Constructors ------------------------------------------------
   45   
   46      /**
   47       * Construct a new Any Substring query expression
   48       *
   49       * @param attr the attribute to test
   50       * @param string the string to test
   51       */
   52      public AnySubStringQueryExp(AttributeValueExp attr, StringValueExp string)
   53      {
   54         this.attr = attr;
   55         this.string = string;
   56      }
   57   
   58      // Public ------------------------------------------------------
   59   
   60      // QueryExp implementation -------------------------------------
   61   
   62      public boolean apply(ObjectName name)
   63         throws BadStringOperationException,
   64                BadBinaryOpValueExpException,
   65                BadAttributeValueExpException,
   66                InvalidApplicationException
   67      {
   68         ValueExp calcAttr = attr.apply(name);
   69         ValueExp calcString = string.apply(name);
   70         if (calcAttr instanceof StringValueExp)
   71         {
   72            return ((StringValueExp)calcAttr).toString().indexOf(
   73                   ((StringValueExp)calcString).toString()) != -1;
   74         }
   75         // REVIEW: correct?
   76         return false;
   77      }
   78   
   79      // Object overrides --------------------------------------------
   80   
   81      public String toString()
   82      {
   83         return new String("(" + attr.toString() + " anySubString " +
   84                           string.toString() + ")");
   85      }
   86   
   87      // Protected ---------------------------------------------------
   88   
   89      // Private -----------------------------------------------------
   90   
   91      // Inner classes -----------------------------------------------
   92   }

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