2.17.2: 2011-06-17

net.sf.basedb.core.query
Class QueryParameter

java.lang.Object
  extended by net.sf.basedb.core.query.QueryParameter

public class QueryParameter
extends Object

Holds information (name, type and value) about a single parameter to a query.

Version:
2.9
Author:
Nicklas
Last modified
$Date: 2011-02-04 09:25:16 +0100 (Fri, 04 Feb 2011) $

Field Summary
private  Item itemType
           
private  String name
           
private  boolean permanent
           
private  Type type
           
private  Object value
           
 
Constructor Summary
QueryParameter(String name)
          Create a new empty non-permanent query parameter.
QueryParameter(String name, boolean permanent, Type type, Object value)
          Create a new query parameter.
 
Method Summary
 boolean equals(Object o)
           
 Item getItemType()
          The parameter should be an entity of the given item type.
 String getName()
          Get the name of the parameter.
 Type getType()
          Get the type of the parameter.
 Object getValue()
          Get the value of the parameter.
 int hashCode()
           
 boolean isPermanent()
          Check if the parameter is a permanent parameter.
 void setItemType(Item itemType)
          Changes the type of the parameter.
 void setType(Type type)
          Changes the type of the parameter.
 void setValue(Object value)
          Change the value of the parameter.
 String toString()
           
 void validateValue()
          Validate the parameter value using the type information if it has been provided.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

name

private final String name

permanent

private final boolean permanent

type

private Type type

itemType

private Item itemType

value

private Object value
Constructor Detail

QueryParameter

public QueryParameter(String name)
Create a new empty non-permanent query parameter.

Parameters:
name - The name of the parameter

QueryParameter

public QueryParameter(String name,
                      boolean permanent,
                      Type type,
                      Object value)
Create a new query parameter.

Parameters:
name - The name of the parameter
permanent - If the parameter should be permanent or not. A permanent parameter can't change it's value
type - The type of value
value - The value
Method Detail

getName

public String getName()
Get the name of the parameter.


isPermanent

public boolean isPermanent()
Check if the parameter is a permanent parameter. A permanent paramer can't be changed.


getType

public Type getType()
Get the type of the parameter.


setType

public void setType(Type type)
Changes the type of the parameter. Ignored if the parameter is permanent. Also sets the getItemType() value to null.

Parameters:
type - The new type

getValue

public Object getValue()
Get the value of the parameter.


setValue

public void setValue(Object value)
Change the value of the parameter. Ignored if the parameter is permanent.

Parameters:
value - The new value

getItemType

public Item getItemType()
The parameter should be an entity of the given item type.

Returns:
An Item object or null
Since:
2.17

setItemType

public void setItemType(Item itemType)
Changes the type of the parameter. Ignored if the parameter is permanent. Also sets the getType() value to null.

Parameters:
itemType - The new type
Since:
2.17

validateValue

public void validateValue()
Validate the parameter value using the type information if it has been provided. Null values are always accepted. If no type or item type has been set the value is also always accepted. The value can be either a single value or a collection of values. If a type has been set the value is validated with Type.isCorrectType(Object). If an item type has been set it is checked that the value is an instance of the given item type.

Since:
2.17

hashCode

public int hashCode()
Overrides:
hashCode in class Object

equals

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

toString

public String toString()
Overrides:
toString in class Object

2.17.2: 2011-06-17