Moderator: JIDE Support
private void registerFilterFactoriesForNumber(final Class type, final String resourceKey) {
// For number
registerFilterFactory(type, new FilterFactory() {
public Filter createFilter(Object... objects) {
return new AllFilter<Number>();
}
public Class[] getExpectedDataTypes() {
return new Class[0];
}
public String getName() {
return "all";
}
public String getConditionString(Locale locale) {
return AbstractFilter.getConditionString(locale, resourceKey, getName());
}
});
registerFilterFactory(type, new FilterFactory() {
public Filter createFilter(Object... objects) {
return new EqualFilter<Number>((Number) objects[0]);
}
public Class[] getExpectedDataTypes() {
return new Class[]{type};
}
public String getName() {
return "equal";
}
public String getConditionString(Locale locale) {
return AbstractFilter.getConditionString(locale, resourceKey, getName());
}
});
registerFilterFactory(type, new FilterFactory() {
public Filter createFilter(Object... objects) {
return new NotEqualFilter<Number>((Number) objects[0]);
}
public Class[] getExpectedDataTypes() {
return new Class[]{type};
}
public String getName() {
return "not.equal";
}
public String getConditionString(Locale locale) {
return AbstractFilter.getConditionString(locale, resourceKey, getName());
}
});
registerFilterFactory(type, new FilterFactory() {
public Filter createFilter(Object... objects) {
return new InFilter<Object>((Object[]) objects[0]);
}
public Class[] getExpectedDataTypes() {
return new Class[]{Array.newInstance(type, 0).getClass()};
}
public String getName() {
return "in";
}
public String getConditionString(Locale locale) {
return AbstractFilter.getConditionString(locale, resourceKey, getName());
}
});
registerFilterFactory(type, new FilterFactory() {
public Filter createFilter(Object... objects) {
return new NotFilter(new InFilter<Object>((Object[]) objects[0]));
}
public Class[] getExpectedDataTypes() {
return new Class[]{Array.newInstance(type, 0).getClass()};
}
public String getName() {
return "not.in";
}
public String getConditionString(Locale locale) {
return AbstractFilter.getConditionString(locale, resourceKey, getName());
}
});
registerFilterFactory(type, new FilterFactory() {
public Filter createFilter(Object... objects) {
return new EmptyFilter<Number>();
}
public Class[] getExpectedDataTypes() {
return new Class[0];
}
public String getName() {
return "empty";
}
public String getConditionString(Locale locale) {
return AbstractFilter.getConditionString(locale, resourceKey, getName());
}
});
registerFilterFactory(type, new FilterFactory() {
public Filter createFilter(Object... objects) {
return new NotFilter(new EmptyFilter<Number>());
}
public Class[] getExpectedDataTypes() {
return new Class[0];
}
public String getName() {
return "not.empty";
}
public String getConditionString(Locale locale) {
return AbstractFilter.getConditionString(locale, resourceKey, getName());
}
});
registerFilterFactory(type, new FilterFactory() {
public Filter createFilter(Object... objects) {
return new GreaterThanFilter<Number>((Number) objects[0]);
}
public Class[] getExpectedDataTypes() {
return new Class[]{type};
}
public String getName() {
return "greater";
}
public String getConditionString(Locale locale) {
return AbstractFilter.getConditionString(locale, resourceKey, getName());
}
});
registerFilterFactory(type, new FilterFactory() {
public Filter createFilter(Object... objects) {
return new GreaterOrEqualFilter<Number>((Number) objects[0]);
}
public Class[] getExpectedDataTypes() {
return new Class[]{type};
}
public String getName() {
return "greaterOrEqual";
}
public String getConditionString(Locale locale) {
return AbstractFilter.getConditionString(locale, resourceKey, getName());
}
});
registerFilterFactory(type, new FilterFactory() {
public Filter createFilter(Object... objects) {
return new LessThanFilter<Number>((Number) objects[0]);
}
public Class[] getExpectedDataTypes() {
return new Class[]{type};
}
public String getName() {
return "less";
}
public String getConditionString(Locale locale) {
return AbstractFilter.getConditionString(locale, resourceKey, getName());
}
});
registerFilterFactory(type, new FilterFactory() {
public Filter createFilter(Object... objects) {
return new LessOrEqualFilter<Number>((Number) objects[0]);
}
public Class[] getExpectedDataTypes() {
return new Class[]{type};
}
public String getName() {
return "lessOrEqual";
}
public String getConditionString(Locale locale) {
return AbstractFilter.getConditionString(locale, resourceKey, getName());
}
});
registerFilterFactory(type, new FilterFactory() {
public Filter createFilter(Object... objects) {
return new BetweenFilter<Number>((Number) objects[0], (Number) objects[1]);
}
public Class[] getExpectedDataTypes() {
return new Class[]{type, type};
}
public String getName() {
return "between";
}
public String getConditionString(Locale locale) {
return AbstractFilter.getConditionString(locale, resourceKey, getName());
}
});
registerFilterFactory(type, new FilterFactory() {
public Filter createFilter(Object... objects) {
return new NotBetweenFilter<Number>((Number) objects[0], (Number) objects[1]);
}
public Class[] getExpectedDataTypes() {
return new Class[]{type, type};
}
public String getName() {
return "not.between";
}
public String getConditionString(Locale locale) {
return AbstractFilter.getConditionString(locale, resourceKey, getName());
}
});
}
private void registerFilterFactoriesForNumber(final Class type, final String resourceKey, boolean includeTwoParameters) {
// For number
FilterFactoryManager.getDefaultInstance().registerFilterFactory(type, new FilterFactory() {
public Filter createFilter(Object... objects) {
return new AllFilter<Number>();
}
public Class[] getExpectedDataTypes() {
return new Class[0];
}
public String getName() {
return "all";
}
public String getConditionString(Locale locale) {
return AbstractFilter.getConditionString(locale, resourceKey, getName());
}
});
FilterFactoryManager.getDefaultInstance(). registerFilterFactory(type, new FilterFactory() {
public Filter createFilter(Object... objects) {
return new EqualFilter<Number>((Number) objects[0]);
}
public Class[] getExpectedDataTypes() {
return new Class[]{type};
}
public String getName() {
return "equal";
}
public String getConditionString(Locale locale) {
return AbstractFilter.getConditionString(locale, resourceKey, getName());
}
});
FilterFactoryManager.getDefaultInstance().registerFilterFactory(type, new FilterFactory() {
public Filter createFilter(Object... objects) {
return new NotEqualFilter<Number>((Number) objects[0]);
}
public Class[] getExpectedDataTypes() {
return new Class[]{type};
}
public String getName() {
return "not.equal";
}
public String getConditionString(Locale locale) {
return AbstractFilter.getConditionString(locale, resourceKey, getName());
}
});
FilterFactoryManager.getDefaultInstance().registerFilterFactory(type, new FilterFactory() {
public Filter createFilter(Object... objects) {
return new InFilter<Object>((Object[]) objects[0]);
}
public Class[] getExpectedDataTypes() {
return new Class[]{Array.newInstance(type, 0).getClass()};
}
public String getName() {
return "in";
}
public String getConditionString(Locale locale) {
return AbstractFilter.getConditionString(locale, resourceKey, getName());
}
});
FilterFactoryManager.getDefaultInstance().registerFilterFactory(type, new FilterFactory() {
public Filter createFilter(Object... objects) {
return new NotFilter(new InFilter<Object>((Object[]) objects[0]));
}
public Class[] getExpectedDataTypes() {
return new Class[]{Array.newInstance(type, 0).getClass()};
}
public String getName() {
return "not.in";
}
public String getConditionString(Locale locale) {
return AbstractFilter.getConditionString(locale, resourceKey, getName());
}
});
FilterFactoryManager.getDefaultInstance().registerFilterFactory(type, new FilterFactory() {
public Filter createFilter(Object... objects) {
return new EmptyFilter<Number>();
}
public Class[] getExpectedDataTypes() {
return new Class[0];
}
public String getName() {
return "empty";
}
public String getConditionString(Locale locale) {
return AbstractFilter.getConditionString(locale, resourceKey, getName());
}
});
FilterFactoryManager.getDefaultInstance().registerFilterFactory(type, new FilterFactory() {
public Filter createFilter(Object... objects) {
return new NotFilter(new EmptyFilter<Number>());
}
public Class[] getExpectedDataTypes() {
return new Class[0];
}
public String getName() {
return "not.empty";
}
public String getConditionString(Locale locale) {
return AbstractFilter.getConditionString(locale, resourceKey, getName());
}
});
FilterFactoryManager.getDefaultInstance().registerFilterFactory(type, new FilterFactory() {
public Filter createFilter(Object... objects) {
return new GreaterThanFilter<Number>((Number) objects[0]);
}
public Class[] getExpectedDataTypes() {
return new Class[]{type};
}
public String getName() {
return "greater";
}
public String getConditionString(Locale locale) {
return AbstractFilter.getConditionString(locale, resourceKey, getName());
}
});
FilterFactoryManager.getDefaultInstance().registerFilterFactory(type, new FilterFactory() {
public Filter createFilter(Object... objects) {
return new GreaterOrEqualFilter<Number>((Number) objects[0]);
}
public Class[] getExpectedDataTypes() {
return new Class[]{type};
}
public String getName() {
return "greaterOrEqual";
}
public String getConditionString(Locale locale) {
return AbstractFilter.getConditionString(locale, resourceKey, getName());
}
});
FilterFactoryManager.getDefaultInstance().registerFilterFactory(type, new FilterFactory() {
public Filter createFilter(Object... objects) {
return new LessThanFilter<Number>((Number) objects[0]);
}
public Class[] getExpectedDataTypes() {
return new Class[]{type};
}
public String getName() {
return "less";
}
public String getConditionString(Locale locale) {
return AbstractFilter.getConditionString(locale, resourceKey, getName());
}
});
FilterFactoryManager.getDefaultInstance().registerFilterFactory(type, new FilterFactory() {
public Filter createFilter(Object... objects) {
return new LessOrEqualFilter<Number>((Number) objects[0]);
}
public Class[] getExpectedDataTypes() {
return new Class[]{type};
}
public String getName() {
return "lessOrEqual";
}
public String getConditionString(Locale locale) {
return AbstractFilter.getConditionString(locale, resourceKey, getName());
}
});
if (includeTwoParameters) {
FilterFactoryManager.getDefaultInstance().registerFilterFactory(type, new FilterFactory() {
public Filter createFilter(Object... objects) {
return new BetweenFilter<Number>((Number) objects[0], (Number) objects[1]);
}
public Class[] getExpectedDataTypes() {
return new Class[]{type, type};
}
public String getName() {
return "between";
}
public String getConditionString(Locale locale) {
return AbstractFilter.getConditionString(locale, resourceKey, getName());
}
});
FilterFactoryManager.getDefaultInstance().registerFilterFactory(type, new FilterFactory() {
public Filter createFilter(Object... objects) {
return new NotBetweenFilter<Number>((Number) objects[0], (Number) objects[1]);
}
public Class[] getExpectedDataTypes() {
return new Class[]{type, type};
}
public String getName() {
return "not.between";
}
public String getConditionString(Locale locale) {
return AbstractFilter.getConditionString(locale, resourceKey, getName());
}
});
}
}
filterableTableModel.addFilter(column, new MultipleValuesFilter(value));
Users browsing this forum: Google [Bot] and 2 guests