private Analyzer getLuceneAnalyzer() throws ProviderException { try { Class clazz = ClassUtil.findClass("", m_analyzerClass); Constructor constructor = clazz.getConstructor(Version.LUCENE_36.getClass()); Analyzer analyzer = (Analyzer) constructor.newInstance(Version.LUCENE_36); return analyzer; } catch (Exception e) { String msg = "Could not get LuceneAnalyzer class " + m_analyzerClass + ", reason: "; log.error(msg, e); throw new ProviderException(msg + e); } }
protected <N extends Number> NumericRangeQuery<?> numericRange( Class<N> clazz, String field, @Nullable N min, @Nullable N max, boolean minInc, boolean maxInc) { if (clazz.equals(Integer.class)) { return NumericRangeQuery.newIntRange(field, (Integer) min, (Integer) max, minInc, maxInc); } else if (clazz.equals(Double.class)) { return NumericRangeQuery.newDoubleRange(field, (Double) min, (Double) max, minInc, minInc); } else if (clazz.equals(Float.class)) { return NumericRangeQuery.newFloatRange(field, (Float) min, (Float) max, minInc, minInc); } else if (clazz.equals(Long.class)) { return NumericRangeQuery.newLongRange(field, (Long) min, (Long) max, minInc, minInc); } else if (clazz.equals(Byte.class) || clazz.equals(Short.class)) { return NumericRangeQuery.newIntRange( field, min != null ? min.intValue() : null, max != null ? max.intValue() : null, minInc, maxInc); } else { throw new IllegalArgumentException("Unsupported numeric type " + clazz.getName()); } }