jdk/src/share/classes/java/awt/image/renderable/ParameterBlock.java
author prappo
Tue, 01 Jul 2014 14:44:37 +0100
changeset 25187 08aff438def8
parent 25186 63e1a2ec30f5
child 25777 bb88947b6766
permissions -rw-r--r--
8048874: Replace uses of 'new Byte', 'new Short' and 'new Character' with appropriate alternative across core classes Reviewed-by: chegar, psandoz, prappo Contributed-by: Otavio Santana <otaviojava@java.net>
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     1
/*
22656
b8ee81ac6fb3 8033526: Fix serial lint warnings in java.awt.*
darcy
parents: 5506
diff changeset
     2
 * Copyright (c) 1998, 2014, Oracle and/or its affiliates. All rights reserved.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
90ce3da70b43 Initial load
duke
parents:
diff changeset
     4
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
90ce3da70b43 Initial load
duke
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
     7
 * published by the Free Software Foundation.  Oracle designates this
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     8
 * particular file as subject to the "Classpath" exception as provided
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
     9
 * by Oracle in the LICENSE file that accompanied this code.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    10
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    11
 * This code is distributed in the hope that it will be useful, but WITHOUT
90ce3da70b43 Initial load
duke
parents:
diff changeset
    12
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
90ce3da70b43 Initial load
duke
parents:
diff changeset
    13
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
90ce3da70b43 Initial load
duke
parents:
diff changeset
    14
 * version 2 for more details (a copy is included in the LICENSE file that
90ce3da70b43 Initial load
duke
parents:
diff changeset
    15
 * accompanied this code).
90ce3da70b43 Initial load
duke
parents:
diff changeset
    16
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    17
 * You should have received a copy of the GNU General Public License version
90ce3da70b43 Initial load
duke
parents:
diff changeset
    18
 * 2 along with this work; if not, write to the Free Software Foundation,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    19
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    20
 *
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
    21
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
    22
 * or visit www.oracle.com if you need additional information or have any
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
    23
 * questions.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    24
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    25
90ce3da70b43 Initial load
duke
parents:
diff changeset
    26
package java.awt.image.renderable;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    27
import java.awt.image.RenderedImage;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    28
import java.io.Serializable;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    29
import java.util.Vector;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    30
90ce3da70b43 Initial load
duke
parents:
diff changeset
    31
/**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    32
 * A <code>ParameterBlock</code> encapsulates all the information about sources and
90ce3da70b43 Initial load
duke
parents:
diff changeset
    33
 * parameters (Objects) required by a RenderableImageOp, or other
90ce3da70b43 Initial load
duke
parents:
diff changeset
    34
 * classes that process images.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    35
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    36
 * <p> Although it is possible to place arbitrary objects in the
90ce3da70b43 Initial load
duke
parents:
diff changeset
    37
 * source Vector, users of this class may impose semantic constraints
90ce3da70b43 Initial load
duke
parents:
diff changeset
    38
 * such as requiring all sources to be RenderedImages or
90ce3da70b43 Initial load
duke
parents:
diff changeset
    39
 * RenderableImage.  <code>ParameterBlock</code> itself is merely a container and
90ce3da70b43 Initial load
duke
parents:
diff changeset
    40
 * performs no checking on source or parameter types.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    41
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    42
 * <p> All parameters in a <code>ParameterBlock</code> are objects; convenience
90ce3da70b43 Initial load
duke
parents:
diff changeset
    43
 * add and set methods are available that take arguments of base type and
90ce3da70b43 Initial load
duke
parents:
diff changeset
    44
 * construct the appropriate subclass of Number (such as
90ce3da70b43 Initial load
duke
parents:
diff changeset
    45
 * Integer or Float).  Corresponding get methods perform a
90ce3da70b43 Initial load
duke
parents:
diff changeset
    46
 * downward cast and have return values of base type; an exception
90ce3da70b43 Initial load
duke
parents:
diff changeset
    47
 * will be thrown if the stored values do not have the correct type.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    48
 * There is no way to distinguish between the results of
90ce3da70b43 Initial load
duke
parents:
diff changeset
    49
 * "short s; add(s)" and "add(new Short(s))".
90ce3da70b43 Initial load
duke
parents:
diff changeset
    50
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    51
 * <p> Note that the get and set methods operate on references.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    52
 * Therefore, one must be careful not to share references between
90ce3da70b43 Initial load
duke
parents:
diff changeset
    53
 * <code>ParameterBlock</code>s when this is inappropriate.  For example, to create
90ce3da70b43 Initial load
duke
parents:
diff changeset
    54
 * a new <code>ParameterBlock</code> that is equal to an old one except for an
90ce3da70b43 Initial load
duke
parents:
diff changeset
    55
 * added source, one might be tempted to write:
90ce3da70b43 Initial load
duke
parents:
diff changeset
    56
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    57
 * <pre>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    58
 * ParameterBlock addSource(ParameterBlock pb, RenderableImage im) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    59
 *     ParameterBlock pb1 = new ParameterBlock(pb.getSources());
90ce3da70b43 Initial load
duke
parents:
diff changeset
    60
 *     pb1.addSource(im);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    61
 *     return pb1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    62
 * }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    63
 * </pre>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    64
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    65
 * <p> This code will have the side effect of altering the original
90ce3da70b43 Initial load
duke
parents:
diff changeset
    66
 * <code>ParameterBlock</code>, since the getSources operation returned a reference
90ce3da70b43 Initial load
duke
parents:
diff changeset
    67
 * to its source Vector.  Both pb and pb1 share their source Vector,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    68
 * and a change in either is visible to both.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    69
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    70
 * <p> A correct way to write the addSource function is to clone
90ce3da70b43 Initial load
duke
parents:
diff changeset
    71
 * the source Vector:
90ce3da70b43 Initial load
duke
parents:
diff changeset
    72
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    73
 * <pre>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    74
 * ParameterBlock addSource (ParameterBlock pb, RenderableImage im) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    75
 *     ParameterBlock pb1 = new ParameterBlock(pb.getSources().clone());
90ce3da70b43 Initial load
duke
parents:
diff changeset
    76
 *     pb1.addSource(im);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    77
 *     return pb1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    78
 * }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    79
 * </pre>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    80
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    81
 * <p> The clone method of <code>ParameterBlock</code> has been defined to
90ce3da70b43 Initial load
duke
parents:
diff changeset
    82
 * perform a clone of both the source and parameter Vectors for
90ce3da70b43 Initial load
duke
parents:
diff changeset
    83
 * this reason.  A standard, shallow clone is available as
90ce3da70b43 Initial load
duke
parents:
diff changeset
    84
 * shallowClone.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    85
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    86
 * <p> The addSource, setSource, add, and set methods are
90ce3da70b43 Initial load
duke
parents:
diff changeset
    87
 * defined to return 'this' after adding their argument.  This allows
90ce3da70b43 Initial load
duke
parents:
diff changeset
    88
 * use of syntax like:
90ce3da70b43 Initial load
duke
parents:
diff changeset
    89
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    90
 * <pre>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    91
 * ParameterBlock pb = new ParameterBlock();
90ce3da70b43 Initial load
duke
parents:
diff changeset
    92
 * op = new RenderableImageOp("operation", pb.add(arg1).add(arg2));
90ce3da70b43 Initial load
duke
parents:
diff changeset
    93
 * </pre>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    94
 * */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    95
