rescuecore
Class Property

java.lang.Object
  extended byrescuecore.Property
All Implemented Interfaces:
RescueConstants, java.io.Serializable

public class Property
extends java.lang.Object
implements RescueConstants, java.io.Serializable

This class encapsulates information about an individual property within a RescueObject

See Also:
Serialized Form

Field Summary
 
Fields inherited from interface rescuecore.RescueConstants
AGENT_TYPE_AMBULANCE_CENTER, AGENT_TYPE_AMBULANCE_TEAM, AGENT_TYPE_ANY, AGENT_TYPE_ANY_AGENT, AGENT_TYPE_ANY_BUILDING, AGENT_TYPE_ANY_MOBILE, AGENT_TYPE_CIVILIAN, AGENT_TYPE_FIRE_BRIGADE, AGENT_TYPE_FIRE_STATION, AGENT_TYPE_POLICE_FORCE, AGENT_TYPE_POLICE_OFFICE, AK_ACKNOWLEDGE, AK_CLEAR, AK_CONNECT, AK_EXTINGUISH, AK_LOAD, AK_MOVE, AK_RESCUE, AK_REST, AK_SAY, AK_TELL, AK_UNLOAD, BYTE_SIZE, COMMAND_ACKNOWLEDGE, COMMAND_CLEAR, COMMAND_CONNECT, COMMAND_EXTINGUISH, COMMAND_LOAD, COMMAND_MOVE, COMMAND_RESCUE, COMMAND_REST, COMMAND_SAY, COMMAND_TELL, COMMAND_UNLOAD, FIERYNESS_BURNING, FIERYNESS_BURNT_OUT, FIERYNESS_HEATING, FIERYNESS_INFERNO, FIERYNESS_MODERATELY_BURNT, FIERYNESS_NOT_BURNT, FIERYNESS_SLIGHTLY_BURNT, FIERYNESS_VERY_BURNT, GK_CONNECT_ERROR, GK_CONNECT_OK, HEADER_NULL, INT_SIZE, INTERNAL_TYPE_AMBULANCE_CENTER, INTERNAL_TYPE_AMBULANCE_TEAM, INTERNAL_TYPE_ANY_BUILDING, INTERNAL_TYPE_ANY_HUMANOID, INTERNAL_TYPE_ANY_PLATOON, INTERNAL_TYPE_BUILDING, INTERNAL_TYPE_CAR, INTERNAL_TYPE_CIVILIAN, INTERNAL_TYPE_FIRE_BRIGADE, INTERNAL_TYPE_FIRE_STATION, INTERNAL_TYPE_NODE, INTERNAL_TYPE_POLICE_FORCE, INTERNAL_TYPE_POLICE_OFFICE, INTERNAL_TYPE_REFUGE, INTERNAL_TYPE_RIVER, INTERNAL_TYPE_RIVER_NODE, INTERNAL_TYPE_ROAD, INTERNAL_TYPE_WORLD, KA_CONNECT_ERROR, KA_CONNECT_OK, KA_HEAR, KA_SENSE, KG_ACKNOWLEDGE, KG_CONNECT, KG_UPDATE, KS_COMMANDS, KS_CONNECT_ERROR, KS_CONNECT_OK, KS_UPDATE, KV_CONNECT_ERROR, KV_CONNECT_OK, KV_UPDATE, MAX_CENTER_MESSAGES, MAX_EXTINGUISH_DISTANCE, MAX_EXTINGUISH_POWER, MAX_HP, MAX_PLATOON_MESSAGES, MAX_RESCUE_DISTANCE, MAX_WATER, PROPERTY_BLOCK, PROPERTY_BROKENNESS, PROPERTY_BUILDING_APEXES, PROPERTY_BUILDING_AREA_GROUND, PROPERTY_BUILDING_AREA_TOTAL, PROPERTY_BUILDING_ATTRIBUTES, PROPERTY_BUILDING_CODE, PROPERTY_BUILDING_SHAPE_ID, PROPERTY_BURIEDNESS, PROPERTY_CARS_PASS_TO_HEAD, PROPERTY_CARS_PASS_TO_TAIL, PROPERTY_DAMAGE, PROPERTY_DIRECTION, PROPERTY_EDGES, PROPERTY_ENTRANCES, PROPERTY_FIERYNESS, PROPERTY_FLOORS, PROPERTY_HEAD, PROPERTY_HP, PROPERTY_HUMANS_PASS_TO_HEAD, PROPERTY_HUMANS_PASS_TO_TAIL, PROPERTY_IGNITION, PROPERTY_LATITUDE, PROPERTY_LENGTH, PROPERTY_LINES_TO_HEAD, PROPERTY_LINES_TO_TAIL, PROPERTY_LONGITUDE, PROPERTY_MAX, PROPERTY_MEDIAN_STRIP, PROPERTY_NULL, PROPERTY_POCKET_TO_TURN_ACROSS, PROPERTY_POSITION, PROPERTY_POSITION_EXTRA, PROPERTY_POSITION_HISTORY, PROPERTY_REPAIR_COST, PROPERTY_ROAD_KIND, PROPERTY_SHORTCUT_TO_TURN, PROPERTY_SIGNAL, PROPERTY_SIGNAL_TIMING, PROPERTY_STAMINA, PROPERTY_START_TIME, PROPERTY_STRETCHED_LENGTH, PROPERTY_TAIL, PROPERTY_TYPE_BOOLEAN, PROPERTY_TYPE_INT, PROPERTY_TYPE_INT_ARRAY, PROPERTY_WATER_QUANTITY, PROPERTY_WIDTH, PROPERTY_WIDTH_FOR_WALKERS, PROPERTY_WIND_DIRECTION, PROPERTY_WIND_FORCE, PROPERTY_X, PROPERTY_Y, SAY_LENGTH, SHORT_SIZE, SK_ACKNOWLEDGE, SK_CONNECT, SK_UPDATE, TELL_LENGTH, TYPE_AMBULANCE_CENTER, TYPE_AMBULANCE_TEAM, TYPE_BUILDING, TYPE_CAR, TYPE_CIVILIAN, TYPE_FIRE_BRIGADE, TYPE_FIRE_STATION, TYPE_NODE, TYPE_NULL, TYPE_POLICE_FORCE, TYPE_POLICE_OFFICE, TYPE_REFUGE, TYPE_RIVER, TYPE_RIVER_NODE, TYPE_ROAD, TYPE_WORLD, VK_ACKNOWLEDGE, VK_CONNECT
 
