Constructor and Description |
---|
AndroidData() |
Modifier and Type | Method and Description |
---|---|
void |
createDirectory(java.lang.String... path)
Creates a directory within in the game data location
|
boolean |
hasDirectory(java.lang.String... path)
Checks if the directory exists in the game data location
|
boolean |
hasFile(java.lang.String... filepath)
Checks if the file exists in the game data location
|
<T> T |
readJson(java.lang.Class<T> clazz,
java.lang.String... filepath)
Converts JSON from a file into an object.
|
<T> T |
readXml(java.lang.Class<T> clazz,
java.lang.String... filepath)
Converts XML from a file into an object.
|
void |
wipe()
Wipes all data within the game data location
|
<T> void |
writeJson(T object,
java.lang.String... filepath)
Writes an object as JSON to a file.
|
<T> void |
writeXml(T object,
java.lang.String... filepath)
Writes an object as XML to a file.
|
public <T> T readXml(java.lang.Class<T> clazz, java.lang.String... filepath) throws java.lang.Exception
Data
readXml
in interface Data
clazz
- The object type to convert the XML intofilepath
- The path to the XML file. This will be resolved as a path
within the game data location.java.lang.Exception
- Thrown if the XML is invalid, the file does not exist or the
game data location cannot be accessed.public <T> void writeXml(T object, java.lang.String... filepath) throws java.lang.Exception
Data
writeXml
in interface Data
object
- The object to be written to the filefilepath
- The path to the XML file. This will be resolved as a path
within the game data location.java.lang.Exception
- Thrown if the game data location cannot be accessed or the
data cannot be written to the file.public <T> T readJson(java.lang.Class<T> clazz, java.lang.String... filepath) throws java.lang.Exception
Data
readJson
in interface Data
clazz
- The object type to convert the JSON intofilepath
- The path to the JSON file. This will be resolved as a path
within the game data location.java.lang.Exception
- Thrown if the XML is invalid, the file does not exist or the
game data location cannot be accessed.public <T> void writeJson(T object, java.lang.String... filepath) throws java.lang.Exception
Data
writeJson
in interface Data
object
- The object to be written to the filefilepath
- The path to the JSON file. This will be resolved as a path
within the game data location.java.lang.Exception
- Thrown if the game data location cannot be accessed or the
data cannot be written to the file.public boolean hasFile(java.lang.String... filepath) throws java.lang.Exception
Data
public boolean hasDirectory(java.lang.String... path) throws java.lang.Exception
Data
hasDirectory
in interface Data
path
- The path to the directory within the game data locationjava.lang.Exception
- Thrown if the game data location cannot be accessedpublic void createDirectory(java.lang.String... path) throws java.lang.Exception
Data
createDirectory
in interface Data
path
- The path to the directory within the game data locationjava.lang.Exception
- Thrown if the game data location cannot be accessed or the
directory could not be created