org.boxed_economy.besp.model.fmfw
クラス Agent

java.lang.Object
  拡張org.boxed_economy.besp.model.fmfw.FmFwObject
      拡張org.boxed_economy.besp.model.fmfw.Entity
          拡張org.boxed_economy.besp.model.fmfw.Agent
すべての実装インタフェース:
java.io.Serializable

public final class Agent
extends Entity

BoxedEconomyにおけるエージェントとなるクラスです。worldに配置されます。 --以下のオブジェクトを所有し、Managerクラスを通して管理します。 Goods,Behavior,Relation,Information また、TimeEventを受け取ってBehaviorを駆動します。 Agentは継承することを前提にはしていません。

バージョン:
$Id: Agent.java,v 1.2 2004/03/21 20:07:07 macchan Exp $
作成者:
macchan
関連項目:
直列化された形式

入れ子クラスの概要
 
クラス org.boxed_economy.besp.model.fmfw.FmFwObject から継承した入れ子クラス
FmFwObject.InstanceCounter
 
コンストラクタの概要
protected Agent(AgentType type)
          Agentを生成するコンストラクタです。
 
メソッドの概要
 void addBehavior(BehaviorType type)
          Behaviorを追加します。
 void addGoods(Goods goods)
          財を追加します。
 void addRelation(Agent target)
          デフォルトのTypeを利用してRelationを追加します。
 void addRelation(RelationType relationType, Agent target)
          Relationを追加します。
 void destroy()
          このAgentが死亡(あるいは倒産)する時に呼ばれるメソッドです。
protected  void fireBehaviorAdded(UpdateAgentEvent e)
           
protected  void fireBehaviorRemoved(UpdateAgentEvent e)
           
protected  void fireGoodsAdded(UpdateAgentEvent e)
           
protected  void fireGoodsRemoved(UpdateAgentEvent e)
           
protected  void fireInformationAdded(UpdateAgentEvent e)
           
protected  void fireInformationRemoved(UpdateAgentEvent e)
           
protected  void fireRelationAdded(UpdateAgentEvent e)
           
protected  void fireRelationRemoved(UpdateAgentEvent e)
           
 java.util.List getAllBehaviors()
          Returns All Behaviors.
 java.util.List getAllRelations()
          Returns All Relations.
 Behavior getBehavior(BehaviorType type)
          引数のTypeであるBehaviorを返します。
 java.util.Collection getBehaviors(BehaviorType type)
          引数のTypeであるBehaviorをCollectionとして全て返します。
 java.util.Collection getBehaviorsRecursively(BehaviorType type)
          引数のType及びその子タイプであるBehaviorをCollectionとして全て返します。
 java.util.Collection getGoodsTypes()
          このAgentが持つ全ての財の種類を返します
 Information getInformation(Information key)
          引数のInformationをキーとするInformation(cloneではありません)を返します キーが見つからなかった場合、Exceptionを返します。
 GoodsQuantity getQuantity(GoodsType type)
          指定された種類の財の量を取得します。
 GoodsQuantity getQuantityRecursively(GoodsType type)
          指定された種類の財の量を取得します。
 Relation getRelation(RelationType type)
          引数のTypeであるRelationを返します。
 Relation getRelation(RelationType type, Agent agent)
          引数のType、かつ関係先が引数のAgentであるRelationを返します
 java.util.Collection getRelations(RelationType type)
          引数のTypeであるrelationをCollectionとして全て返します。
 java.util.Collection getRelationsRecursively(RelationType type)
          引数のType及びそのTypeの子のTypeである全てのrelationを返します。
 java.util.Collection getRelationTypes()
          このAgentの持つRelationのTypeを返します。
 AgentType getType()
          AgentTypeを取得します.
 boolean hasGoods(GoodsType type)
          指定された種類の財を持っているかどうか調べます
 void initialize()
          agentの持つgoodsManager、informationManager、relationManager、behaviorManager をinitalizeします。
 void putInformation(Information key, Information value)
          Informationを追加します。
 void receiveDeathEvent(Agent target)
          他のAgentが死亡(あるいは倒産)したときに、そのAgentとの関係を削除するために 呼ばれるメソッドです。
 Behavior receiveOpenChannelEvent(OpenChannelEvent e)
          Channelを開設するためにChannelOpenEventを受け取るメソッドです。
 void receiveTimeEvent(TimeEvent e)
          TimeEventを受け取ってbehaviorManagerに送ります。
 Goods removeAllGoods(GoodsType type)
          指定された種類の財をすべて引き出します。
 java.util.Collection removeAllGoodsRecursively(GoodsType type)
          指定された種類の財をすべて引き出します。
 void removeBehavior(Behavior behavior)
          Behaviorを終了して削除します。
 Goods removeGoods(GoodsType type, double quantity)
          指定された種類の財を指定量引き出します。
 java.util.Collection removeGoodsRecursively(GoodsType type, double quantity)
          指定された種類の財を指定量引き出します。
 Information removeInformation(Information key)
          引数のInformationをキーとするInformationを削除します。
 void removeRelation(Relation relation)
          引数のRelationを削除します。
 void removeRelations(RelationType type)
          引数のTypeのRelation全てを削除します。
 void removeRelationsRecursively(RelationType type)
          引数のType及びその子TypeのRelation全てを削除します。
 
クラス org.boxed_economy.besp.model.fmfw.Entity から継承したメソッド
getInformation, getInformations, getWorld, hasInformation, putInformation, setInformations, setWorld
 
クラス org.boxed_economy.besp.model.fmfw.FmFwObject から継承したメソッド
finalize, getInstanceCounters
 
クラス java.lang.Object から継承したメソッド
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

コンストラクタの詳細

Agent

protected Agent(AgentType type)
Agentを生成するコンストラクタです。

パラメータ:
type - 生成時に指定するAgentType
メソッドの詳細

initialize

public void initialize()
agentの持つgoodsManager、informationManager、relationManager、behaviorManager をinitalizeします。worldから呼ばれます。


getType

public AgentType getType()
AgentTypeを取得します.

戻り値:
type AgentType

destroy

public void destroy()
このAgentが死亡(あるいは倒産)する時に呼ばれるメソッドです。


receiveTimeEvent

public void receiveTimeEvent(TimeEvent e)
TimeEventを受け取ってbehaviorManagerに送ります。

パラメータ:
e - TimeEvent

receiveDeathEvent

public void receiveDeathEvent(Agent target)
他のAgentが死亡(あるいは倒産)したときに、そのAgentとの関係を削除するために 呼ばれるメソッドです。AgentManagerから呼ばれます。

パラメータ:
target - 死亡(あるいは倒産、消滅)したAgent

putInformation

public void putInformation(Information key,
                           Information value)
Informationを追加します。KeyにInformationを指定してください。

オーバーライド:
クラス Entity 内の putInformation
パラメータ:
key - キーのInformation
value - 値のInformation

getInformation

public Information getInformation(Information key)
引数のInformationをキーとするInformation(cloneではありません)を返します キーが見つからなかった場合、Exceptionを返します。

オーバーライド:
クラス Entity 内の getInformation
パラメータ:
key -
戻り値:
Information

removeInformation

public Information removeInformation(Information key)
引数のInformationをキーとするInformationを削除します。 キーが見つからなかった場合、Exceptionを返します。

オーバーライド:
クラス Entity 内の removeInformation
パラメータ:
key - 検索キー
戻り値:
Information 削除したInformation

addBehavior

public void addBehavior(BehaviorType type)
Behaviorを追加します。追加されたBehaviorは開始状態をとります。 この時、追加されたBehaviorにはAgentがセットされます。


removeBehavior

public void removeBehavior(Behavior behavior)
Behaviorを終了して削除します。 このメソッドに限り、Behavior終了のトラブルを避けるためprotectedにします。


getBehavior

public Behavior getBehavior(BehaviorType type)
引数のTypeであるBehaviorを返します。(複数存在していた場合、一番初めに追加されたBehaviorを返します) もし、存在しなければExceptionが投げられます。

パラメータ:
type - 検索対象のType
戻り値:
Collection 該当するBehaviorのリスト

getBehaviors

public java.util.Collection getBehaviors(BehaviorType type)
引数のTypeであるBehaviorをCollectionとして全て返します。 もし、存在しなければ空のCollectionを返します。

パラメータ:
type - 検索対象のType
戻り値:
List 該当するRelationのリスト

getBehaviorsRecursively

public java.util.Collection getBehaviorsRecursively(BehaviorType type)
引数のType及びその子タイプであるBehaviorをCollectionとして全て返します。 もし、存在しなければ空のCollectionを返します。

パラメータ:
type - 検索対象のType
戻り値:
List 該当するBehaviorのリスト

getAllBehaviors

public java.util.List getAllBehaviors()
Returns All Behaviors.

戻り値:
Collection The collection which has all behaviors.

receiveOpenChannelEvent

public Behavior receiveOpenChannelEvent(OpenChannelEvent e)
Channelを開設するためにChannelOpenEventを受け取るメソッドです。 ChannelEventを受け取るBehaviorを最終的に返します。

パラメータ:
e - Channel開設に必要なChannelOpenEvent

addGoods

public void addGoods(Goods goods)
財を追加します。

パラメータ:
goods - 追加する財

removeGoods

public Goods removeGoods(GoodsType type,
                         double quantity)
指定された種類の財を指定量引き出します。 指定された種類の財が指定量存在しない場合は、Exceptionが投げられます。

パラメータ:
type - 引き出す財の種類
quantity - 引き出す財の量
戻り値:
Goods 引き出された財

