Package me.micartey.mvml
Class MvmlParser
- java.lang.Object
-
- me.micartey.mvml.MvmlParser
-
public class MvmlParser extends java.lang.Object
-
-
Constructor Summary
Constructors Constructor Description MvmlParser()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description java.lang.String
get(java.lang.String key)
Get the value of a key<T> T
get(java.lang.String key, java.lang.Class<T> type)
Get the value of a key and convert it to a certain typevoid
migrate()
Migrate the current values to a new file.void
read()
Overwrite the memory with information stored on discjava.util.List<java.util.Map.Entry<java.lang.String,java.lang.String>>
readAll()
Get all key and values as pairs (to store and iterate)void
remove(java.lang.String key)
Delete a node by keyvoid
save()
Overwrite the file on disc with information stored in memoryvoid
set(java.lang.String key, java.lang.Object value)
Set a value for a key.
-
-
-
Method Detail
-
get
public java.lang.String get(java.lang.String key)
Get the value of a key- Parameters:
key
- Key- Returns:
- value (String)
-
get
public <T> T get(java.lang.String key, java.lang.Class<T> type)
Get the value of a key and convert it to a certain type- Type Parameters:
T
- object type- Parameters:
key
- Keytype
- object class- Returns:
- instance of T
-
remove
public void remove(java.lang.String key)
Delete a node by key- Parameters:
key
- Key to node
-
readAll
public java.util.List<java.util.Map.Entry<java.lang.String,java.lang.String>> readAll()
Get all key and values as pairs (to store and iterate)- Returns:
- list of pairs
-
set
public void set(java.lang.String key, java.lang.Object value)
Set a value for a key. If the path is not present, it will create all required NodescreateNodePath(Node, String)
- Parameters:
key
- Keyvalue
- Value
-
save
public void save()
Overwrite the file on disc with information stored in memory
-
read
public void read()
Overwrite the memory with information stored on disc
-
migrate
public void migrate() throws java.io.IOException
Migrate the current values to a new file. This expects that the file has been replaced after loading. It will attempt to re-read the file and override the values with the old values. New keys will not be overwritten- Throws:
java.io.IOException
- if something happens while parsing
-
-