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

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

Introduction

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

Prototype

public static float[] getFloatValues(String[] values) 

Source Link

Document

Returns the String values as a float array.

Usage

From source file:com.liferay.expando.web.internal.portlet.ExpandoPortlet.java

License:Open Source License

protected Serializable getValue(PortletRequest portletRequest, String name, int type) throws PortalException {

    String delimiter = StringPool.COMMA;

    Serializable value = null;//from www  .j  ava 2  s. c  om

    if (type == ExpandoColumnConstants.BOOLEAN) {
        value = ParamUtil.getBoolean(portletRequest, name);
    } else if (type == ExpandoColumnConstants.BOOLEAN_ARRAY) {
    } else if (type == ExpandoColumnConstants.DATE) {
        User user = _portal.getUser(portletRequest);

        int valueDateMonth = ParamUtil.getInteger(portletRequest, name + "Month");
        int valueDateDay = ParamUtil.getInteger(portletRequest, name + "Day");
        int valueDateYear = ParamUtil.getInteger(portletRequest, name + "Year");
        int valueDateHour = ParamUtil.getInteger(portletRequest, name + "Hour");
        int valueDateMinute = ParamUtil.getInteger(portletRequest, name + "Minute");
        int valueDateAmPm = ParamUtil.getInteger(portletRequest, name + "AmPm");

        if (valueDateAmPm == Calendar.PM) {
            valueDateHour += 12;
        }

        value = _portal.getDate(valueDateMonth, valueDateDay, valueDateYear, valueDateHour, valueDateMinute,
                user.getTimeZone(), ValueDataException.class);
    } else if (type == ExpandoColumnConstants.DATE_ARRAY) {
    } else if (type == ExpandoColumnConstants.DOUBLE) {
        value = ParamUtil.getDouble(portletRequest, name);
    } else if (type == ExpandoColumnConstants.DOUBLE_ARRAY) {
        String paramValue = ParamUtil.getString(portletRequest, name);

        if (paramValue.contains(StringPool.NEW_LINE)) {
            delimiter = StringPool.NEW_LINE;
        }

        String[] values = StringUtil.split(paramValue, delimiter);

        value = GetterUtil.getDoubleValues(values);
    } else if (type == ExpandoColumnConstants.FLOAT) {
        value = ParamUtil.getFloat(portletRequest, name);
    } else if (type == ExpandoColumnConstants.FLOAT_ARRAY) {
        String paramValue = ParamUtil.getString(portletRequest, name);

        if (paramValue.contains(StringPool.NEW_LINE)) {
            delimiter = StringPool.NEW_LINE;
        }

        String[] values = StringUtil.split(paramValue, delimiter);

        value = GetterUtil.getFloatValues(values);
    } else if (type == ExpandoColumnConstants.INTEGER) {
        value = ParamUtil.getInteger(portletRequest, name);
    } else if (type == ExpandoColumnConstants.INTEGER_ARRAY) {
        String paramValue = ParamUtil.getString(portletRequest, name);

        if (paramValue.contains(StringPool.NEW_LINE)) {
            delimiter = StringPool.NEW_LINE;
        }

        String[] values = StringUtil.split(paramValue, delimiter);

        value = GetterUtil.getIntegerValues(values);
    } else if (type == ExpandoColumnConstants.LONG) {
        value = ParamUtil.getLong(portletRequest, name);
    } else if (type == ExpandoColumnConstants.LONG_ARRAY) {
        String paramValue = ParamUtil.getString(portletRequest, name);

        if (paramValue.contains(StringPool.NEW_LINE)) {
            delimiter = StringPool.NEW_LINE;
        }

        String[] values = StringUtil.split(paramValue, delimiter);

        value = GetterUtil.getLongValues(values);
    } else if (type == ExpandoColumnConstants.NUMBER) {
        value = ParamUtil.getNumber(portletRequest, name);
    } else if (type == ExpandoColumnConstants.NUMBER_ARRAY) {
        String paramValue = ParamUtil.getString(portletRequest, name);

        if (paramValue.contains(StringPool.NEW_LINE)) {
            delimiter = StringPool.NEW_LINE;
        }

        String[] values = StringUtil.split(paramValue, delimiter);

        value = GetterUtil.getNumberValues(values);
    } else if (type == ExpandoColumnConstants.SHORT) {
        value = ParamUtil.getShort(portletRequest, name);
    } else if (type == ExpandoColumnConstants.SHORT_ARRAY) {
        String paramValue = ParamUtil.getString(portletRequest, name);

        if (paramValue.contains(StringPool.NEW_LINE)) {
            delimiter = StringPool.NEW_LINE;
        }

        String[] values = StringUtil.split(paramValue, delimiter);

        value = GetterUtil.getShortValues(values);
    } else if (type == ExpandoColumnConstants.STRING_ARRAY) {
        String paramValue = ParamUtil.getString(portletRequest, name);

        if (paramValue.contains(StringPool.NEW_LINE)) {
            delimiter = StringPool.NEW_LINE;
        }

        value = StringUtil.split(paramValue, delimiter);
    } else if (type == ExpandoColumnConstants.STRING_LOCALIZED) {
        value = (Serializable) LocalizationUtil.getLocalizationMap(portletRequest, name);
    } else {
        value = ParamUtil.getString(portletRequest, name);
    }

    return value;
}

