public class

GenericRequestKeys

extends Object
implements RequestKeys
java.lang.Object
   ↳ com.microstrategy.web.beans.GenericRequestKeys
Known Direct Subclasses
Known Indirect Subclasses

Class Overview

This class provides provides a skeletal implementation of the interface RequestKeys, to minimize the effort required to implement this interface and allow subclasses to focus only on how to initialize the key-values collection from various sources.

The implementation of this class actually adopts lazy initialization. It calls back the protected method initializeRequestKeys() when the first time you access to the key-values collection. Subclasses should provide their own specific implementation of initialization.

Summary

Public Constructors
GenericRequestKeys()
Constructs a new GenericRequestKeys instance
Public Methods
String add(String key, String value)
Appends a value to a collection mapped by the key specified.
Object addObject(String key, Object value)
Appends an Object to a collection mapped by the key specified.
MarkupOutput getDebugOut()
Get the Debug Information into the output
int getIntValue(String keyName, int valueIndex, int defaultValue)
Parses the value of given request key to an integer.
int getIntValue(String keyName, int valueIndex)
Parses the value of given request key to an integer.
Enumeration getKeyListByPrefix(String prefix)
Returns an enumeration over all the keys with the specified prefix.
String getName(int nameIndex)
Returns the key at the specified position from the current collection.
int getNameCount()
Returns the total number of keys stored in the collection.
String getValue(String keyName)
Returns from this collection a comma separated string of all the values mapped by the specified keyName.
String getValue(String keyName, int valueIndex)
Returns the value at the specified position mapped by the specified keyName.
int getValueCount(String keyName)
Returns from this collection the number of values mapped with the keyName.
Object getValueObject(String keyName, int valueIndex)
Returns the Object at the specified position mapped by the specified keyName.
Enumeration getValueObject(String key)
Returns the collection of all the values mapped by the specified keyName.
boolean isEmpty()
Returns whether the value collection is empty.
void remove(String key)
Removes the argument with the given key.
void setValue(String key, String value, int index)
Replaces the value at a specific index for a given key.
void setValueObject(String key, Object value, int index)
Replaces the Object at a specific index for a given key.
String toString()
Protected Methods
String add(String key, String value, String delimiter)
Appends a value to a collection mapped by the key specified.
LinkedList addKeyValue(String key, Object value)
Adds an Object to the collection defined by the key.
LinkedList getAllValues(String keyName)
Retrieves all values associated with the key.
Object getObjectAtIndex(String keyName, int valueIndex)
Retrieves the Object located at a specific index within the collection defined by keyName.
void initializeRequestKeys()
Initializes the key-value collection from various sources.
void setInitialized(boolean initialized)
Sets a flag indicating whether this collection has been initialized.
void setObjectAtIndex(String key, Object value, int index)
Used by setValue and setValueObject to do the actual work.
[Expand]
Inherited Methods
From class java.lang.Object
From interface com.microstrategy.web.beans.RequestKeys

Public Constructors

public GenericRequestKeys ()

Constructs a new GenericRequestKeys instance

Public Methods

public String add (String key, String value)

Appends a value to a collection mapped by the key specified. A new collection is created if there is no such an collection existing. The initialized flag is set to True after calling this method.

By default, there is no tokenizing of the string. This call is equivalent to call add(key, value, null).

Parameters
key the key under which the new value will be appended
value the value to be appended
Returns
  • a copy of the value added

public Object addObject (String key, Object value)

Appends an Object to a collection mapped by the key specified. A new collection is created if there is no such an collection existing. The initialized flag is set to True after calling this method.

Parameters
key the key under which the new Object will be appended
value the Object to be appended
Returns
  • a copy of the Object added

public MarkupOutput getDebugOut ()

Get the Debug Information into the output

Returns

public int getIntValue (String keyName, int valueIndex, int defaultValue)

Parses the value of given request key to an integer.

Parameters
defaultValue The default value.
Returns
  • An integer value, if the value can be parsed to an integer. Otherwise, it returns the default value.

public int getIntValue (String keyName, int valueIndex)

Parses the value of given request key to an integer.

