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

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

Introduction

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

Prototype

public static short[] getShortValues(String[] values) 

Source Link

Document

Returns the String array values as a short 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;// w  w w.j  a v a  2 s  . c o m

    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 ww  .  ja  v  a2s  .  c  om*/

    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 short[] getShortArray() throws PortalException, SystemException {
    validate(ExpandoColumnConstants.SHORT_ARRAY);

    return GetterUtil.getShortValues(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  ww. j a  va2 s  .  c om

    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;
    }
}