public class ParameterBlock extends Object implements Cloneable, Serializable
ParameterBlock
は、RenderableImageOpや、イメージを処理するほかのクラスによって必要とされるソースおよびパラメータ(Object)についてのすべての情報をカプセル化します。
ソースVectorには任意のオブジェクトを配置できますが、このクラスのユーザーは、たとえば、すべてのソースはRenderedImagesまたはRenderableImageでなければならない、などのような意味制約を加えることもできます。 ParameterBlock
自体はコンテナにすぎないので、ソースまたはパラメータの型のチェックは行いません。
ParameterBlock
のパラメータはすべてオブジェクトです。基本型の引数をとる簡易addメソッドおよびsetメソッドが利用可能で、適切なNumber (IntegerまたはFloatなど)のサブクラスを作成します。 対応するgetメソッドは、下方キャストを実行し、基本型の戻り値を受け取ります。 格納される値の型が正しい型でない場合は、例外がスローされます。short s; add(s)の結果とadd(new Short(s))の結果は区別できません。
getメソッドおよびsetメソッドは参照に影響を与えます。 したがって、ParameterBlock
間での参照の共有が不適切な場合は、共有しないようにしてください。 たとえば、追加されたソースを除いて、古いParameterBlockと同じ新しいParameterBlock
を作成する場合に、次のように記述してしまいがちです。
ParameterBlock addSource(ParameterBlock pb, RenderableImage im) { ParameterBlock pb1 = new ParameterBlock(pb.getSources()); pb1.addSource(im); return pb1; }
このコードは、getSources操作がソースVectorへの参照を返したために、元のParameterBlock
を変更する副作用があります。 pbとpb1はソースVectorを共有しているので、一方の変更は両方に対して可視になります。
addSource関数の記述方法で適切なのは、次のようにソースVectorを複製する方法です。
ParameterBlock addSource (ParameterBlock pb, RenderableImage im) { ParameterBlock pb1 = new ParameterBlock(pb.getSources().clone()); pb1.addSource(im); return pb1; }
ParameterBlock
のcloneメソッドは、こうした理由でソースとパラメータの両方のVectorの複製を実行するように定義されています。 標準のシャロー複製をshallowCloneとして利用できます。
addSource、setSource、add、およびsetの各メソッドは、引数を追加したあとでthisを返すように定義されます。 そのため、次のような構文の使用が可能です。
ParameterBlock pb = new ParameterBlock(); op = new RenderableImageOp("operation", pb.add(arg1).add(arg2));
修飾子と型 | フィールド | 説明 |
---|---|---|
protected Vector<Object> |
parameters |
任意のObjectとして格納される、ソース以外のパラメータのVectorです。
|
protected Vector<Object> |
sources |
任意のObjectとして格納される、ソースのVectorです。
|
コンストラクタ | 説明 |
---|---|
ParameterBlock() |
ダミー・コンストラクタです。
|
ParameterBlock(Vector<Object> sources) |
指定されたソースのVectorを使って
ParameterBlock を構築します。 |
ParameterBlock(Vector<Object> sources, Vector<Object> parameters) |
指定されたソースのVectorおよびパラメータのVectorを使って
ParameterBlock を構築します。 |
修飾子と型 | メソッド | 説明 |
---|---|---|
ParameterBlock |
add(byte b) |
Byteをパラメータのリストに追加します。
|
ParameterBlock |
add(char c) |
Characterをパラメータのリストに追加します。
|
ParameterBlock |
add(double d) |
Doubleをパラメータのリストに追加します。
|
ParameterBlock |
add(float f) |
Floatをパラメータのリストに追加します。
|
ParameterBlock |
add(int i) |
Integerをパラメータのリストに追加します。
|
ParameterBlock |
add(long l) |
Longをパラメータのリストに追加します。
|
ParameterBlock |
add(Object obj) |
オブジェクトをパラメータのリストに追加します。
|
ParameterBlock |
add(short s) |
Shortをパラメータのリストに追加します。
|
ParameterBlock |
addSource(Object source) |
イメージをソースのリストの最後に追加します。
|
Object |
clone() |
ParameterBlock のコピーを作成します。 |
byte |
getByteParameter(int index) |
パラメータをbyteとして返す簡易メソッドです。
|
char |
getCharParameter(int index) |
パラメータをcharとして返す簡易メソッドです。
|
double |
getDoubleParameter(int index) |
パラメータをdoubleとして返す簡易メソッドです。
|
float |
getFloatParameter(int index) |
パラメータをfloatとして返す簡易メソッドです。
|
int |
getIntParameter(int index) |
パラメータをintとして返す簡易メソッドです。
|
long |
getLongParameter(int index) |
パラメータをlongとして返す簡易メソッドです。
|
int |
getNumParameters() |
パラメータの数を返します。ソース・イメージは含みません。
|
int |
getNumSources() |
ソース・イメージの数を返します。
|
Object |
getObjectParameter(int index) |
パラメータをオブジェクトとして取得します。
|
Class[] |
getParamClasses() |
パラメータの型を記述するClassオブジェクトの配列を返します。
|
Vector<Object> |
getParameters() |
パラメータのVector全体を返します。
|
RenderableImage |
getRenderableSource(int index) |
ソースをRenderableImageとして返します。
|
RenderedImage |
getRenderedSource(int index) |
ソースを
RenderedImage として返します。 |
short |
getShortParameter(int index) |
パラメータをshortとして返す簡易メソッドです。
|
Object |
getSource(int index) |
ソースを一般的なObjectとして返します。
|
Vector<Object> |
getSources() |
ソースのVector全体を返します。
|
void |
removeParameters() |
パラメータのリストをクリアします。
|
void |
removeSources() |
ソース・イメージのリストをクリアします。
|
ParameterBlock |
set(byte b, int index) |
パラメータのリストのObjectをByteに置き換えます。
|
ParameterBlock |
set(char c, int index) |
パラメータのリストのObjectをCharacterに置き換えます。
|
ParameterBlock |
set(double d, int index) |
パラメータのリストのObjectをDoubleに置き換えます。
|
ParameterBlock |
set(float f, int index) |
パラメータのリストのObjectをFloatに置き換えます。
|
ParameterBlock |
set(int i, int index) |
パラメータのリストのObjectをIntegerに置き換えます。
|
ParameterBlock |
set(long l, int index) |
パラメータのリストのObjectをLongに置き換えます。
|
ParameterBlock |
set(Object obj, int index) |
パラメータのリストのObjectを置き換えます。
|
ParameterBlock |
set(short s, int index) |
パラメータのリストのObjectをShortに置き換えます。
|
void |
setParameters(Vector<Object> parameters) |
指定されたVectorにパラメータのVector全体を設定します。
|
ParameterBlock |
setSource(Object source, int index) |
ソースのリストのエントリを新しいソースに置き換えます。
|
void |
setSources(Vector<Object> sources) |
指定されたVectorにソースのVector全体を設定します。
|
Object |
shallowClone() |
ParameterBlock のシャロー・コピーを作成します。 |
public ParameterBlock()
public ParameterBlock(Vector<Object> sources)
ParameterBlock
を構築します。sources
- ソース・イメージのVector
public Object shallowClone()
ParameterBlock
のシャロー・コピーを作成します。 ソースおよびパラメータのVectorは参照でコピーされます。追加や変更は両方のバージョンに対して可視になります。 ParameterBlock
のObjectの複製。public Object clone()
ParameterBlock
のコピーを作成します。 ソースおよびパラメータのVectorは複製されますが、実際のソースおよびパラメータは参照でコピーされます。 このため、複製でのソースおよびパラメータの順序と数の変更は、元のParameterBlock
からは不可視になります。 一方、共有されるソースまたはパラメータ自体の変更は可視になります。 public ParameterBlock addSource(Object source)
source
- ソース・リストに格納されるイメージ・オブジェクト。source
を格納する新規のParameterBlock
。public Object getSource(int index)
index
- 返されるソースのインデックス。sources
Vector
内の指定されたインデックスにあるソースを表すObject
。setSource(Object, int)
public ParameterBlock setSource(Object source, int index)
source
- 指定されたソース・イメージindex
- 指定されたsource
を挿入するsources
Vector
内のインデックスsource
を指定されたindex
で格納する新規のParameterBlock
。getSource(int)
public RenderedImage getRenderedSource(int index)
RenderedImage
として返します。 このメソッドは簡易メソッドです。 ソースがRenderedImageでない場合、例外がスローされます。 index
- 返されるソースのインデックスsources
Vector
内の指定されたインデックスにあるソース・イメージを表すRenderedImage
。public RenderableImage getRenderableSource(int index)
index
- 返されるソースのインデックスsources
Vector
内の指定されたインデックスにあるソース・イメージを表すRenderableImage
。public int getNumSources()
sources
Vector
内のソース・イメージの数。public Vector<Object> getSources()
sources
Vector
。setSources(Vector)
public void setSources(Vector<Object> sources)
sources
- ソース・イメージのVector
getSources()
public void removeSources()
public int getNumParameters()
parameters
Vector
内のパラメータの数。public Vector<Object> getParameters()
parameters
Vector
。setParameters(Vector)
public void setParameters(Vector<Object> parameters)
parameters
- パラメータの指定されたVector
getParameters()
public void removeParameters()
public ParameterBlock add(Object obj)
obj
- parameters
Vector
に追加するObject
ParameterBlock
。public ParameterBlock add(byte b)
b
- parameters
Vector
に追加するbyteParameterBlock
。public ParameterBlock add(char c)
c
- parameters
Vector
に追加するcharParameterBlock
。public ParameterBlock add(short s)
s
- parameters
Vector
に追加するshortParameterBlock
。public ParameterBlock add(int i)
i
- parameters
Vector
に追加するintParameterBlock
。public ParameterBlock add(long l)
l
- parameters
Vector
に追加するlongParameterBlock
。public ParameterBlock add(float f)
f
- parameters
Vector
に追加するfloatParameterBlock
。public ParameterBlock add(double d)
d
- parameters
Vector
に追加するdoubleParameterBlock
。public ParameterBlock set(Object obj, int index)
obj
- parameters
Vector
内の指定されたインデックスにあるパラメータを置き換えるパラメータindex
- 指定されたパラメータに置き換えられるパラメータのインデックスParameterBlock
。public ParameterBlock set(byte b, int index)
b
- parameters
Vector
内の指定されたインデックスにあるパラメータを置き換えるパラメータindex
- 指定されたパラメータに置き換えられるパラメータのインデックスParameterBlock
。public ParameterBlock set(char c, int index)
c
- parameters
Vector
内の指定されたインデックスにあるパラメータを置き換えるパラメータindex
- 指定されたパラメータに置き換えられるパラメータのインデックスParameterBlock
。public ParameterBlock set(short s, int index)
s
- parameters
Vector
内の指定されたインデックスにあるパラメータを置き換えるパラメータindex
- 指定されたパラメータに置き換えられるパラメータのインデックスParameterBlock
。public ParameterBlock set(int i, int index)
i
- parameters
Vector
内の指定されたインデックスにあるパラメータを置き換えるパラメータindex
- 指定されたパラメータに置き換えられるパラメータのインデックスParameterBlock
。public ParameterBlock set(long l, int index)
l
- parameters
Vector
内の指定されたインデックスにあるパラメータを置き換えるパラメータindex
- 指定されたパラメータに置き換えられるパラメータのインデックスParameterBlock
。public ParameterBlock set(float f, int index)
f
- parameters
Vector
内の指定されたインデックスにあるパラメータを置き換えるパラメータindex
- 指定されたパラメータに置き換えられるパラメータのインデックスParameterBlock
。public ParameterBlock set(double d, int index)
d
- parameters
Vector
内の指定されたインデックスにあるパラメータを置き換えるパラメータindex
- 指定されたパラメータに置き換えられるパラメータのインデックスParameterBlock
。public Object getObjectParameter(int index)
index
- 取得するパラメータのインデックスparameters
Vector
内の指定されたインデックスにあるパラメータを表すObject
。public byte getByteParameter(int index)
null
の場合、またはByte
でない場合は、例外がスローされます。 index
- 返されるパラメータのインデックス。byte
値としてのパラメータ。ClassCastException
- 指定されたインデックスでのパラメータがByte
でない場合NullPointerException
- 指定されたインデックスでのパラメータがnull
の場合ArrayIndexOutOfBoundsException
- index
が負の場合、またはこのParameterBlock
オブジェクトの現在のサイズ以上である場合public char getCharParameter(int index)
null
の場合、またはCharacter
でない場合は、例外がスローされます。 index
- 返されるパラメータのインデックス。char
値としてのパラメータ。ClassCastException
- 指定されたインデックスでのパラメータがCharacter
でない場合NullPointerException
- 指定されたインデックスでのパラメータがnull
の場合ArrayIndexOutOfBoundsException
- index
が負の場合、またはこのParameterBlock
オブジェクトの現在のサイズ以上である場合public short getShortParameter(int index)
null
の場合、またはShort
でない場合は、例外がスローされます。 index
- 返されるパラメータのインデックス。short
値としてのパラメータ。ClassCastException
- 指定されたインデックスでのパラメータがShort
でない場合NullPointerException
- 指定されたインデックスでのパラメータがnull
の場合ArrayIndexOutOfBoundsException
- index
が負の場合、またはこのParameterBlock
オブジェクトの現在のサイズ以上である場合public int getIntParameter(int index)
null
の場合、またはInteger
でない場合は、例外がスローされます。 index
- 返されるパラメータのインデックス。int
値としてのパラメータ。ClassCastException
- 指定されたインデックスでのパラメータがInteger
でない場合NullPointerException
- 指定されたインデックスでのパラメータがnull
の場合ArrayIndexOutOfBoundsException
- index
が負の場合、またはこのParameterBlock
オブジェクトの現在のサイズ以上である場合public long getLongParameter(int index)
null
の場合、またはLong
でない場合は、例外がスローされます。 index
- 返されるパラメータのインデックス。long
値としてのパラメータ。ClassCastException
- 指定されたインデックスでのパラメータがLong
でない場合NullPointerException
- 指定されたインデックスでのパラメータがnull
の場合ArrayIndexOutOfBoundsException
- index
が負の場合、またはこのParameterBlock
オブジェクトの現在のサイズ以上である場合public float getFloatParameter(int index)
null
の場合、またはFloat
でない場合は、例外がスローされます。 index
- 返されるパラメータのインデックス。float
値としてのパラメータ。ClassCastException
- 指定されたインデックスでのパラメータがFloat
でない場合NullPointerException
- 指定されたインデックスでのパラメータがnull
の場合ArrayIndexOutOfBoundsException
- index
が負の場合、またはこのParameterBlock
オブジェクトの現在のサイズ以上である場合public double getDoubleParameter(int index)
null
の場合、またはDouble
でない場合は、例外がスローされます。 index
- 返されるパラメータのインデックス。double
値としてのパラメータ。ClassCastException
- 指定されたインデックスでのパラメータがDouble
でない場合NullPointerException
- 指定されたインデックスでのパラメータがnull
の場合ArrayIndexOutOfBoundsException
- index
が負の場合、またはこのParameterBlock
オブジェクトの現在のサイズ以上である場合public Class[] getParamClasses()
Class
オブジェクトの配列。 バグまたは機能を送信
詳細なAPIリファレンスおよび開発者ドキュメントについては、Java SEのドキュメントを参照してください。 そのドキュメントには、概念的な概要、用語の定義、回避方法、有効なコード例などの、開発者を対象にしたより詳細な説明が含まれています。
Copyright © 1993, 2025, Oracle and/or its affiliates. All rights reserved. Use is subject to license terms. Documentation Redistribution Policyも参照してください。