public class YAMLProcessor extends YAMLNode
For example, given the following configuration file:
members:
- Hollie
- Jason
- Bobo
- Aya
- Tetsu
worldguard:
fire:
spread: false
blocks: [cloth, rock, glass]
sturmeh:
cool: false
eats:
babies: true
Calling code could access sturmeh's baby eating state by using
getBoolean("sturmeh.eats.babies", false). For lists, there are
methods such as getStringList that will return a type safe list.
| Modifier and Type | Field and Description |
|---|---|
static char |
COMMENT_CHAR |
protected File |
file |
protected YAMLFormat |
format |
protected String |
header |
static String |
LINE_BREAK |
protected org.yaml.snakeyaml.Yaml |
yaml |
| Constructor and Description |
|---|
YAMLProcessor(File file,
boolean writeDefaults) |
YAMLProcessor(File file,
boolean writeDefaults,
YAMLFormat format) |
| Modifier and Type | Method and Description |
|---|---|
String |
getComment(String key)
Returns a root-level comment.
|
Map<String,String> |
getComments()
Returns root-level comments.
|
static YAMLNode |
getEmptyNode(boolean writeDefaults)
This method returns an empty ConfigurationNode for using as a
default in methods that select a node from a node list.
|
String |
getHeader()
Return the set header.
|
InputStream |
getInputStream() |
OutputStream |
getOutputStream() |
void |
load()
Loads the configuration file.
|
boolean |
save()
Saves the configuration to disk.
|
void |
setComment(String key,
String... comment)
Set a root-level comment.
|
void |
setComment(String key,
String comment) |
void |
setComments(Map<String,String> comments)
Set root-level comments from a map.
|
void |
setHeader(String... headerLines)
Set the header for the file as a series of lines that are terminated
by a new line sequence.
|
void |
setHeader(String header)
Set the header for the file.
|
addNode, clear, getBlockVector2dList, getBoolean, getBoolean, getBooleanList, getDouble, getDouble, getDoubleList, getInt, getInt, getIntList, getKeys, getList, getMap, getNode, getNodeList, getNodes, getProperty, getString, getString, getStringList, getVector, getVector, getVector2d, getVector2dList, getVectorList, removeProperty, setProperty, setWriteDefaults, writeDefaultspublic static final String LINE_BREAK
public static final char COMMENT_CHAR
protected final org.yaml.snakeyaml.Yaml yaml
protected final File file
protected String header
protected YAMLFormat format
public YAMLProcessor(File file, boolean writeDefaults, YAMLFormat format)
public YAMLProcessor(File file, boolean writeDefaults)
public void load()
throws IOException
IOExceptionpublic void setHeader(String... headerLines)
headerLines - header lines to prependpublic void setHeader(String header)
header - header to prependpublic String getHeader()
public boolean save()
public InputStream getInputStream() throws IOException
IOExceptionpublic OutputStream getOutputStream() throws IOException
IOExceptionpublic String getComment(String key)
key - the property keynullpublic void setComment(String key, String... comment)
key - the property keycomment - the comment. May be null, in which case the comment
is removed.public Map<String,String> getComments()
public void setComments(Map<String,String> comments)
comments - comment mappublic static YAMLNode getEmptyNode(boolean writeDefaults)
Copyright © 2010-2014. All Rights Reserved.