Package net.sf.basedb.core.query
Class QueryParameter
java.lang.Object
net.sf.basedb.core.query.QueryParameter
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) $
-
Field Summary
-
Constructor Summary
ConstructorDescriptionQueryParameter
(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
Modifier and TypeMethodDescriptionboolean
The parameter should be an entity of the given item type.getName()
Get the name of the parameter.getType()
Get the type of the parameter.getValue()
Get the value of the parameter.int
hashCode()
boolean
Check if the parameter is a permanent parameter.void
setItemType
(Item itemType) Changes the type of the parameter.void
Changes the type of the parameter.void
Change the value of the parameter.toString()
void
Validate the parameter value using the type information if it has been provided.
-
Field Details
-
name
-
permanent
private final boolean permanent -
type
-
itemType
-
value
-
-
Constructor Details
-
QueryParameter
Create a new empty non-permanent query parameter.- Parameters:
name
- The name of the parameter
-
QueryParameter
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 Details
-
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
Get the type of the parameter. -
setType
Changes the type of the parameter. Ignored if the parameter is permanent. Also sets thegetItemType()
value to null.- Parameters:
type
- The new type
-
getValue
Get the value of the parameter. -
setValue
Change the value of the parameter. Ignored if the parameter is permanent.- Parameters:
value
- The new value
-
getItemType
The parameter should be an entity of the given item type.- Returns:
- An Item object or null
- Since:
- 2.17
-
setItemType
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
-
hashCode
public int hashCode() -
equals
-
toString
-