public class OE extends Event implements java.lang.Cloneable, ToXML
Modifier and Type | Field and Description |
---|---|
protected java.util.Map<java.lang.String,OEAgent> |
agents |
protected java.util.Map<java.lang.String,GroupInstance> |
groups |
protected OS |
os |
protected GoalInstance |
purpose |
protected java.util.Map<java.lang.String,SchemeInstance> |
schs |
Constructor and Description |
---|
OE(GoalInstance purpose,
OS os) |
Modifier and Type | Method and Description |
---|---|
void |
abortScheme(SchemeInstance sch)
Aborts (and removes) the scheme instance from the OE's Schemes.
|
OEAgent |
addAgent(java.lang.String agName)
Adds an agent in the OE.
|
GroupInstance |
addGroup(java.lang.String grSpecId)
Creates a new root group instance from the specification denoted by grSpecId.
|
GroupInstance |
addGroup(java.lang.String grId,
java.lang.String grSpecId)
Creates a new root group instance (identified by grId) from the specification denoted by grSpecId.
|
void |
changePurpose(java.lang.String newPurpose) |
java.lang.Object |
clone()
the clone object is a full/independent copy of this object,i.e.,
all OE inner objects are also cloned.
|
static OE |
createOE(java.lang.String purpose,
java.lang.String OSxmlURI)
Creates a new organisational entity with purpose and organisation specification as
state in the file OSxmlURI.
|
GroupInstance |
findGroup(java.lang.String grId)
looks for a group with grId in this OE (and inside all its groups)
|
java.util.Collection<GroupInstance> |
findInstancesOf(Group grSpec)
finds all groups (and subgroups) that instantiates grSpec
|
java.util.Collection<GroupInstance> |
findInstancesOf(java.lang.String grSpec)
finds all groups (and subgroups) that instantiates grSpec
|
java.util.Collection<SchemeInstance> |
findInstancesOfSchSpec(java.lang.String schSpecId)
finds all schemes that instantiates schSpecId
|
SchemeInstance |
findScheme(java.lang.String schId)
looks for a Scheme with schId
|
void |
finishScheme(SchemeInstance sch)
Removes the scheme instance from the OE's Schemes.
|
OEAgent |
getAgent(java.lang.String agId) |
java.util.Collection<OEAgent> |
getAgents() |
java.util.Collection<OEAgent> |
getAgents(GroupInstance gr,
Role role)
gets all agents that plays
role in gr . |
java.util.Collection<OEAgent> |
getAgents(GroupInstance gr,
java.lang.String roleId)
gets all agents that plays
role in gr . |
java.util.Collection<GroupInstance> |
getAllSubGroupsTree()
return all groups of the OE, even subgroups
|
org.w3c.dom.Element |
getAsDOM(org.w3c.dom.Document document) |
java.util.Collection<GroupInstance> |
getGroups()
returns the root groups
|
OS |
getOS()
gets the OS of this entity
|
GoalInstance |
getPurpose() |
java.util.Collection<SchemeInstance> |
getSchemes() |
int |
getSubGroupInstancesQty(java.lang.String grSpecId)
returns the number of grSpecId instances
|
java.lang.String |
getXMLTag() |
OE |
partialOE(OEAgent ag)
gets a partial view of this OE, only entities allowed for the ag will be shown.
|
void |
rebuildHash()
since serialisation of maps has a bug, we need to rebuild them after serialisation!
|
void |
removeAgent(java.lang.String agId,
boolean check)
Removes an agent from the OE.
|
void |
removeGroup(java.lang.String grId)
Removes a group instance from this OE.
|
SchemeInstance |
startScheme(java.lang.String schSpecId)
Creates a new scheme instance.
|
SchemeInstance |
startScheme(java.lang.String schId,
java.lang.String schSpecId)
Creates a new scheme instance with a particular id.
|
java.lang.String |
toString() |
protected GoalInstance purpose
protected OS os
protected java.util.Map<java.lang.String,OEAgent> agents
protected java.util.Map<java.lang.String,GroupInstance> groups
protected java.util.Map<java.lang.String,SchemeInstance> schs
public OE(GoalInstance purpose, OS os) throws MoiseConsistencyException
MoiseConsistencyException
public static OE createOE(java.lang.String purpose, java.lang.String OSxmlURI) throws MoiseConsistencyException
Example:
OE currentOE = OE.createOE("winGame", "jojOS.xml");
purpose
- the purpose of the entityOSxmlURI
- the organisation specificationMoiseConsistencyException
- in case the XML file is not well formedpublic OE partialOE(OEAgent ag) throws MoiseConsistencyException
MoiseConsistencyException
public java.lang.Object clone()
clone
in class java.lang.Object
public void rebuildHash()
public void changePurpose(java.lang.String newPurpose)
public GoalInstance getPurpose()
public OS getOS()
public OEAgent addAgent(java.lang.String agName) throws MoiseException
Example:
agName
- the agent nameMoiseException
public void removeAgent(java.lang.String agId, boolean check) throws MoiseException
Example: currentOE.removeAgent("Jomi");
agId
- the agent id (the id is in OE)check
- if true, the moise consistencies will be checkedMoiseConsistencyException
- the must not have roles or missionsMoiseException
public OEAgent getAgent(java.lang.String agId)
public java.util.Collection<OEAgent> getAgents()
public java.util.Collection<OEAgent> getAgents(GroupInstance gr, java.lang.String roleId)
role
in gr
.
if gr == null, does not consider the grouppublic java.util.Collection<OEAgent> getAgents(GroupInstance gr, Role role)
role
in gr
.
if gr == null, the group is not consideredpublic GroupInstance addGroup(java.lang.String grSpecId) throws MoiseException
Example:
Group team = currentOE.addGroup("team");
grSpecId
- the group specification id (the id is in OS)MoiseConsistencyException
- the grSpecId is not a root groupMoiseCardinalityException
- the cardinality (the max subgroup is already achieved)MoiseException
public GroupInstance addGroup(java.lang.String grId, java.lang.String grSpecId) throws MoiseException
Example:
Group team = currentOE.addGroup("g1", "team");
grId
- the id of the new groupgrSpecId
- the group specification id (the id is in OS)MoiseConsistencyException
- the grSpecId is not a root groupMoiseCardinalityException
- the cardinality (the max subgroup is already achieved)MoiseException
public void removeGroup(java.lang.String grId) throws MoiseConsistencyException
Example: currentOE.removeGroup("gr_team0");
grId
- the group instance idMoiseConsistencyException
- the group has players, the group has subgroupspublic java.util.Collection<GroupInstance> getGroups()
public java.util.Collection<GroupInstance> getAllSubGroupsTree()
public int getSubGroupInstancesQty(java.lang.String grSpecId)
public GroupInstance findGroup(java.lang.String grId)
public java.util.Collection<GroupInstance> findInstancesOf(Group grSpec)
public java.util.Collection<GroupInstance> findInstancesOf(java.lang.String grSpec)
public SchemeInstance startScheme(java.lang.String schSpecId) throws MoiseException
Example: Scheme sch = currentOE.startScheme("sideAttack");
schSpecId
- the scheme specification (from OS)MoiseException
public SchemeInstance startScheme(java.lang.String schId, java.lang.String schSpecId) throws MoiseException
Example: Scheme sch = currentOE.startScheme("s1", "sideAttack");
schId
- the name of the new schemeschSpecId
- the scheme specification (from OS)MoiseException
public void finishScheme(SchemeInstance sch) throws MoiseException
Example: currentOE.finischScheme(satt);
where satt
is a Scheme handler.
sch
- the scheme instance object handlerMoiseException
- only schemes without players can be normally finishedpublic void abortScheme(SchemeInstance sch) throws MoiseException
Example: currentOE.abortScheme(satt);
where satt
is a Scheme handler.
sch
- the scheme instance object handlerMoiseException
public SchemeInstance findScheme(java.lang.String schId)
public java.util.Collection<SchemeInstance> findInstancesOfSchSpec(java.lang.String schSpecId)
public java.util.Collection<SchemeInstance> getSchemes()
public java.lang.String getXMLTag()
public org.w3c.dom.Element getAsDOM(org.w3c.dom.Document document)
public java.lang.String toString()
toString
in class java.lang.Object