Methods Summary |
---|
void | afterDeserialize(SessionFactoryImpl factory)
definition = factory.getFilterDefinition(filterName);
|
public org.hibernate.engine.FilterDefinition | getFilterDefinition()
return definition;
|
public java.lang.String | getName()Get the name of this filter.
return definition.getFilterName();
|
public java.lang.Object | getParameter(java.lang.String name)Get the value of the named parameter for the current filter.
return parameters.get( name );
|
public java.util.Map | getParameters()
return parameters;
|
public org.hibernate.Filter | setParameter(java.lang.String name, java.lang.Object value)Set the named parameter's value for this filter.
// Make sure this is a defined parameter and check the incoming value type
// TODO: what should be the actual exception type here?
Type type = definition.getParameterType( name );
if ( type == null ) {
throw new IllegalArgumentException( "Undefined filter parameter [" + name + "]" );
}
if ( value != null && !type.getReturnedClass().isAssignableFrom( value.getClass() ) ) {
throw new IllegalArgumentException( "Incorrect type for parameter [" + name + "]" );
}
parameters.put( name, value );
return this;
|
public org.hibernate.Filter | setParameterList(java.lang.String name, java.util.Collection values)Set the named parameter's value list for this filter. Used
in conjunction with IN-style filter criteria.
// Make sure this is a defined parameter and check the incoming value type
if ( values == null ) {
throw new IllegalArgumentException( "Collection must be not null!" );
}
Type type = definition.getParameterType( name );
if ( type == null ) {
throw new HibernateException( "Undefined filter parameter [" + name + "]" );
}
if ( values.size() > 0 ) {
Class elementClass = values.iterator().next().getClass();
if ( !type.getReturnedClass().isAssignableFrom( elementClass ) ) {
throw new HibernateException( "Incorrect type for parameter [" + name + "]" );
}
}
parameters.put( name, values );
return this;
|
public org.hibernate.Filter | setParameterList(java.lang.String name, java.lang.Object[] values)Set the named parameter's value list for this filter. Used
in conjunction with IN-style filter criteria.
return setParameterList( name, Arrays.asList( values ) );
|
public void | validate()Perform validation of the filter state. This is used to verify the
state of the filter after its enablement and before its use.
// for each of the defined parameters, make sure its value
// has been set
Iterator itr = definition.getParameterNames().iterator();
while ( itr.hasNext() ) {
final String parameterName = (String) itr.next();
if ( parameters.get( parameterName ) == null ) {
throw new HibernateException(
"Filter [" + getName() + "] parameter [" + parameterName + "] value not set"
);
}
}
|