• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Java StringUtils类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中org.apache.lucene.queryparser.flexible.core.util.StringUtils的典型用法代码示例。如果您正苦于以下问题:Java StringUtils类的具体用法?Java StringUtils怎么用?Java StringUtils使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



StringUtils类属于org.apache.lucene.queryparser.flexible.core.util包,在下文中一共展示了StringUtils类的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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: isDefaultField

import org.apache.lucene.queryparser.flexible.core.util.StringUtils; //导入依赖的package包/类
/**
 * This method is use toQueryString to detect if fld is the default field
 * 
 * @param fld - field name
 * @return true if fld is the default field
 */
// TODO: remove this method, it's commonly used by {@link
// #toQueryString(org.apache.lucene.queryParser.core.parser.EscapeQuerySyntax)}
// to figure out what is the default field, however, {@link
// #toQueryString(org.apache.lucene.queryParser.core.parser.EscapeQuerySyntax)}
// should receive the default field value directly by parameter
protected boolean isDefaultField(CharSequence fld) {
  if (this.toQueryStringIgnoreFields)
    return true;
  if (fld == null)
    return true;
  if (QueryNodeImpl.PLAINTEXT_FIELD_NAME.equals(StringUtils.toString(fld)))
    return true;
  return false;
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:21,代码来源:QueryNodeImpl.java


示例4: 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


示例5: 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


示例6: 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


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


示例8: eq

import org.apache.lucene.queryparser.flexible.core.util.StringUtils; //导入依赖的package包/类
public static QueryBuilder eq(String key, Object value) {
    return QueryBuilders.queryStringQuery(StringUtils.toString(value)).field(key);
}
 
开发者ID:querydsl,项目名称:querydsl-contrib,代码行数:4,代码来源:ElasticsearchSerializerTest.java


示例9: eq

import org.apache.lucene.queryparser.flexible.core.util.StringUtils; //导入依赖的package包/类
public static QueryBuilder eq(String key, Object value) {
    return QueryBuilders.queryString(StringUtils.toString(value)).field(key);
}
 
开发者ID:querydsl,项目名称:querydsl-contrib,代码行数:4,代码来源:ElasticsearchSerializerTest.java


示例10: purgeOldSnapshots

import org.apache.lucene.queryparser.flexible.core.util.StringUtils; //导入依赖的package包/类
private void purgeOldSnapshots() {
	logger.info("Purging expired snapshot(s) for index(es): {} ", this.snapshotSettings.getIndices());
	// get old snapshots to remove
	GetSnapshotsRequestBuilder getBuilder = new GetSnapshotsRequestBuilder(this.client.admin().cluster(), this.snapshotSettings.getRepository());
	GetSnapshotsResponse getResp = getBuilder.get();

	Set<String> configIndices = getConfiguredIndicesAsSet();
	if (getResp != null && getResp.getSnapshots() != null) {
		ImmutableList<SnapshotInfo> snapshots = getResp.getSnapshots();
		if (snapshots == null || snapshots.isEmpty()) {
			return;
		}

		logger.debug("Found a total of {} snapshots in the repository", snapshots.size());
		List<String> purgeSnapshots = new ArrayList<String>();
		for (Iterator<SnapshotInfo> i = snapshots.iterator(); i.hasNext();) {
			SnapshotInfo snap = i.next();
			logger.debug("This snapshot [{}] includes the following indices: {}", snap.name(), StringUtils.toString(snap.indices()));

			if(this.snapshotSettings.isPurgeIndicesMustMatch()){					
				// if number of indices don't match, do not purge
				if (snap.indices().size() != configIndices.size()) {
					logger.info("Snapshot [{}] not purged. The number of indices in the snapshot ({}) must match the number of indices in the current configuration ({}). To purge all snapshots, configure purge_indices_must_match:false.", snap.name(), snap.indices().size(), configIndices.size());
					continue;
				}

				// if the size matches, verify that the indexes within the snapshot are exactly the same as those
				// configured for the river
				if (!snapshotIndicesMatch(snap, configIndices)) {
					logger.info("Snapshot [{}] not purged. In order to purge a snapshot automatically, the specific indexes must match exactly. The snapshot does not match current purge configuration indices. To purge all snapshots, configure purge_indices_must_match:false.", snap.name());
					continue;
				}
			} 

			// finally check if the snapshot is beyond the purgeAfter age
			Date expiration = new Date(snap.startTime() + this.snapshotSettings.getPurgeAfter().millis());
			if (expiration.before(new Date())) {
				purgeSnapshots.add(snap.name());
			}
		} 

		// remove old snapshots
		logger.debug("{} snapshots are scheduled to be purged.", purgeSnapshots.size());
		for (String snapshotName : purgeSnapshots) {
			DeleteSnapshotRequestBuilder deleteBuilder = new DeleteSnapshotRequestBuilder(this.client.admin().cluster());
			deleteBuilder.setRepository(this.snapshotSettings.getRepository());
			deleteBuilder.setSnapshot(snapshotName);
			DeleteSnapshotResponse deleteResp = deleteBuilder.get();
			if (deleteResp.isAcknowledged()) {
				logger.info("Expired snapshot [{}] has been deleted.", snapshotName);
			} else {
				logger.error("Not able to delete expired snapshot [{}]", snapshotName);
			}
		}
	}
}
 
开发者ID:garmin,项目名称:elasticsearch-river-snapshot,代码行数:57,代码来源:SnapshotsExecutor.java


示例11: postProcessNode

import org.apache.lucene.queryparser.flexible.core.util.StringUtils; //导入依赖的package包/类
@Override
protected QueryNode postProcessNode(QueryNode node) throws QueryNodeException {

  if (node instanceof FieldableNode && 
      (node.getParent() == null || !(node.getParent() instanceof FieldableNode))) {
    
    FieldableNode fieldNode = (FieldableNode) node;
    QueryConfigHandler config = getQueryConfigHandler();

    if (config != null) {
      CharSequence field = fieldNode.getField();
      FieldConfig fieldConfig = config.getFieldConfig(StringUtils.toString(field));

      if (fieldConfig != null) {
        Float boost = fieldConfig.get(ConfigurationKeys.BOOST);

        if (boost != null) {
          return new BoostQueryNode(node, boost);
        }

      }

    }

  }

  return node;

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


示例12: 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类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java DocumentSummaryInformation类代码示例发布时间:2022-05-22
下一篇:
Java ProjectStructureConfigurable类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap