|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectcom.googlecode.fascinator.common.JsonConfig
public class JsonConfig
Manages JSON configuration. Configuration values are read from a specified JSON and if not found, the system-wide JSON will also be searched.
| Constructor Summary | |
|---|---|
JsonConfig()
Creates a config with only the system settings |
|
JsonConfig(File jsonFile)
Creates a JSON configuration from the specified file |
|
JsonConfig(InputStream jsonIn)
Creates a JSON configuration from the specified input stream |
|
JsonConfig(String jsonString)
Create a JSON configuration from the specified input string |
|
| Method Summary | |
|---|---|
static File |
backupSystemFile()
Performs a backup on the system-wide configuration file from the default config dir if it exists. |
String |
get(String path)
Gets the value of the specified node |
String |
get(String path,
String defaultValue)
Gets the value of the specified node, with a specified default if the not was not found |
Map<String,JsonConfigHelper> |
getJsonMap(String path)
Gets the JSON Map of the specified node |
List<Object> |
getList(String path)
Gets values of the specified node as a list. |
Map<String,Object> |
getMap(String path)
Gets a map of the child nodes of the specified node |
Map<String,Object> |
getMapWithChild(String path)
Gets a map of the child (and the 2nd level children) nodes of the specified node |
static File |
getSystemFile()
Gets the system-wide configuration file from the default config dir. |
boolean |
isConfigured()
Tests whether or not the system-config has been properly configured. |
boolean |
isOutdated()
To check if configuration file is outdated |
void |
set(String path,
String value,
boolean system)
Sets the value of the specified node. |
void |
store(Writer writer)
Serialises the current state of the JSON configuration to the specified writer. |
void |
store(Writer writer,
boolean pretty)
Serialises the current state of the JSON configuration to the specified writer. |
String |
toString()
|
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Constructor Detail |
|---|
public JsonConfig()
throws IOException
IOException - if these was an error parsing or reading the system
JSON file
public JsonConfig(File jsonFile)
throws IOException
jsonFile - a JSON file
IOException - if there was an error parsing or reading the file
public JsonConfig(InputStream jsonIn)
throws IOException
jsonIn - a JSON stream
IOException - if there was an error parsing or reading the stream
public JsonConfig(String jsonString)
throws IOException
jsonString -
IOException| Method Detail |
|---|
public String get(String path)
path - XPath to node
public String get(String path,
String defaultValue)
path - XPath to nodedefaultValue - value to return if the node was not found
public List<Object> getList(String path)
path - XPath to node
public Map<String,Object> getMap(String path)
path - XPath to node
public Map<String,Object> getMapWithChild(String path)
path - XPath to node
public void set(String path,
String value,
boolean system)
path - XPath to nodevalue - value to setsystem - set the value in the system configuration
public void store(Writer writer)
throws IOException
writer - a writer
IOException - if there was an error writing the configuration
public void store(Writer writer,
boolean pretty)
throws IOException
writer - a writerpretty - use pretty printer
IOException - if there was an error writing the configuration
public static File backupSystemFile()
throws IOException
IOException - if there was an error reading or writing either file
public static File getSystemFile()
throws IOException
IOException - if there was an error reading or writing the system
configuration filepublic Map<String,JsonConfigHelper> getJsonMap(String path)
path - XPath to node
public String toString()
toString in class Objectpublic boolean isConfigured()
true if configured, false if still
using defaultspublic boolean isOutdated()
true if outdated, false otherwise
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||