home *** CD-ROM | disk | FTP | other *** search
/ Symantec Visual Cafe for Java 2.5 / symantec-visual-cafe-2.5-database-dev-edition.iso / Extras / OSpace / jgl.exe / jgl_2_0 / src / COM / objectspace / jgl / InstanceOf.java < prev    next >
Encoding:
Java Source  |  1997-03-14  |  901 b   |  39 lines

  1. // Copyright(c) 1997 ObjectSpace, Inc.
  2.  
  3. package COM.objectspace.jgl;
  4.  
  5. import java.lang.Class;
  6.  
  7. /**
  8.  * InstanceOf is a unary predicate that performs the same function as the
  9.  * instanceof keyword.
  10.  * <p>
  11.  * @version 2.0.2
  12.  * @author ObjectSpace, Inc.
  13.  */
  14.  
  15. public final class InstanceOf implements UnaryPredicate
  16.   {
  17.   private Class c;
  18.  
  19.   /**
  20.    * Construct myself to perform the equivalent of the instanceof operator for the given class.
  21.    */
  22.   public InstanceOf( Class c )
  23.     {
  24.     this.c= c;
  25.     }
  26.  
  27.   /**
  28.    * Test operand for belonging to a specific class.
  29.    * @param object The operand
  30.    * @return true if the specified Object argument is non-null and can be
  31.    * successfully cast to the type passed in my constructor.
  32.    * @see java.lang.Class#isInstance
  33.    */
  34.   public boolean execute( Object object )
  35.     {
  36.     return c.isInstance( object );
  37.     }
  38.   }
  39.