|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectrescuecore.Handy
A collection of useful methods
Field Summary |
Method Summary | |
static java.lang.String |
arrayAsString(int[] array)
Turn an array of integers into a String containing a comma-seperated list of numbers |
static byte |
decodeByte(byte[] buffer,
int off)
Decode a byte from a buffer |
static byte[] |
decodeBytes(byte[] buffer,
int off,
int length)
Decode a byte array from a buffer |
static int |
decodeInt(byte[] buffer,
int off)
Decode an int from a buffer |
static short |
decodeShort(byte[] buffer,
int off)
Decode a short from a buffer |
static java.lang.String |
decodeString(byte[] buffer,
int off,
int length)
Decode a String from a buffer |
static byte[] |
encodeByte(int value)
Encode a byte into a byte array |
static void |
encodeByte(int value,
byte[] buf,
int off)
Encode a byte into a buffer |
static void |
encodeBytes(byte[] bytes,
byte[] buf,
int off)
Encode a byte arrray into a buffer |
static void |
encodeBytes(byte[] bytes,
int bytesOffset,
int bytesLength,
byte[] buf,
int off)
Encode part of a byte array into a buffer |
static byte[] |
encodeInt(int value)
Encode an int into a byte array |
static void |
encodeInt(int value,
byte[] buf,
int off)
Encode an int into a buffer |
static byte[] |
encodeShort(int value)
Encode a short into a byte array |
static void |
encodeShort(int value,
byte[] buf,
int off)
Encode a short into a buffer |
static byte[] |
encodeString(java.lang.String value,
int length)
Encode a String into a byte array |
static void |
encodeString(java.lang.String value,
int length,
byte[] buf,
int off)
Encode a String into a buffer |
static java.lang.String |
getAgentTypeName(int type)
Turn an agent type into a human-readable String |
static java.lang.String |
getCommandTypeName(int header)
Translate a command type into a human-readable string |
static java.lang.String |
getPropertyName(int type)
Translate a property name into a human-readable string |
static java.lang.String |
getTypeName(int type)
Translate a type name into a human-readable string |
static java.lang.String |
hex(byte b)
Turn a byte into a hexadecimal String |
static boolean |
isDifferent(int[] a,
int[] b)
Find out if two int arrays are different. |
static void |
printBytes(byte[] data)
Print an array of bytes to System.out in a nice way |
static void |
printBytes(int startIndex,
byte[] data,
java.lang.String description)
Print four bytes to System.out in a nice way |
static void |
printBytes(java.lang.String header,
byte[] data)
Print an array of bytes to System.out in a nice way |
static void |
printCommand(Command c)
Write out the contents and description of a command - this is useful for debugging |
static void |
printKA_CONNECT_OK(byte[] data)
Write out the contents and description of a KA_CONNECT_OK command |
static void |
printKA_SENSE(byte[] data)
Write out the contents and description of a KA_SENSE command |
static int |
printObject(int index,
byte[] data)
Write out the contents of a RescueObject update with the relevant bytes |
static int |
printProperty(int index,
byte[] data)
Write out the contents of a property update with the relevant bytes |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Method Detail |
public static void printBytes(byte[] data)
data
- The bytes to print outpublic static void printBytes(java.lang.String header, byte[] data)
header
- A string to print out as a titledata
- The bytes to print outpublic static void printCommand(Command c)
c
- The command to print outpublic static void printKA_CONNECT_OK(byte[] data)
data
- The body of the commandpublic static void printKA_SENSE(byte[] data)
data
- The body of the commandpublic static int printObject(int index, byte[] data)
index
- The index into the buffer to read this RescueObject fromdata
- The buffer containing update data
public static int printProperty(int index, byte[] data)
index
- The index into the buffer to read this property fromdata
- The buffer containing update data
public static void printBytes(int startIndex, byte[] data, java.lang.String description)
startIndex
- The index of the first bytedata
- The buffer containing the bytes to print outdescription
- A description of what these four bytes actually meanpublic static java.lang.String hex(byte b)
b
- The byte to convert
public static byte decodeByte(byte[] buffer, int off)
buffer
- The buffer we are looking atoff
- The offset into the buffer to start decoding from
public static byte[] decodeBytes(byte[] buffer, int off, int length)
buffer
- The buffer we are looking atoff
- The offset into the buffer to start decoding fromlength
- The number of bytes to read
public static short decodeShort(byte[] buffer, int off)
buffer
- The buffer we are looking atoff
- The offset into the buffer to start decoding from
public static int decodeInt(byte[] buffer, int off)
buffer
- The buffer we are looking atoff
- The offset into the buffer to start decoding from
public static java.lang.String decodeString(byte[] buffer, int off, int length)
buffer
- The buffer we are looking atoff
- The offset into the buffer to start decoding fromlength
- The maximum number of characters in the String
public static byte[] encodeByte(int value)
value
- The byte to encode
public static void encodeByte(int value, byte[] buf, int off)
value
- The byte to encodebuf
- The buffer to write the result intooff
- The offset to start writing atpublic static void encodeBytes(byte[] bytes, byte[] buf, int off)
bytes
- The byte array to encodebuf
- The buffer to write the result intooff
- The offset to start writing atpublic static void encodeBytes(byte[] bytes, int bytesOffset, int bytesLength, byte[] buf, int off)
bytes
- The byte arrray to encodebytesOffset
- The offset into bytes to start writing frombytesLength
- The number of bytes to writebuf
- The buffer to write the result intooff
- The offset to start writing atpublic static byte[] encodeShort(int value)
value
- The short to encode
public static void encodeShort(int value, byte[] buf, int off)
value
- The short to encodebuf
- The buffer to write the result intooff
- The offset to start writing atpublic static byte[] encodeInt(int value)
value
- The int to encode
public static void encodeInt(int value, byte[] buf, int off)
value
- The int to encodebuf
- The buffer to write the result intooff
- The offset to start writing atpublic static byte[] encodeString(java.lang.String value, int length)
value
- The String to encodelength
- The maximum number of bytes to use
public static void encodeString(java.lang.String value, int length, byte[] buf, int off)
value
- The String to encodelength
- The maximum number of bytes to writebuf
- The buffer to write the result intooff
- The offset to start writing atpublic static boolean isDifferent(int[] a, int[] b)
a
- The first arrayb
- The second array
public static java.lang.String getTypeName(int type)
type
- The type we want to convert
RescueConstants.TYPE_CIVILIAN
,
RescueConstants.TYPE_FIRE_BRIGADE
,
RescueConstants.TYPE_AMBULANCE_TEAM
,
RescueConstants.TYPE_POLICE_FORCE
,
RescueConstants.TYPE_ROAD
,
RescueConstants.TYPE_NODE
,
RescueConstants.TYPE_RIVER
,
RescueConstants.TYPE_RIVER_NODE
,
RescueConstants.TYPE_BUILDING
,
RescueConstants.TYPE_REFUGE
,
RescueConstants.TYPE_FIRE_STATION
,
RescueConstants.TYPE_AMBULANCE_CENTER
,
RescueConstants.TYPE_POLICE_OFFICE
,
RescueConstants.TYPE_WORLD
,
RescueConstants.TYPE_CAR
public static java.lang.String getPropertyName(int type)
type
- The property we want to convert
RescueConstants.PROPERTY_NULL
,
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_HISTORY
,
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_IGNITION
,
RescueConstants.PROPERTY_BROKENNESS
,
RescueConstants.PROPERTY_FIERYNESS
,
RescueConstants.PROPERTY_ENTRANCES
,
RescueConstants.PROPERTY_BUILDING_SHAPE_ID
,
RescueConstants.PROPERTY_BUILDING_CODE
,
RescueConstants.PROPERTY_BUILDING_AREA_GROUND
,
RescueConstants.PROPERTY_BUILDING_AREA_TOTAL
,
RescueConstants.PROPERTY_BUILDING_APEXES
,
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_MEDIAN_STRIP
,
RescueConstants.PROPERTY_LINES_TO_HEAD
,
RescueConstants.PROPERTY_LINES_TO_TAIL
,
RescueConstants.PROPERTY_WIDTH_FOR_WALKERS
,
RescueConstants.PROPERTY_EDGES
,
RescueConstants.PROPERTY_SIGNAL
,
RescueConstants.PROPERTY_SIGNAL_TIMING
,
RescueConstants.PROPERTY_SHORTCUT_TO_TURN
,
RescueConstants.PROPERTY_POCKET_TO_TURN_ACROSS
public static java.lang.String getCommandTypeName(int header)
header
- The type we want to convert
RescueConstants.HEADER_NULL
,
RescueConstants.AK_CONNECT
,
RescueConstants.AK_ACKNOWLEDGE
,
RescueConstants.AK_REST
,
RescueConstants.AK_MOVE
,
RescueConstants.AK_EXTINGUISH
,
RescueConstants.AK_RESCUE
,
RescueConstants.AK_CLEAR
,
RescueConstants.AK_LOAD
,
RescueConstants.AK_UNLOAD
,
RescueConstants.KA_CONNECT_OK
,
RescueConstants.KA_CONNECT_ERROR
,
RescueConstants.KA_SENSE
,
RescueConstants.KA_HEAR
,
RescueConstants.SK_CONNECT
,
RescueConstants.SK_ACKNOWLEDGE
,
RescueConstants.SK_UPDATE
,
RescueConstants.KS_CONNECT_OK
,
RescueConstants.KS_CONNECT_ERROR
,
RescueConstants.KS_COMMANDS
,
RescueConstants.KG_CONNECT
,
RescueConstants.KG_ACKNOWLEDGE
,
RescueConstants.KG_UPDATE
,
RescueConstants.GK_CONNECT_OK
,
RescueConstants.GK_CONNECT_ERROR
public static java.lang.String getAgentTypeName(int type)
type
- The agent type to convert
public static java.lang.String arrayAsString(int[] array)
array
- The array to convert
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |