public class ParserJ
extends java.lang.Object
Modifier and Type | Field and Description |
---|---|
java.lang.String |
commentStart
The string used to mark the beginning of comments; typically '#'.
|
static char |
DefaultDelimiter
The default character used to divide each key from its value.
|
char |
delimiter
The character used to divide each key from its value.
|
java.util.Map<java.lang.String,java.lang.String> |
jdata
The parsed data in an immutable map with iteration order matching the original sources.
|
java.lang.String |
name
The name of this parser; typically the filename.
|
static char |
SectionSeparator
The character used to divide sections in INI-file tags.
|
Constructor and Description |
---|
ParserJ(java.io.InputStream in,
java.lang.String name)
Constructs an instance with the default delimiter between keys and values amd commentStart string '#'.
|
ParserJ(java.io.InputStream in,
java.lang.String name,
char delimiter)
Constructs an instance with the default commentStart string '#'.
|
ParserJ(java.io.InputStream in,
java.lang.String name,
char delimiter,
java.lang.String commentStart)
Constructs an instance.
|
Modifier and Type | Method and Description |
---|---|
static java.util.List<java.lang.String> |
parseCsvList(java.lang.String s)
Splits a string into a list of parts.
|
static ParserJ |
readFile(java.io.File file)
Reads a file using the default delimiter '='.
|
static ParserJ |
readFile(java.io.File file,
char delimiter)
Reads a file.
|
static ParserJ |
readFromClasspath(java.lang.String resourceName)
Reads a classpath resource via the classloader using the default delimiter '='.
|
static ParserJ |
readFromClasspath(java.lang.String resourceName,
char delimiter)
Reads a classpath resource via the classloader.
|
static ParserJ |
readSource(ConfigSourceJ source)
Reads an arbitrary source using the default delimiter '='.
|
static ParserJ |
readSource(ConfigSourceJ source,
char delimiter)
Reads an arbitrary source.
|
static ParserJ |
readStream(java.io.InputStream in,
java.lang.String name)
Reads an input stream using the default delimiter '='.
|
static ParserJ |
readStream(java.io.InputStream in,
java.lang.String name,
char delimiter)
Reads an input stream.
|
public static final char SectionSeparator
public static final char DefaultDelimiter
public final java.lang.String name
public final char delimiter
public final java.lang.String commentStart
public final java.util.Map<java.lang.String,java.lang.String> jdata
public ParserJ(java.io.InputStream in, java.lang.String name, char delimiter, java.lang.String commentStart) throws java.io.IOException
in
- the input stream from the file or other such resource.name
- the name of the file or other such resource.delimiter
- the character separating keys from values.commentStart
- the string marking the start of each comment.java.io.IOException
- if there was difficulty reading the input stream.public ParserJ(java.io.InputStream in, java.lang.String name, char delimiter) throws java.io.IOException
in
- the input stream from the file or other such resource.name
- the name of the file or other such resource.delimiter
- the character separating keys from values.java.io.IOException
- if there was difficulty reading the input stream.public ParserJ(java.io.InputStream in, java.lang.String name) throws java.io.IOException
in
- the input stream from the file or other such resource.name
- the name of the file or other such resource.java.io.IOException
- if there was difficulty reading the input stream.public static java.util.List<java.lang.String> parseCsvList(java.lang.String s)
s
- the string to be split, usually obtained from a configuration file.public static ParserJ readSource(ConfigSourceJ source, char delimiter) throws ConfigException
source
- some source of data, which must not be nulldelimiter
- provides a different delimiter between keys and their values (default is '=')ConfigException
public static ParserJ readSource(ConfigSourceJ source) throws ConfigException
source
- some source of data, which must not be nullConfigException
public static ParserJ readStream(java.io.InputStream in, java.lang.String name, char delimiter) throws ConfigException
in
- the input stream, which must not be nulldelimiter
- provides a different delimiter between keys and their values (default is '=')ConfigException
public static ParserJ readStream(java.io.InputStream in, java.lang.String name) throws ConfigException
in
- the input stream, which must not be nullConfigException
public static ParserJ readFromClasspath(java.lang.String resourceName, char delimiter) throws ConfigException
resourceName
- the name of the configuration file as a resource on the classpathdelimiter
- provides a different delimiter between keys and their values (default is '=')ConfigException
public static ParserJ readFromClasspath(java.lang.String resourceName) throws ConfigException
resourceName
- the name of the configuration file as a resource on the classpathConfigException
public static ParserJ readFile(java.io.File file, char delimiter) throws ConfigException
file
- the source file, which must not be nulldelimiter
- provides a different delimiter between keys and their values (default is '=')ConfigException
public static ParserJ readFile(java.io.File file) throws ConfigException
file
- the source file, which must not be nullConfigException