|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectme.grison.jtoml.impl.Toml
public class Toml
Toml parsing class front-end.
Toml toml = Toml.parse("pi = 3.141592653589793");
Double pi = toml.getDouble("pi");
| Field Summary | |
|---|---|
protected Map<String,Object> |
context
The instance context map holding key/values parsed from a TOML String or File |
protected Matcher |
keyPathMatcher
A matcher to retrieve the path to a key. |
protected TomlParser |
tomlParser
Current instance parser: default to `Toml.defaultParser` if none specified |
| Constructor Summary | |
|---|---|
Toml()
Default constructor. |
|
Toml(TomlParser tomlParser)
Constructor using a specific TOML parser. |
|
| Method Summary | ||
|---|---|---|
Map<String,Object> |
findContext(Map<String,Object> context,
String key)
Find the correct level context. |
|
Object |
get(String key)
Get the object. |
|
|
getAs(String key,
Class<T> clazz)
Get a new instance of the given Class filled with the value that can be found in the current context at the given key. |
|
Boolean |
getBoolean(String key)
Get a boolean. |
|
Calendar |
getDate(String key)
Get the date (as Calendar) |
|
Double |
getDouble(String key)
Get the double value. |
|
List<Object> |
getList(String key)
Get the list. |
|
Long |
getLong(String key)
Get the Long value. |
|
Map<String,Object> |
getMap(String key)
Get a Map. |
|
String |
getString(String key)
Get the string. |
|
TomlParser |
getTomlParser()
Gets the parser currently used to parse TOML. |
|
static Toml |
parse(File file)
Creates a TOML instance loaded with the given file. |
|
static Toml |
parse(File file,
TomlParser tomlParser)
Creates a TOML instance loaded with the given file and using the given TOML parser. |
|
static Toml |
parse(String tomlString)
Creates a TOML instance loaded with the given String. |
|
static Toml |
parse(String tomlString,
TomlParser tomlParser)
Creates a TOML instance loaded with the given file and using the given TOML parser. |
|
Toml |
parseFile(File file)
Parse the given File as TOML. |
|
Toml |
parseString(String string)
Parse the given String as TOML. |
|
String |
serialize()
Serializes the current instance context to a TOML String. |
|
static String |
serialize(Object object)
Serializes the given Object to a TOML String. |
|
String |
serialize(String rootKey)
Serializes the current instance context to a TOML String. |
|
static String |
serialize(String rootKey,
Object object)
Serializes the given Object to a TOML String. |
|
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
protected Map<String,Object> context
protected final Matcher keyPathMatcher
protected TomlParser tomlParser
| Constructor Detail |
|---|
public Toml()
public Toml(TomlParser tomlParser)
tomlParser - the specific TOML parser to be used.| Method Detail |
|---|
public static Toml parse(String tomlString)
tomlString - the TOML String to load.
public static Toml parse(String tomlString,
TomlParser tomlParser)
tomlString - the TOML String to load.tomlParser - the TOML parser to use
IOException
public static Toml parse(File file)
throws IOException
file - the TOML file to load
IOException
public static Toml parse(File file,
TomlParser tomlParser)
throws IOException
file - the TOML file to loadtomlParser - the TOML parser to use
IOExceptionpublic Toml parseString(String string)
Parser
parseString in interface Parserstring - the string to be parsed.
public Toml parseFile(File file)
throws FileNotFoundException
Parser
parseFile in interface Parserfile - the file to be parsed.
FileNotFoundExceptionpublic TomlParser getTomlParser()
public Map<String,Object> findContext(Map<String,Object> context,
String key)
context - the contextkey - the key
public Object get(String key)
Getter
get in interface Getterkey - the key where the object is located
public String getString(String key)
Getter
getString in interface Getterkey - the key where the object is located
public Long getLong(String key)
Getter
getLong in interface Getterkey - the key where the object is located
public Double getDouble(String key)
Getter
getDouble in interface Getterkey - the key where the object is located
public Calendar getDate(String key)
Getter
getDate in interface Getterkey - the key where the object is located
public List<Object> getList(String key)
Getter
getList in interface Getterkey - the key where the object is located
public Map<String,Object> getMap(String key)
Getter
getMap in interface Getterkey - the key where the object is located
public Boolean getBoolean(String key)
Getter
getBoolean in interface Getterkey - the key where the object is located
public <T> T getAs(String key,
Class<T> clazz)
getAs in interface GetterT - the resulting object typekey - the key where the value is locatedclazz - the class of the resulting object
public String serialize()
public String serialize(String rootKey)
rootKey - the root key.
public static String serialize(Object object)
object - the Object to be serialized
public static String serialize(String rootKey,
Object object)
rootKey - the root key (can be empty or null)object - the Object to be serialized
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||