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 a BufferedReader
    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.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

  • 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

      public IniList parseINI​(java.lang.String path) throws java.io.IOException
      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

      public IniList parseINI​(java.lang.String path, java.lang.Class<?> c) throws java.io.IOException
      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 read
      c - 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

      public IniList parseINI​(java.io.File file) throws java.io.IOException
      Parses the INI-style wrapping the given file in a BufferedReader
      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

      public IniList parseINI​(java.io.BufferedReader in) throws java.io.IOException
      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 read
      c - the Class to use for finding the named resource
      Returns:
      the BufferedReader corresponding to the named resource
      See Also:
      openTextResource(String)