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


Java GetterUtil.getFloat方法代码示例

本文整理汇总了Java中com.liferay.portal.kernel.util.GetterUtil.getFloat方法的典型用法代码示例。如果您正苦于以下问题:Java GetterUtil.getFloat方法的具体用法?Java GetterUtil.getFloat怎么用?Java GetterUtil.getFloat使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.liferay.portal.kernel.util.GetterUtil的用法示例。


在下文中一共展示了GetterUtil.getFloat方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: buildSplittedQuery

import com.liferay.portal.kernel.util.GetterUtil; //导入方法依赖的package包/类
/**
 * {@inheritDoc}
 */
@Override
public BooleanQuery buildSplittedQuery(
	JSONObject configurationObject, QueryParams queryParams)
	throws Exception {

	BooleanQuery query = new BooleanQueryImpl();
	
	String keywordSplitter = configurationObject.getString("keywordSplitter");

	String [] keywords = queryParams.getKeywords().split(keywordSplitter);
		
	for (String keyword : keywords) {
		WildcardQuery q = buildClause(configurationObject, keyword);
		query.add(q, BooleanClauseOccur.SHOULD);
	}
	
	float boost = GetterUtil.getFloat(configurationObject.get("boost"), 1.0f);
	query.setBoost(boost);
	
	return query;
}
 
开发者ID:peerkar,项目名称:liferay-gsearch,代码行数:25,代码来源:WildcardQueryBuilderImpl.java

示例2: buildQuery

import com.liferay.portal.kernel.util.GetterUtil; //导入方法依赖的package包/类
/**
 * {@inheritDoc}
 */
@Override
public WildcardQuery buildQuery(
	JSONObject configurationObject, QueryParams queryParams)
	throws Exception {

	WildcardQuery wildcardQuery = buildClause(configurationObject, queryParams.getKeywords());

	float boost = GetterUtil.getFloat(configurationObject.get("boost"), 1.0f);
	wildcardQuery.setBoost(boost);
	
	return wildcardQuery;
}
 
开发者ID:peerkar,项目名称:liferay-gsearch,代码行数:16,代码来源:WildcardQueryBuilderImpl.java

示例3: buildQuery

import com.liferay.portal.kernel.util.GetterUtil; //导入方法依赖的package包/类
/**
 * {@inheritDoc}
 */
@Override
public MatchQuery buildQuery(
	JSONObject configurationObject, QueryParams queryParams)
	throws Exception {

	String fieldName = configurationObject.getString("fieldName");

	if (fieldName == null) {
		return null;
	}

	MatchQuery matchQuery =
		new MatchQuery(fieldName, queryParams.getKeywords());
	
	float boost =
		GetterUtil.getFloat(configurationObject.get("boost"), 1.0f);
	matchQuery.setBoost(boost);

	String operator =
					GetterUtil.getString(configurationObject.get("operator"), "and");

	if ("and".equals(operator)) {
		matchQuery.setOperator(Operator.AND);
	}

	if (configurationObject.get("fuzziness") != null && configurationObject.get("fuzziness") != "") {
		float fuzziness = GetterUtil.getFloat(configurationObject.get("fuzziness"), 0.0f);
		matchQuery.setFuzziness(fuzziness);
	}
	
	return matchQuery;
}
 
开发者ID:peerkar,项目名称:liferay-gsearch,代码行数:36,代码来源:MatchQueryBuilderImpl.java

示例4: getPhraseSuggester

import com.liferay.portal.kernel.util.GetterUtil; //导入方法依赖的package包/类
/**
 * Get phrase suggester.
 * 
 * @param configuration
 * @param locale
 * @param keywords
 * @return
 * @throws Exception
 */
protected Suggester getPhraseSuggester(
	JSONObject configuration, Locale locale, String keywords) throws Exception {
	
	StringBundler sb = new StringBundler();

	sb.append(configuration.getString("fieldPrefix"));

	if (configuration.getBoolean(("isLocalized"))) {
		sb.append(locale.toString());
	}
	sb.append(configuration.getString("fieldSuffix"));
	
	PhraseSuggester suggester = new PhraseSuggester(
		configuration.getString("suggesterName"), sb.toString(), keywords);

	
	int size = GetterUtil.getInteger(configuration.get("numberOfSuggestions"), 5);
	suggester.setSize(size);
	
	float confidence = GetterUtil.getFloat(configuration.get("confidence"), 0.1f);
	suggester.setConfidence(confidence);

	int gramSize = GetterUtil.getInteger(configuration.get("gramSize"), 2);
	suggester.setGramSize(gramSize);

	float maxErrors = GetterUtil.getFloat(configuration.get("maxErrors"), 2.0f);
	suggester.setMaxErrors(maxErrors);

	float realWordErrorLikelihood = GetterUtil.getFloat(configuration.get("realWordErrorLikelihood"), 0.95f);
	suggester.setRealWordErrorLikelihood(realWordErrorLikelihood);

	return suggester;
}
 