public class ParameterBlock implements Cloneable, Serializable {
22656
b8ee81ac6fb3 8033526: Fix serial lint warnings in java.awt.*
darcy
parents: 5506
diff changeset
    96
    private static final long serialVersionUID = -7577115551785240750L;
b8ee81ac6fb3 8033526: Fix serial lint warnings in java.awt.*
darcy
parents: 5506
diff changeset
    97
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    98
    /** A Vector of sources, stored as arbitrary Objects. */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    99
    protected Vector<Object> sources = new Vector<Object>();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   100
90ce3da70b43 Initial load
duke
parents:
diff changeset
   101
    /** A Vector of non-source parameters, stored as arbitrary Objects. */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   102
    protected Vector<Object> parameters = new Vector<Object>();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   103
90ce3da70b43 Initial load
duke
parents:
diff changeset
   104
    /** A dummy constructor. */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   105
    public ParameterBlock() {}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   106
90ce3da70b43 Initial load
duke
parents:
diff changeset
   107
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   108
     * Constructs a <code>ParameterBlock</code> with a given Vector
90ce3da70b43 Initial load
duke
parents:
diff changeset
   109
     * of sources.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   110
     * @param sources a <code>Vector</code> of source images
90ce3da70b43 Initial load
duke
parents:
diff changeset
   111
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   112
    public ParameterBlock(Vector<Object> sources) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   113
        setSources(sources);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   114
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   115
90ce3da70b43 Initial load
duke
parents:
diff changeset
   116
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   117
     * Constructs a <code>ParameterBlock</code> with a given Vector of sources and
90ce3da70b43 Initial load
duke
parents:
diff changeset
   118
     * Vector of parameters.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   119
     * @param sources a <code>Vector</code> of source images
90ce3da70b43 Initial load
duke
parents:
diff changeset
   120
     * @param parameters a <code>Vector</code> of parameters to be used in the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   121
     *        rendering operation
90ce3da70b43 Initial load
duke
parents:
diff changeset
   122
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   123
    public ParameterBlock(Vector<Object> sources,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   124
                          Vector<Object> parameters)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   125
    {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   126
        setSources(sources);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   127
        setParameters(parameters);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   128
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   129
90ce3da70b43 Initial load
duke
parents:
diff changeset
   130
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   131
     * Creates a shallow copy of a <code>ParameterBlock</code>.  The source and
90ce3da70b43 Initial load
duke
parents:
diff changeset
   132
     * parameter Vectors are copied by reference -- additions or
90ce3da70b43 Initial load
duke
parents:
diff changeset
   133
     * changes will be visible to both versions.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   134
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   135
     * @return an Object clone of the <code>ParameterBlock</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   136
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   137
    public Object shallowClone() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   138
        try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   139
            return super.clone();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   140
        } catch (Exception e) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   141
            // We can't be here since we implement Cloneable.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   142
            return null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   143
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   144
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   145
90ce3da70b43 Initial load
duke
parents:
diff changeset
   146
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   147
     * Creates a copy of a <code>ParameterBlock</code>.  The source and parameter
90ce3da70b43 Initial load
duke
parents:
diff changeset
   148
     * Vectors are cloned, but the actual sources and parameters are
90ce3da70b43 Initial load
duke
parents:
diff changeset
   149
     * copied by reference.  This allows modifications to the order
90ce3da70b43 Initial load
duke
parents:
diff changeset
   150
     * and number of sources and parameters in the clone to be invisible
90ce3da70b43 Initial load
duke
parents:
diff changeset
   151
     * to the original <code>ParameterBlock</code>.  Changes to the shared sources or
90ce3da70b43 Initial load
duke
parents:
diff changeset
   152
     * parameters themselves will still be visible.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   153
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   154
     * @return an Object clone of the <code>ParameterBlock</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   155
     */
24549
147a5c8b7793 8039109: Fix unchecked and raw lint warnings in java.awt
darcy
parents: 22656
diff changeset
   156
    @SuppressWarnings("unchecked") // casts from clone
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   157
    public Object clone() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   158
        ParameterBlock theClone;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   159
90ce3da70b43 Initial load
duke
parents:
diff changeset
   160
        try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   161
            theClone = (ParameterBlock) super.clone();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   162
        } catch (Exception e) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   163
            // We can't be here since we implement Cloneable.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   164
            return null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   165
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   166
90ce3da70b43 Initial load
duke
parents:
diff changeset
   167
        if (sources != null) {
24549
147a5c8b7793 8039109: Fix unchecked and raw lint warnings in java.awt
darcy
parents: 22656
diff changeset
   168
            theClone.setSources((Vector<Object>)sources.clone());
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   169
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   170
        if (parameters != null) {
24549
147a5c8b7793 8039109: Fix unchecked and raw lint warnings in java.awt
darcy
parents: 22656
diff changeset
   171
            theClone.setParameters((Vector<Object>)parameters.clone());
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   172
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   173
        return (Object) theClone;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   174
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   175
90ce3da70b43 Initial load
duke
parents:
diff changeset
   176
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   177
     * Adds an image to end of the list of sources.  The image is
90ce3da70b43 Initial load
duke
parents:
diff changeset
   178
     * stored as an object in order to allow new node types in the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   179
     * future.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   180
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   181
     * @param source an image object to be stored in the source list.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   182
     * @return a new <code>ParameterBlock</code> containing the specified
90ce3da70b43 Initial load
duke
parents:
diff changeset
   183
     *         <code>source</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   184
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   185
    public ParameterBlock addSource(Object source) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   186
        sources.addElement(source);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   187
        return this;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   188
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   189
90ce3da70b43 Initial load
duke
parents:
diff changeset
   190
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   191
     * Returns a source as a general Object.  The caller must cast it into
90ce3da70b43 Initial load
duke
parents:
diff changeset
   192
     * an appropriate type.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   193
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   194
     * @param index the index of the source to be returned.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   195
     * @return an <code>Object</code> that represents the source located
90ce3da70b43 Initial load
duke
parents:
diff changeset
   196
     *         at the specified index in the <code>sources</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   197
     *         <code>Vector</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   198
     * @see #setSource(Object, int)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   199
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   200
    public Object getSource(int index) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   201
        return sources.elementAt(index);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   202
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   203
90ce3da70b43 Initial load
duke
parents:
diff changeset
   204
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   205
     * Replaces an entry in the list of source with a new source.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   206
     * If the index lies beyond the current source list,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   207
     * the list is extended with nulls as needed.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   208
     * @param source the specified source image
90ce3da70b43 Initial load
duke
parents:
diff changeset
   209
     * @param index the index into the <code>sources</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   210
     *              <code>Vector</code> at which to
90ce3da70b43 Initial load
duke
parents:
diff changeset
   211
     *              insert the specified <code>source</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   212
     * @return a new <code>ParameterBlock</code> that contains the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   213
     *         specified <code>source</code> at the specified
90ce3da70b43 Initial load
duke
parents:
diff changeset
   214
     *         <code>index</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   215
     * @see #getSource(int)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   216
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   217
    public ParameterBlock setSource(Object source, int index) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   218
        int oldSize = sources.size();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   219
        int newSize = index + 1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   220
        if (oldSize < newSize) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   221
            sources.setSize(newSize);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   222
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   223
        sources.setElementAt(source, index);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   224
        return this;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   225
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   226
90ce3da70b43 Initial load
duke
parents:
diff changeset
   227
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   228
     * Returns a source as a <code>RenderedImage</code>.  This method is
90ce3da70b43 Initial load
duke
parents:
diff changeset
   229
     * a convenience method.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   230
     * An exception will be thrown if the source is not a RenderedImage.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   231
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   232
     * @param index the index of the source to be returned
90ce3da70b43 Initial load
duke
parents:
diff changeset
   233
     * @return a <code>RenderedImage</code> that represents the source
90ce3da70b43 Initial load
duke
parents:
diff changeset
   234
     *         image that is at the specified index in the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   235
     *         <code>sources</code> <code>Vector</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   236
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   237
    public RenderedImage getRenderedSource(int index) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   238
        return (RenderedImage) sources.elementAt(index);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   239
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   240
90ce3da70b43 Initial load
duke
parents:
diff changeset
   241
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   242
     * Returns a source as a RenderableImage.  This method is a
90ce3da70b43 Initial load
duke
parents:
diff changeset
   243
     * convenience method.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   244
     * An exception will be thrown if the sources is not a RenderableImage.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   245
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   246
     * @param index the index of the source to be returned
90ce3da70b43 Initial load
duke
parents:
diff changeset
   247
     * @return a <code>RenderableImage</code> that represents the source
90ce3da70b43 Initial load
duke
parents:
diff changeset
   248
     *         image that is at the specified index in the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   249
     *         <code>sources</code> <code>Vector</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   250
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   251
    public RenderableImage getRenderableSource(int index) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   252
        return (RenderableImage) sources.elementAt(index);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   253
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   254
90ce3da70b43 Initial load
duke
parents:
diff changeset
   255
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   256
     * Returns the number of source images.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   257
     * @return the number of source images in the <code>sources</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   258
     *         <code>Vector</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   259
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   260
    public int getNumSources() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   261
        return sources.size();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   262
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   263
90ce3da70b43 Initial load
duke
parents:
diff changeset
   264
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   265
     * Returns the entire Vector of sources.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   266
     * @return the <code>sources</code> <code>Vector</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   267
     * @see #setSources(Vector)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   268
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   269
    public Vector<Object> getSources() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   270
        return sources;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   271
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   272
90ce3da70b43 Initial load
duke
parents:
diff changeset
   273
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   274
     * Sets the entire Vector of sources to a given Vector.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   275
     * @param sources the <code>Vector</code> of source images
90ce3da70b43 Initial load
duke
parents:
diff changeset
   276
     * @see #getSources
90ce3da70b43 Initial load
duke
parents:
diff changeset
   277
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   278
    public void setSources(Vector<Object> sources) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   279
        this.sources = sources;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   280
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   281
90ce3da70b43 Initial load
duke
parents:
diff changeset
   282
    /** Clears the list of source images. */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   283
    public void removeSources() {
24549
147a5c8b7793 8039109: Fix unchecked and raw lint warnings in java.awt
darcy
parents: 22656
diff changeset
   284
        sources = new Vector<>();
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   285
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   286
90ce3da70b43 Initial load
duke
parents:
diff changeset
   287
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   288
     * Returns the number of parameters (not including source images).
90ce3da70b43 Initial load
duke
parents:
diff changeset
   289
     * @return the number of parameters in the <code>parameters</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   290
     *         <code>Vector</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   291
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   292
    public int getNumParameters() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   293
        return parameters.size();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   294
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   295
90ce3da70b43 Initial load
duke
parents:
diff changeset
   296
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   297
     * Returns the entire Vector of parameters.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   298
     * @return the <code>parameters</code> <code>Vector</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   299
     * @see #setParameters(Vector)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   300
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   301
    public Vector<Object> getParameters() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   302
        return parameters;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   303
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   304
90ce3da70b43 Initial load
duke
parents:
diff changeset
   305
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   306
     * Sets the entire Vector of parameters to a given Vector.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   307
     * @param parameters the specified <code>Vector</code> of
90ce3da70b43 Initial load
duke
parents:
diff changeset
   308
     *        parameters
90ce3da70b43 Initial load
duke
parents:
diff changeset
   309
     * @see #getParameters
90ce3da70b43 Initial load
duke
parents:
diff changeset
   310
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   311
    public void setParameters(Vector<Object> parameters) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   312
        this.parameters = parameters;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   313
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   314
90ce3da70b43 Initial load
duke
parents:
diff changeset
   315
    /** Clears the list of parameters. */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   316
    public void removeParameters() {
24549
147a5c8b7793 8039109: Fix unchecked and raw lint warnings in java.awt
darcy
parents: 22656
diff changeset
   317
        parameters = new Vector<>();
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   318
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   319
90ce3da70b43 Initial load
duke
parents:
diff changeset
   320
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   321
     * Adds an object to the list of parameters.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   322
     * @param obj the <code>Object</code> to add to the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   323
     *            <code>parameters</code> <code>Vector</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   324
     * @return a new <code>ParameterBlock</code> containing
90ce3da70b43 Initial load
duke
parents:
diff changeset
   325
     *         the specified parameter.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   326
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   327
    public ParameterBlock add(Object obj) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   328
        parameters.addElement(obj);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   329
        return this;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   330
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   331
90ce3da70b43 Initial load
duke
parents:
diff changeset
   332
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   333
     * Adds a Byte to the list of parameters.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   334
     * @param b the byte to add to the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   335
     *            <code>parameters</code> <code>Vector</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   336
     * @return a new <code>ParameterBlock</code> containing
90ce3da70b43 Initial load
duke
parents:
diff changeset
   337
     *         the specified parameter.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   338
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   339
    public ParameterBlock add(byte b) {
25187
08aff438def8 8048874: Replace uses of 'new Byte', 'new Short' and 'new Character' with appropriate alternative across core classes
prappo
parents: 25186
diff changeset
   340
        return add(Byte.valueOf(b));
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   341
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   342
90ce3da70b43 Initial load
duke
parents:
diff changeset
   343
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   344
     * Adds a Character to the list of parameters.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   345
     * @param c the char to add to the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   346
     *            <code>parameters</code> <code>Vector</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   347
     * @return a new <code>ParameterBlock</code> containing
90ce3da70b43 Initial load
duke
parents:
diff changeset
   348
     *         the specified parameter.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   349
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   350
    public ParameterBlock add(char c) {
25187
08aff438def8 8048874: Replace uses of 'new Byte', 'new Short' and 'new Character' with appropriate alternative across core classes
prappo
parents: 25186
diff changeset
   351
        return add(Character.valueOf(c));
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   352
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   353
90ce3da70b43 Initial load
duke
parents:
diff changeset
   354
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   355
     * Adds a Short to the list of parameters.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   356
     * @param s the short to add to the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   357
     *            <code>parameters</code> <code>Vector</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   358
     * @return a new <code>ParameterBlock</code> containing
90ce3da70b43 Initial load
duke
parents:
diff changeset
   359
     *         the specified parameter.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   360
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   361
    public ParameterBlock add(short s) {
25187
08aff438def8 8048874: Replace uses of 'new Byte', 'new Short' and 'new Character' with appropriate alternative across core classes
prappo
parents: 25186
diff changeset
   362
        return add(Short.valueOf(s));
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   363
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   364
90ce3da70b43 Initial load
duke
parents:
diff changeset
   365
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   366
     * Adds a Integer to the list of parameters.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   367
     * @param i the int to add to the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   368
     *            <code>parameters</code> <code>Vector</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   369
     * @return a new <code>ParameterBlock</code> containing
90ce3da70b43 Initial load
duke
parents:
diff changeset
   370
     *         the specified parameter.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   371
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   372
    public ParameterBlock add(int i) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   373
        return add(new Integer(i));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   374
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   375
90ce3da70b43 Initial load
duke
parents:
diff changeset
   376
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   377
     * Adds a Long to the list of parameters.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   378
     * @param l the long to add to the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   379
     *            <code>parameters</code> <code>Vector</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   380
     * @return a new <code>ParameterBlock</code> containing
90ce3da70b43 Initial load
duke
parents:
diff changeset
   381
     *         the specified parameter.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   382
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   383
    public ParameterBlock add(long l) {
25186
63e1a2ec30f5 8048267: Replace uses of 'new Long()' with appropriate alternative across core classes
prappo
parents: 24549
diff changeset
   384
        return add(Long.valueOf(l));
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   385
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   386
90ce3da70b43 Initial load
duke
parents:
diff changeset
   387
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   388
     * Adds a Float to the list of parameters.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   389
     * @param f the float to add to the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   390
     *            <code>parameters</code> <code>Vector</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   391
     * @return a new <code>ParameterBlock</code> containing
90ce3da70b43 Initial load
duke
parents:
diff changeset
   392
     *         the specified parameter.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   393
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   394
    public ParameterBlock add(float f) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   395
        return add(new Float(f));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   396
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   397
90ce3da70b43 Initial load
duke
parents:
diff changeset
   398
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   399
     * Adds a Double to the list of parameters.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   400
     * @param d the double to add to the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   401
     *            <code>parameters</code> <code>Vector</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   402
     * @return a new <code>ParameterBlock</code> containing
90ce3da70b43 Initial load
duke
parents:
diff changeset
   403
     *         the specified parameter.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   404
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   405
    public ParameterBlock add(double d) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   406
        return add(new Double(d));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   407
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   408
90ce3da70b43 Initial load
duke
parents:
diff changeset
   409
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   410
     * Replaces an Object in the list of parameters.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   411
     * If the index lies beyond the current source list,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   412
     * the list is extended with nulls as needed.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   413
     * @param obj the parameter that replaces the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   414
     *        parameter at the specified index in the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   415
     *        <code>parameters</code> <code>Vector</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   416
     * @param index the index of the parameter to be
90ce3da70b43 Initial load
duke
parents:
diff changeset
   417
     *        replaced with the specified parameter
90ce3da70b43 Initial load
duke
parents:
diff changeset
   418
     * @return a new <code>ParameterBlock</code> containing
90ce3da70b43 Initial load
duke
parents:
diff changeset
   419
     *        the specified parameter.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   420
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   421
    public ParameterBlock set(Object obj, int index) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   422
        int oldSize = parameters.size();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   423
        int newSize = index + 1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   424
        if (oldSize < newSize) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   425
            parameters.setSize(newSize);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   426
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   427
        parameters.setElementAt(obj, index);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   428
        return this;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   429
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   430
90ce3da70b43 Initial load
duke
parents:
diff changeset
   431
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   432
     * Replaces an Object in the list of parameters with a Byte.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   433
     * If the index lies beyond the current source list,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   434
     * the list is extended with nulls as needed.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   435
     * @param b the parameter that replaces the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   436
     *        parameter at the specified index in the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   437
     *        <code>parameters</code> <code>Vector</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   438
     * @param index the index of the parameter to be
90ce3da70b43 Initial load
duke
parents:
diff changeset
   439
     *        replaced with the specified parameter
90ce3da70b43 Initial load
duke
parents:
diff changeset
   440
     * @return a new <code>ParameterBlock</code> containing
90ce3da70b43 Initial load
duke
parents:
diff changeset
   441
     *        the specified parameter.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   442
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   443
    public ParameterBlock set(byte b, int index) {
25187
08aff438def8 8048874: Replace uses of 'new Byte', 'new Short' and 'new Character' with appropriate alternative across core classes
prappo
parents: 25186
diff changeset
   444
        return set(Byte.valueOf(b), index);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   445
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   446
90ce3da70b43 Initial load
duke
parents:
diff changeset
   447
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   448
     * Replaces an Object in the list of parameters with a Character.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   449
     * If the index lies beyond the current source list,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   450
     * the list is extended with nulls as needed.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   451
     * @param c the parameter that replaces the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   452
     *        parameter at the specified index in the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   453
     *        <code>parameters</code> <code>Vector</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   454
     * @param index the index of the parameter to be
90ce3da70b43 Initial load
duke
parents:
diff changeset
   455
     *        replaced with the specified parameter
90ce3da70b43 Initial load
duke
parents:
diff changeset
   456
     * @return a new <code>ParameterBlock</code> containing
90ce3da70b43 Initial load
duke
parents:
diff changeset
   457
     *        the specified parameter.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   458
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   459
    public ParameterBlock set(char c, int index) {
25187
08aff438def8 8048874: Replace uses of 'new Byte', 'new Short' and 'new Character' with appropriate alternative across core classes
prappo
parents: 25186
diff changeset
   460
        return set(Character.valueOf(c), index);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   461
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   462
90ce3da70b43 Initial load
duke
parents:
diff changeset
   463
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   464
     * Replaces an Object in the list of parameters with a Short.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   465
     * If the index lies beyond the current source list,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   466
     * the list is extended with nulls as needed.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   467
     * @param s the parameter that replaces the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   468
     *        parameter at the specified index in the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   469
     *        <code>parameters</code> <code>Vector</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   470
     * @param index the index of the parameter to be
90ce3da70b43 Initial load
duke
parents:
diff changeset
   471
     *        replaced with the specified parameter
90ce3da70b43 Initial load
duke
parents:
diff changeset
   472
     * @return a new <code>ParameterBlock</code> containing
90ce3da70b43 Initial load
duke
parents:
diff changeset
   473
     *        the specified parameter.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   474
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   475
    public ParameterBlock set(short s, int index) {
25187
08aff438def8 8048874: Replace uses of 'new Byte', 'new Short' and 'new Character' with appropriate alternative across core classes
prappo
parents: 25186
diff changeset
   476
        return set(Short.valueOf(s), index);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   477
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   478
90ce3da70b43 Initial load
duke
parents:
diff changeset
   479
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   480
     * Replaces an Object in the list of parameters with an Integer.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   481
     * If the index lies beyond the current source list,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   482
     * the list is extended with nulls as needed.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   483
     * @param i the parameter that replaces the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   484
     *        parameter at the specified index in the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   485
     *        <code>parameters</code> <code>Vector</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   486
     * @param index the index of the parameter to be
90ce3da70b43 Initial load
duke
parents:
diff changeset
   487
     *        replaced with the specified parameter
90ce3da70b43 Initial load
duke
parents:
diff changeset
   488
     * @return a new <code>ParameterBlock</code> containing
90ce3da70b43 Initial load
duke
parents:
diff changeset
   489
     *        the specified parameter.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   490
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   491
    public ParameterBlock set(int i, int index) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   492
        return set(new Integer(i), index);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   493
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   494
90ce3da70b43 Initial load
duke
parents:
diff changeset
   495
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   496
     * Replaces an Object in the list of parameters with a Long.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   497
     * If the index lies beyond the current source list,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   498
     * the list is extended with nulls as needed.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   499
     * @param l the parameter that replaces the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   500
     *        parameter at the specified index in the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   501
     *        <code>parameters</code> <code>Vector</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   502
     * @param index the index of the parameter to be
90ce3da70b43 Initial load
duke
parents:
diff changeset
   503
     *        replaced with the specified parameter
90ce3da70b43 Initial load
duke
parents:
diff changeset
   504
     * @return a new <code>ParameterBlock</code> containing
90ce3da70b43 Initial load
duke
parents:
diff changeset
   505
     *        the specified parameter.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   506
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   507
    public ParameterBlock set(long l, int index) {
25186
63e1a2ec30f5 8048267: Replace uses of 'new Long()' with appropriate alternative across core classes
prappo
parents: 24549
diff changeset
   508
        return set(Long.valueOf(l), index);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   509
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   510
90ce3da70b43 Initial load
duke
parents:
diff changeset
   511
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   512
     * Replaces an Object in the list of parameters with a Float.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   513
     * If the index lies beyond the current source list,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   514
     * the list is extended with nulls as needed.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   515
     * @param f the parameter that replaces the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   516
     *        parameter at the specified index in the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   517
     *        <code>parameters</code> <code>Vector</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   518
     * @param index the index of the parameter to be
90ce3da70b43 Initial load
duke
parents:
diff changeset
   519
     *        replaced with the specified parameter
90ce3da70b43 Initial load
duke
parents:
diff changeset
   520
     * @return a new <code>ParameterBlock</code> containing
90ce3da70b43 Initial load
duke
parents:
diff changeset
   521
     *        the specified parameter.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   522
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   523
    public ParameterBlock set(float f, int index) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   524
        return set(new Float(f), index);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   525
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   526
90ce3da70b43 Initial load
duke
parents:
diff changeset
   527
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   528
     * Replaces an Object in the list of parameters with a Double.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   529
     * If the index lies beyond the current source list,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   530
     * the list is extended with nulls as needed.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   531
     * @param d the parameter that replaces the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   532
     *        parameter at the specified index in the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   533
     *        <code>parameters</code> <code>Vector</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   534
     * @param index the index of the parameter to be
90ce3da70b43 Initial load
duke
parents:
diff changeset
   535
     *        replaced with the specified parameter
90ce3da70b43 Initial load
duke
parents:
diff changeset
   536
     * @return a new <code>ParameterBlock</code> containing
90ce3da70b43 Initial load
duke
parents:
diff changeset
   537
     *        the specified parameter.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   538
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   539
    public ParameterBlock set(double d, int index) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   540
        return set(new Double(d), index);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   541
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   542
90ce3da70b43 Initial load
duke
parents:
diff changeset
   543
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   544
     * Gets a parameter as an object.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   545
     * @param index the index of the parameter to get
90ce3da70b43 Initial load
duke
parents:
diff changeset
   546
     * @return an <code>Object</code> representing the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   547
     *         the parameter at the specified index
90ce3da70b43 Initial load
duke
parents:
diff changeset
   548
     *         into the <code>parameters</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   549
     *         <code>Vector</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   550
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   551
    public Object getObjectParameter(int index) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   552
        return parameters.elementAt(index);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   553
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   554
90ce3da70b43 Initial load
duke
parents:
diff changeset
   555
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   556
     * A convenience method to return a parameter as a byte.  An
90ce3da70b43 Initial load
duke
parents:
diff changeset
   557
     * exception is thrown if the parameter is
90ce3da70b43 Initial load
duke
parents:
diff changeset
   558
     * <code>null</code> or not a <code>Byte</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   559
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   560
     * @param index the index of the parameter to be returned.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   561
     * @return the parameter at the specified index
90ce3da70b43 Initial load
duke
parents:
diff changeset
   562
     *         as a <code>byte</code> value.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   563
     * @throws ClassCastException if the parameter at the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   564
     *         specified index is not a <code>Byte</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   565
     * @throws NullPointerException if the parameter at the specified
90ce3da70b43 Initial load
duke
parents:
diff changeset
   566
     *         index is <code>null</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   567
     * @throws ArrayIndexOutOfBoundsException if <code>index</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   568
     *         is negative or not less than the current size of this
90ce3da70b43 Initial load
duke
parents:
diff changeset
   569
     *         <code>ParameterBlock</code> object
90ce3da70b43 Initial load
duke
parents:
diff changeset
   570
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   571
    public byte getByteParameter(int index) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   572
        return ((Byte)parameters.elementAt(index)).byteValue();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   573
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   574
90ce3da70b43 Initial load
duke
parents:
diff changeset
   575
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   576
     * A convenience method to return a parameter as a char.  An
90ce3da70b43 Initial load
duke
parents:
diff changeset
   577
     * exception is thrown if the parameter is
90ce3da70b43 Initial load
duke
parents:
diff changeset
   578
     * <code>null</code> or not a <code>Character</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   579
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   580
     * @param index the index of the parameter to be returned.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   581
     * @return the parameter at the specified index
90ce3da70b43 Initial load
duke
parents:
diff changeset
   582
     *         as a <code>char</code> value.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   583
     * @throws ClassCastException if the parameter at the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   584
     *         specified index is not a <code>Character</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   585
     * @throws NullPointerException if the parameter at the specified
90ce3da70b43 Initial load
duke
parents:
diff changeset
   586
     *         index is <code>null</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   587
     * @throws ArrayIndexOutOfBoundsException if <code>index</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   588
     *         is negative or not less than the current size of this
90ce3da70b43 Initial load
duke
parents:
diff changeset
   589
     *         <code>ParameterBlock</code> object
90ce3da70b43 Initial load
duke
parents:
diff changeset
   590
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   591
    public char getCharParameter(int index) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   592
        return ((Character)parameters.elementAt(index)).charValue();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   593
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   594
90ce3da70b43 Initial load
duke
parents:
diff changeset
   595
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   596
     * A convenience method to return a parameter as a short.  An
90ce3da70b43 Initial load
duke
parents:
diff changeset
   597
     * exception is thrown if the parameter is
90ce3da70b43 Initial load
duke
parents:
diff changeset
   598
     * <code>null</code> or not a <code>Short</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   599
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   600
     * @param index the index of the parameter to be returned.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   601
     * @return the parameter at the specified index
90ce3da70b43 Initial load
duke
parents:
diff changeset
   602
     *         as a <code>short</code> value.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   603
     * @throws ClassCastException if the parameter at the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   604
     *         specified index is not a <code>Short</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   605
     * @throws NullPointerException if the parameter at the specified
90ce3da70b43 Initial load
duke
parents:
diff changeset
   606
     *         index is <code>null</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   607
     * @throws ArrayIndexOutOfBoundsException if <code>index</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   608
     *         is negative or not less than the current size of this
90ce3da70b43 Initial load
duke
parents:
diff changeset
   609
     *         <code>ParameterBlock</code> object
90ce3da70b43 Initial load
duke
parents:
diff changeset
   610
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   611
    public short getShortParameter(int index) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   612
        return ((Short)parameters.elementAt(index)).shortValue();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   613
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   614
90ce3da70b43 Initial load
duke
parents:
diff changeset
   615
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   616
     * A convenience method to return a parameter as an int.  An
90ce3da70b43 Initial load
duke
parents:
diff changeset
   617
     * exception is thrown if the parameter is
90ce3da70b43 Initial load
duke
parents:
diff changeset
   618
     * <code>null</code> or not an <code>Integer</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   619
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   620
     * @param index the index of the parameter to be returned.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   621
     * @return the parameter at the specified index
90ce3da70b43 Initial load
duke
parents:
diff changeset
   622
     *         as a <code>int</code> value.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   623
     * @throws ClassCastException if the parameter at the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   624
     *         specified index is not a <code>Integer</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   625
     * @throws NullPointerException if the parameter at the specified
90ce3da70b43 Initial load
duke
parents:
diff changeset
   626
     *         index is <code>null</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   627
     * @throws ArrayIndexOutOfBoundsException if <code>index</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   628
     *         is negative or not less than the current size of this
90ce3da70b43 Initial load
duke
parents:
diff changeset
   629
     *         <code>ParameterBlock</code> object
90ce3da70b43 Initial load
duke
parents:
diff changeset
   630
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   631
    public int getIntParameter(int index) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   632
        return ((Integer)parameters.elementAt(index)).intValue();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   633
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   634
90ce3da70b43 Initial load
duke
parents:
diff changeset
   635
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   636
     * A convenience method to return a parameter as a long.  An
90ce3da70b43 Initial load
duke
parents:
diff changeset
   637
     * exception is thrown if the parameter is
90ce3da70b43 Initial load
duke
parents:
diff changeset
   638
     * <code>null</code> or not a <code>Long</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   639
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   640
     * @param index the index of the parameter to be returned.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   641
     * @return the parameter at the specified index
90ce3da70b43 Initial load
duke
parents:
diff changeset
   642
     *         as a <code>long</code> value.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   643
     * @throws ClassCastException if the parameter at the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   644
     *         specified index is not a <code>Long</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   645
     * @throws NullPointerException if the parameter at the specified
90ce3da70b43 Initial load
duke
parents:
diff changeset
   646
     *         index is <code>null</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   647
     * @throws ArrayIndexOutOfBoundsException if <code>index</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   648
     *         is negative or not less than the current size of this
90ce3da70b43 Initial load
duke
parents:
diff changeset
   649
     *         <code>ParameterBlock</code> object
90ce3da70b43 Initial load
duke
parents:
diff changeset
   650
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   651
    public long getLongParameter(int index) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   652
        return ((Long)parameters.elementAt(index)).longValue();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   653
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   654
90ce3da70b43 Initial load
duke
parents:
diff changeset
   655
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   656
     * A convenience method to return a parameter as a float.  An
90ce3da70b43 Initial load
duke
parents:
diff changeset
   657
     * exception is thrown if the parameter is
90ce3da70b43 Initial load
duke
parents:
diff changeset
   658
     * <code>null</code> or not a <code>Float</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   659
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   660
     * @param index the index of the parameter to be returned.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   661
     * @return the parameter at the specified index
90ce3da70b43 Initial load
duke
parents:
diff changeset
   662
     *         as a <code>float</code> value.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   663
     * @throws ClassCastException if the parameter at the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   664
     *         specified index is not a <code>Float</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   665
     * @throws NullPointerException if the parameter at the specified
90ce3da70b43 Initial load
duke
parents:
diff changeset
   666
     *         index is <code>null</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   667
     * @throws ArrayIndexOutOfBoundsException if <code>index</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   668
     *         is negative or not less than the current size of this
90ce3da70b43 Initial load
duke
parents:
diff changeset
   669
     *         <code>ParameterBlock</code> object
90ce3da70b43 Initial load
duke
parents:
diff changeset
   670
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   671
    public float getFloatParameter(int index) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   672
        return ((Float)parameters.elementAt(index)).floatValue();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   673
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   674
90ce3da70b43 Initial load
duke
parents:
diff changeset
   675
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   676
     * A convenience method to return a parameter as a double.  An
90ce3da70b43 Initial load
duke
parents:
diff changeset
   677
     * exception is thrown if the parameter is
90ce3da70b43 Initial load
duke
parents:
diff changeset
   678
     * <code>null</code> or not a <code>Double</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   679
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   680
     * @param index the index of the parameter to be returned.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   681
     * @return the parameter at the specified index
90ce3da70b43 Initial load
duke
parents:
diff changeset
   682
     *         as a <code>double</code> value.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   683
     * @throws ClassCastException if the parameter at the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   684
     *         specified index is not a <code>Double</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   685
     * @throws NullPointerException if the parameter at the specified
90ce3da70b43 Initial load
duke
parents:
diff changeset
   686
     *         index is <code>null</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   687
     * @throws ArrayIndexOutOfBoundsException if <code>index</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   688
     *         is negative or not less than the current size of this
90ce3da70b43 Initial load
duke
parents:
diff changeset
   689
     *         <code>ParameterBlock</code> object
90ce3da70b43 Initial load
duke
parents:
diff changeset
   690
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   691
    public double getDoubleParameter(int index) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   692
        return ((Double)parameters.elementAt(index)).doubleValue();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   693
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   694
90ce3da70b43 Initial load
duke
parents:
diff changeset
   695
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   696
     * Returns an array of Class objects describing the types
90ce3da70b43 Initial load
duke
parents:
diff changeset
   697
     * of the parameters.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   698
     * @return an array of <code>Class</code> objects.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   699
     */
24549
147a5c8b7793 8039109: Fix unchecked and raw lint warnings in java.awt
darcy
parents: 22656
diff changeset
   700
    public Class<?>[] getParamClasses() {
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   701
        int numParams = getNumParameters();
24549
147a5c8b7793 8039109: Fix unchecked and raw lint warnings in java.awt
darcy
parents: 22656
diff changeset
   702
        Class<?>[] classes = new Class<?>[numParams];
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   703
        int i;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   704
90ce3da70b43 Initial load
duke
parents:
diff changeset
   705
        for (i = 0; i < numParams; i++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   706
            Object obj = getObjectParameter(i);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   707
            if (obj instanceof Byte) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   708
              classes[i] = byte.class;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   709
            } else if (obj instanceof Character) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   710
              classes[i] = char.class;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   711
            } else if (obj instanceof Short) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   712
              classes[i] = short.class;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   713
            } else if (obj instanceof Integer) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   714
              classes[i] = int.class;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   715
            } else if (obj instanceof Long) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   716
              classes[i] = long.class;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   717
            } else if (obj instanceof Float) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   718
              classes[i] = float.class;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   719
            } else if (obj instanceof Double) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   720
              classes[i] = double.class;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   721
            } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   722
              classes[i] = obj.getClass();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   723
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   724
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   725
90ce3da70b43 Initial load
duke
parents:
diff changeset
   726
        return classes;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   727
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   728
}