copyright The Portico Project 2008.

org.portico.shared.model
Class OCInstance

java.lang.Object
  extended by org.portico.shared.model.OCInstance
All Implemented Interfaces:
Serializable

public class OCInstance
extends Object
implements Serializable

This class represents a specific object instance. It contains all the relevant information about the instance (such as name, handle and attributes).

See Also:
Serialized Form

Field Summary
private  Map<Integer,ACInstance> attributes
           
private  int handle
           
private  String name
           
private static long serialVersionUID
           
private  OCMetadata type
           
 
Constructor Summary
OCInstance()
           
OCInstance(int handle, String name, OCMetadata type)
           
 
Method Summary
 void addAllAttributes(Set<ACInstance> atts)
          This method will just call addAttribute(ACInstance) for each of the attributes contained in the given set.
 void addAttribute(ACInstance attribute)
          Stores the given attribute in this object instance.
 Set<ACInstance> getAllAttributes()
          Returns a set of all the contained attributes for this object instance.
 Set<ACInstance> getAllOwnedAttributes(int fedHandle)
          Returns a set of all the attribute instances contained within this instance that are owned by the federate of the given handle.
 ACInstance getAttribute(int handle)
          Fetch and return the contained attribute of the given handle.
 int getClassHandle()
           
 int getHandle()
           
 String getName()
           
 int getOwner()
          Returns the handle of the owning federate or PorticoConstants.NULL_HANDLE if it is not owned.
 OCMetadata getType()
           
 boolean isOwner(int federateHandle)
          Returns true if the given parameter is equal to result of getOwned(), false otherwise.
 ACInstance removeAttribute(int handle)
          Remove and return the attribute contained within this instance of the given handle.
 void setHandle(int handle)
           
 void setName(String name)
           
 void setType(OCMetadata type)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

serialVersionUID

private static final long serialVersionUID
See Also:
Constant Field Values

handle

private int handle

name

private String name

type

private OCMetadata type

attributes

private Map<Integer,ACInstance> attributes
Constructor Detail

OCInstance

public OCInstance()

OCInstance

public OCInstance(int handle,
                  String name,
                  OCMetadata type)
Method Detail

addAttribute

public void addAttribute(ACInstance attribute)
Stores the given attribute in this object instance. This will set the container of the instance to this OCInstance and will store it locally. No check is made to see if this is actually valid according to the FOM or not. The attributes are stored locally in a map, the key to which is the handle of the attribute (as defined from the FOM). If there is already an attribute for that attribute handle in this object, it will be overwritten.


addAllAttributes

public void addAllAttributes(Set<ACInstance> atts)
This method will just call addAttribute(ACInstance) for each of the attributes contained in the given set.


removeAttribute

public ACInstance removeAttribute(int handle)
Remove and return the attribute contained within this instance of the given handle. If there is no attribute for that handle, null will be returned. If there is, its contains variable will be set to null as it is removed and returned.


getAttribute

public ACInstance getAttribute(int handle)
Fetch and return the contained attribute of the given handle. If there is none, null will be returned.


getAllAttributes

public Set<ACInstance> getAllAttributes()
Returns a set of all the contained attributes for this object instance.


getAllOwnedAttributes

public Set<ACInstance> getAllOwnedAttributes(int fedHandle)
Returns a set of all the attribute instances contained within this instance that are owned by the federate of the given handle. If none are owned, an empty set is returned.


getHandle

public int getHandle()

setHandle

public void setHandle(int handle)

getName

public String getName()

setName

public void setName(String name)

getOwner

public int getOwner()
Returns the handle of the owning federate or PorticoConstants.NULL_HANDLE if it is not owned. This method will look for the privilegeToDelete attribute within the instance and return the owner of that. If it can't be found for any reason, PorticoConstants.NULL_HANDLER will be returned.

The "owner" of the instance is defined as the federate that holds ownership of the privilegeToDelete attribute.


isOwner

public boolean isOwner(int federateHandle)
Returns true if the given parameter is equal to result of getOwned(), false otherwise.

The "owner" of the instance is defined as the federate that holds ownership of the privilegeToDelete attribute.


getType

public OCMetadata getType()

setType

public void setType(OCMetadata type)

getClassHandle

public int getClassHandle()

copyright The Portico Project 2008.