Example usage for com.liferay.portal.kernel.util GetterUtil getFloat

List of usage examples for com.liferay.portal.kernel.util GetterUtil getFloat

Introduction

In this page you can find the example usage for com.liferay.portal.kernel.util GetterUtil getFloat.

Prototype

public static float getFloat(String value, float defaultValue) 

Source Link

Document

Returns the String value as a float.

Usage

From source file:com.rivetlogic.elasticsearch.portlet.util.ElasticsearchPropsValues.java

License:Open Source License

/**
 * Sets the suggestion query fields./*from w  w w. j  ava 2s . c  o m*/
 */
private void setSuggestionQueryFields() {
    suggestionQueryFields = new HashMap<String, Float>();
    String csFields = getPortletProperty(ElasticsearchPortletConstants.SUGGESTION_QUERY_FIELDS_KEY);

    if (Validator.isNotNull(csFields)) {
        String[] fieldList = csFields.split(StringPool.COMMA);
        /** Iterate over the fields and add to Querybuilder */
        for (String field : fieldList) {
            String[] fieldWithBoostValue = field.split(ElasticsearchPortletConstants.CARET_SPLITCHAR);
            String filedName = fieldWithBoostValue[0] + ElasticsearchPortletConstants.NGRAMS_WITH_PERIOD;
            float boost = ElasticsearchPortletConstants.FLOAT_ZERO_VALUE;
            if (fieldWithBoostValue.length > ElasticsearchPortletConstants.INTEGER_ONE_VALUE) {
                boost = GetterUtil.getFloat(fieldWithBoostValue[1], boost);
            }
            suggestionQueryFields.put(filedName, boost);
        }
    } else {
        _log.error("Query fields to get suggestions is missing from properties...");
    }
}