578 lines · 18.3 KB · Java
RawDownload
     *          that implements <CODE>interfaceName</CODE>,     *          <CODE>object</CODE> is returned downcast to type {@link     *          java.lang.Class Class}; otherwise an exception is thrown.     *     * @exception  NullPointerException     *     (unchecked exception) Thrown if <CODE>object</CODE> is null.     * @exception  ClassCastException     *     (unchecked exception) Thrown if <CODE>object</CODE> is not a     *     {@link java.lang.Class Class} that implements     *     <CODE>interfaceName</CODE>.     */    public static Class<?>        verifyAttributeCategory(Object object, Class<?> interfaceName) {         Class result = (Class) object;        if (interfaceName.isAssignableFrom (result)) {            return result;        }        else {            throw new ClassCastException();        }    }     /**     * Verify that the given object is an instance of the given interface, which     * is assumed to be interface {@link Attribute Attribute} or a subinterface     * thereof.     *     * @param  object     Object to test.     * @param  interfaceName  Interface of which the object must be an instance.     *     * @return  If <CODE>object</CODE> is an instance of     *          <CODE>interfaceName</CODE>, <CODE>object</CODE> is returned     *          downcast to type {@link Attribute Attribute}; otherwise an     *          exception is thrown.     *     * @exception  NullPointerException     *     (unchecked exception) Thrown if <CODE>object</CODE> is null.     * @exception  ClassCastException     *     (unchecked exception) Thrown if <CODE>object</CODE> is not an     *     instance of <CODE>interfaceName</CODE>.     */    public static Attribute        verifyAttributeValue(Object object, Class<?> interfaceName) {         if (object == null) {            throw new NullPointerException();        }        else if (interfaceName.isInstance (object)) {            return (Attribute) object;        } else {            throw new ClassCastException();        }    }     /**     * Verify that the given attribute category object is equal to the     * category of the given attribute value object. If so, this method     * returns doing nothing. If not, this method throws an exception.     *     * @param  category   Attribute category to test.     * @param  attribute  Attribute value to test.     *     * @exception  NullPointerException     *     (unchecked exception) Thrown if the <CODE>category</CODE> is     *     null or if the <CODE>attribute</CODE> is null.     * @exception  IllegalArgumentException     *     (unchecked exception) Thrown if the <CODE>category</CODE> is not     *     equal to the category of the <CODE>attribute</CODE>.     */    public static void        verifyCategoryForValue(Class<?> category, Attribute attribute) {         if (!category.equals (attribute.getCategory())) {            throw new IllegalArgumentException();        }    }}

Lines 501–578 of 578. Previous lines