FilterHelperpublic class FilterHelper extends Object Implementation of FilterHelper. |
Fields Summary |
---|
private final String[] | filterNames | private final String[] | filterConditions |
Constructors Summary |
---|
public FilterHelper(Map filters, org.hibernate.dialect.Dialect dialect, org.hibernate.dialect.function.SQLFunctionRegistry functionRegistry)The map of defined filters. This is expected to be in format
where the filter names are the map keys, and the defined
conditions are the values.
int filterCount = filters.size();
filterNames = new String[filterCount];
filterConditions = new String[filterCount];
Iterator iter = filters.entrySet().iterator();
filterCount = 0;
while ( iter.hasNext() ) {
final Map.Entry entry = (Map.Entry) iter.next();
filterNames[filterCount] = (String) entry.getKey();
filterConditions[filterCount] = Template.renderWhereStringTemplate(
(String) entry.getValue(),
FilterImpl.MARKER,
dialect,
functionRegistry
);
filterConditions[filterCount] = StringHelper.replace( filterConditions[filterCount],
":",
":" + filterNames[filterCount] + "." );
filterCount++;
}
|
Methods Summary |
---|
public boolean | isAffectedBy(java.util.Map enabledFilters)
for ( int i = 0, max = filterNames.length; i < max; i++ ) {
if ( enabledFilters.containsKey( filterNames[i] ) ) {
return true;
}
}
return false;
| public java.lang.String | render(java.lang.String alias, java.util.Map enabledFilters)
StringBuffer buffer = new StringBuffer();
render( buffer, alias, enabledFilters );
return buffer.toString();
| public void | render(java.lang.StringBuffer buffer, java.lang.String alias, java.util.Map enabledFilters)
if ( filterNames != null && filterNames.length > 0 ) {
for ( int i = 0, max = filterNames.length; i < max; i++ ) {
if ( enabledFilters.containsKey( filterNames[i] ) ) {
final String condition = filterConditions[i];
if ( StringHelper.isNotEmpty( condition ) ) {
buffer.append( " and " )
.append( StringHelper.replace( condition, FilterImpl.MARKER, alias ) );
}
}
}
}
|
|