Method Summary
 boolean decode(java.io.DataInput in, int timestamp)
          Decode an update from the kernel.
 boolean getBooleanValue()
          Get the value of this property as a boolean.
 int[] getIntArrayValue()
          Get the value of this property as an integer array.
 int getIntValue()
          Get the value of this property as an integer.
 int getLastUpdate()
          Get the last time this property was updated
 int getPropertyType()
          Get the type of this property
 java.lang.String getStringValue()
          Get the value of this property as a string
 int getValueType()
          Get the data type of this property
 boolean isOlderThan(int time)
          Find out whether this property was last updated before a certain time
 boolean isValueKnown()
          Find out whether the value of this property is known or assumed
static Property make(int property)
          Generate a new Property of a particular type
 boolean setValue(boolean value, int timestamp)
          Set the boolean value of this property.
 boolean setValue(int[] value, int timestamp)
          Set the integer array value of this property.
 boolean setValue(int value, int timestamp)
          Set the integer value of this property.
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Method Detail

make

public static Property make(int property)
                     throws UnknownPropertyException
Generate a new Property of a particular type

Parameters:
property - The property we are interested in
Returns:
A Property object that holds the relevant information about the given property
Throws:
UnknownPropertyException - if 'property' is not recognised
See Also:
RescueConstants.PROPERTY_START_TIME, RescueConstants.PROPERTY_LONGITUDE, RescueConstants.PROPERTY_LATITUDE, RescueConstants.PROPERTY_WIND_FORCE, RescueConstants.PROPERTY_WIND_DIRECTION, RescueConstants.PROPERTY_X, RescueConstants.PROPERTY_Y, RescueConstants.PROPERTY_DIRECTION, RescueConstants.PROPERTY_POSITION, RescueConstants.PROPERTY_POSITION_EXTRA, RescueConstants.PROPERTY_STAMINA, RescueConstants.PROPERTY_HP, RescueConstants.PROPERTY_DAMAGE, RescueConstants.PROPERTY_BURIEDNESS, RescueConstants.PROPERTY_FLOORS, RescueConstants.PROPERTY_BUILDING_ATTRIBUTES, RescueConstants.PROPERTY_BROKENNESS, RescueConstants.PROPERTY_FIERYNESS, RescueConstants.PROPERTY_BUILDING_SHAPE_ID, RescueConstants.PROPERTY_BUILDING_CODE, RescueConstants.PROPERTY_BUILDING_AREA_GROUND, RescueConstants.PROPERTY_BUILDING_AREA_TOTAL, RescueConstants.PROPERTY_WATER_QUANTITY, RescueConstants.PROPERTY_STRETCHED_LENGTH, RescueConstants.PROPERTY_HEAD, RescueConstants.PROPERTY_TAIL, RescueConstants.PROPERTY_LENGTH, RescueConstants.PROPERTY_ROAD_KIND, RescueConstants.PROPERTY_CARS_PASS_TO_HEAD, RescueConstants.PROPERTY_CARS_PASS_TO_TAIL, RescueConstants.PROPERTY_HUMANS_PASS_TO_HEAD, RescueConstants.PROPERTY_HUMANS_PASS_TO_TAIL, RescueConstants.PROPERTY_WIDTH, RescueConstants.PROPERTY_BLOCK, RescueConstants.PROPERTY_REPAIR_COST, RescueConstants.PROPERTY_LINES_TO_HEAD, RescueConstants.PROPERTY_LINES_TO_TAIL, RescueConstants.PROPERTY_WIDTH_FOR_WALKERS, RescueConstants.PROPERTY_IGNITION, RescueConstants.PROPERTY_MEDIAN_STRIP, RescueConstants.PROPERTY_SIGNAL, RescueConstants.PROPERTY_SHORTCUT_TO_TURN, RescueConstants.PROPERTY_POCKET_TO_TURN_ACROSS, RescueConstants.PROPERTY_POSITION_HISTORY, RescueConstants.PROPERTY_ENTRANCES, RescueConstants.PROPERTY_BUILDING_APEXES, RescueConstants.PROPERTY_EDGES, RescueConstants.PROPERTY_SIGNAL_TIMING

