Class ConfigFile

java.lang.Object
i5.las2peer.tools.helper.ConfigFile

public class ConfigFile
extends java.lang.Object
  • Constructor Summary

    Constructors 
    Constructor Description
    ConfigFile()  
    ConfigFile​(java.io.InputStream is)  
    ConfigFile​(java.lang.String filename)  
  • Method Summary

    Modifier and Type Method Description
    java.lang.String get​(java.lang.String key)
    Gets a keyed value from the global section.
    java.lang.String get​(java.lang.String sectionName, java.lang.String key)
    Gets a keyed value from the given section.
    java.util.List<java.lang.String> getAll()
    Gets all non keyed values from the global section.
    java.util.List<java.lang.String> getAll​(java.lang.String sectionName)
    Gets all non keyed values from the given section.
    boolean hasSection​(java.lang.String sectionName)
    Checks if a section with the given name exists.
    void put​(java.lang.String key, java.lang.Object value)
    If value is null, nothing is addded If key is empty or null, just the value is added If a value for the given key already exists, the value is overwritten If the value has type Iterable, all elements are added to the section with key as name An existing section with that name is overwritten, except no name is given (global section)!
    void store​(java.io.OutputStream os)
    Writes this configuration to the given output stream.

    Methods inherited from class java.lang.Object

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

    • ConfigFile

      public ConfigFile()
    • ConfigFile

      public ConfigFile​(java.lang.String filename) throws java.io.IOException
      Throws:
      java.io.IOException
    • ConfigFile

      public ConfigFile​(java.io.InputStream is) throws java.io.IOException
      Throws:
      java.io.IOException
  • Method Details

    • put

      public void put​(java.lang.String key, java.lang.Object value)
      If value is null, nothing is addded If key is empty or null, just the value is added If a value for the given key already exists, the value is overwritten If the value has type Iterable, all elements are added to the section with key as name An existing section with that name is overwritten, except no name is given (global section)!
      Parameters:
      key -
      value -
    • get

      public java.lang.String get​(java.lang.String key)
      Gets a keyed value from the global section.
      Parameters:
      key - The key to identify the value.
      Returns:
      Returns the value or null, if the key is unknown.
    • get

      public java.lang.String get​(java.lang.String sectionName, java.lang.String key)
      Gets a keyed value from the given section.
      Parameters:
      sectionName - The name of the section.
      key - The key to identify the value.
      Returns:
      Returns the value or null, if the key is unknown.
    • getAll

      public java.util.List<java.lang.String> getAll()
      Gets all non keyed values from the global section.
      Returns:
      Returns a list of values or an empty list.
    • getAll

      public java.util.List<java.lang.String> getAll​(java.lang.String sectionName)
      Gets all non keyed values from the given section.
      Parameters:
      sectionName - The name of the section.
      Returns:
      Returns a list of values or null, if no such section exists.
    • store

      public void store​(java.io.OutputStream os) throws java.io.IOException
      Writes this configuration to the given output stream.
      Parameters:
      os - The output stream to write to.
      Throws:
      java.io.IOException - If writing to the stream fails.
    • hasSection

      public boolean hasSection​(java.lang.String sectionName)
      Checks if a section with the given name exists.
      Parameters:
      sectionName - The section name to check.
      Returns:
      Returns true, if a section with the given name exists, false otherwise.