standup.joke
Class BackendSQL

java.lang.Object
  extended by standup.joke.Backend
      extended by standup.joke.BackendSQL
All Implemented Interfaces:
Profileable

public class BackendSQL
extends Backend

A subclass of Backend that always genuinely generates new jokes.

Author:
Ruli Manurung

Field Summary
 
Fields inherited from class standup.joke.Backend
generator
 
Constructor Summary
BackendSQL()
          Default constructor
 
Method Summary
(package private)  JokeStructure generateNewJoke(String newJokeID, JokeConstraints jcs)
          Generates a new one that satisfies the given JokeConstraints and labels it with the given joke ID.
 boolean setProfile(Profile profile, boolean repeat)
          Sets this Backend to use the specified joke generation profile.
 
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
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

BackendSQL

public BackendSQL()
           throws STANDUPSQLException,
                  GeneratorException
Default constructor

Parameters:
cla -
Throws:
STANDUPSQLException
GeneratorException
Method Detail

setProfile

public boolean setProfile(Profile profile,
                          boolean repeat)
Sets this Backend to use the specified joke generation profile. It also sets up the schema instantiation exclusion (temporary) tables on the SQL database.

Specified by:
setProfile in interface Profileable
Overrides:
setProfile in class Backend
Parameters:
profile - the Profile to be used
repeat - whether this is the first time a profile is being set for the current user during this session
Returns:
true if successful, false otherwise (e.g. if the given profile was not an instance of ProfileJokeGeneration.
See Also:
Generator.setupExclusionTable(JokeSet, String)

generateNewJoke

JokeStructure generateNewJoke(String newJokeID,
                              JokeConstraints jcs)
Generates a new one 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 generated joke
jcs - the constraints on the joke to be generated
Returns:
a joke that satisfies jcs, or null if none could be generated
See Also:
Generator.generateJoke(String, JokeConstraints)