webeq3.util
Class OptionsInfo

java.lang.Object
  extended by webeq3.util.OptionsInfo

public class OptionsInfo
extends java.lang.Object

This class facilitates the loading and saving of options from or to a file.


Constructor Summary
OptionsInfo()
          Constructs a OptionsInfo object.
OptionsInfo(java.lang.String file)
          Constructs a OptionsInfo object with the specified file.
 
Method Summary
 void clearOptions()
          Clears all the loaded options.
 java.lang.String getFile()
          Returns the absolute path for the options file.
 java.lang.String getOption(java.lang.String key)
          Returns the option value specified by the key.
 boolean isEmpty()
          Returns true if there is no option loaded yet, returns false otherwise.
 void readOptions()
          Loads all of the options from the specified file.
 void setFile(java.lang.String file)
          Sets the absolute path for the options file.
 void setOption(java.lang.String key, java.lang.String value)
          Maps the specified option key to the specified option value.
 boolean writeOptions()
          Saves all of the options in the format of "key=value" to the specified file.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

OptionsInfo

public OptionsInfo()
Constructs a OptionsInfo object.


OptionsInfo

public OptionsInfo(java.lang.String file)
Constructs a OptionsInfo object with the specified file.

Parameters:
file - the absolute path of the file that this OptionsInfo object loads from and saves to
Method Detail

clearOptions

public void clearOptions()
Clears all the loaded options.


getFile

public java.lang.String getFile()
Returns the absolute path for the options file.

Returns:
the absolute path for the options file

getOption

public java.lang.String getOption(java.lang.String key)
Returns the option value specified by the key.

Parameters:
key - key of the option
Returns:
the value to which the key is mapped; null if the key is not mapped to any value

isEmpty

public boolean isEmpty()
Returns true if there is no option loaded yet, returns false otherwise.

Returns:
true if there is no option loaded yet; false otherwise

readOptions

public void readOptions()
Loads all of the options from the specified file.


setFile

public void setFile(java.lang.String file)
Sets the absolute path for the options file.

Parameters:
file - the absolute path for the options file

setOption

public void setOption(java.lang.String key,
                      java.lang.String value)
Maps the specified option key to the specified option value. Neither the key nor the value can be null.

The value can be retrieved by calling the get method with a key that is equal to the original key.

Parameters:
key - the key of the option
value - the value of the option

writeOptions

public boolean writeOptions()
Saves all of the options in the format of "key=value" to the specified file.

Returns:
false if any IO error occurs; true otherwise

Copyright (c) 2015 Design Science
All rights reserved