net.petterroea.starterkit
Class PropertiesFile

java.lang.Object
  extended by net.petterroea.starterkit.PropertiesFile

public class PropertiesFile
extends java.lang.Object

Old codefile that i have used since hMod(Inspired by one of the code files in hMod). Works good^^

Author:
Petterroea

Field Summary
private  java.lang.String fileExtension
          The file extension to be used
private  java.lang.String product
          The complete file name
private  java.util.Properties propertiesFile
          The file we are wrapping
 
Constructor Summary
PropertiesFile(java.io.File theFile)
          Creates or loads a PropertiesFile based on the given file
PropertiesFile(java.lang.String name)
          Creates or loads a new PropertiesFile based on the given name, without a file extension
 
Method Summary
 boolean containsKey(java.lang.String name)
          Checks if a property/key called name exists
 boolean getBool(java.lang.String name)
          Gets a boolean with the property behind name.
 int getInt(java.lang.String name)
          Gets a integer with the property behind name.
 java.lang.String getProperty(java.lang.String name)
          Gets a string with the property behind name
 java.lang.String getString(java.lang.String name)
          Gets a string with the property behind name
(package private)  void reload()
          Reloads the file
 void removeKey(java.lang.String name)
          Removes the key/property from the file
(package private)  void save()
          Saves the properties file
 void setBool(java.lang.String name, boolean value)
          Sets a boolean property.
 void setInt(java.lang.String name, int value)
          Sets a integer property.
 void setString(java.lang.String name, java.lang.String value)
          Sets a string property.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

product

private java.lang.String product
The complete file name


propertiesFile

private java.util.Properties propertiesFile
The file we are wrapping


fileExtension

private java.lang.String fileExtension
The file extension to be used

Constructor Detail

PropertiesFile

public PropertiesFile(java.lang.String name)
Creates or loads a new PropertiesFile based on the given name, without a file extension

Parameters:
name - The file name

PropertiesFile

public PropertiesFile(java.io.File theFile)
Creates or loads a PropertiesFile based on the given file

Parameters:
theFile - File to load from
Method Detail

reload

void reload()
      throws java.io.IOException
Reloads the file

Throws:
java.io.IOException

save

void save()
Saves the properties file


containsKey

public boolean containsKey(java.lang.String name)
Checks if a property/key called name exists

Parameters:
name - The name to check
Returns:
True if it exists

removeKey

public void removeKey(java.lang.String name)
Removes the key/property from the file

Parameters:
name - The name to remove

getProperty

public java.lang.String getProperty(java.lang.String name)
Gets a string with the property behind name

Parameters:
name - Name of the property to get
Returns:
A string containing the property

getString

public java.lang.String getString(java.lang.String name)
Gets a string with the property behind name

Parameters:
name - Name of the property to get
Returns:
A string containing the property

setString

public void setString(java.lang.String name,
                      java.lang.String value)
Sets a string property. Autosaves

Parameters:
name - Name of property
value - Value of property

getInt

public int getInt(java.lang.String name)
Gets a integer with the property behind name. You can get an error if the property is not int-formatted

Parameters:
name - Name of the property to get
Returns:
A int containing the property

setInt

public void setInt(java.lang.String name,
                   int value)
Sets a integer property. Autosaves

Parameters:
name - The name of the property
value - Value to be set

getBool

public boolean getBool(java.lang.String name)
Gets a boolean with the property behind name. You can get an error if the property is not true or false.

Parameters:
name - Name of the property to get
Returns:
A boolean containing the property

setBool

public void setBool(java.lang.String name,
                    boolean value)
Sets a boolean property. Autosaves

Parameters:
name - Name of the property
value - Value of the property