org.apache.excalibur.source
Class SourceParameters

java.lang.Object
  extended byorg.apache.excalibur.source.SourceParameters
All Implemented Interfaces:
java.lang.Cloneable, java.io.Serializable

public final class SourceParameters
extends java.lang.Object
implements java.io.Serializable, java.lang.Cloneable

This class holds parameters for a Source object. It differs from the usual Parameters object because it can hold more than one value for a parameter, as is the case for HTTP request parameters.

Only particular kinds of Source implementations, such as URLSource support this kind of parameters, passed as the SourceResolver.URI_PARAMETERS entry in the parameters argument of SourceResolver.resolveURI(String, String, Map).

Version:
$Id: SourceParameters.java,v 1.5 2004/03/12 13:02:55 cziegeler Exp $
Author:
Avalon Development Team
See Also:
Serialized Form

Constructor Summary
SourceParameters()
          Standard Constructor creating an empty parameters object
SourceParameters(java.lang.String queryString)
          Construct a new object from a queryString
 
Method Summary
 void add(SourceParameters parameters)
          Add all parameters from the incoming parameters object.
 java.lang.Object clone()
          Returns a copy of the parameters object.
 boolean containsParameter(java.lang.String name)
          Test if a value for this parameter exists.
static SourceParameters create(Configuration conf)
          Create a new parameters object from the children of the configuration.
 java.lang.String getEncodedQueryString()
          Build a query string and encode each parameter value.
 Parameters getFirstParameters()
          Create a Parameters object.
 java.lang.String getParameter(java.lang.String name)
          Get the value of a parameter.
 java.lang.String getParameter(java.lang.String name, java.lang.String defaultValue)
          Get the value of a parameter.
 boolean getParameterAsBoolean(java.lang.String name, boolean defaultValue)
          Get the boolean value of a parameter.
 int getParameterAsInteger(java.lang.String name, int defaultValue)
          Get the integer value of a parameter.
 java.util.Map getParameterMap()
          Returns an immutable java.util.Map containing parameter names as keys and parameter values as map values.
 java.util.Iterator getParameterNames()
          Get all parameter names.
 java.util.Iterator getParameterValues(java.lang.String name)
          Get all values of a parameter.
 java.lang.String[] getParameterValuesAsArray(java.lang.String name)
          Get all values of a parameter.
 java.lang.String getQueryString()
          Build a query string.
 boolean hasParameters()
          Test if there are any parameters.
 void removeParameter(java.lang.String name)
          Remove all values for this parameter
 void setParameter(java.lang.String name, java.lang.String value)
          Add a parameter.
 void setSingleParameterValue(java.lang.String name, java.lang.String value)
          Set the value of this parameter to the given value.
 java.lang.String toString()
          Overriding toString
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

SourceParameters

public SourceParameters()
Standard Constructor creating an empty parameters object


SourceParameters

public SourceParameters(java.lang.String queryString)
Construct a new object from a queryString

Method Detail

create

public static SourceParameters create(Configuration conf)
Create a new parameters object from the children of the configuration. If no children are available null is returned.


setParameter

public void setParameter(java.lang.String name,
                         java.lang.String value)
Add a parameter. The parameter is added with the given value.

Parameters:
name - The name of the parameter.
value - The value of the parameter.

getParameter

public java.lang.String getParameter(java.lang.String name)
Get the value of a parameter.

Parameters:
name - The name of the parameter.
Returns:
The value of the first parameter with the name or null

getParameter

public java.lang.String getParameter(java.lang.String name,
                                     java.lang.String defaultValue)
Get the value of a parameter.

Parameters:
name - The name of the parameter.
defaultValue - The default value if the parameter does not exist.
Returns:
The value of the first parameter with the name or defaultValue

getParameterAsInteger

public int getParameterAsInteger(java.lang.String name,
                                 int defaultValue)
Get the integer value of a parameter.

Parameters:
name - The name of the parameter.
defaultValue - The default value if the parameter does not exist.
Returns:
The value of the first parameter with the name or defaultValue

getParameterAsBoolean

public boolean getParameterAsBoolean(java.lang.String name,
                                     boolean defaultValue)
Get the boolean value of a parameter.

Parameters:
name - The name of the parameter.
defaultValue - The default value if the parameter does not exist.
Returns:
The value of the first parameter with the name or defaultValue

containsParameter

public boolean containsParameter(java.lang.String name)
Test if a value for this parameter exists.

Parameters:
name - The name of the parameter.
Returns:
true if a value exists, otherwise false

getParameterValues

public java.util.Iterator getParameterValues(java.lang.String name)
Get all values of a parameter.

Parameters:
name - The name of the parameter.
Returns:
Iterator for the (String) values or null if the parameter is not defined.

getParameterValuesAsArray

public java.lang.String[] getParameterValuesAsArray(java.lang.String name)
Get all values of a parameter.

Parameters:
name - The name of the parameter.
Returns:
An Array for the (String) values or null.

getParameterNames

public java.util.Iterator getParameterNames()
Get all parameter names.

Returns:
Iterator for the (String) parameter names.

getFirstParameters

public Parameters getFirstParameters()
Create a Parameters object. The first value of each parameter is added to the Parameters object.

Returns:
An Parameters object - if no parameters are defined this is an empty object.

getQueryString

public java.lang.String getQueryString()
Build a query string. The query string can e.g. be used for http connections.

Returns:
A query string which contains for each parameter/value pair a part, like "parameter=value" separated by "&". If no parameter is defined null is returned.

getEncodedQueryString

public java.lang.String getEncodedQueryString()
Build a query string and encode each parameter value. The query string can e.g. be used for http connections.

Returns:
A query string which contains for each parameter/value pair a part, like "parameter=value" separated by "&". If no parameter is defined null is returned.

add

public void add(SourceParameters parameters)
Add all parameters from the incoming parameters object.


toString

public java.lang.String toString()
Overriding toString


clone

public java.lang.Object clone()
Returns a copy of the parameters object.


hasParameters

public boolean hasParameters()
Test if there are any parameters.


setSingleParameterValue

public void setSingleParameterValue(java.lang.String name,
                                    java.lang.String value)
Set the value of this parameter to the given value. Remove all other values for this parameter.


removeParameter

public void removeParameter(java.lang.String name)
Remove all values for this parameter


getParameterMap

public java.util.Map getParameterMap()
Returns an immutable java.util.Map containing parameter names as keys and parameter values as map values. The keys in the parameter map are of type String. The values in the parameter map are of type String array.



Copyright © 1997-2005 The Apache Software Foundation. All Rights Reserved.