standup.joke
Class ProfileJokeGeneration

java.lang.Object
  extended by standup.profiling.Profile
      extended by standup.joke.ProfileJokeGeneration
All Implemented Interfaces:
XMLizable, XMLsaveable

public class ProfileJokeGeneration
extends Profile

A Profile relating to joke generation. It contains:

Author:
Ruli Manurung

Field Summary
private  String favouriteJokesFilename
           
private  JokeSet favourites
          A JokeSet representing the user's favourite jokes.
static String FILENAME_FAVOURITE_JOKES
           
static String FILENAME_GENERATED_JOKE_LOG
           
private  JokeSet generatedJokeLog
          A JokeSet representing previously generated jokes.
private  String generatedJokeLogFilename
           
private  int jokeIDCounter
          Not a user option, but a counter of jokes generated
static String XMLTAG
           
 
Constructor Summary
ProfileJokeGeneration(File proFile)
          Constructor method where the Options is supplied from an appropriate file.
ProfileJokeGeneration(File dir, Element profileElement)
           
ProfileJokeGeneration(File dir, OptionsJokeGeneration opty, int idc, String _gjl, String _fav)
          Constructor method where the parameters are supplied directly
 
Method Summary
 void addUserConstraints(JokeConstraints jcs, JokeTypeSet allJokeTypes, LexicalComponents lxc)
          Constructs the various constraints found in this profile relating to joke generation, and adds them to the given JokeConstraints.
 OptionsJokeGeneration createDefaultOptions()
          Returns an appropriate instance of Options with default values, i.e.
 String getFavouriteJokesFilename()
           
 JokeSet getFavourites()
           
 JokeSet getGeneratedJokeLog()
           
 String getGeneratedJokeLogFilename()
           
 int getNextJokeCounter()
           
 OptionsJokeGeneration getOptions()
          Returns the Options contained within this Profile.
 void incrementJokeIDCounter()
           
 OptionsJokeGeneration loadOptions(Element element)
          Returns an appropriate instance of Options whose values are taken from the given XML Element.
 void quickSave(File file)
          This saves the ProfileGeneration XML file but *not* the associated files, i.e.
 void save(File file)
          This saves the ProfileGeneration XML file and also saves the associated files, i.e.
 void saveFavourites(File dir)
           
 void saveJokeLog(File dir)
           
 boolean setOptions(Options incomingOptions)
          Makes the given Options the one used within this Profile.
 void writeXML(Writer out, String indent)
          This method writes the necessary information contained within an instance to an XML file.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

XMLTAG

public static final String XMLTAG
See Also:
Constant Field Values

FILENAME_GENERATED_JOKE_LOG

public static final String FILENAME_GENERATED_JOKE_LOG
See Also:
Constant Field Values

FILENAME_FAVOURITE_JOKES

public static final String FILENAME_FAVOURITE_JOKES
See Also:
Constant Field Values

jokeIDCounter

private int jokeIDCounter
Not a user option, but a counter of jokes generated


generatedJokeLog

private final JokeSet generatedJokeLog
A JokeSet representing previously generated jokes.


generatedJokeLogFilename

private final String generatedJokeLogFilename

favourites

private final JokeSet favourites
A JokeSet representing the user's favourite jokes.


favouriteJokesFilename

private final String favouriteJokesFilename
Constructor Detail

ProfileJokeGeneration

public ProfileJokeGeneration(File dir,
                             OptionsJokeGeneration opty,
                             int idc,
                             String _gjl,
                             String _fav)
Constructor method where the parameters are supplied directly

Parameters:
proFile -

ProfileJokeGeneration

public ProfileJokeGeneration(File dir,
                             Element profileElement)

ProfileJokeGeneration

public ProfileJokeGeneration(File proFile)
Constructor method where the Options is supplied from an appropriate file.

Parameters:
proFile -
Method Detail

getOptions

public OptionsJokeGeneration getOptions()
Description copied from class: Profile
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.

Overrides:
getOptions in class Profile
Returns:

setOptions

public boolean setOptions(Options incomingOptions)
Description copied from class: Profile
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.

Overrides:
setOptions in class Profile
Returns:

addUserConstraints

public void addUserConstraints(JokeConstraints jcs,
                               JokeTypeSet allJokeTypes,
                               LexicalComponents lxc)
Constructs the various constraints found in this profile relating to joke generation, and adds them to the given JokeConstraints.

It currently handles the following constraints:

Note that InstantiationConstraintNovelty is not handled here, as this method is intended for both new and old jokes. If it was added here, no old jokes would ever be retrieved!

Parameters:
jcs - the JokeConstraints that is to contain the various user constraints
allJokeTypes - a JokeTypeSet containing all known JokeTypes -- required for the construction of JokeConstraintTypes

writeXML

public void writeXML(Writer out,
                     String indent)
              throws IOException,
                     XMLException
Description copied from interface: XMLizable
This method writes the necessary information contained within an instance to an XML file.

Parameters:
out - The output stream for the XML file, which is assumed to be already opened and writable.
indent - A string to be prepended before every line written by this method. If passed appropriate white space, e.g. XMLUtils.xmlIndent, it can be used to control indentation.
Throws:
IOException
XMLException

getNextJokeCounter

public int getNextJokeCounter()

incrementJokeIDCounter

public void incrementJokeIDCounter()

getGeneratedJokeLogFilename

public String getGeneratedJokeLogFilename()

getGeneratedJokeLog

public JokeSet getGeneratedJokeLog()

saveJokeLog

public void saveJokeLog(File dir)

getFavouriteJokesFilename

public String getFavouriteJokesFilename()

getFavourites

public JokeSet getFavourites()

saveFavourites

public void saveFavourites(File dir)

quickSave

public void quickSave(File file)
               throws XMLException
This saves the ProfileGeneration XML file but *not* the associated files, i.e. joke log, favourites, lexical components.

Specified by:
quickSave in class Profile
Parameters:
file - File where this ProfileGeneration is to be saved.
Throws:
XMLException

save

public void save(File file)
          throws XMLException
This saves the ProfileGeneration XML file and also saves the associated files, i.e. joke log, favourites, lexical components.

Parameters:
file - File where this ProfileGeneration is to be saved.
Throws:
XMLException

createDefaultOptions

public OptionsJokeGeneration createDefaultOptions()
                                           throws ProfileException
Description copied from class: Profile
Returns an appropriate instance of Options with default values, i.e. those contained with the default options package (see ProfileManager.getDefaultOptionsPackage()).

Specified by:
createDefaultOptions in class Profile
Returns:
Throws:
ProfileException

loadOptions

public OptionsJokeGeneration loadOptions(Element element)
Description copied from class: Profile
Returns an appropriate instance of Options whose values are taken from the given XML Element.

Specified by:
loadOptions in class Profile
Returns: