0N/A/*
2362N/A * Copyright (c) 1998, 2004, Oracle and/or its affiliates. All rights reserved.
0N/A * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
0N/A *
0N/A * This code is free software; you can redistribute it and/or modify it
0N/A * under the terms of the GNU General Public License version 2 only, as
2362N/A * published by the Free Software Foundation. Oracle designates this
0N/A * particular file as subject to the "Classpath" exception as provided
2362N/A * by Oracle in the LICENSE file that accompanied this code.
0N/A *
0N/A * This code is distributed in the hope that it will be useful, but WITHOUT
0N/A * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
0N/A * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
0N/A * version 2 for more details (a copy is included in the LICENSE file that
0N/A * accompanied this code).
0N/A *
0N/A * You should have received a copy of the GNU General Public License version
0N/A * 2 along with this work; if not, write to the Free Software Foundation,
0N/A * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
0N/A *
2362N/A * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
2362N/A * or visit www.oracle.com if you need additional information or have any
2362N/A * questions.
0N/A */
0N/A
0N/Apackage java.awt.image.renderable;
0N/Aimport java.awt.image.RenderedImage;
0N/Aimport java.io.Serializable;
0N/Aimport java.util.Vector;
0N/A
0N/A/**
0N/A * A <code>ParameterBlock</code> encapsulates all the information about sources and
0N/A * parameters (Objects) required by a RenderableImageOp, or other
0N/A * classes that process images.
0N/A *
0N/A * <p> Although it is possible to place arbitrary objects in the
0N/A * source Vector, users of this class may impose semantic constraints
0N/A * such as requiring all sources to be RenderedImages or
0N/A * RenderableImage. <code>ParameterBlock</code> itself is merely a container and
0N/A * performs no checking on source or parameter types.
0N/A *
0N/A * <p> All parameters in a <code>ParameterBlock</code> are objects; convenience
0N/A * add and set methods are available that take arguments of base type and
0N/A * construct the appropriate subclass of Number (such as
0N/A * Integer or Float). Corresponding get methods perform a
0N/A * downward cast and have return values of base type; an exception
0N/A * will be thrown if the stored values do not have the correct type.
0N/A * There is no way to distinguish between the results of
0N/A * "short s; add(s)" and "add(new Short(s))".
0N/A *
0N/A * <p> Note that the get and set methods operate on references.
0N/A * Therefore, one must be careful not to share references between
0N/A * <code>ParameterBlock</code>s when this is inappropriate. For example, to create
0N/A * a new <code>ParameterBlock</code> that is equal to an old one except for an
0N/A * added source, one might be tempted to write:
0N/A *
0N/A * <pre>
0N/A * ParameterBlock addSource(ParameterBlock pb, RenderableImage im) {
0N/A * ParameterBlock pb1 = new ParameterBlock(pb.getSources());
0N/A * pb1.addSource(im);
0N/A * return pb1;
0N/A * }
0N/A * </pre>
0N/A *
0N/A * <p> This code will have the side effect of altering the original
0N/A * <code>ParameterBlock</code>, since the getSources operation returned a reference
0N/A * to its source Vector. Both pb and pb1 share their source Vector,
0N/A * and a change in either is visible to both.
0N/A *
0N/A * <p> A correct way to write the addSource function is to clone
0N/A * the source Vector:
0N/A *
0N/A * <pre>
0N/A * ParameterBlock addSource (ParameterBlock pb, RenderableImage im) {
0N/A * ParameterBlock pb1 = new ParameterBlock(pb.getSources().clone());
0N/A * pb1.addSource(im);
0N/A * return pb1;
0N/A * }
0N/A * </pre>
0N/A *
0N/A * <p> The clone method of <code>ParameterBlock</code> has been defined to
0N/A * perform a clone of both the source and parameter Vectors for
0N/A * this reason. A standard, shallow clone is available as
0N/A * shallowClone.
0N/A *
0N/A * <p> The addSource, setSource, add, and set methods are
0N/A * defined to return 'this' after adding their argument. This allows
0N/A * use of syntax like:
0N/A *
0N/A * <pre>
0N/A * ParameterBlock pb = new ParameterBlock();
0N/A * op = new RenderableImageOp("operation", pb.add(arg1).add(arg2));
0N/A * </pre>
0N/A * */
0N/Apublic class ParameterBlock implements Cloneable, Serializable {
0N/A /** A Vector of sources, stored as arbitrary Objects. */
0N/A protected Vector<Object> sources = new Vector<Object>();
0N/A
0N/A /** A Vector of non-source parameters, stored as arbitrary Objects. */
0N/A protected Vector<Object> parameters = new Vector<Object>();
0N/A
0N/A /** A dummy constructor. */
0N/A public ParameterBlock() {}
0N/A
0N/A /**
0N/A * Constructs a <code>ParameterBlock</code> with a given Vector
0N/A * of sources.
0N/A * @param sources a <code>Vector</code> of source images
0N/A */
0N/A public ParameterBlock(Vector<Object> sources) {
0N/A setSources(sources);
0N/A }
0N/A
0N/A /**
0N/A * Constructs a <code>ParameterBlock</code> with a given Vector of sources and
0N/A * Vector of parameters.
0N/A * @param sources a <code>Vector</code> of source images
0N/A * @param parameters a <code>Vector</code> of parameters to be used in the
0N/A * rendering operation
0N/A */
0N/A public ParameterBlock(Vector<Object> sources,
0N/A Vector<Object> parameters)
0N/A {
0N/A setSources(sources);
0N/A setParameters(parameters);
0N/A }
0N/A
0N/A /**
0N/A * Creates a shallow copy of a <code>ParameterBlock</code>. The source and
0N/A * parameter Vectors are copied by reference -- additions or
0N/A * changes will be visible to both versions.
0N/A *
0N/A * @return an Object clone of the <code>ParameterBlock</code>.
0N/A */
0N/A public Object shallowClone() {
0N/A try {
0N/A return super.clone();
0N/A } catch (Exception e) {
0N/A // We can't be here since we implement Cloneable.
0N/A return null;
0N/A }
0N/A }
0N/A
0N/A /**
0N/A * Creates a copy of a <code>ParameterBlock</code>. The source and parameter
0N/A * Vectors are cloned, but the actual sources and parameters are
0N/A * copied by reference. This allows modifications to the order
0N/A * and number of sources and parameters in the clone to be invisible
0N/A * to the original <code>ParameterBlock</code>. Changes to the shared sources or
0N/A * parameters themselves will still be visible.
0N/A *
0N/A * @return an Object clone of the <code>ParameterBlock</code>.
0N/A */
0N/A public Object clone() {
0N/A ParameterBlock theClone;
0N/A
0N/A try {
0N/A theClone = (ParameterBlock) super.clone();
0N/A } catch (Exception e) {
0N/A // We can't be here since we implement Cloneable.
0N/A return null;
0N/A }
0N/A
0N/A if (sources != null) {
0N/A theClone.setSources((Vector)sources.clone());
0N/A }
0N/A if (parameters != null) {
0N/A theClone.setParameters((Vector)parameters.clone());
0N/A }
0N/A return (Object) theClone;
0N/A }
0N/A
0N/A /**
0N/A * Adds an image to end of the list of sources. The image is
0N/A * stored as an object in order to allow new node types in the
0N/A * future.
0N/A *
0N/A * @param source an image object to be stored in the source list.
0N/A * @return a new <code>ParameterBlock</code> containing the specified
0N/A * <code>source</code>.
0N/A */
0N/A public ParameterBlock addSource(Object source) {
0N/A sources.addElement(source);
0N/A return this;
0N/A }
0N/A
0N/A /**
0N/A * Returns a source as a general Object. The caller must cast it into
0N/A * an appropriate type.
0N/A *
0N/A * @param index the index of the source to be returned.
0N/A * @return an <code>Object</code> that represents the source located
0N/A * at the specified index in the <code>sources</code>
0N/A * <code>Vector</code>.
0N/A * @see #setSource(Object, int)
0N/A */
0N/A public Object getSource(int index) {
0N/A return sources.elementAt(index);
0N/A }
0N/A
0N/A /**
0N/A * Replaces an entry in the list of source with a new source.
0N/A * If the index lies beyond the current source list,
0N/A * the list is extended with nulls as needed.
0N/A * @param source the specified source image
0N/A * @param index the index into the <code>sources</code>
0N/A * <code>Vector</code> at which to
0N/A * insert the specified <code>source</code>
0N/A * @return a new <code>ParameterBlock</code> that contains the
0N/A * specified <code>source</code> at the specified
0N/A * <code>index</code>.
0N/A * @see #getSource(int)
0N/A */
0N/A public ParameterBlock setSource(Object source, int index) {
0N/A int oldSize = sources.size();
0N/A int newSize = index + 1;
0N/A if (oldSize < newSize) {
0N/A sources.setSize(newSize);
0N/A }
0N/A sources.setElementAt(source, index);
0N/A return this;
0N/A }
0N/A
0N/A /**
0N/A * Returns a source as a <code>RenderedImage</code>. This method is
0N/A * a convenience method.
0N/A * An exception will be thrown if the source is not a RenderedImage.
0N/A *
0N/A * @param index the index of the source to be returned
0N/A * @return a <code>RenderedImage</code> that represents the source
0N/A * image that is at the specified index in the
0N/A * <code>sources</code> <code>Vector</code>.
0N/A */
0N/A public RenderedImage getRenderedSource(int index) {
0N/A return (RenderedImage) sources.elementAt(index);
0N/A }
0N/A
0N/A /**
0N/A * Returns a source as a RenderableImage. This method is a
0N/A * convenience method.
0N/A * An exception will be thrown if the sources is not a RenderableImage.
0N/A *
0N/A * @param index the index of the source to be returned
0N/A * @return a <code>RenderableImage</code> that represents the source
0N/A * image that is at the specified index in the
0N/A * <code>sources</code> <code>Vector</code>.
0N/A */
0N/A public RenderableImage getRenderableSource(int index) {
0N/A return (RenderableImage) sources.elementAt(index);
0N/A }
0N/A
0N/A /**
0N/A * Returns the number of source images.
0N/A * @return the number of source images in the <code>sources</code>
0N/A * <code>Vector</code>.
0N/A */
0N/A public int getNumSources() {
0N/A return sources.size();
0N/A }
0N/A
0N/A /**
0N/A * Returns the entire Vector of sources.
0N/A * @return the <code>sources</code> <code>Vector</code>.
0N/A * @see #setSources(Vector)
0N/A */
0N/A public Vector<Object> getSources() {
0N/A return sources;
0N/A }
0N/A
0N/A /**
0N/A * Sets the entire Vector of sources to a given Vector.
0N/A * @param sources the <code>Vector</code> of source images
0N/A * @see #getSources
0N/A */
0N/A public void setSources(Vector<Object> sources) {
0N/A this.sources = sources;
0N/A }
0N/A
0N/A /** Clears the list of source images. */
0N/A public void removeSources() {
0N/A sources = new Vector();
0N/A }
0N/A
0N/A /**
0N/A * Returns the number of parameters (not including source images).
0N/A * @return the number of parameters in the <code>parameters</code>
0N/A * <code>Vector</code>.
0N/A */
0N/A public int getNumParameters() {
0N/A return parameters.size();
0N/A }
0N/A
0N/A /**
0N/A * Returns the entire Vector of parameters.
0N/A * @return the <code>parameters</code> <code>Vector</code>.
0N/A * @see #setParameters(Vector)
0N/A */
0N/A public Vector<Object> getParameters() {
0N/A return parameters;
0N/A }
0N/A
0N/A /**
0N/A * Sets the entire Vector of parameters to a given Vector.
0N/A * @param parameters the specified <code>Vector</code> of
0N/A * parameters
0N/A * @see #getParameters
0N/A */
0N/A public void setParameters(Vector<Object> parameters) {
0N/A this.parameters = parameters;
0N/A }
0N/A
0N/A /** Clears the list of parameters. */
0N/A public void removeParameters() {
0N/A parameters = new Vector();
0N/A }
0N/A
0N/A /**
0N/A * Adds an object to the list of parameters.
0N/A * @param obj the <code>Object</code> to add to the
0N/A * <code>parameters</code> <code>Vector</code>
0N/A * @return a new <code>ParameterBlock</code> containing
0N/A * the specified parameter.
0N/A */
0N/A public ParameterBlock add(Object obj) {
0N/A parameters.addElement(obj);
0N/A return this;
0N/A }
0N/A
0N/A /**
0N/A * Adds a Byte to the list of parameters.
0N/A * @param b the byte to add to the
0N/A * <code>parameters</code> <code>Vector</code>
0N/A * @return a new <code>ParameterBlock</code> containing
0N/A * the specified parameter.
0N/A */
0N/A public ParameterBlock add(byte b) {
0N/A return add(new Byte(b));
0N/A }
0N/A
0N/A /**
0N/A * Adds a Character to the list of parameters.
0N/A * @param c the char to add to the
0N/A * <code>parameters</code> <code>Vector</code>
0N/A * @return a new <code>ParameterBlock</code> containing
0N/A * the specified parameter.
0N/A */
0N/A public ParameterBlock add(char c) {
0N/A return add(new Character(c));
0N/A }
0N/A
0N/A /**
0N/A * Adds a Short to the list of parameters.
0N/A * @param s the short to add to the
0N/A * <code>parameters</code> <code>Vector</code>
0N/A * @return a new <code>ParameterBlock</code> containing
0N/A * the specified parameter.
0N/A */
0N/A public ParameterBlock add(short s) {
0N/A return add(new Short(s));
0N/A }
0N/A
0N/A /**
0N/A * Adds a Integer to the list of parameters.
0N/A * @param i the int to add to the
0N/A * <code>parameters</code> <code>Vector</code>
0N/A * @return a new <code>ParameterBlock</code> containing
0N/A * the specified parameter.
0N/A */
0N/A public ParameterBlock add(int i) {
0N/A return add(new Integer(i));
0N/A }
0N/A
0N/A /**
0N/A * Adds a Long to the list of parameters.
0N/A * @param l the long to add to the
0N/A * <code>parameters</code> <code>Vector</code>
0N/A * @return a new <code>ParameterBlock</code> containing
0N/A * the specified parameter.
0N/A */
0N/A public ParameterBlock add(long l) {
0N/A return add(new Long(l));
0N/A }
0N/A
0N/A /**
0N/A * Adds a Float to the list of parameters.
0N/A * @param f the float to add to the
0N/A * <code>parameters</code> <code>Vector</code>
0N/A * @return a new <code>ParameterBlock</code> containing
0N/A * the specified parameter.
0N/A */
0N/A public ParameterBlock add(float f) {
0N/A return add(new Float(f));
0N/A }
0N/A
0N/A /**
0N/A * Adds a Double to the list of parameters.
0N/A * @param d the double to add to the
0N/A * <code>parameters</code> <code>Vector</code>
0N/A * @return a new <code>ParameterBlock</code> containing
0N/A * the specified parameter.
0N/A */
0N/A public ParameterBlock add(double d) {
0N/A return add(new Double(d));
0N/A }
0N/A
0N/A /**
0N/A * Replaces an Object in the list of parameters.
0N/A * If the index lies beyond the current source list,
0N/A * the list is extended with nulls as needed.
0N/A * @param obj the parameter that replaces the
0N/A * parameter at the specified index in the
0N/A * <code>parameters</code> <code>Vector</code>
0N/A * @param index the index of the parameter to be
0N/A * replaced with the specified parameter
0N/A * @return a new <code>ParameterBlock</code> containing
0N/A * the specified parameter.
0N/A */
0N/A public ParameterBlock set(Object obj, int index) {
0N/A int oldSize = parameters.size();
0N/A int newSize = index + 1;
0N/A if (oldSize < newSize) {
0N/A parameters.setSize(newSize);
0N/A }
0N/A parameters.setElementAt(obj, index);
0N/A return this;
0N/A }
0N/A
0N/A /**
0N/A * Replaces an Object in the list of parameters with a Byte.
0N/A * If the index lies beyond the current source list,
0N/A * the list is extended with nulls as needed.
0N/A * @param b the parameter that replaces the
0N/A * parameter at the specified index in the
0N/A * <code>parameters</code> <code>Vector</code>
0N/A * @param index the index of the parameter to be
0N/A * replaced with the specified parameter
0N/A * @return a new <code>ParameterBlock</code> containing
0N/A * the specified parameter.
0N/A */
0N/A public ParameterBlock set(byte b, int index) {
0N/A return set(new Byte(b), index);
0N/A }
0N/A
0N/A /**
0N/A * Replaces an Object in the list of parameters with a Character.
0N/A * If the index lies beyond the current source list,
0N/A * the list is extended with nulls as needed.
0N/A * @param c the parameter that replaces the
0N/A * parameter at the specified index in the
0N/A * <code>parameters</code> <code>Vector</code>
0N/A * @param index the index of the parameter to be
0N/A * replaced with the specified parameter
0N/A * @return a new <code>ParameterBlock</code> containing
0N/A * the specified parameter.
0N/A */
0N/A public ParameterBlock set(char c, int index) {
0N/A return set(new Character(c), index);
0N/A }
0N/A
0N/A /**
0N/A * Replaces an Object in the list of parameters with a Short.
0N/A * If the index lies beyond the current source list,
0N/A * the list is extended with nulls as needed.
0N/A * @param s the parameter that replaces the
0N/A * parameter at the specified index in the
0N/A * <code>parameters</code> <code>Vector</code>
0N/A * @param index the index of the parameter to be
0N/A * replaced with the specified parameter
0N/A * @return a new <code>ParameterBlock</code> containing
0N/A * the specified parameter.
0N/A */
0N/A public ParameterBlock set(short s, int index) {
0N/A return set(new Short(s), index);
0N/A }
0N/A
0N/A /**
0N/A * Replaces an Object in the list of parameters with an Integer.
0N/A * If the index lies beyond the current source list,
0N/A * the list is extended with nulls as needed.
0N/A * @param i the parameter that replaces the
0N/A * parameter at the specified index in the
0N/A * <code>parameters</code> <code>Vector</code>
0N/A * @param index the index of the parameter to be
0N/A * replaced with the specified parameter
0N/A * @return a new <code>ParameterBlock</code> containing
0N/A * the specified parameter.
0N/A */
0N/A public ParameterBlock set(int i, int index) {
0N/A return set(new Integer(i), index);
0N/A }
0N/A
0N/A /**
0N/A * Replaces an Object in the list of parameters with a Long.
0N/A * If the index lies beyond the current source list,
0N/A * the list is extended with nulls as needed.
0N/A * @param l the parameter that replaces the
0N/A * parameter at the specified index in the
0N/A * <code>parameters</code> <code>Vector</code>
0N/A * @param index the index of the parameter to be
0N/A * replaced with the specified parameter
0N/A * @return a new <code>ParameterBlock</code> containing
0N/A * the specified parameter.
0N/A */
0N/A public ParameterBlock set(long l, int index) {
0N/A return set(new Long(l), index);
0N/A }
0N/A
0N/A /**
0N/A * Replaces an Object in the list of parameters with a Float.
0N/A * If the index lies beyond the current source list,
0N/A * the list is extended with nulls as needed.
0N/A * @param f the parameter that replaces the
0N/A * parameter at the specified index in the
0N/A * <code>parameters</code> <code>Vector</code>
0N/A * @param index the index of the parameter to be
0N/A * replaced with the specified parameter
0N/A * @return a new <code>ParameterBlock</code> containing
0N/A * the specified parameter.
0N/A */
0N/A public ParameterBlock set(float f, int index) {
0N/A return set(new Float(f), index);
0N/A }
0N/A
0N/A /**
0N/A * Replaces an Object in the list of parameters with a Double.
0N/A * If the index lies beyond the current source list,
0N/A * the list is extended with nulls as needed.
0N/A * @param d the parameter that replaces the
0N/A * parameter at the specified index in the
0N/A * <code>parameters</code> <code>Vector</code>
0N/A * @param index the index of the parameter to be
0N/A * replaced with the specified parameter
0N/A * @return a new <code>ParameterBlock</code> containing
0N/A * the specified parameter.
0N/A */
0N/A public ParameterBlock set(double d, int index) {
0N/A return set(new Double(d), index);
0N/A }
0N/A
0N/A /**
0N/A * Gets a parameter as an object.
0N/A * @param index the index of the parameter to get
0N/A * @return an <code>Object</code> representing the
0N/A * the parameter at the specified index
0N/A * into the <code>parameters</code>
0N/A * <code>Vector</code>.
0N/A */
0N/A public Object getObjectParameter(int index) {
0N/A return parameters.elementAt(index);
0N/A }
0N/A
0N/A /**
0N/A * A convenience method to return a parameter as a byte. An
0N/A * exception is thrown if the parameter is
0N/A * <code>null</code> or not a <code>Byte</code>.
0N/A *
0N/A * @param index the index of the parameter to be returned.
0N/A * @return the parameter at the specified index
0N/A * as a <code>byte</code> value.
0N/A * @throws ClassCastException if the parameter at the
0N/A * specified index is not a <code>Byte</code>
0N/A * @throws NullPointerException if the parameter at the specified
0N/A * index is <code>null</code>
0N/A * @throws ArrayIndexOutOfBoundsException if <code>index</code>
0N/A * is negative or not less than the current size of this
0N/A * <code>ParameterBlock</code> object
0N/A */
0N/A public byte getByteParameter(int index) {
0N/A return ((Byte)parameters.elementAt(index)).byteValue();
0N/A }
0N/A
0N/A /**
0N/A * A convenience method to return a parameter as a char. An
0N/A * exception is thrown if the parameter is
0N/A * <code>null</code> or not a <code>Character</code>.
0N/A *
0N/A * @param index the index of the parameter to be returned.
0N/A * @return the parameter at the specified index
0N/A * as a <code>char</code> value.
0N/A * @throws ClassCastException if the parameter at the
0N/A * specified index is not a <code>Character</code>
0N/A * @throws NullPointerException if the parameter at the specified
0N/A * index is <code>null</code>
0N/A * @throws ArrayIndexOutOfBoundsException if <code>index</code>
0N/A * is negative or not less than the current size of this
0N/A * <code>ParameterBlock</code> object
0N/A */
0N/A public char getCharParameter(int index) {
0N/A return ((Character)parameters.elementAt(index)).charValue();
0N/A }
0N/A
0N/A /**
0N/A * A convenience method to return a parameter as a short. An
0N/A * exception is thrown if the parameter is
0N/A * <code>null</code> or not a <code>Short</code>.
0N/A *
0N/A * @param index the index of the parameter to be returned.
0N/A * @return the parameter at the specified index
0N/A * as a <code>short</code> value.
0N/A * @throws ClassCastException if the parameter at the
0N/A * specified index is not a <code>Short</code>
0N/A * @throws NullPointerException if the parameter at the specified
0N/A * index is <code>null</code>
0N/A * @throws ArrayIndexOutOfBoundsException if <code>index</code>
0N/A * is negative or not less than the current size of this
0N/A * <code>ParameterBlock</code> object
0N/A */
0N/A public short getShortParameter(int index) {
0N/A return ((Short)parameters.elementAt(index)).shortValue();
0N/A }
0N/A
0N/A /**
0N/A * A convenience method to return a parameter as an int. An
0N/A * exception is thrown if the parameter is
0N/A * <code>null</code> or not an <code>Integer</code>.
0N/A *
0N/A * @param index the index of the parameter to be returned.
0N/A * @return the parameter at the specified index
0N/A * as a <code>int</code> value.
0N/A * @throws ClassCastException if the parameter at the
0N/A * specified index is not a <code>Integer</code>
0N/A * @throws NullPointerException if the parameter at the specified
0N/A * index is <code>null</code>
0N/A * @throws ArrayIndexOutOfBoundsException if <code>index</code>
0N/A * is negative or not less than the current size of this
0N/A * <code>ParameterBlock</code> object
0N/A */
0N/A public int getIntParameter(int index) {
0N/A return ((Integer)parameters.elementAt(index)).intValue();
0N/A }
0N/A
0N/A /**
0N/A * A convenience method to return a parameter as a long. An
0N/A * exception is thrown if the parameter is
0N/A * <code>null</code> or not a <code>Long</code>.
0N/A *
0N/A * @param index the index of the parameter to be returned.
0N/A * @return the parameter at the specified index
0N/A * as a <code>long</code> value.
0N/A * @throws ClassCastException if the parameter at the
0N/A * specified index is not a <code>Long</code>
0N/A * @throws NullPointerException if the parameter at the specified
0N/A * index is <code>null</code>
0N/A * @throws ArrayIndexOutOfBoundsException if <code>index</code>
0N/A * is negative or not less than the current size of this
0N/A * <code>ParameterBlock</code> object
0N/A */
0N/A public long getLongParameter(int index) {
0N/A return ((Long)parameters.elementAt(index)).longValue();
0N/A }
0N/A
0N/A /**
0N/A * A convenience method to return a parameter as a float. An
0N/A * exception is thrown if the parameter is
0N/A * <code>null</code> or not a <code>Float</code>.
0N/A *
0N/A * @param index the index of the parameter to be returned.
0N/A * @return the parameter at the specified index
0N/A * as a <code>float</code> value.
0N/A * @throws ClassCastException if the parameter at the
0N/A * specified index is not a <code>Float</code>
0N/A * @throws NullPointerException if the parameter at the specified
0N/A * index is <code>null</code>
0N/A * @throws ArrayIndexOutOfBoundsException if <code>index</code>
0N/A * is negative or not less than the current size of this
0N/A * <code>ParameterBlock</code> object
0N/A */
0N/A public float getFloatParameter(int index) {
0N/A return ((Float)parameters.elementAt(index)).floatValue();
0N/A }
0N/A
0N/A /**
0N/A * A convenience method to return a parameter as a double. An
0N/A * exception is thrown if the parameter is
0N/A * <code>null</code> or not a <code>Double</code>.
0N/A *
0N/A * @param index the index of the parameter to be returned.
0N/A * @return the parameter at the specified index
0N/A * as a <code>double</code> value.
0N/A * @throws ClassCastException if the parameter at the
0N/A * specified index is not a <code>Double</code>
0N/A * @throws NullPointerException if the parameter at the specified
0N/A * index is <code>null</code>
0N/A * @throws ArrayIndexOutOfBoundsException if <code>index</code>
0N/A * is negative or not less than the current size of this
0N/A * <code>ParameterBlock</code> object
0N/A */
0N/A public double getDoubleParameter(int index) {
0N/A return ((Double)parameters.elementAt(index)).doubleValue();
0N/A }
0N/A
0N/A /**
0N/A * Returns an array of Class objects describing the types
0N/A * of the parameters.
0N/A * @return an array of <code>Class</code> objects.
0N/A */
0N/A public Class [] getParamClasses() {
0N/A int numParams = getNumParameters();
0N/A Class [] classes = new Class[numParams];
0N/A int i;
0N/A
0N/A for (i = 0; i < numParams; i++) {
0N/A Object obj = getObjectParameter(i);
0N/A if (obj instanceof Byte) {
0N/A classes[i] = byte.class;
0N/A } else if (obj instanceof Character) {
0N/A classes[i] = char.class;
0N/A } else if (obj instanceof Short) {
0N/A classes[i] = short.class;
0N/A } else if (obj instanceof Integer) {
0N/A classes[i] = int.class;
0N/A } else if (obj instanceof Long) {
0N/A classes[i] = long.class;
0N/A } else if (obj instanceof Float) {
0N/A classes[i] = float.class;
0N/A } else if (obj instanceof Double) {
0N/A classes[i] = double.class;
0N/A } else {
0N/A classes[i] = obj.getClass();
0N/A }
0N/A }
0N/A
0N/A return classes;
0N/A }
0N/A}