copyright The Portico Project 2008.

org.portico.shared.model
Class RegionInstance

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

public class RegionInstance
extends Object
implements Serializable

This class represents a HLA 1.3 Region.

A RegionInstance contains a number of Extent, where each Extent contains a set of upper and lower bounds for a number of Dimensions. Extents are contained within the RegionInstance in an array, so you must specify the size etc... on construction. A RegionInstance is also linked to a single routing Space.

See Also:
Serialized Form

Field Summary
private  Extent[] extents
           
private  int federateHandle
           
private  int regionToken
           
private static long serialVersionUID
           
private  int spaceHandle
           
 
Constructor Summary
private RegionInstance(int regionToken, int federateHandle, int spaceHandle, int extentCount)
          This constructor is used in the clone() method only.
  RegionInstance(int federateHandle, Space space, int extentCount)
           
 
Method Summary
private  void checkIndex(int index)
          Checks the provided index to make sure it is valid for this Region (greater than 0 and less than the number of contained extents-1).
 RegionInstance clone()
          This method will do a deep-copy of the current , returning the new instance such that it has all the values that the original (current) instance has.
 void copy(RegionInstance other)
          Remove any current state and copy all the values from the given RegionInstance to this one.
 boolean equals(Object other)
          Returns true if the parameter is an instance of RegionInstance and it has the same region token as the current instance, false otherwise.
 Extent getExtent(int index)
          Get the extent at the given index.
 int getFederateHandle()
          Returns the handle of the federate that created this region
 long getNumberOfExtents()
           
 long getRangeLowerBound(int index, int dimension)
           
 long getRangeLowerBoundNotificationLimit(int extentHandle, int dimensionHandle)
          For now, this just returns the exact same value as getRangeLowerBound(int, int)
 long getRangeUpperBound(int index, int dimension)
           
 long getRangeUpperBoundNotificationLimit(int extentHandle, int dimensionHandle)
          For now, this just returns the exact same value as getRangeUpperBound(int, int)
 int getSize()
          Get the number of extents stored in this region
 int getSpaceHandle()
           
 int getToken()
          Get the unique handle for this region instance
 boolean overlapsWith(RegionInstance other)
          This method will return true if the given region overlaps with the other region, false otherwise.
 void setExtent(Extent extent, int index)
          Set the extent at the given index.
 void setRangeLowerBound(int index, int dimension, long bound)
          Modify lower bound of extent along indicated dimension.
 void setRangeUpperBound(int index, int dimension, long bound)
          Modify upper bound of extent along indicated dimension.
 void setToken(int regionHandle)
          Set the unique handle for this region instance
 String toString()
           
 String toVerboseString()
          Generates a verbose string outlining the current state of the region.
 
Methods inherited from class java.lang.Object
finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

serialVersionUID

private static final long serialVersionUID
See Also:
Constant Field Values

spaceHandle

private int spaceHandle

regionToken

private int regionToken

extents

private Extent[] extents

federateHandle

private int federateHandle
Constructor Detail

RegionInstance

public RegionInstance(int federateHandle,
                      Space space,
                      int extentCount)

RegionInstance

private RegionInstance(int regionToken,
                       int federateHandle,
                       int spaceHandle,
                       int extentCount)
This constructor is used in the clone() method only. It doesn't require a Space as it doesn't need to build the entire instance from scratch.

Method Detail

clone

public RegionInstance clone()
This method will do a deep-copy of the current , returning the new instance such that it has all the values that the original (current) instance has.

Overrides:
clone in class Object

copy

public void copy(RegionInstance other)
Remove any current state and copy all the values from the given RegionInstance to this one. Note that this is a semi-clone in that it will create new instances of all the contained Extents, rather than just using the same references that exist in the other region. This way, changes to the other region will not affect this region.


equals

public boolean equals(Object other)
Returns true if the parameter is an instance of RegionInstance and it has the same region token as the current instance, false otherwise. Note that only the token is checked. The values contained in the two instances could be totally different (if one had been changed locally for example).

Overrides:
equals in class Object

checkIndex

private void checkIndex(int index)
                 throws JArrayIndexOutOfBounds
Checks the provided index to make sure it is valid for this Region (greater than 0 and less than the number of contained extents-1). If the index is not OK, an exception will be thrown.

Throws:
JArrayIndexOutOfBounds

getExtent

public Extent getExtent(int index)
                 throws JArrayIndexOutOfBounds
Get the extent at the given index. If the index is below 0 or greater than the number of extents in this region, an exception will be thrown.

Throws:
JArrayIndexOutOfBounds

getSize

public int getSize()
Get the number of extents stored in this region


setExtent

public void setExtent(Extent extent,
                      int index)
               throws JArrayIndexOutOfBounds
Set the extent at the given index. If the index is below 0 or greater than the number of extents in this region, an exception will be thrown. If the extent is null, the call will be ignored and no addition will be made.

If an Extent already exists at the given index, it will be overwritten.

Throws:
JArrayIndexOutOfBounds

getToken

public int getToken()
Get the unique handle for this region instance


setToken

public void setToken(int regionHandle)
Set the unique handle for this region instance


getFederateHandle

public int getFederateHandle()
Returns the handle of the federate that created this region

Returns:

overlapsWith

public boolean overlapsWith(RegionInstance other)
This method will return true if the given region overlaps with the other region, false otherwise. This method will compare each of the Extents in this region, with each of the Extents in the other region. If *any* extent from this region overlaps with one from the other region, then true will be returned.


toString

public String toString()
Overrides:
toString in class Object

toVerboseString

public String toVerboseString()
Generates a verbose string outlining the current state of the region. This string include full extent data, so it could be quite large.


getNumberOfExtents

public long getNumberOfExtents()
Returns:
long Number of extents in this Region

getRangeLowerBound

public long getRangeLowerBound(int index,
                               int dimension)
                        throws JArrayIndexOutOfBounds
Parameters:
extentIndex - int
dimensionHandle - int
Returns:
long Lower bound of extent along indicated dimension
Throws:
JArrayIndexOutOfBounds

getRangeUpperBound

public long getRangeUpperBound(int index,
                               int dimension)
                        throws JArrayIndexOutOfBounds
Parameters:
extentIndex - int
dimensionHandle - int
Returns:
long Upper bound of extent along indicated dimension
Throws:
JArrayIndexOutOfBounds

getSpaceHandle

public int getSpaceHandle()
Returns:
int Handle of routing space of which this Region is a subset

setRangeLowerBound

public void setRangeLowerBound(int index,
                               int dimension,
                               long bound)
                        throws JArrayIndexOutOfBounds
Modify lower bound of extent along indicated dimension.

Parameters:
extentIndex - int
dimensionHandle - int
newLowerBound - long
Throws:
JArrayIndexOutOfBounds

setRangeUpperBound

public void setRangeUpperBound(int index,
                               int dimension,
                               long bound)
                        throws JArrayIndexOutOfBounds
Modify upper bound of extent along indicated dimension.

Parameters:
extentIndex - int
dimensionHandle - int
newUpperBound - long
Throws:
JArrayIndexOutOfBounds

getRangeLowerBoundNotificationLimit

public long getRangeLowerBoundNotificationLimit(int extentHandle,
                                                int dimensionHandle)
                                         throws JArrayIndexOutOfBounds
For now, this just returns the exact same value as getRangeLowerBound(int, int)

Throws:
JArrayIndexOutOfBounds

getRangeUpperBoundNotificationLimit

public long getRangeUpperBoundNotificationLimit(int extentHandle,
                                                int dimensionHandle)
                                         throws JArrayIndexOutOfBounds
For now, this just returns the exact same value as getRangeUpperBound(int, int)

Throws:
JArrayIndexOutOfBounds

copyright The Portico Project 2008.