ohymosj
クラス OhObject

java.lang.Object
  拡張ohymosj.OhObject
直系の既知のサブクラス:
OhElement, OhPort

public class OhObject
extends java.lang.Object

基本型モデルを表すクラスです。

クラス OhObject では、

  ・オブジェクトの名前    : _className, _objectName, _objectNumber
  ・オブジェクトの所有者  : _owner
 
を記憶し、
  ・オブジェクトの比較機能
  ・所有者の設定機能
  ・オブジェクト情報の出力機能
 
を定義しました。

OHyMoSJ のクラスは全て基本型モデルのクラス OhObject を継承して作成します。

OHyMoSJ のユーザは、普通はクラス OhObject を継承して作成された OhElementOhSendPort など、 クラス OhObject の下位のクラスを継承してユーザが必要とするクラスを作成すれば十分であって、 クラス OhObject を直接継承してクラスを作成することはないでしょう。

クラス OhObject は、メンバ変数

	String _className;   //; クラス名
	String _objectName;  //; オブジェクト名
	int _objectNumber;   //; オブジェクト番号
 	Object _owner;       //; Object 型にキャストされた所有者
 
を持っています。 OHyMoSJ のクラスは全て基本型 OhObject を継承して作成するので、 OHyMoSJ の全てのインスタンスがこれらのメンバ変数を持っていることになります。

_className は、各派生クラスごとに共通の文字列に設定して下さい。 例えば、派生クラス ABC ではコンストラクタで

  _className = "ABC";
 
と設定します。

_objectName, _objectNumber には、そのオブジェクト自身の名前と番号を OhObject.OhObject(String, int) または OhObject.init(String, int) で設定します。 二重設定はできません。

プログラマが明示的に _objectName, _objectNumber を設定していないときは、 _objectName は null、_objectNumber は -1 に設定されています。

【簡単な例】

  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.

  • Definition of "_owner".
    When an object A has an object B as its field, A is called the owner of B.
    The field "owner", a type Object, is the pointer to the owner of the current object.
  • Definition of "_className"
    _className stores the name of the class.
    For example, "_className" of an object of the class Object is "Object".
  • Definition of "_objectName"
    _objectName stores the name of the objcet.
    User descides the name of each object.
  • Definition of "_objectNumber"
    _objectNumber stores the identification number.
  • _objectName and _objectNumber are used to identify OHyMoSJ elements owned by an OHyMoSJ element. Suppose an OHyMoSJ element A owns OHyMoSJ elements e1, e2, ..., eN, elements e1, e2, ..., eN should be able to be identified by the pair, _objectName and _objectNumber.

    バージョン:
    $Revision: 1.36 $ $Date: 2004/02/12 05:56:35 $
    作成者:
    satoh

    フィールドの概要
    protected  java.lang.String _className
               クラス名を表す文字列です。
    protected  java.lang.String _objectName
               オブジェクト名を表す文字列です。
    protected  int _objectNumber
               オブジェクト番号を表すint値です。
    protected  java.lang.Object _owner
               所有者を表すオブジェクトです。
    protected static java.lang.String NEWLINE
               OS に依存しない改行コードを表す文字列です。
     
    コンストラクタの概要
    OhObject()
               デフォルトコンストラクタです。
    OhObject(java.lang.String aObjName, int aObjNum)
               引数に指定されたメンバ変数を持つ OhObject を作成します。
     
    メソッドの概要
     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)
               aOwner(引数)を所有者に設定します。
     
    クラス java.lang.Object から継承したメソッド
    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
     

    フィールドの詳細

    _className

    protected java.lang.String _className
    クラス名を表す文字列です。

    '_className' stores the class name.


    _objectName

    protected java.lang.String _objectName
    オブジェクト名を表す文字列です。

    '_objetcName' stores the object name.


    _objectNumber

    protected int _objectNumber
    オブジェクト番号を表すint値です。

    '_objectNumber' stores the object number.


    _owner

    protected java.lang.Object _owner
    所有者を表すオブジェクトです。

    The "owner" of the current object casted to type Object.


    NEWLINE

    protected static java.lang.String NEWLINE
    OS に依存しない改行コードを表す文字列です。

    New line.

    コンストラクタの詳細

    OhObject

    public OhObject()
    デフォルトコンストラクタです。 メンバ変数を以下の通り初期化します。
      ・_className    : "OhObject"
      ・_objectName   : null
      ・_objectNumber : -1
      ・_owner        : null
     


    OhObject

    public OhObject(java.lang.String aObjName,
                    int aObjNum)
             throws OhError
    引数に指定されたメンバ変数を持つ OhObject を作成します。 OhObject.init(String, int) に aObjNum, aObjNum を渡し、 メンバ変数を以下の通り初期化します。
      ・_className    : "OhObject"
      ・_objectName   : aObjName
      ・_objectNumber : aObjNum
      ・_owner        : null
     

    パラメータ:
    aObjName - a String value
    aObjNum - an int value
    例外:
    OhError - if an error occurs
    メソッドの詳細

    init

    public boolean init(java.lang.String aObjName,
                        int aObjNum)
                 throws OhError
    オブジェクト名、オブジェクト番号を初期化します。 具体的には、引数 aObjName, aObjNum を _objectName, _objectNumber に設定します。 また、_objectName が設定済みの時は、二重設定と判断し、エラーメッセージを表示後 false を返します。 この場合、_objectName, _objectNumber を変更しません。 コンストラクタの定義、及びデフォルトコンストラクタで生成したオブジェクトの初期化に用います。

    Initialization.

    パラメータ:
    aObjName - a String value
    aObjNum - an int value
    戻り値:
    a boolean value
    例外:
    OhError - if an error occurs

    getClassName

    public java.lang.String getClassName()
    クラス名を取得します。

    Gets the class name.

    戻り値:
    a String value

    getObjectName

    public java.lang.String getObjectName()
    オブジェクト名を取得します。

    Gets the object name.

    戻り値:
    a String value

    getObjectNumber

    public int getObjectNumber()
    オブジェクト番号を取得します。

    Gets the object number.

    戻り値:
    an int value

    getOwner

    public java.lang.Object getOwner()
    所有者を取得します。

    Gets the owner of the current object casted to type Object.

    戻り値:
    an Object value

    getTopOwner

    public java.lang.Object getTopOwner()
    最高所有者を取得します。

    Gets the top owner of the receiver.

    戻り値:
    an Object value

    objCompare

    public 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 value
    aObjName - a String value
    aObjNum - an int value
    戻り値:
    a boolean value

    objCompare

    public 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 value
    aObjNum - an int value
    戻り値:
    a boolean value

    objCompare

    public 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
    戻り値:
    a boolean value

    setOwner

    public void setOwner(java.lang.Object aOwner)
                  throws OhError
    aOwner(引数)を所有者に設定します。

    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 occurs

    getAbsName

    public 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
    
     

    戻り値:
    a String value

    cPrint

    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 value
    aHead - a String value

    oPrint

    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 value
    aHead - a String value