com.indexdata.mkjsf.pazpar2.commands
Class CommandParameter

java.lang.Object
  extended by com.indexdata.mkjsf.pazpar2.commands.CommandParameter
All Implemented Interfaces:
Serializable
Direct Known Subclasses:
FilterParameter, LimitParameter, QueryParameter

public class CommandParameter
extends Object
implements Serializable

Represents a Pazpar2 command parameter with a name, an operator, a simple value and/or one or more complex values (expressions).

Examples:

Author:
Niels Erik
See Also:
Serialized Form

Constructor Summary
CommandParameter(String name)
           
CommandParameter(String name, String operator, Expression... expressions)
          Instantiates a parameter with one or more expressions
CommandParameter(String name, String operator, int value)
          Instantiates a parameter with a numeric value
CommandParameter(String name, String operator, String value)
          Instantiates a parameter with a simple value
CommandParameter(String name, String operator, String value, Expression... expressions)
          Instantiates a parameter with a simple value and one or more expressions
 
Method Summary
 void addExpression(Expression expression)
          Adds an expression to the end of the list of current expressions (if any)
 CommandParameter copy()
          Clones the CommandParameter
 boolean equals(Object otherParameter)
           
 String getEncodedQueryString()
          Returns a URL encoded string of this parameter with name, operator, simple value and/or expressions
 List<Expression> getExpressions()
          Returns a list of all current expressions
 List<Expression> getExpressions(String... expressionFields)
          Returns expressions selected by their left-hand keys - as in 'expressionField=value'.
 String getName()
          Returns the name (left of operator) of this parameter
 String getSimpleValue()
          Returns the simple parameter value or null if no simple value was set for this parameter
 String getValueWithExpressions()
          Returns the simple parameter value and/or any expressions, separated by 'AND'
 boolean hasExpressions()
          Returns true if this parameter has expressions (complex values)
 boolean hasExpressions(String expressionField)
          Returns true if this parameter has expressions of the given type, that is, expressions where the left-of-operator key equals 'expressionField'
 int hashCode()
           
 boolean hasOperator()
           
 boolean hasValue()
          Returns true if this parameter has a simple value
 void removeExpression(Expression expression)
          Removes a single expression identified by all its characteristics
 void removeExpressions(String... expressionFields)
          Removes expressions selected by their left-of-operator fields/keys - as in 'expressionField=value'.
 void removeExpressionsAfter(Expression expression, String... expressionFields)
          Removes all expressions that appear after the provided expression and that have the given keys to the left of their operators - as in 'expressionField=value'.
 String toString()
           
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

CommandParameter

public CommandParameter(String name)

CommandParameter

public CommandParameter(String name,
                        String operator,
                        String value,
                        Expression... expressions)
Instantiates a parameter with a simple value and one or more expressions

Parameters:
name -
operator -
value -
expressions -

CommandParameter

public CommandParameter(String name,
                        String operator,
                        Expression... expressions)
Instantiates a parameter with one or more expressions

Parameters:
name -
operator -
expressions -

CommandParameter

public CommandParameter(String name,
                        String operator,
                        String value)
Instantiates a parameter with a simple value

Parameters:
name -
operator -
value -

CommandParameter

public CommandParameter(String name,
                        String operator,
                        int value)
Instantiates a parameter with a numeric value

Parameters:
name -
operator -
value -
Method Detail

getName

public String getName()
Returns the name (left of operator) of this parameter

Returns:
name (left of operator) of this parameter

getExpressions

public List<Expression> getExpressions()
Returns a list of all current expressions

Returns:
a list of all current expressions

getExpressions

public List<Expression> getExpressions(String... expressionFields)
Returns expressions selected by their left-hand keys - as in 'expressionField=value'.

If the parameter has expressions expr1=x,expr2=y,expr3=z,expr1=u then invoking this method with {"expr1","expr3"} would return expr1=x,expr3=z,expr1=u but not expr2=y.

Parameters:
expressionFields - The expression types to return
Returns:
a list of expressions with the given keys to the left of the operator

addExpression

public void addExpression(Expression expression)
Adds an expression to the end of the list of current expressions (if any)

Parameters:
expression - to add

removeExpression

public void removeExpression(Expression expression)
Removes a single expression identified by all its characteristics

Parameters:
expression - to remove

removeExpressionsAfter

public void removeExpressionsAfter(Expression expression,
                                   String... expressionFields)
Removes all expressions that appear after the provided expression and that have the given keys to the left of their operators - as in 'expressionField=value'.

This method is intended for bread crumb-like UI controls

Parameters:
expression - The expression to use a starting point for removal (not inclusive)
expressionFields - The expression fields to remove

removeExpressions

public void removeExpressions(String... expressionFields)
Removes expressions selected by their left-of-operator fields/keys - as in 'expressionField=value'.

If the parameter has expressions expr1=x,expr2=y,expr3=z,expr1=u then invoking this method with {"expr1","expr3"} would remove expr1=x,expr3=z and expr1=u but leave expr2=y.

Parameters:
expressionFields - The expression types (by field) to remove

hasOperator

public boolean hasOperator()
Returns:
true if an operator was defined for this parameter yet

hasValue

public boolean hasValue()
Returns true if this parameter has a simple value

Returns:
true if this parameter has a simple value

hasExpressions

public boolean hasExpressions()
Returns true if this parameter has expressions (complex values)

Returns:
true if this parameter has expressions (complex values)

hasExpressions

public boolean hasExpressions(String expressionField)
Returns true if this parameter has expressions of the given type, that is, expressions where the left-of-operator key equals 'expressionField'

Parameters:
expressionField - the type of expression to look for
Returns:
true if this parameter has expressions of the given type, that is, expressions where the left-of-operator key equals 'expressionField'

getEncodedQueryString

public String getEncodedQueryString()
Returns a URL encoded string of this parameter with name, operator, simple value and/or expressions

Returns:
URL encoded string of this parameter with name, operator, simple value and/or expressions

getSimpleValue

public String getSimpleValue()
Returns the simple parameter value or null if no simple value was set for this parameter

Returns:
the simple parameter value, null if no simple value was set for this parameter

getValueWithExpressions

public String getValueWithExpressions()
Returns the simple parameter value and/or any expressions, separated by 'AND'

Returns:
the simple parameter value and/or any expressions separated by 'AND'

equals

public boolean equals(Object otherParameter)
Overrides:
equals in class Object

hashCode

public int hashCode()
Overrides:
hashCode in class Object

toString

public String toString()
Overrides:
toString in class Object

copy

public CommandParameter copy()
Clones the CommandParameter

Returns:
a deep, detached clone of this command parameter, for copying a parameter to a new state.


Copyright © 2013. All Rights Reserved.