当前位置: 首页>>代码示例>>Java>>正文


Java StringUtils.toString方法代码示例

本文整理汇总了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);
    
  }
  
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:40,代码来源:AbstractRangeQueryNode.java

示例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;
  
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:31,代码来源:TermRangeQueryNodeBuilder.java

示例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);
    
  }
  
}
 
开发者ID:pkarmstr,项目名称:NYBC,代码行数:40,代码来源:AbstractRangeQueryNode.java

示例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)));
}
 
开发者ID:snowdrop,项目名称:spring-data-snowdrop,代码行数:4,代码来源:LuceneQueryBuilder.java

示例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));
      
  }
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:46,代码来源:NumericRangeQueryNodeBuilder.java

示例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));
}
 
开发者ID:querydsl,项目名称:querydsl-contrib,代码行数:4,代码来源:ElasticsearchSerializer.java

示例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;

}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:24,代码来源:QueryConfigHandler.java


注:本文中的org.apache.lucene.queryparser.flexible.core.util.StringUtils.toString方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。