Package moise.oe
Class GroupInstance
java.lang.Object
moise.common.MoiseElement
moise.oe.GroupInstance
- All Implemented Interfaces:
java.io.Serializable,java.lang.Comparable,Identifiable,ToXML
public class GroupInstance extends MoiseElement implements ToXML
Represents the instance group of one Group Specification
- Author:
- Jomi Fred Hubner
- See Also:
- Serialized Form
-
Field Summary
Fields Modifier and Type Field Description private static java.util.concurrent.atomic.AtomicIntegergrCountprivate static java.util.logging.Loggerloggerprotected OEoeprotected java.util.Set<RolePlayer>playersprivate static longserialVersionUIDprotected Groupspecprotected java.util.Map<java.lang.String,GroupInstance>subGroupsprotected GroupInstancesuperGroupFields inherited from class moise.common.MoiseElement
debug -
Constructor Summary
Constructors Modifier Constructor Description protectedGroupInstance(java.lang.String id, Group spec)create a new group instance identified by id -
Method Summary
Modifier and Type Method Description voidaddPlayer(RolePlayer rp)adds a role player in this groupGroupInstanceaddSubGroup(java.lang.String grSpecId)Adds a subgroup in a group, the id of the subgroup is defined automatically.GroupInstanceaddSubGroup(java.lang.String grId, java.lang.String grSpecId)Adds a subgroup in a group.voidcheckRemove()GroupInstancefindGroup(java.lang.String grId)looks for a group with grId in this Group (and its subgroups)java.util.Collection<GroupInstance>findInstancesOf(Group grSpec)get all groups (and subgroups) that instantiates grSpecjava.util.Set<OEAgent>getAgents(boolean includeSubGroups)returns a collection with OEAgents belonging to this groupjava.util.Collection<GroupInstance>getAllSubGroupsTree()gets this group and all its sub groups, the sob-groups of the subgroups, .....org.w3c.dom.ElementgetAsDOM(org.w3c.dom.Document document)GroupgetGrSpec()java.util.Collection<RolePlayer>getPlayers()returns an iterator for RolePlayer objectsjava.util.Collection<RolePlayer>getPlayers(java.lang.String roleId, boolean includeSubGroups)returns the roleId players in this group (includeSubGroups==false) or in this group and its subgroups (includeSubGroups==true).intgetPlayersQty()returns the total number of players in this group (does not consider players in subgroups)java.util.Collection<SchemeInstance>getRespSchemes()returns a set of schemes which this group is responsible forintgetSubGroupInstacesQty()returns the number of subgroups instancesintgetSubGroupInstacesQty(java.lang.String grSpecId)returns the number of grSpecId instancesjava.util.Collection<GroupInstance>getSubGroups()GroupInstancegetSuperGroup()static java.lang.StringgetUniqueId()create a new group instance named automaticallystatic java.lang.StringgetXMLTag()booleanisWellFormed()voidrebuildHash()since serialisation of maps has a bug, we need to rebuild them after serialisation!voidremovePlayer(RolePlayer rp)removes a role player from this groupprotected voidremoveRelations()voidremoveSubGroup(java.lang.String grId)Removes a subgroup instance from this group.protected voidsetOE(OE oe)returns the unique number of the group (the getId uses this number to form the unique id.protected voidsetSuperGroup(GroupInstance gr)java.lang.StringwellFormedStatus()returns "ok" if the group is well formed, otherwise returns the problems descriptionMethods inherited from class moise.common.MoiseElement
compareTo, equals, getBoolProperty, getBoolProperty, getCreationDate, getFullId, getId, getId, getOwner, getPrefix, getPrefix, getProperties, getPropertiesAsDOM, getPropertiesAsProlog, getProperty, getStrProperty, hashCode, setId, setOwner, setPrefix, setPropertiesFromDOM, setProperty, toStringMethods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
-
Field Details
-
spec
-
superGroup
-
oe
-
subGroups
-
players
-
logger
private static java.util.logging.Logger logger -
serialVersionUID
private static final long serialVersionUID- See Also:
- Constant Field Values
-
grCount
private static java.util.concurrent.atomic.AtomicInteger grCount
-
-
Constructor Details
-
GroupInstance
create a new group instance identified by id- Throws:
MoiseConsistencyException
-
-
Method Details
-
rebuildHash
public void rebuildHash()since serialisation of maps has a bug, we need to rebuild them after serialisation! -
getUniqueId
public static java.lang.String getUniqueId()create a new group instance named automatically -
getGrSpec
-
setOE
returns the unique number of the group (the getId uses this number to form the unique id. -
setSuperGroup
-
getSuperGroup
-
isWellFormed
public boolean isWellFormed() -
wellFormedStatus
public java.lang.String wellFormedStatus()returns "ok" if the group is well formed, otherwise returns the problems description -
getRespSchemes
returns a set of schemes which this group is responsible for -
addSubGroup
Adds a subgroup in a group, the id of the subgroup is defined automatically.Example:
Group def = team.addSubGroup("defense");- Parameters:
grId- the id of the new groupgrSpecId- the group specification identification (from OS)- Returns:
- the Group object created
- Throws:
MoiseConsistencyException- the grSpecId is not a subgroup of this groupMoiseCardinalityException- the cardinality (the max subgroup is already achieved)MoiseException
-
addSubGroup
public GroupInstance addSubGroup(java.lang.String grId, java.lang.String grSpecId) throws MoiseExceptionAdds a subgroup in a group.Example:
Group def = team.addSubGroup("d1", "defense");- Parameters:
grId- the id of the new groupgrSpecId- the group specification identification (from OS)- Returns:
- the Group object created
- Throws:
MoiseConsistencyException- the grSpecId is not a subgroup of this groupMoiseCardinalityException- the cardinality (the max subgroup is already achieved)MoiseException
-
removeSubGroup
Removes a subgroup instance from this group.Example:
att.removeSubGroup("gr_defense1");- Parameters:
grId- the group instance id- Throws:
MoiseConsistencyException- the grId is not a subgroup, the group has players, the group has subgroups
-
removeRelations
- Throws:
MoiseConsistencyException
-
checkRemove
- Throws:
MoiseConsistencyException
-
getSubGroupInstacesQty
public int getSubGroupInstacesQty()returns the number of subgroups instances -
getSubGroupInstacesQty
public int getSubGroupInstacesQty(java.lang.String grSpecId)returns the number of grSpecId instances -
getSubGroups
-
getAllSubGroupsTree
gets this group and all its sub groups, the sob-groups of the subgroups, ..... -
findGroup
looks for a group with grId in this Group (and its subgroups) -
findInstancesOf
get all groups (and subgroups) that instantiates grSpec -
addPlayer
adds a role player in this group -
removePlayer
removes a role player from this group -
getPlayers
returns an iterator for RolePlayer objects -
getPlayersQty
public int getPlayersQty()returns the total number of players in this group (does not consider players in subgroups) -
getPlayers
public java.util.Collection<RolePlayer> getPlayers(java.lang.String roleId, boolean includeSubGroups)returns the roleId players in this group (includeSubGroups==false) or in this group and its subgroups (includeSubGroups==true). It returns a collection of OEAgent objects. If roleId is null, all roles are included in the result. -
getAgents
returns a collection with OEAgents belonging to this group -
getXMLTag
public static java.lang.String getXMLTag() -
getAsDOM
public org.w3c.dom.Element getAsDOM(org.w3c.dom.Document document)
-