|
||||||||||
| 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(java.io.File jsonFile)
Creates a JSON configuration from the specified file |
|
JsonConfig(java.io.InputStream jsonIn)
Creates a JSON configuration from the specified input stream |
|
JsonConfig(java.lang.String jsonString)
Create a JSON configuration from the specified input string |
|
| Method Summary | |
|---|---|
static java.io.File |
backupSystemFile()
Performs a backup on the system-wide configuration file from the default config dir if it exists. |
java.lang.String |
get(java.lang.String path)
Gets the value of the specified node |
java.lang.String |
get(java.lang.String path,
java.lang.String defaultValue)
Gets the value of the specified node, with a specified default if the not was not found |
java.util.Map<java.lang.String,JsonConfigHelper> |
getJsonMap(java.lang.String path)
Gets the JSON Map of the specified node |
java.util.List<java.lang.Object> |
getList(java.lang.String path)
Gets values of the specified node as a list. |
java.util.Map<java.lang.String,java.lang.Object> |
getMap(java.lang.String path)
Gets a map of the child nodes of the specified node |
java.util.Map<java.lang.String,java.lang.Object> |
getMapWithChild(java.lang.String path)
Gets a map of the child (and the 2nd level children) nodes of the specified node |
static java.io.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(java.lang.String path,
java.lang.String value,
boolean system)
Sets the value of the specified node. |
void |
store(java.io.Writer writer)
Serialises the current state of the JSON configuration to the specified writer. |
void |
store(java.io.Writer writer,
boolean pretty)
Serialises the current state of the JSON configuration to the specified writer. |
java.lang.String |
toString()
|
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Constructor Detail |
|---|
public JsonConfig()
throws java.io.IOException
java.io.IOException - if these was an error parsing or reading the system
JSON file
public JsonConfig(java.io.File jsonFile)
throws java.io.IOException
jsonFile - a JSON file
java.io.IOException - if there was an error parsing or reading the file
public JsonConfig(java.io.InputStream jsonIn)
throws java.io.IOException
jsonIn - a JSON stream
java.io.IOException - if there was an error parsing or reading the stream
public JsonConfig(java.lang.String jsonString)
throws java.io.IOException
jsonString -
java.io.IOException| Method Detail |
|---|
public java.lang.String get(java.lang.String path)
path - XPath to node
public java.lang.String get(java.lang.String path,
java.lang.String defaultValue)
path - XPath to nodedefaultValue - value to return if the node was not found
public java.util.List<java.lang.Object> getList(java.lang.String path)
path - XPath to node
public java.util.Map<java.lang.String,java.lang.Object> getMap(java.lang.String path)
path - XPath to node
public java.util.Map<java.lang.String,java.lang.Object> getMapWithChild(java.lang.String path)
path - XPath to node
public void set(java.lang.String path,
java.lang.String value,
boolean system)
path - XPath to nodevalue - value to setsystem - set the value in the system configuration
public void store(java.io.Writer writer)
throws java.io.IOException
writer - a writer
java.io.IOException - if there was an error writing the configuration
public void store(java.io.Writer writer,
boolean pretty)
throws java.io.IOException
writer - a writerpretty - use pretty printer
java.io.IOException - if there was an error writing the configuration
public static java.io.File backupSystemFile()
throws java.io.IOException
java.io.IOException - if there was an error reading or writing either file
public static java.io.File getSystemFile()
throws java.io.IOException
java.io.IOException - if there was an error reading or writing the system
configuration filepublic java.util.Map<java.lang.String,JsonConfigHelper> getJsonMap(java.lang.String path)
path - XPath to node
public java.lang.String toString()
toString in class java.lang.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 | |||||||||