com.atlassian.confluence.macro.params
Class BaseParameter<T>

java.lang.Object
  extended by com.atlassian.confluence.macro.params.BaseParameter<T>
All Implemented Interfaces:
Parameter<T>
Direct Known Subclasses:
BooleanQueryFactoryParameter, MaxResultsParameter, MultiValueParameter, SearchSortParameter

public abstract class BaseParameter<T>
extends java.lang.Object
implements Parameter<T>

A base implementation of Parameter, providing support for multiple default parameter names, and a default value if no parameter is specified.

Since:
2.9

Field Summary
protected  boolean shouldValidate
           
 
Constructor Summary
protected BaseParameter(java.util.List<java.lang.String> names, java.lang.String defaultValue)
           
protected BaseParameter(java.lang.String[] names, java.lang.String defaultValue)
           
protected BaseParameter(java.lang.String name, java.lang.String defaultValue)
           
 
Method Summary
 void addParameterAlias(java.lang.String name)
          Deprecated. since 3.1: this class is not thread safe and should not be mutated
protected abstract  T findObject(java.lang.String paramValue, MacroExecutionContext ctx)
          Responsible for converting a macro parameter string value to its proper object representation (say "1" to new Integer(1))
 T findValue(MacroExecutionContext ctx)
          Attempts to find the value from the specified MacroExecutionContext object.
 java.lang.String getDefaultValue()
          Returns the default value for this parameter if no match is found in the context.
protected  java.lang.String getParameter(java.util.Map<java.lang.String,java.lang.String> params, java.util.List names, java.lang.String defaultValue)
          Returns the literal value of the parameter in the specified Map, using the specified List for names and aliases and the specified default value.
 java.lang.String getParameterValue(java.util.Map<java.lang.String,java.lang.String> params)
          Returns the literal value of the parameter, or the default value if none is present.
 void setDefaultValue(java.lang.String defaultValue)
          Deprecated. since 3.1: this class is not thread safe and should not be mutated
 void setParameterNames(java.lang.String[] names)
          Deprecated. since 3.1: this class is not thread safe and should not be mutated
 void setValidate(boolean shouldValidate)
          Sets whether this parameter should attempt to validate its values.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

shouldValidate

protected boolean shouldValidate
Constructor Detail

BaseParameter

protected BaseParameter(java.lang.String name,
                        java.lang.String defaultValue)

BaseParameter

protected BaseParameter(java.lang.String[] names,
                        java.lang.String defaultValue)

BaseParameter

protected BaseParameter(java.util.List<java.lang.String> names,
                        java.lang.String defaultValue)
Method Detail

addParameterAlias

@Deprecated
public final void addParameterAlias(java.lang.String name)
Deprecated. since 3.1: this class is not thread safe and should not be mutated

Adds the specified String as an alias to the default name of this parameter.

Parameters:
name - another name for the parameter recognized by this object

setParameterNames

@Deprecated
public final void setParameterNames(java.lang.String[] names)
Deprecated. since 3.1: this class is not thread safe and should not be mutated

Sets the specified String array as the names by which to recognize this parameter.

Parameters:
names - the names of the parameter to recognize

setDefaultValue

@Deprecated
public final void setDefaultValue(java.lang.String defaultValue)
Deprecated. since 3.1: this class is not thread safe and should not be mutated

Sets the default value to be returned for this parameter if no match is found in the context.

Parameters:
defaultValue - the default value for this parameter

getDefaultValue

public final java.lang.String getDefaultValue()
Returns the default value for this parameter if no match is found in the context.

Returns:
the default value for this parameter

getParameter

protected final java.lang.String getParameter(java.util.Map<java.lang.String,java.lang.String> params,
                                              java.util.List names,
                                              java.lang.String defaultValue)
Returns the literal value of the parameter in the specified Map, using the specified List for names and aliases and the specified default value.

Parameters:
params - the Map of parameters to search
names - the parameter names to look for
defaultValue - the default value to return if no match is found
Returns:
the parameter value, or the default if none is found

getParameterValue

public final java.lang.String getParameterValue(java.util.Map<java.lang.String,java.lang.String> params)
Returns the literal value of the parameter, or the default value if none is present.

Parameters:
params - the Map of parameters to search
Returns:
the literal value of the parameter

setValidate

public final void setValidate(boolean shouldValidate)
Description copied from interface: Parameter
Sets whether this parameter should attempt to validate its values.

Specified by:
setValidate in interface Parameter<T>
Parameters:
shouldValidate - true if this parameter should attempt to validate

findValue

public final T findValue(MacroExecutionContext ctx)
                  throws ParameterException
Description copied from interface: Parameter
Attempts to find the value from the specified MacroExecutionContext object.

Specified by:
findValue in interface Parameter<T>
Parameters:
ctx - The execution context for the macro.
Returns:
The parameter value.
Throws:
ParameterException - if there was a problem while processing the parameter.

findObject

protected abstract T findObject(java.lang.String paramValue,
                                MacroExecutionContext ctx)
                         throws ParameterException
Responsible for converting a macro parameter string value to its proper object representation (say "1" to new Integer(1))

Throws:
ParameterException


Copyright © 2003-2014 Atlassian. All Rights Reserved.