From source file:com.liferay.portlet.expando.action.EditExpandoAction.java

License:Open Source License

protected Serializable getValue(PortletRequest portletRequest, String name, int type)
        throws PortalException, SystemException {

    String delimiter = StringPool.COMMA;

    Serializable value = null;/*  w  w  w .  j  ava2s .  co m*/

    if (type == ExpandoColumnConstants.BOOLEAN) {
        value = ParamUtil.getBoolean(portletRequest, name);
    } else if (type == ExpandoColumnConstants.BOOLEAN_ARRAY) {
    } else if (type == ExpandoColumnConstants.DATE) {
        User user = PortalUtil.getUser(portletRequest);

        int valueDateMonth = ParamUtil.getInteger(portletRequest, name + "Month");
        int valueDateDay = ParamUtil.getInteger(portletRequest, name + "Day");
        int valueDateYear = ParamUtil.getInteger(portletRequest, name + "Year");
        int valueDateHour = ParamUtil.getInteger(portletRequest, name + "Hour");
        int valueDateMinute = ParamUtil.getInteger(portletRequest, name + "Minute");
        int valueDateAmPm = ParamUtil.getInteger(portletRequest, name + "AmPm");

        if (valueDateAmPm == Calendar.PM) {
            valueDateHour += 12;
        }

        value = PortalUtil.getDate(valueDateMonth, valueDateDay, valueDateYear, valueDateHour, valueDateMinute,
                user.getTimeZone(), new ValueDataException());
    } else if (type == ExpandoColumnConstants.DATE_ARRAY) {
    } else if (type == ExpandoColumnConstants.DOUBLE) {
        value = ParamUtil.getDouble(portletRequest, name);
    } else if (type == ExpandoColumnConstants.DOUBLE_ARRAY) {
        String paramValue = ParamUtil.getString(portletRequest, name);

        if (paramValue.contains(StringPool.NEW_LINE)) {
            delimiter = StringPool.NEW_LINE;
        }

        String[] values = StringUtil.split(paramValue, delimiter);

        value = GetterUtil.getDoubleValues(values);
    } else if (type == ExpandoColumnConstants.FLOAT) {
        value = ParamUtil.getFloat(portletRequest, name);
    } else if (type == ExpandoColumnConstants.FLOAT_ARRAY) {
        String paramValue = ParamUtil.getString(portletRequest, name);

        if (paramValue.contains(StringPool.NEW_LINE)) {
            delimiter = StringPool.NEW_LINE;
        }

        String[] values = StringUtil.split(paramValue, delimiter);

        value = GetterUtil.getFloatValues(values);
    } else if (type == ExpandoColumnConstants.INTEGER) {
        value = ParamUtil.getInteger(portletRequest, name);
    } else if (type == ExpandoColumnConstants.INTEGER_ARRAY) {
        String paramValue = ParamUtil.getString(portletRequest, name);

        if (paramValue.contains(StringPool.NEW_LINE)) {
            delimiter = StringPool.NEW_LINE;
        }

        String[] values = StringUtil.split(paramValue, delimiter);

        value = GetterUtil.getIntegerValues(values);
    } else if (type == ExpandoColumnConstants.LONG) {
        value = ParamUtil.getLong(portletRequest, name);
    } else if (type == ExpandoColumnConstants.LONG_ARRAY) {
        String paramValue = ParamUtil.getString(portletRequest, name);

        if (paramValue.contains(StringPool.NEW_LINE)) {
            delimiter = StringPool.NEW_LINE;
        }

        String[] values = StringUtil.split(paramValue, delimiter);

        value = GetterUtil.getLongValues(values);
    } else if (type == ExpandoColumnConstants.SHORT) {
        value = ParamUtil.getShort(portletRequest, name);
    } else if (type == ExpandoColumnConstants.SHORT_ARRAY) {
        String paramValue = ParamUtil.getString(portletRequest, name);

        if (paramValue.contains(StringPool.NEW_LINE)) {
            delimiter = StringPool.NEW_LINE;
        }

        String[] values = StringUtil.split(paramValue, delimiter);

        value = GetterUtil.getShortValues(values);
    } else if (type == ExpandoColumnConstants.STRING_ARRAY) {
        String paramValue = ParamUtil.getString(portletRequest, name);

        if (paramValue.contains(StringPool.NEW_LINE)) {
            delimiter = StringPool.NEW_LINE;
        }

        value = StringUtil.split(paramValue, delimiter);
    } else {
        value = ParamUtil.getString(portletRequest, name);
    }

    return value;
}

From source file:com.liferay.portlet.expando.model.impl.ExpandoValueImpl.java

License:Open Source License

public float[] getFloatArray() throws PortalException, SystemException {
    validate(ExpandoColumnConstants.FLOAT_ARRAY);

    return GetterUtil.getFloatValues(StringUtil.split(getData()));
}

