本文整理汇总了Java中org.apache.lucene.queryparser.flexible.core.util.StringUtils.toString方法的典型用法代码示例。如果您正苦于以下问题:Java StringUtils.toString方法的具体用法?Java StringUtils.toString怎么用?Java StringUtils.toString使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.lucene.queryparser.flexible.core.util.StringUtils
的用法示例。
在下文中一共展示了StringUtils.toString方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: setBounds
import org.apache.lucene.queryparser.flexible.core.util.StringUtils; //导入方法依赖的package包/类
/**
* Sets the lower and upper bounds.
*
* @param lower the lower bound, <code>null</code> if lower bound is open
* @param upper the upper bound, <code>null</code> if upper bound is open
* @param lowerInclusive <code>true</code> if the lower bound is inclusive, otherwise, <code>false</code>
* @param upperInclusive <code>true</code> if the upper bound is inclusive, otherwise, <code>false</code>
*
* @see #getLowerBound()
* @see #getUpperBound()
* @see #isLowerInclusive()
* @see #isUpperInclusive()
*/
public void setBounds(T lower, T upper, boolean lowerInclusive,
boolean upperInclusive) {
if (lower != null && upper != null) {
String lowerField = StringUtils.toString(lower.getField());
String upperField = StringUtils.toString(upper.getField());
if ((upperField != null || lowerField != null)
&& ((upperField != null && !upperField.equals(lowerField)) || !lowerField
.equals(upperField))) {
throw new IllegalArgumentException(
"lower and upper bounds should have the same field name!");
}
this.lowerInclusive = lowerInclusive;
this.upperInclusive = upperInclusive;
ArrayList<QueryNode> children = new ArrayList<>(2);
children.add(lower);
children.add(upper);
set(children);
}
}
示例2: build
import org.apache.lucene.queryparser.flexible.core.util.StringUtils; //导入方法依赖的package包/类
@Override
public TermRangeQuery build(QueryNode queryNode) throws QueryNodeException {
TermRangeQueryNode rangeNode = (TermRangeQueryNode) queryNode;
FieldQueryNode upper = rangeNode.getUpperBound();
FieldQueryNode lower = rangeNode.getLowerBound();
String field = StringUtils.toString(rangeNode.getField());
String lowerText = lower.getTextAsString();
String upperText = upper.getTextAsString();
if (lowerText.length() == 0) {
lowerText = null;
}
if (upperText.length() == 0) {
upperText = null;
}
TermRangeQuery rangeQuery = TermRangeQuery.newStringRange(field, lowerText, upperText, rangeNode
.isLowerInclusive(), rangeNode.isUpperInclusive());
MultiTermQuery.RewriteMethod method = (MultiTermQuery.RewriteMethod) queryNode
.getTag(MultiTermRewriteMethodProcessor.TAG_ID);
if (method != null) {
rangeQuery.setRewriteMethod(method);
}
return rangeQuery;
}
示例3: setBounds
import org.apache.lucene.queryparser.flexible.core.util.StringUtils; //导入方法依赖的package包/类
/**
* Sets the lower and upper bounds.
*
* @param lower the lower bound, <code>null</code> if lower bound is open
* @param upper the upper bound, <code>null</code> if upper bound is open
* @param lowerInclusive <code>true</code> if the lower bound is inclusive, otherwise, <code>false</code>
* @param upperInclusive <code>true</code> if the upper bound is inclusive, otherwise, <code>false</code>
*
* @see #getLowerBound()
* @see #getUpperBound()
* @see #isLowerInclusive()
* @see #isUpperInclusive()
*/
public void setBounds(T lower, T upper, boolean lowerInclusive,
boolean upperInclusive) {
if (lower != null && upper != null) {
String lowerField = StringUtils.toString(lower.getField());
String upperField = StringUtils.toString(upper.getField());
if ((upperField != null || lowerField != null)
&& ((upperField != null && !upperField.equals(lowerField)) || !lowerField
.equals(upperField))) {
throw new IllegalArgumentException(
"lower and upper bounds should have the same field name!");
}
this.lowerInclusive = lowerInclusive;
this.upperInclusive = upperInclusive;
ArrayList<QueryNode> children = new ArrayList<QueryNode>(2);
children.add(lower);
children.add(upper);
set(children);
}
}
示例4: fuzzy
import org.apache.lucene.queryparser.flexible.core.util.StringUtils; //导入方法依赖的package包/类
public Query fuzzy(String fieldName, Object value) {
return new FuzzyQuery(new Term(fieldName, StringUtils.toString(value)));
}
示例5: build
import org.apache.lucene.queryparser.flexible.core.util.StringUtils; //导入方法依赖的package包/类
@Override
public NumericRangeQuery<? extends Number> build(QueryNode queryNode)
throws QueryNodeException {
NumericRangeQueryNode numericRangeNode = (NumericRangeQueryNode) queryNode;
NumericQueryNode lowerNumericNode = numericRangeNode.getLowerBound();
NumericQueryNode upperNumericNode = numericRangeNode.getUpperBound();
Number lowerNumber = lowerNumericNode.getValue();
Number upperNumber = upperNumericNode.getValue();
NumericConfig numericConfig = numericRangeNode.getNumericConfig();
NumericType numberType = numericConfig.getType();
String field = StringUtils.toString(numericRangeNode.getField());
boolean minInclusive = numericRangeNode.isLowerInclusive();
boolean maxInclusive = numericRangeNode.isUpperInclusive();
int precisionStep = numericConfig.getPrecisionStep();
switch (numberType) {
case LONG:
return NumericRangeQuery.newLongRange(field, precisionStep,
(Long) lowerNumber, (Long) upperNumber, minInclusive, maxInclusive);
case INT:
return NumericRangeQuery.newIntRange(field, precisionStep,
(Integer) lowerNumber, (Integer) upperNumber, minInclusive,
maxInclusive);
case FLOAT:
return NumericRangeQuery.newFloatRange(field, precisionStep,
(Float) lowerNumber, (Float) upperNumber, minInclusive,
maxInclusive);
case DOUBLE:
return NumericRangeQuery.newDoubleRange(field, precisionStep,
(Double) lowerNumber, (Double) upperNumber, minInclusive,
maxInclusive);
default :
throw new QueryNodeException(new MessageImpl(
QueryParserMessages.UNSUPPORTED_NUMERIC_DATA_TYPE, numberType));
}
}
示例6: asDBKey
import org.apache.lucene.queryparser.flexible.core.util.StringUtils; //导入方法依赖的package包/类
public String asDBKey(Operation<?> expr, int index) {
return StringUtils.toString(asDBValue(expr, index));
}
示例7: getFieldConfig
import org.apache.lucene.queryparser.flexible.core.util.StringUtils; //导入方法依赖的package包/类
/**
* Returns an implementation of
* {@link FieldConfig} for a specific field name. If the implemented
* {@link QueryConfigHandler} does not know a specific field name, it may
* return <code>null</code>, indicating there is no configuration for that
* field.
*
* @param fieldName
* the field name
* @return a {@link FieldConfig} object containing the field name
* configuration or <code>null</code>, if the implemented
* {@link QueryConfigHandler} has no configuration for that field
*/
public FieldConfig getFieldConfig(String fieldName) {
FieldConfig fieldConfig = new FieldConfig(StringUtils.toString(fieldName));
for (FieldConfigListener listener : this.listeners) {
listener.buildFieldConfig(fieldConfig);
}
return fieldConfig;
}