Package loci.common
Class IniParser
java.lang.Object
loci.common.IniParser
public class IniParser
extends java.lang.Object
A simple parser for INI configuration files. Supports pound (#) as comments,
and backslash (\) to continue values across multiple lines.
- Author:
- Curtis Rueden ctrueden at wisc.edu
-
Constructor Summary
Constructors Constructor Description IniParser()
-
Method Summary
Modifier and Type Method Description static java.io.BufferedReader
openTextResource(java.lang.String path)
Opens a buffered reader for the given resource.static java.io.BufferedReader
openTextResource(java.lang.String path, java.lang.Class<?> c)
Opens a buffered reader for the given resource.IniList
parseINI(java.io.BufferedReader in)
Parses the INI-style configuration data from the given input stream.IniList
parseINI(java.io.File file)
Parses the INI-style wrapping the given file in aBufferedReader
IniList
parseINI(java.lang.String path)
Parses the INI-style configuration data from the given resource.IniList
parseINI(java.lang.String path, java.lang.Class<?> c)
Parses the INI-style configuration data from the given resource, using the given class to find the resource.void
setBackslashContinuesLine(boolean slashContinues)
Set whether or not a '\' at the end of a line signifies that the line continues on the following line.void
setCommentDelimiter(java.lang.String delimiter)
Set the String that identifies a comment.
-
Constructor Details
-
IniParser
public IniParser()
-
-
Method Details
-
setCommentDelimiter
public void setCommentDelimiter(java.lang.String delimiter)Set the String that identifies a comment. Defaults to "#".- Parameters:
delimiter
- the String used to identify comments
-
setBackslashContinuesLine
public void setBackslashContinuesLine(boolean slashContinues)Set whether or not a '\' at the end of a line signifies that the line continues on the following line. By default, a '\' does continue the line.- Parameters:
slashContinues
- true if a '\' at the end of a line signifies that the line continues on the following line
-
parseINI
Parses the INI-style configuration data from the given resource.- Parameters:
path
- the name of the resource to read- Returns:
- the IniList parsed from the named resource
- Throws:
java.io.IOException
- if the resource cannot be read- See Also:
openTextResource(String)
-
parseINI
Parses the INI-style configuration data from the given resource, using the given class to find the resource.- Parameters:
path
- the name of the resource to readc
- the Class to use for finding the named resource- Returns:
- the IniList parsed from the named resource
- Throws:
java.io.IOException
- if the resource cannot be read- See Also:
openTextResource(String, Class)
-
parseINI
Parses the INI-style wrapping the given file in aBufferedReader
- Parameters:
file
- the file on disk from which to read- Returns:
- the IniList parsed from the file
- Throws:
java.io.IOException
- if the file cannot be read
-
parseINI
Parses the INI-style configuration data from the given input stream.- Parameters:
in
- the BufferedReader stream from which to read- Returns:
- the IniList parsed from the reader
- Throws:
java.io.IOException
- if the stream cannot be read
-
openTextResource
public static java.io.BufferedReader openTextResource(java.lang.String path)Opens a buffered reader for the given resource.- Parameters:
path
- the name of the resource to read- Returns:
- the BufferedReader corresponding to the named resource
- See Also:
openTextResource(String)
-
openTextResource
public static java.io.BufferedReader openTextResource(java.lang.String path, java.lang.Class<?> c)Opens a buffered reader for the given resource.- Parameters:
path
- the name of the resource to readc
- the Class to use for finding the named resource- Returns:
- the BufferedReader corresponding to the named resource
- See Also:
openTextResource(String)
-