standup.profiling
Class Profile

java.lang.Object
  extended by standup.profiling.Profile
All Implemented Interfaces:
XMLizable, XMLsaveable
Direct Known Subclasses:
ProfileCloudFrontend, ProfileJokeGeneration, ProfileLexicon

public abstract class Profile
extends Object
implements XMLsaveable

A subclass of Profile stores user-specific information for a corresponding Profileable implementation.

It contains values for various option settings chosen by the user, stored in an Options class, and other user-specific data such as usage records, history, etc.

Note that Profile implements XMLsaveable -- this is because a Profile can be loaded/saved to disk as an XML file.

Author:
Ruli Manurung

Field Summary
private  Options options
           
 
Constructor Summary
Profile()
          Constructor that creates a default profile (using appropriate default options).
Profile(Element element)
          Constructor given an XML Element that contains an appropriate profile definition.
Profile(File profileFile)
          Constructor given an XML File that contains an appropriate profile definition.
Profile(Options options)
          Constructor where the Options are directly provided as an argument.
Profile(URL profileURL)
          Constructor given a URL that refers to an XML file that contains an appropriate profile definition.
 
Method Summary
abstract  Options createDefaultOptions()
          Returns an appropriate instance of Options with default values, i.e.
 Options getOptions()
          Returns the Options contained within this Profile.
abstract  Options loadOptions(Element element)
          Returns an appropriate instance of Options whose values are taken from the given XML Element.
abstract  void quickSave(File file)
          Saves this Profile but not any associated files along with it.
 boolean setOptions(Options options)
          Makes the given Options the one used within this Profile.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface standup.xml.XMLsaveable
save
 
Methods inherited from interface standup.xml.XMLizable
writeXML
 

Field Detail

options

private Options options
Constructor Detail

Profile

public Profile(Options options)
Constructor where the Options are directly provided as an argument.

Parameters:
options -

Profile

public Profile(URL profileURL)
Constructor given a URL that refers to an XML file that contains an appropriate profile definition.

Parameters:
profileURL -

Profile

public Profile(File profileFile)
Constructor given an XML File that contains an appropriate profile definition.

Parameters:
profileFile -

Profile

public Profile()
        throws ProfileException
Constructor that creates a default profile (using appropriate default options).

Throws:
ProfileException

Profile

public Profile(Element element)
Constructor given an XML Element that contains an appropriate profile definition.

Parameters:
element -
Method Detail

getOptions

public Options getOptions()
Returns the Options contained within this Profile. It might be useful to override this method to return the options cast as the appropriate specific Options subclass.

Returns:

setOptions

public boolean setOptions(Options options)
Makes the given Options the one used within this Profile. Always returns true. Override this method to do validation that the given Options is indeed appropriate for the particular subclass of Profile.

Parameters:
options -
Returns:

createDefaultOptions

public abstract Options createDefaultOptions()
                                      throws ProfileException
Returns an appropriate instance of Options with default values, i.e. those contained with the default options package (see ProfileManager.getDefaultOptionsPackage()).

Returns:
Throws:
ProfileException

loadOptions

public abstract Options loadOptions(Element element)
Returns an appropriate instance of Options whose values are taken from the given XML Element.

Returns:

quickSave

public abstract void quickSave(File file)
                        throws XMLException
Saves this Profile but not any associated files along with it. This is for profiles which may depend on other files aside from the XML file created by ProfileManager. For example, the joke generation backend ProfileJokeGeneration contains pointers to XML files that contain the custom lexicon, topic database, etc. If a Profile doesn't have any such files, this method behaves the same as XMLsaveable.save(File).

Parameters:
file - the file to which this Profile should be saved.
Throws:
XMLException