Class ConfigFile

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

public class ConfigFile extends Object
  • Constructor Details

  • Method Details

    • put

      public void put(String key, 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 String get(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 String get(String sectionName, 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 List<String> getAll()
      Gets all non keyed values from the global section.
      Returns:
      Returns a list of values or an empty list.
    • getAll

      public List<String> getAll(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(OutputStream os) throws IOException
      Writes this configuration to the given output stream.
      Parameters:
      os - The output stream to write to.
      Throws:
      IOException - If writing to the stream fails.
    • hasSection

      public boolean hasSection(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.