Class GoTournaments.GoHttpRequest

java.lang.Object
  extended by GoTournaments.GoHttpRequest
Enclosing class:
GoTournaments

private class GoTournaments.GoHttpRequest
extends java.lang.Object

A class to provide a simple interface for the HttpServletRequest. Provides methods to handle sessions and cookies and to automatically convert data received to various types.


Field Summary
private  javax.servlet.http.HttpServletRequest req
           
 
Constructor Summary
GoTournaments.GoHttpRequest(javax.servlet.http.HttpServletRequest httpservletrequest)
          Constructs a GoHttpRequest interface for an HttpServletRequest.
 
Method Summary
 java.lang.String get(java.lang.String name)
          As above, but an empty String is returned instead of null.
 boolean getBool(java.lang.String name)
          As in get(), but with an automatic conversion to a boolean.
 boolean getCheckbox(java.lang.String name)
          As in get(), but with an automatic conversion to a checkbox state (boolean).
 java.lang.String getCookie(java.lang.String name)
          Returns the value of a cookie or an empty String if the cookie isn't set.
 ID getEID()
          As above, but always gets the entry ID ("eid").
 ID getID(java.lang.String name)
          As in get(), but with an automatic conversion to a Go ID object.
 java.lang.String getParameter(java.lang.String name)
          Returns the value of a field sent either with 'get' or 'post' method as a String.
 ID getTID()
          As above, but always gets the tournament ID ("tid").
 boolean isAdmin()
          Returns true if the user is logged in to the system, otherwise false.
 boolean login(java.lang.String login_password)
          Logs the user in to the system as an administrator if given password matches the administrator password.
 void logout()
          Logs the user out of the system.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

req

private final transient javax.servlet.http.HttpServletRequest req
Constructor Detail

GoTournaments.GoHttpRequest

public GoTournaments.GoHttpRequest(javax.servlet.http.HttpServletRequest httpservletrequest)
Constructs a GoHttpRequest interface for an HttpServletRequest.

Method Detail

getParameter

public java.lang.String getParameter(java.lang.String name)
Returns the value of a field sent either with 'get' or 'post' method as a String. If the field isn't set, null is returned.

Parameters:
name - the name of the field

get

public java.lang.String get(java.lang.String name)
As above, but an empty String is returned instead of null.


getBool

public boolean getBool(java.lang.String name)
As in get(), but with an automatic conversion to a boolean. A String equal to "true" is converted to a true. Anything else is converted to a false.


getCheckbox

public boolean getCheckbox(java.lang.String name)
As in get(), but with an automatic conversion to a checkbox state (boolean). A checked checkbox always has the value "checked" in the system, which is converted to a true, while a non-checked checkbox has no value (an empty String), which, as well as anything else, is converted to a false.


getID

public ID getID(java.lang.String name)
As in get(), but with an automatic conversion to a Go ID object. If the field value cannot be parsed, a null is returned.


getTID

public ID getTID()
As above, but always gets the tournament ID ("tid").


getEID

public ID getEID()
As above, but always gets the entry ID ("eid").


login

public boolean login(java.lang.String login_password)
Logs the user in to the system as an administrator if given password matches the administrator password. Returns true on a match, otherwise false. Uses a HTTP session to store the state.

Parameters:
login_password - the password given by the user.

logout

public void logout()
Logs the user out of the system. Uses a HTTP session to store the state.


isAdmin

public boolean isAdmin()
Returns true if the user is logged in to the system, otherwise false. Uses a HTTP session to store the state.


getCookie

public java.lang.String getCookie(java.lang.String name)
Returns the value of a cookie or an empty String if the cookie isn't set.

Parameters:
name - the name of the cookie.