org.cdlib.xtf.xslt
Class Session

Object
  extended by Session

public class Session
extends Object

Utility functions to store and access variables in the user's session. Also provides functions that can be called to check whether session tracking is enabled, and map URLs.

Author:
Martin Haye

Constructor Summary
Session()
           
 
Method Summary
static String encodeURL(XPathContext context, String origURL)
          Function to encode a URL, adding session ID if necessary.
static Value getData(XPathContext context, String name)
          Function to get a data from a session variable.
static String getID()
          Function to get the current session's identifier
static String getString(XPathContext context, Value value)
          Gets a proper string for the value.
private static Value getValue(XPathContext context, String str)
          Checks if the input string is actually an XML document.
static boolean isEnabled(XPathContext context)
          Checks whether session tracking was enabled in the servlet config
static boolean noCookie()
          Function to detect if cookies are turned off
static void setData(XPathContext context, String name, String value)
          Function to put data into a session variable.
static void setData(XPathContext context, String name, Value value)
          Function to put structured data into a session variable.
 
Methods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Session

public Session()
Method Detail

isEnabled

public static boolean isEnabled(XPathContext context)
Checks whether session tracking was enabled in the servlet config


getData

public static Value getData(XPathContext context,
                            String name)
                     throws XPathException
Function to get a data from a session variable.

Throws:
XPathException

setData

public static void setData(XPathContext context,
                           String name,
                           Value value)
                    throws XPathException
Function to put structured data into a session variable.

Throws:
XPathException

setData

public static void setData(XPathContext context,
                           String name,
                           String value)
Function to put data into a session variable.


encodeURL

public static String encodeURL(XPathContext context,
                               String origURL)
Function to encode a URL, adding session ID if necessary.


getID

public static String getID()
Function to get the current session's identifier


noCookie

public static boolean noCookie()
Function to detect if cookies are turned off


getString

public static String getString(XPathContext context,
                               Value value)
                        throws XPathException
Gets a proper string for the value. If the value is simply a string, we return just that. If the value is some structured XML, we return XML with a header.

Parameters:
context - Context for the evaluation
Returns:
A byte stream, properly formatted
Throws:
XPathException

getValue

private static Value getValue(XPathContext context,
                              String str)
                       throws XPathException
Checks if the input string is actually an XML document. If so, returns a value containing the parsed XML as a node. Otherwise, returns a simple string value.

Parameters:
str - The string to check.
Returns:
Either a SingletonNode or a StringValue.
Throws:
XPathException