src/share/classes/javax/print/attribute/AttributeSetUtilities.java

Print this page




 506      * Attribute Attribute} or a subinterface thereof.
 507      *
 508      * @param  object     Object to test.
 509      * @param  interfaceName  Interface the object must implement.
 510      *
 511      * @return  If <CODE>object</CODE> is a {@link java.lang.Class Class}
 512      *          that implements <CODE>interfaceName</CODE>,
 513      *          <CODE>object</CODE> is returned downcast to type {@link
 514      *          java.lang.Class Class}; otherwise an exception is thrown.
 515      *
 516      * @exception  NullPointerException
 517      *     (unchecked exception) Thrown if <CODE>object</CODE> is null.
 518      * @exception  ClassCastException
 519      *     (unchecked exception) Thrown if <CODE>object</CODE> is not a
 520      *     {@link java.lang.Class Class} that implements
 521      *     <CODE>interfaceName</CODE>.
 522      */
 523     public static Class<?>
 524         verifyAttributeCategory(Object object, Class<?> interfaceName) {
 525 
 526         Class result = (Class) object;
 527         if (interfaceName.isAssignableFrom (result)) {
 528             return result;
 529         }
 530         else {
 531             throw new ClassCastException();
 532         }
 533     }
 534 
 535     /**
 536      * Verify that the given object is an instance of the given interface, which
 537      * is assumed to be interface {@link Attribute Attribute} or a subinterface
 538      * thereof.
 539      *
 540      * @param  object     Object to test.
 541      * @param  interfaceName  Interface of which the object must be an instance.
 542      *
 543      * @return  If <CODE>object</CODE> is an instance of
 544      *          <CODE>interfaceName</CODE>, <CODE>object</CODE> is returned
 545      *          downcast to type {@link Attribute Attribute}; otherwise an
 546      *          exception is thrown.




 506      * Attribute Attribute} or a subinterface thereof.
 507      *
 508      * @param  object     Object to test.
 509      * @param  interfaceName  Interface the object must implement.
 510      *
 511      * @return  If <CODE>object</CODE> is a {@link java.lang.Class Class}
 512      *          that implements <CODE>interfaceName</CODE>,
 513      *          <CODE>object</CODE> is returned downcast to type {@link
 514      *          java.lang.Class Class}; otherwise an exception is thrown.
 515      *
 516      * @exception  NullPointerException
 517      *     (unchecked exception) Thrown if <CODE>object</CODE> is null.
 518      * @exception  ClassCastException
 519      *     (unchecked exception) Thrown if <CODE>object</CODE> is not a
 520      *     {@link java.lang.Class Class} that implements
 521      *     <CODE>interfaceName</CODE>.
 522      */
 523     public static Class<?>
 524         verifyAttributeCategory(Object object, Class<?> interfaceName) {
 525 
 526         Class<?> result = (Class) object;
 527         if (interfaceName.isAssignableFrom (result)) {
 528             return result;
 529         }
 530         else {
 531             throw new ClassCastException();
 532         }
 533     }
 534 
 535     /**
 536      * Verify that the given object is an instance of the given interface, which
 537      * is assumed to be interface {@link Attribute Attribute} or a subinterface
 538      * thereof.
 539      *
 540      * @param  object     Object to test.
 541      * @param  interfaceName  Interface of which the object must be an instance.
 542      *
 543      * @return  If <CODE>object</CODE> is an instance of
 544      *          <CODE>interfaceName</CODE>, <CODE>object</CODE> is returned
 545      *          downcast to type {@link Attribute Attribute}; otherwise an
 546      *          exception is thrown.