com.huguesjohnson.hapsby
Class SaveGame

java.lang.Object
  extended by com.huguesjohnson.hapsby.SaveGame

public class SaveGame
extends java.lang.Object

Class to read & write values to a file.

Author:
Hugues Johnson

Constructor Summary
SaveGame(java.io.File file)
          Create a new SaveGame, opens the file passed in the constructor.
SaveGame(java.lang.String filePath)
          Create a new SaveGame, opens the file passed in the constructor.
 
Method Summary
 void close()
          Close the save game.
 int getIntValue(int offset, int length, SaveGameProperty.ByteOrder byteOrder)
          Returns an integer value from the save game.
 java.lang.String getStringValue(int offset, int length, SaveGameProperty.ByteOrder byteOrder)
          Returns a string value from a save game.
 void setIntValue(int offset, int length, int value, SaveGameProperty.ByteOrder byteOrder)
          Writes an integer value to the save game.
 void setStringValue(int offset, int length, java.lang.String value, SaveGameProperty.ByteOrder byteOrder)
          Writes a string value to the save game.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SaveGame

public SaveGame(java.lang.String filePath)
Create a new SaveGame, opens the file passed in the constructor.

Parameters:
filePath - Full path to the save game to open.

SaveGame

public SaveGame(java.io.File file)
Create a new SaveGame, opens the file passed in the constructor.

Parameters:
file - Save game file to open.
Method Detail

close

public void close()
Close the save game.


getIntValue

public int getIntValue(int offset,
                       int length,
                       SaveGameProperty.ByteOrder byteOrder)
Returns an integer value from the save game.

Parameters:
offset - Decimal value pointing to the first byte of the value to retrieve.
length - Length (number of bytes) of the value.
byteOrder - The byte order of the value.
Returns:
The value stored at offset X (offset*length) in decimal format.

setIntValue

public void setIntValue(int offset,
                        int length,
                        int value,
                        SaveGameProperty.ByteOrder byteOrder)
Writes an integer value to the save game.

Parameters:
offset - Decimal value pointing to the first byte of the value to store.
length - Length (number of bytes) of the value.
value - The decimal number to be stored at offset X (offset*length).
byteOrder - The byte order of the value to store.

setStringValue

public void setStringValue(int offset,
                           int length,
                           java.lang.String value,
                           SaveGameProperty.ByteOrder byteOrder)
Writes a string value to the save game.

Parameters:
offset - Decimal value pointing to the first byte of the string to store.
length - Length (number of bytes) of the string.
value - The string to be stored at offset.
byteOrder - The byte order of the string (just in case there's some oddball save game where strings are stored in reverse).

getStringValue

public java.lang.String getStringValue(int offset,
                                       int length,
                                       SaveGameProperty.ByteOrder byteOrder)
Returns a string value from a save game.

Parameters:
offset - Decimal value pointing to the first byte of the string to retrieve.
length - Length (number of bytes) of the string.
byteOrder - The byte order of the string (just in case there's some oddball save game where strings are stored in reverse).
Returns:
Value stored at offset X (offset*length) in string format.


Copyright © 2000-2009 Hugues Johnson