|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object wyvern.common.util.UserProps
This class can read a properties file, but also looks for a ".local" version of the file. Maintains the distinction between user settings and default settings. Writes out user settings to a ".local" version of the file, which can be re-read later.
Field Summary | |
protected java.util.Properties |
defaultProps_
|
protected java.lang.String |
LOCAL_SETTINGS_DIR
|
protected java.lang.String |
LOCAL_SETTINGS_PATH
|
protected java.util.Properties |
mergedProps_
|
protected java.util.Properties |
userProps_
|
Constructor Summary | |
UserProps(java.lang.String filename)
Constructs a new UserProps. |
Method Summary | |
void |
debug(java.lang.String msg)
Prints debugging message if debugging is on. |
int |
getIntProperty(java.lang.String name)
Returns a property with an integer value. |
protected java.lang.String |
getLocalSettingsPath(java.lang.String filename)
Gets the absolute path to the .local version of the file. |
java.lang.String |
getProperty(java.lang.String name)
Returns true if a game engine property is set. |
java.util.Properties |
getSettings()
Returns a Properties containing all the application settings. |
java.util.Properties |
getUserSettings()
Returns the set of user-specified overrides. |
boolean |
isPropertySet(java.lang.String name)
Returns true if the property is "true", else false. |
protected void |
loadLocalSettings(java.lang.String localpath)
Tries to load the ".local" version of the file, containing any user overrides for the default settings. |
void |
mergeUserSettings()
Notifies us that someone modified the Properties object (probably by removing one or more properties) returned from getUserSettings(). |
void |
printDefaultProperties()
Prints default settings, for debugging. |
void |
printUserProperties()
Prints current user settings, for debugging. |
void |
saveUserSettings()
Saves the current user settings we've stored. |
void |
saveUserSettings(java.util.Properties props)
Saves user settings to mapedit.ini.local |
void |
setIntUserProperty(java.lang.String name,
int value)
Saves an int setting. |
void |
setProperty(java.lang.String name,
java.lang.String value)
Sets an arbitrary property by name. |
void |
setUserProperty(java.lang.String name,
java.lang.String value)
Sets a user-override for a property. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
protected java.util.Properties defaultProps_
protected java.util.Properties userProps_
protected java.util.Properties mergedProps_
protected final java.lang.String LOCAL_SETTINGS_PATH
protected java.lang.String LOCAL_SETTINGS_DIR
Constructor Detail |
public UserProps(java.lang.String filename)
filename
- the relative path to the initfile, in the form
"wyvern/wherever/myfile.ini".Method Detail |
protected void loadLocalSettings(java.lang.String localpath)
localpath
- the absolute path to the fileprotected java.lang.String getLocalSettingsPath(java.lang.String filename)
filename
- the relative ("wyvern/whatever/foo.ini") initfile pathpublic java.util.Properties getSettings()
public java.util.Properties getUserSettings()
public void saveUserSettings(java.util.Properties props) throws java.lang.Exception
props
- the set of user settings to save.
ALL user-overridden settings must be in this list.
It's OK to have default settings in there as well.
an
- exception if the file couldn't be written
java.lang.Exception
public void saveUserSettings() throws java.lang.Exception
an
- exception if the file couldn't be written
java.lang.Exception
public void mergeUserSettings()
public java.lang.String getProperty(java.lang.String name)
name
- the property name
public boolean isPropertySet(java.lang.String name)
name
- the property name
public void setProperty(java.lang.String name, java.lang.String value)
name
- the property to setvalue
- the value to set it topublic void setUserProperty(java.lang.String name, java.lang.String value)
public void setIntUserProperty(java.lang.String name, int value)
public int getIntProperty(java.lang.String name)
name
- the property name
public void printUserProperties()
public void printDefaultProperties()
public void debug(java.lang.String msg)
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |