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


Java GetterUtil.getString方法代码示例

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


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

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

示例2: mappingContent

import com.liferay.portal.kernel.util.GetterUtil; //导入方法依赖的package包/类
private JSONObject mappingContent(JSONObject mappingSrc, JSONObject srcFormData, long dossierId) {
	JSONObject returnOBJ = JSONFactoryUtil.createJSONObject();

	// dossierId

	// subject

	// deliverableCode

	//

	Map<String, Object> jsonMap = jsonToMap(mappingSrc);

	for (Map.Entry<String, Object> entry : jsonMap.entrySet()) {

		String entryKey = entry.getKey();

		String entryValue = GetterUtil.getString(entry.getValue());

		String uEntryValue = StringPool.BLANK;

		JSONObject jEntryValue = JSONFactoryUtil.createJSONObject();

		_log.info("EntryKey" + entryValue);

		if (entryValue.startsWith("#") && entryValue.contains("@")) {
			_log.info("GetElementForm___" + entryValue);

			// TODO review entryvalue
			uEntryValue = getValueElementFormData(srcFormData, entryValue);
			entry.setValue(uEntryValue);

		}

		if (entryValue.contains(SPEC_DELIVERABLES) || entryValue.contains(SPEC_DOSSIER_FILE_ID)
				|| entryValue.contains(SPEC_DELIVERABLE_CODE) || entryValue.contains(SPEC_SUBJECT)) {
			_log.info("SpecialForm" + entryValue);

			uEntryValue = getSpecialValue(entryValue);
			entry.setValue(uEntryValue);

		}

		if (entryValue.startsWith("#") && !entryValue.contains("@")) {
			_log.info("GetAllForm" + entryValue);

			entryValue = StringUtil.replaceFirst(entryValue, "#", StringPool.BLANK);

			jEntryValue = getValueFormData(entryValue, dossierId);

			entry.setValue(jEntryValue);

		}

	}

	returnOBJ = convertToJSON(jsonMap);

	return returnOBJ;
}
 
开发者ID:VietOpenCPS,项目名称:opencps-v2,代码行数:61,代码来源:DossierFileListenner.java

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

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