⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 parameterblock.java

📁 java1.6众多例子参考
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
    /**      * Adds a Long to the list of parameters.      * @param l the long to add to the      *            <code>parameters</code> <code>Vector</code>     * @return a new <code>ParameterBlock</code> containing      *         the specified parameter.     */    public ParameterBlock add(long l) {        return add(new Long(l));    }    /**      * Adds a Float to the list of parameters.      * @param f the float to add to the      *            <code>parameters</code> <code>Vector</code>     * @return a new <code>ParameterBlock</code> containing      *         the specified parameter.     */    public ParameterBlock add(float f) {        return add(new Float(f));    }    /**      * Adds a Double to the list of parameters.      * @param d the double to add to the      *            <code>parameters</code> <code>Vector</code>     * @return a new <code>ParameterBlock</code> containing      *         the specified parameter.     */    public ParameterBlock add(double d) {        return add(new Double(d));    }    /**     * Replaces an Object in the list of parameters.     * If the index lies beyond the current source list,     * the list is extended with nulls as needed.     * @param obj the parameter that replaces the      *        parameter at the specified index in the     *        <code>parameters</code> <code>Vector</code>     * @param index the index of the parameter to be      *        replaced with the specified parameter     * @return a new <code>ParameterBlock</code> containing     *        the specified parameter.     */    public ParameterBlock set(Object obj, int index) {        int oldSize = parameters.size();        int newSize = index + 1;        if (oldSize < newSize) {            parameters.setSize(newSize);        }        parameters.setElementAt(obj, index);        return this;    }    /**     * Replaces an Object in the list of parameters with a Byte.     * If the index lies beyond the current source list,     * the list is extended with nulls as needed.     * @param b the parameter that replaces the      *        parameter at the specified index in the     *        <code>parameters</code> <code>Vector</code>     * @param index the index of the parameter to be      *        replaced with the specified parameter     * @return a new <code>ParameterBlock</code> containing     *        the specified parameter.     */    public ParameterBlock set(byte b, int index) {        return set(new Byte(b), index);    }    /**     * Replaces an Object in the list of parameters with a Character.     * If the index lies beyond the current source list,     * the list is extended with nulls as needed.     * @param c the parameter that replaces the      *        parameter at the specified index in the     *        <code>parameters</code> <code>Vector</code>     * @param index the index of the parameter to be      *        replaced with the specified parameter     * @return a new <code>ParameterBlock</code> containing     *        the specified parameter.     */    public ParameterBlock set(char c, int index) {        return set(new Character(c), index);    }    /**     * Replaces an Object in the list of parameters with a Short.     * If the index lies beyond the current source list,     * the list is extended with nulls as needed.     * @param s the parameter that replaces the      *        parameter at the specified index in the     *        <code>parameters</code> <code>Vector</code>     * @param index the index of the parameter to be      *        replaced with the specified parameter     * @return a new <code>ParameterBlock</code> containing     *        the specified parameter.     */    public ParameterBlock set(short s, int index) {        return set(new Short(s), index);    }    /**     * Replaces an Object in the list of parameters with an Integer.     * If the index lies beyond the current source list,     * the list is extended with nulls as needed.     * @param i the parameter that replaces the      *        parameter at the specified index in the     *        <code>parameters</code> <code>Vector</code>     * @param index the index of the parameter to be      *        replaced with the specified parameter     * @return a new <code>ParameterBlock</code> containing     *        the specified parameter.     */    public ParameterBlock set(int i, int index) {        return set(new Integer(i), index);    }    /**     * Replaces an Object in the list of parameters with a Long.     * If the index lies beyond the current source list,     * the list is extended with nulls as needed.     * @param l the parameter that replaces the      *        parameter at the specified index in the     *        <code>parameters</code> <code>Vector</code>     * @param index the index of the parameter to be      *        replaced with the specified parameter     * @return a new <code>ParameterBlock</code> containing     *        the specified parameter.     */    public ParameterBlock set(long l, int index) {        return set(new Long(l), index);    }    /**     * Replaces an Object in the list of parameters with a Float.     * If the index lies beyond the current source list,     * the list is extended with nulls as needed.     * @param f the parameter that replaces the      *        parameter at the specified index in the     *        <code>parameters</code> <code>Vector</code>     * @param index the index of the parameter to be      *        replaced with the specified parameter     * @return a new <code>ParameterBlock</code> containing     *        the specified parameter.     */    public ParameterBlock set(float f, int index) {        return set(new Float(f), index);    }    /**     * Replaces an Object in the list of parameters with a Double.     * If the index lies beyond the current source list,     * the list is extended with nulls as needed.     * @param d the parameter that replaces the      *        parameter at the specified index in the     *        <code>parameters</code> <code>Vector</code>     * @param index the index of the parameter to be      *        replaced with the specified parameter     * @return a new <code>ParameterBlock</code> containing     *        the specified parameter.     */    public ParameterBlock set(double d, int index) {        return set(new Double(d), index);    }    /**     * Gets a parameter as an object.     * @param index the index of the parameter to get     * @return an <code>Object</code> representing the     *         the parameter at the specified index     *         into the <code>parameters</code>     *         <code>Vector</code>.     */    public Object getObjectParameter(int index) {        return parameters.elementAt(index);    }    /**     * A convenience method to return a parameter as a byte.  An     * exception is thrown if the parameter is      * <code>null</code> or not a <code>Byte</code>.     *     * @param index the index of the parameter to be returned.     * @return the parameter at the specified index     *         as a <code>byte</code> value.     * @throws ClassCastException if the parameter at the     *         specified index is not a <code>Byte</code>     * @throws NullPointerException if the parameter at the specified     *         index is <code>null</code>     * @throws ArrayIndexOutOfBoundsException if <code>index</code>     *         is negative or not less than the current size of this     *         <code>ParameterBlock</code> object     */    public byte getByteParameter(int index) {        return ((Byte)parameters.elementAt(index)).byteValue();    }    /**     * A convenience method to return a parameter as a char.  An     * exception is thrown if the parameter is      * <code>null</code> or not a <code>Character</code>.     *     * @param index the index of the parameter to be returned.     * @return the parameter at the specified index            *         as a <code>char</code> value.     * @throws ClassCastException if the parameter at the     *         specified index is not a <code>Character</code>     * @throws NullPointerException if the parameter at the specified     *         index is <code>null</code>     * @throws ArrayIndexOutOfBoundsException if <code>index</code>     *         is negative or not less than the current size of this     *         <code>ParameterBlock</code> object     */    public char getCharParameter(int index) {        return ((Character)parameters.elementAt(index)).charValue();    }        /**     * A convenience method to return a parameter as a short.  An     * exception is thrown if the parameter is      * <code>null</code> or not a <code>Short</code>.     *     * @param index the index of the parameter to be returned.     * @return the parameter at the specified index            *         as a <code>short</code> value.     * @throws ClassCastException if the parameter at the     *         specified index is not a <code>Short</code>     * @throws NullPointerException if the parameter at the specified     *         index is <code>null</code>     * @throws ArrayIndexOutOfBoundsException if <code>index</code>     *         is negative or not less than the current size of this     *         <code>ParameterBlock</code> object     */    public short getShortParameter(int index) {        return ((Short)parameters.elementAt(index)).shortValue();    }    /**     * A convenience method to return a parameter as an int.  An     * exception is thrown if the parameter is      * <code>null</code> or not an <code>Integer</code>.     *     * @param index the index of the parameter to be returned.     * @return the parameter at the specified index            *         as a <code>int</code> value.     * @throws ClassCastException if the parameter at the     *         specified index is not a <code>Integer</code>     * @throws NullPointerException if the parameter at the specified     *         index is <code>null</code>     * @throws ArrayIndexOutOfBoundsException if <code>index</code>     *         is negative or not less than the current size of this     *         <code>ParameterBlock</code> object     */    public int getIntParameter(int index) {        return ((Integer)parameters.elementAt(index)).intValue();    }    /**     * A convenience method to return a parameter as a long.  An     * exception is thrown if the parameter is      * <code>null</code> or not a <code>Long</code>.     *     * @param index the index of the parameter to be returned.     * @return the parameter at the specified index            *         as a <code>long</code> value.     * @throws ClassCastException if the parameter at the     *         specified index is not a <code>Long</code>     * @throws NullPointerException if the parameter at the specified     *         index is <code>null</code>     * @throws ArrayIndexOutOfBoundsException if <code>index</code>     *         is negative or not less than the current size of this     *         <code>ParameterBlock</code> object     */    public long getLongParameter(int index) {        return ((Long)parameters.elementAt(index)).longValue();    }    /**     * A convenience method to return a parameter as a float.  An     * exception is thrown if the parameter is      * <code>null</code> or not a <code>Float</code>.     *     * @param index the index of the parameter to be returned.     * @return the parameter at the specified index            *         as a <code>float</code> value.     * @throws ClassCastException if the parameter at the     *         specified index is not a <code>Float</code>     * @throws NullPointerException if the parameter at the specified     *         index is <code>null</code>     * @throws ArrayIndexOutOfBoundsException if <code>index</code>     *         is negative or not less than the current size of this     *         <code>ParameterBlock</code> object     */    public float getFloatParameter(int index) {        return ((Float)parameters.elementAt(index)).floatValue();    }    /**     * A convenience method to return a parameter as a double.  An     * exception is thrown if the parameter is      * <code>null</code> or not a <code>Double</code>.     *     * @param index the index of the parameter to be returned.     * @return the parameter at the specified index            *         as a <code>double</code> value.     * @throws ClassCastException if the parameter at the     *         specified index is not a <code>Double</code>     * @throws NullPointerException if the parameter at the specified     *         index is <code>null</code>     * @throws ArrayIndexOutOfBoundsException if <code>index</code>     *         is negative or not less than the current size of this     *         <code>ParameterBlock</code> object     */    public double getDoubleParameter(int index) {        return ((Double)parameters.elementAt(index)).doubleValue();    }    /**     * Returns an array of Class objects describing the types     * of the parameters.     * @return an array of <code>Class</code> objects.     */    public Class [] getParamClasses() {        int numParams = getNumParameters();        Class [] classes = new Class[numParams];        int i;        for (i = 0; i < numParams; i++) {            Object obj = getObjectParameter(i);            if (obj instanceof Byte) {              classes[i] = byte.class;            } else if (obj instanceof Character) {              classes[i] = char.class;            } else if (obj instanceof Short) {              classes[i] = short.class;            } else if (obj instanceof Integer) {              classes[i] = int.class;            } else if (obj instanceof Long) {              classes[i] = long.class;            } else if (obj instanceof Float) {              classes[i] = float.class;            } else if (obj instanceof Double) {              classes[i] = double.class;            } else {              classes[i] = obj.getClass();            }        }                return classes;    }}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -