org.matalon.pagerankhits.servlet
Class ServletUtil

java.lang.Object
  extended byorg.matalon.pagerankhits.servlet.ServletUtil

public class ServletUtil
extends java.lang.Object

This class includes common servlet related utilities.

Author:
Yonatan Matalon

Constructor Summary
ServletUtil()
           
 
Method Summary
static java.lang.String validate(java.lang.String paramName, javax.servlet.http.HttpServletRequest request, java.lang.String[] possibleValues)
          Validates that the request includes a parameter named and that its value is one of the possible given values.
static java.lang.String validateNotNull(java.lang.String paramName, javax.servlet.http.HttpServletRequest request)
          Validates that the request includes a parameter named and that its value is not null.
static void writeMatrix(java.io.PrintWriter printWriter, java.lang.String[][] matrix)
          Writes the given matrix to the given PrintWriter.
static void writeSparseMatrix(java.io.PrintWriter printWriter, java.lang.String[][] matrix, java.lang.String matrixName, boolean addVirtualNode)
          Writes the given matrix (named matrixName) to the given PrintWriter.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ServletUtil

public ServletUtil()
Method Detail

validate

public static final java.lang.String validate(java.lang.String paramName,
                                              javax.servlet.http.HttpServletRequest request,
                                              java.lang.String[] possibleValues)
                                       throws javax.servlet.ServletException
Validates that the request includes a parameter named and that its value is one of the possible given values.

Parameters:
paramName -
request -
possibleValues -
Returns:
Parameter's value if valid, otherwise - a ServletException is thrown.
Throws:
javax.servlet.ServletException

validateNotNull

public static final java.lang.String validateNotNull(java.lang.String paramName,
                                                     javax.servlet.http.HttpServletRequest request)
                                              throws javax.servlet.ServletException
Validates that the request includes a parameter named and that its value is not null.

Parameters:
paramName -
request -
Returns:
Parameter's value.
Throws:
javax.servlet.ServletException

writeMatrix

public static final void writeMatrix(java.io.PrintWriter printWriter,
                                     java.lang.String[][] matrix)
Writes the given matrix to the given PrintWriter.

Parameters:
printWriter -
matrix -

writeSparseMatrix

public static final void writeSparseMatrix(java.io.PrintWriter printWriter,
                                           java.lang.String[][] matrix,
                                           java.lang.String matrixName,
                                           boolean addVirtualNode)
Writes the given matrix (named matrixName) to the given PrintWriter. The matrix is written in its sparse form. If addVirtualNode is true, then the written matrix shall include an additional virtual node which has links to all the other nodes and all the other nodes have links to it.

Parameters:
printWriter -
matrix -
matrixName -
addVirtualNode -