src.modules
Class SLModule

java.lang.Object
  extended bysrc.server.ModuleClass
      extended bysrc.modules.SLModule
All Implemented Interfaces:
Module

public class SLModule
extends ModuleClass

Last updated $Date: 2005/08/09 21:00:20 $ by $Author: andreas $ Changelog: $Log: SLModule.html,v $ Revision 1.1.1.1 2005/08/09 21:00:20 andreas Initial entry Revision 1.13 2005/05/11 07:01:51 andreas The Module interface no longer extends the EventReceiver interface. All modules (or other classes) that wants events now have to implement the EventReceiver interface. Revision 1.12 2005/05/09 12:17:35 linus Fixed small errors. Revision 1.11 2005/05/09 12:00:58 linus Added book module and some other stuff. Revision 1.10 2005/05/08 13:09:22 andreas Removed an unused import. Revision 1.9 2005/05/08 12:41:13 linus Added map module to server configuration. Revision 1.8 2005/05/08 10:48:39 linus Fixed latest version of map. Revision 1.7 2005/05/04 21:53:05 andreas Minor change while trying to debug. Revision 1.6 2005/05/04 12:15:29 andreas Removed warnings. Revision 1.5 2005/05/04 11:23:16 linus Added easter egg module and updated modules to work with new modul structure. Revision 1.4 2005/05/02 16:05:33 linus Stripped data of HTML entities. Revision 1.3 2005/05/02 14:53:15 linus Fixed SL config. Revision 1.2 2005/05/02 13:30:33 linus Changed cache method. Revision 1.1 2005/05/02 13:28:02 linus Added test module and SL module.

Version:
$Revision: 1.1.1.1 $ TODO
Author:
linus

Constructor Summary
SLModule()
           
 
Method Summary
 java.lang.String genAliasString(java.util.HashMap aliases)
          Generate the aliases to a string representation.
 java.util.HashMap getAliases(UserSettings settings)
          Fetch and interpret the aliases this user has saved.
 java.lang.String getSLTravel(java.lang.String from, java.lang.String to, java.util.Date d, boolean arrival)
          Get the travel route with SL from and to two stations.
 java.lang.String getStationName(java.lang.String name, UserSettings settings)
          Lookup the SL name of a station.
 boolean isValidCache(ModuleQuery query, java.lang.String cachedUserId, long cacheAge)
          Checks if a cached result is valid or not based on how long ago the result was cached.
 Package processQuery(ModuleQuery query)
          Process a user sent query.
 void trafficProblems()
          Read traffikavvikelser report
 
Methods inherited from class src.server.ModuleClass
getModuleMeta, processSettingRequest, processSettingRequest, setModuleMeta
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SLModule

public SLModule()
Method Detail

processQuery

public Package processQuery(ModuleQuery query)
Description copied from interface: Module
Process a user sent query. This is very individual depending on the service provided by the module.

Parameters:
query - The user sent query.
Returns:
An ErrorPackage if an error occured while processing the query, an OutputPackage with the result otherwise.

trafficProblems

public void trafficProblems()
Read traffikavvikelser report


getStationName

public java.lang.String getStationName(java.lang.String name,
                                       UserSettings settings)
Lookup the SL name of a station. This should probably cache the data it gets.

Throws:
java.io.UnsupportedEncodingException

getSLTravel

public java.lang.String getSLTravel(java.lang.String from,
                                    java.lang.String to,
                                    java.util.Date d,
                                    boolean arrival)
                             throws java.io.IOException
Get the travel route with SL from and to two stations. Requires the from / to to be correct stations.

Parameters:
from - Which station to go from.
to - Which station to go to.
d - The date/time the travel should be started.
Returns:
Throws:
java.io.IOException

getAliases

public java.util.HashMap getAliases(UserSettings settings)
Fetch and interpret the aliases this user has saved.

Parameters:
settings -
Returns:

genAliasString

public java.lang.String genAliasString(java.util.HashMap aliases)
                                throws java.io.UnsupportedEncodingException
Generate the aliases to a string representation. The rep is in the format aliasName=stationName&aliasName2=stationName2.

Parameters:
aliases -
Returns:
Throws:
java.io.UnsupportedEncodingException

isValidCache

public boolean isValidCache(ModuleQuery query,
                            java.lang.String cachedUserId,
                            long cacheAge)
Description copied from interface: Module
Checks if a cached result is valid or not based on how long ago the result was cached. Some services might work fine with returning very old cached results, for instance the result of a map service wont change (often at least) and most cache ages would then be valid. Other things like news services on the other hand should not allow a long cache age.

Parameters:
query - The user query that resulted in the cached result. The user's query parameters are identical to the cached query parameters.
cachedUserId - The userId of the query that is cached.
cacheAge - The number of seconds that has elapsed since the cached version was cached.
Returns:
True if the cache should be concidered to still be valid. False otherwise.