standup.joke
Class BackendJokeSetOnly
java.lang.Object
standup.joke.Backend
standup.joke.BackendJokeSetOnly
- All Implemented Interfaces:
- Profileable
public class BackendJokeSetOnly
- extends Backend
A subclass of Backend
that "generates" jokes purely by retrieving
pre-generated jokes found in the 'joke cache'.
This is used by the 'demo' version of STANDUP. It does not attempt to
establish a connection to the SQL server, and can thus be run on machines
where there is no access to PostgreSQL.
The joke cache is contained in a file in the /standup/resources/xml/
subdirectory found within the STANDUP .jar
file.
- Author:
- Ruli Manurung
Constructor Summary |
BackendJokeSetOnly()
Constructor that uses either
/standup/resources/xml/jokecache.jokes or
/standup/resources/xml/jokecache_corseford.jokes as the joke
cache, depending on the value of the given
CommandLineArguments#KEY_OLDCACHE . |
Methods inherited from class standup.joke.Backend |
addToFavourites, buildUserProfileConstraints, createProfile, getCurrentUserUsedJokeTypes, getFavouriteJokes, getGenerator, getLexicalComponents, getNewJoke, getNewJoke, getNewJoke, getNewJoke, getNewJoke, getNewJoke, getOldJokes, getOldJokes, getOldJokes, getOldJokes, getOldJokes, getOldJokes, getProfile, getProfileFilename, getRootTopic, loadProfile, setProfile |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
jokeCache
JokeSet jokeCache
BackendJokeSetOnly
public BackendJokeSetOnly()
throws GeneratorException
- Constructor that uses either
/standup/resources/xml/jokecache.jokes
or
/standup/resources/xml/jokecache_corseford.jokes
as the joke
cache, depending on the value of the given
CommandLineArguments#KEY_OLDCACHE
.
- Throws:
GeneratorException
generateNewJoke
JokeStructure generateNewJoke(String newJokeID,
JokeConstraints jcs)
- Retrieves a joke from the joke cache that satisfies the given
JokeConstraints
and labels it with the given joke ID.
- Specified by:
generateNewJoke
in class Backend
- Parameters:
newJokeID
- the joke ID for the retrieved jokejcs
- the constraints on the joke to be retrieved
- Returns:
- a joke that satisfies
jcs
, or null
if none could
be retrieved - See Also:
JokeSet.getJokes(JokeConstraints)
,
JokeSet.getRandom()