Parameters
keyName The request key name
valueIndex an index of the value to return (must be between 0 and getValueCount(name)-1.
Returns
  • An integer value, if the value is not null and can be parsed to an integer. Otherwise, it throws NumberFormatException

public Enumeration getKeyListByPrefix (String prefix)

Returns an enumeration over all the keys with the specified prefix.
Returns all the keys if the specified prefix is null or empty.
Returns an empty list if no key is found.

Parameters
prefix the prefix of keys.
Returns
  • an enumeration over all the keys that have the specified prefix.

public String getName (int nameIndex)

Returns the key at the specified position from the current collection.

Parameters
nameIndex the index of the key
Returns
  • the key at the specified index; null if the index is invalid.

public int getNameCount ()

Returns the total number of keys stored in the collection.

Returns
  • the number of keys stored in the collection.

public String getValue (String keyName)

Returns from this collection a comma separated string of all the values mapped by the specified keyName.

Parameters
keyName a key in this collection
Returns
  • all the values mapped to the keyName, separated by the character comma; null if the key does not exist.

public String getValue (String keyName, int valueIndex)

Returns the value at the specified position mapped by the specified keyName.

Parameters
keyName a key in this collection
valueIndex the index of a value mapped to the key specified
Returns
  • the value at the specified position mapped by the specified key; null if the key does not exist.

public int getValueCount (String keyName)

Returns from this collection the number of values mapped with the keyName.

Parameters
keyName a key to a value collection
Returns
  • the count of values to which the specified key is mapped in this collection; 0 if the key is not found.

public Object getValueObject (String keyName, int valueIndex)

Returns the Object at the specified position mapped by the specified keyName.

Parameters
keyName a key in this collection
valueIndex the index of an Object mapped to the key specified
Returns
  • the Object at the specified position mapped by the specified key; null if the key does not exist.

public Enumeration getValueObject (String key)

Returns the collection of all the values mapped by the specified keyName.

Parameters
key a key in this collection
Returns
  • all the values mapped to the keyName; null if the key does not exist.

public boolean isEmpty ()

Returns whether the value collection is empty.

Returns
  • true if the value collection is empty.

public void remove (String key)

Removes the argument with the given key.

Parameters
key the key of the argument to remove.

public void setValue (String key, String value, int index)

Replaces the value at a specific index for a given key. As any key may have several values, this method replaces a specific value. Nothing happens if the index is out of bounds.

Parameters
key the new key whose correponding value is to be added
value the new value to be added
index the position to add the key-value pair.

public void setValueObject (String key, Object value, int index)

Replaces the Object at a specific index for a given key. As any key may have several Objects, this method replaces a specific Object. Nothing happens if the index is out of bounds.

Parameters
key the new key whose correponding Object is to be added
value the new Object to be added
index the position to add the key-value pair.

public String toString ()

Protected Methods

protected String add (String key, String value, String delimiter)

Appends a value to a collection mapped by the key specified. A new collection is created if there is no such an collection existing. The initialized flag is set to True after calling this method.

This method uses the specified delimiter to tokenize the value before adding each token into the collection.

Parameters
key the key under which the new value will be appended.
value the value to be appended.
delimiter the String delimiter used in tokenization.
Returns
  • a copy of the value added

protected LinkedList addKeyValue (String key, Object value)

Adds an Object to the collection defined by the key. Creates the collection if it doesn't exist yet.

Parameters
key the key under which the new Object will be appended
value the Object to be appended
Returns
  • the LinkedList of Objects associated with the key

protected LinkedList getAllValues (String keyName)

Retrieves all values associated with the key. Decoded values are added if they exist.

Parameters
keyName the key to retrieve all values for
Returns
  • LinkedList of all values associated with the key

protected Object getObjectAtIndex (String keyName, int valueIndex)

Retrieves the Object located at a specific index within the collection defined by keyName.

Parameters
keyName key of object collection
valueIndex position of Object to retrieve
Returns
  • the Object retrieved

protected void initializeRequestKeys ()

Initializes the key-value collection from various sources. Implementation class extending this class needs to call the add(String, String) method to add key-value pairs into the collection.

protected void setInitialized (boolean initialized)

Sets a flag indicating whether this collection has been initialized. A false value will trigger this object to re-intialize itself by calling the method initializeRequestKeys().

Parameters
initialized true if the current collection has been initialized.

protected void setObjectAtIndex (String key, Object value, int index)

Used by setValue and setValueObject to do the actual work.

Parameters
key the new key whose correponding Object is to be added
value the new Object to be added
index the position to add the key-value pair.