removeGoodsRecursively

public java.util.Collection removeGoodsRecursively(GoodsType type,
                                                   double quantity)
指定された種類の財を指定量引き出します。 指定された種類に下位種類があれば再帰的に検索します。 指定された種類の財が指定量存在しない場合は、Exceptionが投げられます。

パラメータ:
type - 引き出す財の種類
quantity - 引き出す財の量
戻り値:
Goods 引き出された財

removeAllGoods

public Goods removeAllGoods(GoodsType type)
指定された種類の財をすべて引き出します。 指定された種類の財が存在しない場合は、Exceptionが投げられます。

パラメータ:
type - 引き出す財の種類
戻り値:
Goods 引き出された財

removeAllGoodsRecursively

public java.util.Collection removeAllGoodsRecursively(GoodsType type)
指定された種類の財をすべて引き出します。 指定された種類に下位種類があれば再帰的に検索します。 指定された種類の財が存在しない場合は、Exceptionが投げられます。

パラメータ:
type - 引き出す財の種類
戻り値:
Goods 引き出された財

getQuantity

public GoodsQuantity getQuantity(GoodsType type)
指定された種類の財の量を取得します。 指定された種類の財が無ければ0を表すGoodsQuantityインスタンスが返されます。

パラメータ:
type - 調べる財の種類
戻り値:
GoodsQuantity 財の量

getQuantityRecursively

public GoodsQuantity getQuantityRecursively(GoodsType type)
指定された種類の財の量を取得します。 指定された種類に下位種類があれば再帰的に検索します。 指定された種類の財が無ければ0を表すGoodsQuantityインスタンスが返されます。

パラメータ:
type - 調べる財の種類
戻り値:
GoodsQuantity 財の量の合計

hasGoods

public boolean hasGoods(GoodsType type)
指定された種類の財を持っているかどうか調べます

戻り値:
boolean 持っているかどうか

getGoodsTypes

public java.util.Collection getGoodsTypes()
このAgentが持つ全ての財の種類を返します

戻り値:
Collection GoodsTypeのリスト

addRelation

public void addRelation(Agent target)
デフォルトのTypeを利用してRelationを追加します。


addRelation

public void addRelation(RelationType relationType,
                        Agent target)
Relationを追加します。


removeRelation

public void removeRelation(Relation relation)
引数のRelationを削除します。

パラメータ:
relation - 削除対象のRelation

removeRelations

public void removeRelations(RelationType type)
引数のTypeのRelation全てを削除します。

パラメータ:
type - 削除対象のType

removeRelationsRecursively

public void removeRelationsRecursively(RelationType type)
引数のType及びその子TypeのRelation全てを削除します。

パラメータ:
type - 削除対象のType

getRelationTypes

public java.util.Collection getRelationTypes()
このAgentの持つRelationのTypeを返します。 もし、存在しなければExceptionが投げられます。

戻り値:
Collection Relationの持つTypeのリスト

getRelation

public Relation getRelation(RelationType type)
引数のTypeであるRelationを返します。(複数ある場合、一番最初に追加されたRelationを返します) もし、存在しなければExceptionが投げられます。

パラメータ:
type - 検索対象のType
戻り値:
Relation 該当するRelation

getRelations

public java.util.Collection getRelations(RelationType type)
引数のTypeであるrelationをCollectionとして全て返します。 もし、存在しなければ空のCollectionが返されます

パラメータ:
type - 検索対象のType
戻り値:
Collection 該当するRelationのリスト

getAllRelations

public java.util.List getAllRelations()
Returns All Relations.

戻り値:
Collection The collection which has all behaviors.

getRelationsRecursively

public java.util.Collection getRelationsRecursively(RelationType type)
引数のType及びそのTypeの子のTypeである全てのrelationを返します。 もし、存在しなければ空のCollectionが返されます

パラメータ:
type - 検索対象のType
戻り値:
Collection 該当するRelationのリスト

getRelation

public Relation getRelation(RelationType type,
                            Agent agent)
引数のType、かつ関係先が引数のAgentであるRelationを返します


fireGoodsAdded

protected void fireGoodsAdded(UpdateAgentEvent e)

fireGoodsRemoved

protected void fireGoodsRemoved(UpdateAgentEvent e)

fireInformationAdded

protected void fireInformationAdded(UpdateAgentEvent e)

fireInformationRemoved

protected void fireInformationRemoved(UpdateAgentEvent e)

fireRelationAdded

protected void fireRelationAdded(UpdateAgentEvent e)

fireRelationRemoved

protected void fireRelationRemoved(UpdateAgentEvent e)

fireBehaviorAdded

protected void fireBehaviorAdded(UpdateAgentEvent e)

fireBehaviorRemoved

protected void fireBehaviorRemoved(UpdateAgentEvent e)