From source file:com.liferay.portlet.expando.util.ExpandoConverterUtil.java

License:Open Source License

public static Serializable getAttributeFromString(int type, String attribute) {

    if (attribute == null) {
        return null;
    }/*from w w w .j a  v  a 2  s  .  c  o  m*/

    if (type == ExpandoColumnConstants.BOOLEAN) {
        return GetterUtil.getBoolean(attribute);
    } else if (type == ExpandoColumnConstants.BOOLEAN_ARRAY) {
        return GetterUtil.getBooleanValues(StringUtil.split(attribute));
    } else if (type == ExpandoColumnConstants.DATE) {
        return GetterUtil.getDate(attribute, _getDateFormat());
    } else if (type == ExpandoColumnConstants.DATE_ARRAY) {
        return GetterUtil.getDateValues(StringUtil.split(attribute), _getDateFormat());
    } else if (type == ExpandoColumnConstants.DOUBLE) {
        return GetterUtil.getDouble(attribute);
    } else if (type == ExpandoColumnConstants.DOUBLE_ARRAY) {
        return GetterUtil.getDoubleValues(StringUtil.split(attribute));
    } else if (type == ExpandoColumnConstants.FLOAT) {
        return GetterUtil.getFloat(attribute);
    } else if (type == ExpandoColumnConstants.FLOAT_ARRAY) {
        return GetterUtil.getFloatValues(StringUtil.split(attribute));
    } else if (type == ExpandoColumnConstants.INTEGER) {
        return GetterUtil.getInteger(attribute);
    } else if (type == ExpandoColumnConstants.INTEGER_ARRAY) {
        return GetterUtil.getIntegerValues(StringUtil.split(attribute));
    } else if (type == ExpandoColumnConstants.LONG) {
        return GetterUtil.getLong(attribute);
    } else if (type == ExpandoColumnConstants.LONG_ARRAY) {
        return GetterUtil.getLongValues(StringUtil.split(attribute));
    } else if (type == ExpandoColumnConstants.SHORT) {
        return GetterUtil.getShort(attribute);
    } else if (type == ExpandoColumnConstants.SHORT_ARRAY) {
        return GetterUtil.getShortValues(StringUtil.split(attribute));
    } else if (type == ExpandoColumnConstants.STRING_ARRAY) {
        return StringUtil.split(attribute);
    } else {
        return attribute;
    }
}

From source file:com.rknowsys.portal.search.elastic.ElasticsearchIndexWriter.java

License:Open Source License

private String getElasticsearchDocument(Document document) throws IOException {

    XContentBuilder xContentBuilder = XContentFactory.jsonBuilder();

    xContentBuilder.startObject();/*from   w  w w  .j av  a 2 s  .  c  om*/

    Map<String, Field> fields = document.getFields();
    for (Field field : fields.values()) {
        String name = field.getName();

        if (!field.isLocalized()) {

            if (field.isNumeric()) {
                Class clazz = field.getNumericClass();
                if (clazz.equals(Double.class)) {
                    double[] values = GetterUtil.getDoubleValues(field.getValues());
                    if (values.length > 1) {
                        xContentBuilder.field(name, values);
                    } else {
                        xContentBuilder.field(name, values[0]);
                    }
                } else if (clazz.equals(Float.class)) {
                    float[] values = GetterUtil.getFloatValues(field.getValues());
                    if (values.length > 1) {
                        xContentBuilder.field(name, values);
                    } else {
                        xContentBuilder.field(name, values[0]);
                    }
                } else if (clazz.equals(Integer.class)) {
                    int[] values = GetterUtil.getIntegerValues(field.getValues());
                    if (values.length > 1) {
                        xContentBuilder.field(name, values);
                    } else {
                        xContentBuilder.field(name, values[0]);
                    }
                } else {
                    long[] values = GetterUtil.getLongValues(field.getValues());
                    if (values.length > 1) {
                        xContentBuilder.field(name, values);
                    } else {
                        xContentBuilder.field(name, values[0]);
                    }
                }
            } else {

                if (field.getValues().length > 1) {
                    xContentBuilder.field(name, field.getValues());
                } else {
                    xContentBuilder.field(name, field.getValue());
                }
            }
        } else {
            Map<Locale, String> localizedValues = field.getLocalizedValues();

            for (Map.Entry<Locale, String> entry : localizedValues.entrySet()) {

                String value = entry.getValue();

                if (Validator.isNull(value)) {
                    continue;
                }

                Locale locale = entry.getKey();

                String languageId = LocaleUtil.toLanguageId(locale);

                String defaultLanguageId = LocaleUtil.toLanguageId(LocaleUtil.getDefault());

                if (languageId.equals(defaultLanguageId)) {
                    xContentBuilder.field(name, value.trim());
                }

                String localizedName = DocumentImpl.getLocalizedName(LocaleUtil.fromLanguageId(languageId),
                        name);

                xContentBuilder.field(localizedName, value.trim());
            }
        }
    }

    xContentBuilder.endObject();

    return xContentBuilder.string();
}