OpMath

com.opmath.util.http
Interface ParamIndex

All Known Implementing Classes:
HttpLogOnServlet, HttpProtectedServlet, HttpServlet, HttpSessionServlet, ParamTable, HttpLogOffServlet

public interface ParamIndex

The interface required by objects making use of the parameter ((name / value) => index) functions.

An object that implements the ParamIndex interface provides utilities for managing and accessing parameters passed to servlets using GET and POST methods. In particular, it allows the servlet to establish any number of parameter name - parameter value list associations.

One of the chief advantages of ParamIndex is its ability to support the use of Java switch statements over parameter values. In order for this to work, the index which is associated with each parameter value must be declared as a static final int.

The design of ParamIndex is suited to implementation using a java.util.Hashtable or a subclass of Hashtable.

Copyright: (c) 2002 The Open Math Company Limited

The Terms of Distribution of this software are stipulated in the javadoc Overview for this project.

Since:
J2SE 1.3
Version:
utilities-v011
Author:
Bruno Beloff bruno.beloff@opmath.com

Method Summary
 int getIndex(String paramName, String paramValue)
          Returns the int index associated with the pair paramName / paramValue, as established by registerIndex(String, String, int).
 int getParamIndex(String paramName, HttpServletRequest req)
          Returns the int index of the parameter value found in the HttpServletRequest whose name is paramName and whose value is found in the HttpServletRequest.
 int getValueCount(String paramName)
          Returns the number of parameter values registered against the parameter name paramName.
 Enumeration paramIndices(String paramName)
          Returns an Enumeration of the parameter indices for the values registered against paramName.
 Enumeration paramMappings()
          Returns an Enumeration of the parameter (value => index) mappings known to the registry.
 Enumeration paramNames()
          Returns an Enumeration of the parameter names known to the registry.
 Enumeration paramValues(String paramName)
          Returns an Enumeration of the parameter values registered against paramName.
 void registerIndex(String paramName, String paramValue, int paramValueIndex)
          Associates the value of a servlet parameter with an int index.
 

Method Detail

registerIndex

public void registerIndex(String paramName,
                          String paramValue,
                          int paramValueIndex)
Associates the value of a servlet parameter with an int index. The main use of the register is to enable switch statements to work over commands handed to the servlet; to do this, the int must be declared as static final.

NOTE: Command parameter value strings should always be case-insensitive.

Parameters:
paramName - the String name of the parameter.
paramValue - the String value of the parameter.
paramValueIndex - the int value associated with the parameter value.
Since:
J2SE 1.3

getIndex

public int getIndex(String paramName,
                    String paramValue)
Returns the int index associated with the pair paramName / paramValue, as established by registerIndex(String, String, int).

It is expected that, if the pair paramName / paramValue is not known to the registry, then getIndex(String, String) will return the int value com.opmath.util.http.ParamIndex.PARAM_INDEX_FAIL.

NOTE: Command parameter value strings should always be case-insensitive.

Parameters:
paramName - the String name of the parameter.
paramValue - the String value of the parameter.
Returns:
the associated int value of the parameter, or the int value com.opmath.util.http.ParamIndex.PARAM_INDEX_FAIL.
Since:
J2SE 1.3

getParamIndex

public int getParamIndex(String paramName,
                         HttpServletRequest req)
Returns the int index of the parameter value found in the HttpServletRequest whose name is paramName and whose value is found in the HttpServletRequest.

It is expected that, if paramName is not found in the HttpServletRequest, or if the value for paramName found in the HttpServletRequest is not known to the registry, then getParamIndex(String, HttpServletRequest) will return the int value com.opmath.util.http.ParamIndex.PARAM_INDEX_FAIL.

NOTE: Command parameter value strings should always be case-insensitive.

Parameters:
paramName - the String name of the parameter.
req - the HttpServletRequest containing the parameter.
Returns:
the associated int value of the parameter, or the int value com.opmath.util.http.ParamIndex.PARAM_INDEX_FAIL.
Since:
J2SE 1.3

getValueCount

public int getValueCount(String paramName)
Returns the number of parameter values registered against the parameter name paramName.

It is expected that, if paramName is not known to the registry, then getValueCount(String) will return the int value 0.

Parameters:
paramName - the String name of the parameter.
Returns:
the int total number of values held against this name.
Since:
J2SE 1.3

paramNames

public Enumeration paramNames()
Returns an Enumeration of the parameter names known to the registry.

Returns:
an Enumeration of parameter names.
Since:
J2SE 1.3

paramMappings

public Enumeration paramMappings()
Returns an Enumeration of the parameter (value => index) mappings known to the registry.

Returns:
an Enumeration of parameter (value => index) mappings.
Since:
J2SE 1.3

paramValues

public Enumeration paramValues(String paramName)
Returns an Enumeration of the parameter values registered against paramName.

It is expected that, if paramName is not known to the registry, then paramValues() will return null.

Parameters:
paramName - the String name of the parameter.
Returns:
an Enumeration of parameter values.
Since:
J2SE 1.3

paramIndices

public Enumeration paramIndices(String paramName)
Returns an Enumeration of the parameter indices for the values registered against paramName.

It is expected that, if paramName is not known to the registry, then paramIndices() will return null.

Parameters:
paramName - the String name of the parameter.
Returns:
an Enumeration of parameter names.
Since:
J2SE 1.3

OpMath

Submit a bug or feature to Open Math
Copyright © 2002 Open Math Company Limited, Brighton, UK