| Method from org.hibernate.impl.FilterImpl Detail: |
void afterDeserialize(SessionFactoryImpl factory) {
definition = factory.getFilterDefinition(filterName);
}
|
public FilterDefinition getFilterDefinition() {
return definition;
}
|
public String getName() {
return definition.getFilterName();
}
Get the name of this filter. |
public Object getParameter(String name) {
return parameters.get( name );
}
Get the value of the named parameter for the current filter. |
public Map getParameters() {
return parameters;
}
|
public Filter setParameter(String name,
Object value) throws IllegalArgumentException {
// 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;
}
Set the named parameter's value for this filter. |
public Filter setParameterList(String name,
Collection values) throws HibernateException {
// 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;
}
Set the named parameter's value list for this filter. Used
in conjunction with IN-style filter criteria. |
public Filter setParameterList(String name,
Object[] values) throws IllegalArgumentException {
return setParameterList( name, Arrays.asList( values ) );
}
Set the named parameter's value list for this filter. Used
in conjunction with IN-style filter criteria. |
public void validate() throws HibernateException {
// 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"
);
}
}
}
Perform validation of the filter state. This is used to verify the
state of the filter after its enablement and before its use. |