开发者ID:peerkar,项目名称:liferay-gsearch,代码行数:43,代码来源:GSearchKeywordSuggesterImpl.java

示例5: buildQuery

import com.liferay.portal.kernel.util.GetterUtil; //导入方法依赖的package包/类
/**
 * {@inheritDoc}
 */
@Override
public QueryStringQuery buildQuery(
	JSONObject configurationObject, QueryParams queryParams)
	throws Exception {

	String operator =
		GetterUtil.getString(configurationObject.get("operator"), "and");

	float queryBoost =
		GetterUtil.getFloat(configurationObject.get("boost"), 1.0f);

	QueryStringQuery queryStringQuery = new QueryStringQuery(queryParams.getKeywords());

	JSONArray fields = configurationObject.getJSONArray("fields");
	
	for (int i = 0; i < fields.length(); i++) {

		JSONObject item = fields.getJSONObject(i);

		// Add non translated version
		
		String fieldName = item.getString("fieldName");
		float boost =  GetterUtil.getFloat(item.getString("boost"), 1f);
		
		queryStringQuery.addField(fieldName, boost);
		
		// Add translated version
		
		boolean isLocalized = GetterUtil.getBoolean(item.get("localized"), false);
		
		if (isLocalized) {
			
			String localizedFieldName = fieldName + "_" + queryParams.getLocale().toString();
			float localizedBoost =  GetterUtil.getFloat(item.getString("boostForLocalizedVersion"), 1f);

			queryStringQuery.addField(localizedFieldName, localizedBoost);
		}			
	}

	// Set operator
	
	if (operator.equals("or")) {
		queryStringQuery.setDefaultOperator(Operator.OR);
	}
	else {
		queryStringQuery.setDefaultOperator(Operator.AND);
	}
	
	// Query boost
	
	queryStringQuery.setBoost(queryBoost);

	// Analyzer
	
	String analyzer = configurationObject.getString("analyzer");
	
	if (analyzer != null && analyzer != "") {
		queryStringQuery.setAnalyzer(analyzer);
	}

	return queryStringQuery;
}
 
开发者ID:peerkar,项目名称:liferay-gsearch,代码行数:66,代码来源:QueryStringQueryBuilderImpl.java

示例6: buildLocalizedQuery

import com.liferay.portal.kernel.util.GetterUtil; //导入方法依赖的package包/类
/**
 * {@inheritDoc}
 */
@Override
public BooleanQuery buildLocalizedQuery(
	JSONObject configurationObject, QueryParams queryParams)
	throws Exception {
	
	BooleanQuery booleanQuery = new BooleanQueryImpl();

	String fieldName = configurationObject.getString("fieldName");

	String queryType = configurationObject.getString("queryType");

	if (fieldName == null || queryType == null) {
		return null;
	}

	MatchQuery matchQuery =
		new MatchQuery(fieldName, queryParams.getKeywords());

	// Boost
	
	float boost = GetterUtil.getFloat(configurationObject.get("boost"), 1.0f);

	matchQuery.setBoost(boost);

	// Operator
	
	String operator = GetterUtil.getString(configurationObject.get("operator"), "and");

	if (operator.equals("or")) {
		matchQuery.setOperator(Operator.OR);
	}
	else {
		matchQuery.setOperator(Operator.AND);
	}
	
	// Fuzziness
	
	Float fuzziness = null;
	
	if (configurationObject.get("fuzziness") != null && configurationObject.get("fuzziness") != "") {
		fuzziness = GetterUtil.getFloat(configurationObject.get("fuzziness"), 0.0f);
		matchQuery.setFuzziness(fuzziness);
	}
	
	// Localized query
	
	String localizedFieldName =
			fieldName + "_" + queryParams.getLocale().toString();

	float localizedBoost = GetterUtil.getFloat(
			configurationObject.getString("boostForLocalizedVersion"), 1f);

	MatchQuery localizedQuery =
			new MatchQuery(localizedFieldName, queryParams.getKeywords());

	localizedQuery.setBoost(localizedBoost);

	if ("and".equals(operator)) {
		matchQuery.setOperator(Operator.AND);
	}
	
	if (fuzziness != null) {
		localizedQuery.setFuzziness(fuzziness);
	}

	// Add subqueries to the query
	
	booleanQuery.add(matchQuery, BooleanClauseOccur.SHOULD);
	booleanQuery.add(localizedQuery, BooleanClauseOccur.SHOULD);

	return booleanQuery;
}
 
开发者ID:peerkar,项目名称:liferay-gsearch,代码行数:76,代码来源:MatchQueryBuilderImpl.java


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