|
||||||||||
前のクラス 次のクラス | フレームあり フレームなし | |||||||||
概要: 入れ子 | フィールド | コンストラクタ | メソッド | 詳細: フィールド | コンストラクタ | メソッド |
java.lang.Objectohymosj.OhObject
クラス OhObject では、
OHyMoSJ のクラスは全て基本型モデルのクラス OhObject を継承して作成します。
OHyMoSJ のユーザは、普通はクラス OhObject を継承して作成された
OhElement や OhSendPort など、
クラス OhObject の下位のクラスを継承してユーザが必要とするクラスを作成すれば十分であって、
クラス OhObject を直接継承してクラスを作成することはないでしょう。
クラス OhObject は、メンバ変数
_className は、各派生クラスごとに共通の文字列に設定して下さい。
例えば、派生クラス ABC ではコンストラクタで
_objectName, _objectNumber には、そのオブジェクト自身の名前と番号を
OhObject.OhObject(String, int)
または
OhObject.init(String, int)
で設定します。
二重設定はできません。
プログラマが明示的に _objectName, _objectNumber を設定していないときは、
_objectName は null、_objectNumber は -1 に設定されています。
【簡単な例】
・オブジェクトの名前 : _className, _objectName, _objectNumber
・オブジェクトの所有者 : _owner
を記憶し、
・オブジェクトの比較機能
・所有者の設定機能
・オブジェクト情報の出力機能
を定義しました。
String _className; //; クラス名
String _objectName; //; オブジェクト名
int _objectNumber; //; オブジェクト番号
Object _owner; //; Object 型にキャストされた所有者
を持っています。
OHyMoSJ のクラスは全て基本型 OhObject を継承して作成するので、
OHyMoSJ の全てのインスタンスがこれらのメンバ変数を持っていることになります。
_className = "ABC";
と設定します。
public class Yahoo extends OhObject
{
public Yahoo() {
super();
_className = "Yahoo";
}
public Yahoo(String aObjName, int aObjNum) {
super();
_className = "Yahoo";
init(aObjName, aObjNum);
}
.
.
.
}
_owner には、所有者を OhObject.setOwner(Object) で
設定します。
オブジェクトAがオブジェクトBのメンバ変数である場合、「BをAの所有者」と呼びます。
例えば、
・受信端子Aが要素モデルBのメンバ変数である場合。
・要素モデルAが部分系モデルBのメンバ変数である場合。
これらのメンバ変数を用いて、
などが定義されています。
Base class of all OHyMoSJ classes.
An element of type Object has four basic fields: _owner, _className, _objectName, _objectNumber.
フィールドの概要 | |
protected java.lang.String |
_className
|
protected java.lang.String |
_objectName
|
protected int |
_objectNumber
|
protected java.lang.Object |
_owner
|
protected static java.lang.String |
NEWLINE
|
コンストラクタの概要 | |
OhObject()
|
|
OhObject(java.lang.String aObjName,
int aObjNum)
|
メソッドの概要 | |
void |
cPrint(java.io.PrintWriter aPw,
java.lang.String aHead)
|
java.lang.String |
getAbsName()
|
java.lang.String |
getClassName()
|
java.lang.String |
getObjectName()
|
int |
getObjectNumber()
|
java.lang.Object |
getOwner()
|
java.lang.Object |
getTopOwner()
|
boolean |
init(java.lang.String aObjName,
int aObjNum)
|
boolean |
objCompare(OhObject aObj)
|
boolean |
objCompare(java.lang.String aObjName,
int aObjNum)
|
boolean |
objCompare(java.lang.String aClassName,
java.lang.String aObjName,
int aObjNum)
|
void |
oPrint(java.io.PrintWriter aPw,
java.lang.String aHead)
|
void |
setOwner(java.lang.Object aOwner)
|
クラス java.lang.Object から継承したメソッド |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
フィールドの詳細 |
protected java.lang.String _className
'_className' stores the class name.
protected java.lang.String _objectName
'_objetcName' stores the object name.
protected int _objectNumber
'_objectNumber' stores the object number.
protected java.lang.Object _owner
The "owner" of the current object casted to type Object
.
protected static java.lang.String NEWLINE
New line.
コンストラクタの詳細 |
public OhObject()
・_className : "OhObject" ・_objectName : null ・_objectNumber : -1 ・_owner : null
public OhObject(java.lang.String aObjName, int aObjNum) throws OhError
・_className : "OhObject" ・_objectName : aObjName ・_objectNumber : aObjNum ・_owner : null
aObjName
- a String
valueaObjNum
- an int
value
OhError
- if an error occursメソッドの詳細 |
public boolean init(java.lang.String aObjName, int aObjNum) throws OhError
Initialization.
aObjName
- a String
valueaObjNum
- an int
value
boolean
value
OhError
- if an error occurspublic java.lang.String getClassName()
Gets the class name.
String
valuepublic java.lang.String getObjectName()
Gets the object name.
String
valuepublic int getObjectNumber()
Gets the object number.
int
valuepublic java.lang.Object getOwner()
Gets the owner of the current object casted to type Object.
Object
valuepublic java.lang.Object getTopOwner()
Gets the top owner of the receiver.
Object
valuepublic boolean objCompare(java.lang.String aClassName, java.lang.String aObjName, int aObjNum)
このメソッドは、_className, _objectName, _objectNumber が aClassName, aObjName, aObjNum に一致した場合 true を返します。 どれか1つでも一致しないものがあれば false を返します。
If the current object is same as class name, object name, and object number given by the arguments, this method returns true. Otherwise, false.
aClassName
- a String
valueaObjName
- a String
valueaObjNum
- an int
value
boolean
valuepublic boolean objCompare(java.lang.String aObjName, int aObjNum)
このメソッドは、_objectName, _objectNumber が aObjName, aObjNum に一致した場合 true を返します。 いずれか1つでも一致しないものがあれば false を返します。
If the current object is same as object name and object number as those given as the arguments, this method returns true. Otherwise, false.
aObjName
- a String
valueaObjNum
- an int
value
boolean
valuepublic boolean objCompare(OhObject aObj)
このメソッドは、_className, _objectName, _objectNumber, _owner が すべて aObj と一致した場合 true を返します。 どれか1つでも一致しないものがあれば false を返します。 また、aObj が null の場合も false を返します。
If the current object is same class name, object name, object number, and owner which aObj has, this method returns true. Otherwise, false.
aObj
- an OhObject
value
boolean
valuepublic void setOwner(java.lang.Object aOwner) throws OhError
aOwner とは異なるオブジェクトがすでに所有者として設定されている場合は、 新たに aOwner を所有者に設定せずに、 例外 OhError が投げられます。
Set owner to be "aOwner". When already a different object has been registerd as the owner, you cannot set the new owner. If this case happens, this method throws OhError exception.
aOwner
- an Object
value
OhError
- if an error occurspublic java.lang.String getAbsName()
This method returns a string which specifies the object uniquely.
The string which getAbsName() returns will be created by concatenating
"absolute name of the owner" "/" _objectName "__" _objectNumber.When _owner == NULL, "absolute name of the owner" is taken as "".
Assume that the absolute name of the owner is "/total_sytetem__0",
_objectName of the current object is "elm_t",
and _objectNumber is 0,
then "absname" is
/total_system__0/elm_t__0
String
value
public void cPrint(java.io.PrintWriter aPw, java.lang.String aHead)
Print "aHead", _className, _objectName, _objectNumer to aPw.
| Yahoo a("yahoo", 0);
| a.Cprint(aPw, "+");
prints to aPw
+Yahoo yahoo 0
aPw
- a PrintWriter
valueaHead
- a String
value
public void oPrint(java.io.PrintWriter aPw, java.lang.String aHead)
Trace back the object's ancestry, that is, prints all the ancesters to aPw as far as an ancester exists. "aHead" is printed before the ancestry.
| Yahoo a("yahoo", 0);
| Yahoo b("yahoobb", 1);
| b.setOwner(a);
| PrintWriter aPw;
| b.Oprint(aPw, "+ ");
prints to aPw as follows
| + Yahoo yahoobb 1
| + owner > Yahoo yahoo 0
aPw
- a PrintWriter
valueaHead
- a String
value
|
||||||||||
前のクラス 次のクラス | フレームあり フレームなし | |||||||||
概要: 入れ子 | フィールド | コンストラクタ | メソッド | 詳細: フィールド | コンストラクタ | メソッド |