getPropertyType

public int getPropertyType()
Get the type of this property

Returns:
The type of this property
See Also:
RescueConstants.PROPERTY_START_TIME, RescueConstants.PROPERTY_LONGITUDE, RescueConstants.PROPERTY_LATITUDE, RescueConstants.PROPERTY_WIND_FORCE, RescueConstants.PROPERTY_WIND_DIRECTION, RescueConstants.PROPERTY_X, RescueConstants.PROPERTY_Y, RescueConstants.PROPERTY_DIRECTION, RescueConstants.PROPERTY_POSITION, RescueConstants.PROPERTY_POSITION_EXTRA, RescueConstants.PROPERTY_STAMINA, RescueConstants.PROPERTY_HP, RescueConstants.PROPERTY_DAMAGE, RescueConstants.PROPERTY_BURIEDNESS, RescueConstants.PROPERTY_FLOORS, RescueConstants.PROPERTY_BUILDING_ATTRIBUTES, RescueConstants.PROPERTY_BROKENNESS, RescueConstants.PROPERTY_FIERYNESS, RescueConstants.PROPERTY_BUILDING_SHAPE_ID, RescueConstants.PROPERTY_BUILDING_CODE, RescueConstants.PROPERTY_BUILDING_AREA_GROUND, RescueConstants.PROPERTY_BUILDING_AREA_TOTAL, RescueConstants.PROPERTY_WATER_QUANTITY, RescueConstants.PROPERTY_STRETCHED_LENGTH, RescueConstants.PROPERTY_HEAD, RescueConstants.PROPERTY_TAIL, RescueConstants.PROPERTY_LENGTH, RescueConstants.PROPERTY_ROAD_KIND, RescueConstants.PROPERTY_CARS_PASS_TO_HEAD, RescueConstants.PROPERTY_CARS_PASS_TO_TAIL, RescueConstants.PROPERTY_HUMANS_PASS_TO_HEAD, RescueConstants.PROPERTY_HUMANS_PASS_TO_TAIL, RescueConstants.PROPERTY_WIDTH, RescueConstants.PROPERTY_BLOCK, RescueConstants.PROPERTY_REPAIR_COST, RescueConstants.PROPERTY_LINES_TO_HEAD, RescueConstants.PROPERTY_LINES_TO_TAIL, RescueConstants.PROPERTY_WIDTH_FOR_WALKERS, RescueConstants.PROPERTY_IGNITION, RescueConstants.PROPERTY_MEDIAN_STRIP, RescueConstants.PROPERTY_SIGNAL, RescueConstants.PROPERTY_SHORTCUT_TO_TURN, RescueConstants.PROPERTY_POCKET_TO_TURN_ACROSS, RescueConstants.PROPERTY_POSITION_HISTORY, RescueConstants.PROPERTY_ENTRANCES, RescueConstants.PROPERTY_BUILDING_APEXES, RescueConstants.PROPERTY_EDGES, RescueConstants.PROPERTY_SIGNAL_TIMING

