com.javapathfinder.vjp.config.editors
Class ModePropertyConfiguration

java.lang.Object
  extended by com.javapathfinder.vjp.config.editors.ModePropertyConfiguration

public class ModePropertyConfiguration
extends java.lang.Object

This class serves to manage the userdefined and default properties for JPF. There are three levels of properties:

Each of these levels is represented by a map that contains the name/value pair of their respective properties. When a property is to be retrieved this class first looks to the user defined layer, then to the VJP layer and then finally to the JPF layer. Values defined by the user should only be defined on the user defined layer. Only the user defined layer is saved to the Mode Property Configuration File.

Author:
Sandro Badame

Constructor Summary
ModePropertyConfiguration(org.eclipse.core.resources.IFile configFile, org.eclipse.jdt.core.IJavaProject project)
          Creates a default instance of the PropertyManager.
 
Method Summary
 void addChangeListener(PropertyChangeListener listener)
          Adds a change listener to this configuration.
static java.util.HashMap<java.lang.String,java.lang.String> getConfigFileProperties(org.eclipse.core.resources.IFile file)
          Loads this configuration with the properties contained in configuration file associated.
 java.lang.Object[] getDefaultPropertiesAsArray()
          Returns an object array containing all of the properties listed by the JPF defaults and the VJP defaults.
 org.eclipse.core.resources.IFile getIFile()
          The IFile associated to this configuration.
 Property getProperty(java.lang.String propertyName)
          Retrieves a Property object for the property of this name.
 java.lang.String getPropertyValue(java.lang.String name)
          Retrieves a value for the property of this name.
 java.lang.Object[] getUserDefinedPropertiesAsArray()
          Returns all Properties that are only defined by the user and not found in jpf.properties or defined by VJP
 boolean isDefaultProperty(java.lang.String propertyName)
          Returns whether the property is defined by either jpfDefaults or if in use VJP defaults.
 boolean isDefined(Property prop)
           
 boolean isDefined(java.lang.String propertyName)
           
 boolean isDirty()
           
 boolean isUserDefined(java.lang.String prop)
           
 boolean isUsingDefaultValue(java.lang.String propertyName)
          Returns whether the property is using the default value or a user defined value.
 void movePropertiesFile(org.eclipse.core.runtime.IPath newPath, org.eclipse.core.runtime.IProgressMonitor monitor)
          Move the property file.
 void parseConfigFile()
          Parses the configuration file and handles it appropriatly
 void reloadFromFile()
          Clears all of the config properties contained and then reloads all properties from the configuration file.
 void removeChangeListener(PropertyChangeListener listener)
          Removes this change listener from this configuration.
 void removeProperty(Property property)
          Removes the property from the userdefined status.
 void removeProperty(java.lang.String propertyName)
          Removes this property from this configuration.
 void renameProperty(java.lang.String oldName, java.lang.String newName)
          Renames a property stored in this configuration
 void save()
          Saves the properties stored in this configuration to the corresponding file.
 void save(org.eclipse.core.runtime.IProgressMonitor monitor)
          Saves the properties stored in this configuration to the corresponding file.
 void setProperty(Property prop)
          Sets the given property as a User defined property.
 void setProperty(Property prop, java.lang.String value)
          Sets the given property as a User defined property.
 void setProperty(java.lang.String name, java.lang.String value)
          Sets the given property as a User defined property.
 void setToDefaultValue(Property prop)
          Remove the user defined value of a setting and set it back to its default value
 void setVJPDefault(java.lang.String name, java.lang.String value)
          Set the VJP default value for a property
 void setVJPDefaults(org.eclipse.jdt.core.IJavaProject project)
          Sets the VJP default properties for this configuration based on the the project given.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ModePropertyConfiguration

public ModePropertyConfiguration(org.eclipse.core.resources.IFile configFile,
                                 org.eclipse.jdt.core.IJavaProject project)
Creates a default instance of the PropertyManager. Loads values from file "jpf.properties", then loads values from the config file specified.

Parameters:
configFile - the file that properties and loaded from and stored to.
project - the project used to determine the VJP properties
Method Detail

setVJPDefaults

public void setVJPDefaults(org.eclipse.jdt.core.IJavaProject project)
Sets the VJP default properties for this configuration based on the the project given.

Parameters:
project - The project to be used to define the VJP default settings

reloadFromFile

public void reloadFromFile()
                    throws java.io.IOException,
                           org.eclipse.core.runtime.CoreException
Clears all of the config properties contained and then reloads all properties from the configuration file. NOTE: this does not reload from jpf.properties or default.properties

Throws:
java.io.IOException - if the file can not be read
org.eclipse.core.runtime.CoreException - if the file can not be found

parseConfigFile

public void parseConfigFile()
Parses the configuration file and handles it appropriatly


getConfigFileProperties

public static java.util.HashMap<java.lang.String,java.lang.String> getConfigFileProperties(org.eclipse.core.resources.IFile file)
Loads this configuration with the properties contained in configuration file associated.

Returns:
the HashMap that contains all of the properties loaded from jpf.properties and default.properties
Throws:
java.io.IOException
org.eclipse.core.runtime.CoreException

