Package net.sf.basedb.core.query
Class QueryParameter
- java.lang.Object
-
- 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: 2015-04-20 11:08:18 +0200 (må, 20 apr 2015) $
-
-
Constructor Summary
Constructors Constructor Description 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
All Methods Instance Methods Concrete Methods Modifier and Type Method Description 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.
-
-
-
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 parameterpermanent
- If the parameter should be permanent or not. A permanent parameter can't change it's valuetype
- The type of valuevalue
- 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 thegetItemType()
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 thegetType()
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 withType.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
-
-