getValueType

public int getValueType()
Get the data type of this property

Returns:
The data type of this property
See Also:
RescueConstants.PROPERTY_TYPE_INT, RescueConstants.PROPERTY_TYPE_INT_ARRAY, RescueConstants.PROPERTY_TYPE_BOOLEAN

getLastUpdate

public int getLastUpdate()
Get the last time this property was updated

Returns:
The last time this property was updated

isOlderThan

public boolean isOlderThan(int time)
Find out whether this property was last updated before a certain time

Parameters:
time - The time to check against
Returns:
true if and only if this property was last updated before the given time

isValueKnown

public boolean isValueKnown()
Find out whether the value of this property is known or assumed

Returns:
true if and only if the value of this property is known - i.e. it was last updated after timestep zero

getIntValue

public int getIntValue()
Get the value of this property as an integer. If this property is not represented as an integer normally, then the result will probably be zero.

Returns:
The integer value of this property
See Also:
getValueType()

getIntArrayValue

public int[] getIntArrayValue()
Get the value of this property as an integer array. If this property is not represented as an integer array normally, then the result will probably be null.

Returns:
The integer array value of this property
See Also:
getValueType()

getBooleanValue

public boolean getBooleanValue()
Get the value of this property as a boolean. If this property is not represented as a boolean normally, then the result will probably be false.

Returns:
The boolean value of this property
See Also:
getValueType()

toString

public java.lang.String toString()

getStringValue

public java.lang.String getStringValue()
Get the value of this property as a string

Returns:
A nice string representation of the value of this property

setValue

public boolean setValue(int value,
                        int timestamp)
Set the integer value of this property. The timestamp will also be updated. Note that this method does not check that the update is newer than the current value - it is up to the application to test for this.

Parameters:
value - The new value
timestamp - The timestamp of this update
Returns:
true if and only if the value was actually changed
See Also:
isOlderThan(int), getValueType()

setValue

public boolean setValue(int[] value,
                        int timestamp)
Set the integer array value of this property. The timestamp will also be updated. Note that this method does not check that the update is newer than the current value - it is up to the application to test for this.

Parameters:
value - The new value
timestamp - The timestamp of this update
Returns:
true if and only if the value was actually changed
See Also:
isOlderThan(int), getValueType()

setValue

public boolean setValue(boolean value,
                        int timestamp)
Set the boolean value of this property. The timestamp will also be updated. Note that this method does not check that the update is newer than the current value - it is up to the application to test for this.

Parameters:
value - The new value
timestamp - The timestamp of this update
Returns:
true if and only if the value was actually changed
See Also:
isOlderThan(int), getValueType()

decode

public boolean decode(java.io.DataInput in,
                      int timestamp)
               throws java.io.IOException
Decode an update from the kernel. This will usually be from a KA_SENSE or KA_CONNECT_OK message.

Parameters:
in - A DataInput to read data from
timestamp - The timestamp of this update
Returns:
true if and only if a change was made. A change is considered to be made if two conditions hold: timestamp > last update AND the new value is different to the old value
Throws:
java.io.IOException - if something goes wrong