save

public void save()
          throws java.io.IOException,
                 org.eclipse.core.runtime.CoreException
Saves the properties stored in this configuration to the corresponding file.

Throws:
java.io.IOException
org.eclipse.core.runtime.CoreException

save

public void save(org.eclipse.core.runtime.IProgressMonitor monitor)
          throws java.io.IOException,
                 org.eclipse.core.runtime.CoreException
Saves the properties stored in this configuration to the corresponding file. Progress can be logged on the monitor passed.

Parameters:
monitor - used to track the progress of saving the file
Throws:
java.io.IOException
org.eclipse.core.runtime.CoreException

movePropertiesFile

public void movePropertiesFile(org.eclipse.core.runtime.IPath newPath,
                               org.eclipse.core.runtime.IProgressMonitor monitor)
                        throws org.eclipse.core.runtime.CoreException
Move the property file.

Parameters:
newPath - the path representing the new location of the configuration file
monitor - tracks the progress of moving the file to the new location
Throws:
org.eclipse.core.runtime.CoreException

isDirty

public boolean isDirty()
Returns:
true if there are properties that need to be saved to a file.

getPropertyValue

public java.lang.String getPropertyValue(java.lang.String name)
Retrieves a value for the property of this name. This method first looks to userDefined values, then to VJP defined values (unless useVJP has been set to false), then finally to JPF defined. If none of these levels define the property, then a null value is returned.

Returns:
the value of the property

isDefined

public boolean isDefined(java.lang.String propertyName)
Returns:
true if the property specified is defined.

isDefined

public boolean isDefined(Property prop)
Returns:
true if the property specified is defined.

isUserDefined

public boolean isUserDefined(java.lang.String prop)
Returns:
true if the property is user defined.

getProperty

public Property getProperty(java.lang.String propertyName)
Retrieves a Property object for the property of this name. This method first looks to userDefined values, then to VJP defined values (unless useVJP has been set to false), then finally to JPF defined. If none of these levels define the property, then a null value is returned.

Returns:
a property object that represents the key/value of the property

setProperty

public void setProperty(java.lang.String name,
                        java.lang.String value)
Sets the given property as a User defined property.

Parameters:
name - the name for the property being defined
value - the value for the property being defined

setProperty

public void setProperty(Property prop)
Sets the given property as a User defined property.

Parameters:
prop - the property to set in this configuration

setProperty

public void setProperty(Property prop,
                        java.lang.String value)
Sets the given property as a User defined property.

Parameters:
prop - the name of the property to be defined
value - the value of the propert being defined

setToDefaultValue

public void setToDefaultValue(Property prop)
Remove the user defined value of a setting and set it back to its default value

Parameters:
prop - the property to set back to its default value

isUsingDefaultValue

public boolean isUsingDefaultValue(java.lang.String propertyName)
Returns whether the property is using the default value or a user defined value. If the property is not defined in either JPF or VJP then a false value will be returned.

Parameters:
propertyName - the name of the property to be checked
Returns:
true if the property is using the default value false if the property is using a custom user defined value.

isDefaultProperty

public boolean isDefaultProperty(java.lang.String propertyName)
Returns whether the property is defined by either jpfDefaults or if in use VJP defaults.

Returns:
true if the property is defined as a default property

setVJPDefault

public void setVJPDefault(java.lang.String name,
                          java.lang.String value)
Set the VJP default value for a property

Parameters:
name - the name of the property to be defined.
value - the value of the property to be defined.

removeProperty

public void removeProperty(java.lang.String propertyName)
Removes this property from this configuration.


removeProperty

public void removeProperty(Property property)
Removes the property from the userdefined status. Note: only user defined properties can be removed. This is the same as settings it back to its default value.

Parameters:
the - property to be removed from this configuration

getDefaultPropertiesAsArray

public java.lang.Object[] getDefaultPropertiesAsArray()
Returns an object array containing all of the properties listed by the JPF defaults and the VJP defaults. While only properties defined in either JPF or VJP are in this collection, values may come from the UserDefined level.


getUserDefinedPropertiesAsArray

public java.lang.Object[] getUserDefinedPropertiesAsArray()
Returns all Properties that are only defined by the user and not found in jpf.properties or defined by VJP

Returns:
an array of Properties defined by the user. These properties are not overriding any entry eithey by JPF or VJP. These properties exist soley on their own.

getIFile

public org.eclipse.core.resources.IFile getIFile()
The IFile associated to this configuration.

Returns:
The IFile associated to this configuration.

addChangeListener

public void addChangeListener(PropertyChangeListener listener)
Adds a change listener to this configuration. Change listeners are fired once this configuration becomes dirty.

Parameters:
listener - adds the listener to this configuration.

removeChangeListener

public void removeChangeListener(PropertyChangeListener listener)
Removes this change listener from this configuration.

Parameters:
listener - the listener to be removed from this configuration.

renameProperty

public void renameProperty(java.lang.String oldName,
                           java.lang.String newName)
Renames a property stored in this configuration

Parameters:
oldValue - the name of the old value
newValue - the value