com.mindtree.techworks.insight.preferences.xmlpersistence
Class XMLPreferenceDataHandler

java.lang.Object
  extended by com.mindtree.techworks.insight.preferences.xmlpersistence.XMLPreferenceDataHandler
All Implemented Interfaces:
PreferenceDataHandler

public class XMLPreferenceDataHandler
extends java.lang.Object
implements PreferenceDataHandler

This is an implementation of the PreferenceDataHandler. It populates the preferences stored in an XML file following a schema. The schema is located within the classpath at the location com.mindtree.techworks.insight.preferences.xmlpersistence.res.InsightPreferences.xsd.
For more details on the schema see XMLPreferenceDataReader.

Version:
$Revision: 27 $ $Date: 2007-12-16 04:58:03 -0700 (Sun, 16 Dec 2007) $
Author:
Bindul Bhowmik
See Also:
PreferenceDataHandler

Field Summary
protected static java.lang.String LEXICAL_HANDLER_PROPERTY_ID
          Lexical handler property id (http://xml.org/sax/properties/lexical-handler).
protected  java.lang.String schemaFilePath
          Stores the location of the schema.
static java.lang.String XML_PROP_FILE_URI
          Relative path of the config file
 
Constructor Summary
XMLPreferenceDataHandler()
          Default constructor.
 
Method Summary
 java.util.Collection getAllPreferences()
          Returns all the preferences.
 Preference getPreference(java.lang.String preferenceId)
           Returns a preference for the id passed, or null if no preference is found for the id.
 java.util.Collection getPreferenceNameList()
           Returns a list of PreferenceInfo objects.
 void savePreferences(java.util.List preferences)
          Saves the given preferences
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

LEXICAL_HANDLER_PROPERTY_ID

protected static final java.lang.String LEXICAL_HANDLER_PROPERTY_ID
Lexical handler property id (http://xml.org/sax/properties/lexical-handler).

See Also:
Constant Field Values

XML_PROP_FILE_URI

public static final java.lang.String XML_PROP_FILE_URI
Relative path of the config file

See Also:
Constant Field Values

schemaFilePath

protected java.lang.String schemaFilePath
Stores the location of the schema.

This variable should have been a local variable of the validateXMLFile() method, but it needs to be accessed by the inner class, hench it is made a class field.

Constructor Detail

XMLPreferenceDataHandler

public XMLPreferenceDataHandler()
                         throws PreferenceHandlerInstantiationException
Default constructor.

Throws:
PreferenceHandlerInstantiationException - When the Handler cannot be instantiated because the XML is not valid or is not found.
Method Detail

getPreferenceNameList

public java.util.Collection getPreferenceNameList()

Returns a list of PreferenceInfo objects.

It first checks if the preferences have been loaded onto the cache or not. If not then loads the preferences on the cache and then returns the preference info.

Specified by:
getPreferenceNameList in interface PreferenceDataHandler
Returns:
A collection of Preference Names
See Also:
PreferenceDataHandler.getPreferenceNameList()

getPreference

public Preference getPreference(java.lang.String preferenceId)

Returns a preference for the id passed, or null if no preference is found for the id.

It first checks if the preferences have been loaded onto the cache or not. If not then loads the preferences on the cache and then returns the preference.

Specified by:
getPreference in interface PreferenceDataHandler
Parameters:
preferenceId - The id of the Preference to be loaded
Returns:
The preference for the id passed, or null.
See Also:
PreferenceDataHandler.getPreference(java.lang.String)

savePreferences

public void savePreferences(java.util.List preferences)
                     throws PreferenceHandlerStoreException
Saves the given preferences

Specified by:
savePreferences in interface PreferenceDataHandler
Parameters:
preferences - The Preferences to store.
Throws:
PreferenceHandlerStoreException
See Also:
PreferenceDataHandler.savePreferences(java.util.List)

getAllPreferences

public java.util.Collection getAllPreferences()
Returns all the preferences.

Specified by:
getAllPreferences in interface PreferenceDataHandler
Returns:
A collection of Preferences
See Also:
PreferenceDataHandler.getAllPreferences()


Copyright © 2003-2008 MindTree Consulting Ltd.. All Rights Reserved.