public class JsonConfig
extends java.lang.Object
| Constructor and Description |
|---|
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
|
| Modifier and Type | Method and Description |
|---|---|
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() |
public JsonConfig()
throws java.io.IOException
java.io.IOException - if these was an error parsing or reading the system
JSON filepublic JsonConfig(java.io.File jsonFile)
throws java.io.IOException
jsonFile - a JSON filejava.io.IOException - if there was an error parsing or reading the filepublic JsonConfig(java.io.InputStream jsonIn)
throws java.io.IOException
jsonIn - a JSON streamjava.io.IOException - if there was an error parsing or reading the streampublic JsonConfig(java.lang.String jsonString)
throws java.io.IOException
jsonString - java.io.IOExceptionpublic java.lang.String get(java.lang.String path)
path - XPath to nodepublic java.lang.String get(java.lang.String path,
java.lang.String defaultValue)
path - XPath to nodedefaultValue - value to return if the node was not foundpublic java.util.List<java.lang.Object> getList(java.lang.String path)
path - XPath to nodepublic java.util.Map<java.lang.String,java.lang.Object> getMap(java.lang.String path)
path - XPath to nodepublic java.util.Map<java.lang.String,java.lang.Object> getMapWithChild(java.lang.String path)
path - XPath to nodepublic 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 configurationpublic void store(java.io.Writer writer)
throws java.io.IOException
writer - a writerjava.io.IOException - if there was an error writing the configurationpublic void store(java.io.Writer writer,
boolean pretty)
throws java.io.IOException
writer - a writerpretty - use pretty printerjava.io.IOException - if there was an error writing the configurationpublic static java.io.File backupSystemFile()
throws java.io.IOException
java.io.IOException - if there was an error reading or writing either filepublic 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 nodepublic 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 otherwiseCopyright © 2009-2018. All Rights Reserved.