Example usage for java.lang Short shortValue

List of usage examples for java.lang Short shortValue

Introduction

In this page you can find the example usage for java.lang Short shortValue.

Prototype

@HotSpotIntrinsicCandidate
public short shortValue() 

Source Link

Document

Returns the value of this Short as a short .

Usage

From source file:org.acmsl.commons.utils.ConversionUtils.java

/**
 * Converts given String to short.//w ww  . ja  va 2  s.co  m
 * @param value the value to convert.
 * @return the converted value.
 */
public short toShort(@Nullable final String value) {
    short result = 0;

    @Nullable
    final Short t_Result = toShortIfNotNull(value);

    if (t_Result != null) {
        result = t_Result.shortValue();
    }

    return result;
}

From source file:br.gov.frameworkdemoiselle.internal.configuration.ConfigurationLoaderWithArrayTest.java

@Test
public void testConfigurationPropertiesWithShortArray() {
    ConfigurationPropertiesWithArray config = prepareConfigurationPropertiesWithArray();

    Short shortValue = config.shortArray[0];

    assertEquals(Short.class, shortValue.getClass());
    assertEquals(Short.MAX_VALUE, shortValue.shortValue());
    assertEquals(4, config.shortArray.length);
}

From source file:br.gov.frameworkdemoiselle.internal.configuration.ConfigurationLoaderWithArrayTest.java

@Test
public void testConfigurationXMLWithShortArray() {
    ConfigurationXMLWithArray config = prepareConfigurationXMLWithArray();

    Short shortValue = config.shortArray[0];

    assertEquals(Short.class, shortValue.getClass());
    assertEquals(Short.MAX_VALUE, shortValue.shortValue());
    assertEquals(4, config.shortArray.length);
}

From source file:br.gov.frameworkdemoiselle.internal.configuration.ConfigurationLoaderWithListTest.java

@Test
public void testConfigurationPropertiesWithShortList() {
    ConfigurationPropertiesWithList config = prepareConfigurationPropertiesWithList();

    Short shortValue = config.shortList.get(0);

    assertEquals(Short.class, shortValue.getClass());
    assertEquals(Short.MAX_VALUE, shortValue.shortValue());
    assertEquals(4, config.shortList.size());
}

From source file:br.gov.frameworkdemoiselle.internal.configuration.ConfigurationLoaderWithListTest.java

@Test
public void testConfigurationXMLWithShortList() {
    ConfigurationXMLWithList config = prepareConfigurationXMLWithList();

    Short shortValue = config.shortList.get(0);

    assertEquals(Short.class, shortValue.getClass());
    assertEquals(Short.MAX_VALUE, shortValue.shortValue());
    assertEquals(4, config.shortList.size());
}

From source file:org.lwes.EventTest.java

@Test
public void testNullValue() throws EventSystemException {
    Event evt = createEvent();//from  w  w  w  .j  a v  a2  s  .  co m
    evt.setEventName("Test");
    Short s = evt.getInt16("a");
    assertNull(s);
    evt.setInt16("a", (short) 1);
    s = evt.getInt16("a");
    assertNotNull(s);
    assertEquals("short value incorrect", (short) 1, s.shortValue());
}

From source file:org.mifos.security.rolesandpermission.util.helpers.RoleTempleteBuilder.java

/**
 * This is internal helpher function used to build the templete this give
 * the childern associated with the current id
 *
 * @param activities//from   w ww . j a  va  2s .c  om
 *            List of all Activity object in the system
 * @param id
 *            activity id whose childern we are finding
 * @return List of childern associated with the current activity
 */
private List<ActivityEntity> getChildren(List<ActivityEntity> activities, Short id) {
    List<ActivityEntity> l = new ArrayList<ActivityEntity>();

    for (int i = 0; i < activities.size(); i++) {

        // if id=0 then we are looking for top level activities
        ActivityEntity parent = activities.get(i).getParent();
        if (id.shortValue() == 0) {

            if (null == parent) {
                l.add(activities.get(i));
            }

        } else {

            if (null != parent) {
                if (parent.getId().shortValue() == id.shortValue()) {
                    l.add(activities.get(i));
                }
            }

        }
    }

    return l;
}

From source file:eionet.gdem.conversion.excel.writer.ExcelConversionHandler.java

@Override
public void addCell(String type, String str_value, String style_name) {
    HSSFSheet _sheet = wb.getSheetAt(currentSheet);
    HSSFRow _row = _sheet.getRow(currentRow);
    HSSFCell _cell = _row.createCell((currentCell));

    Double number_value = null;//from   w  ww.  j  ava  2 s .c o m
    Boolean boolean_value = null;
    boolean isNumber = false;
    boolean isBoolean = false;
    if (type == null) {
        type = (String) getDefaultParams("data_type");
    }
    if (type != null) {
        if (type.equals("float") || type.equals("number")) {
            if (str_value != null) {
                try {
                    number_value = new Double(str_value);
                    isNumber = true;
                } catch (Exception e) {
                    // the value is not number, it will be inserted as a string
                    // System.out.println(e.toString());
                }
            } else {
                isNumber = true;
            }
        } else if (type.equals("boolean")) {
            if (str_value != null) {
                try {
                    boolean_value = new Boolean(str_value);
                    isBoolean = true;
                } catch (Exception e) {
                    // the value is not boolean, it will be inserted as a string
                    // System.out.println(e.toString());
                }
            } else {
                isBoolean = true;
            }
        } else if (type.equals("date")) {
            if (str_value != null) {
                try {
                    // cellStyle.setDataFormat(HSSFDataFormat.getBuiltinFormat("yyyymmdd"));

                    /*
                     *
                     * The way how to handle user defined formats not supported right now HSSFDataFormat format =
                     * wb.createDataFormat(); HSSFCellStyle style = wb.createCellStyle();
                     * style.setDataFormat(format.getFormat("yyyymmdd")); _cell.setCellStyle(style);
                     */
                    // cellStyle.setDataFormat(new HSSFDataFormat("yyyymmdd"));
                    /*
                     * try{ l_value=Long.parseLong(value); System.out.println(String.valueOf(l_value)); isLong=true; }
                     * catch(Exception e){ System.out.println(e.toString()); }
                     */
                    /*
                     * if (isLong){ Date d = new Date(); _cell.setCellStyle(cellStyle); //_cell.setCellValue(d);
                     * _cell.setCellValue(value); //System.out.println(d.toString()); isDate=true; } else
                     * _cell.setCellValue(value);
                     */
                    // System.out.println("hh");

                } catch (Exception e) {
                    System.out.println(e.toString());
                }
            }
        }
    }
    if (isNumber) {
        if (number_value != null) {
            _cell.setCellValue(number_value.doubleValue());
        }
        _cell.setCellType(HSSFCell.CELL_TYPE_NUMERIC);
    } else if (isBoolean) {
        if (boolean_value != null) {
            _cell.setCellValue(boolean_value.booleanValue());
        }
        _cell.setCellType(HSSFCell.CELL_TYPE_BOOLEAN);
    } else {
        _cell.setCellType(HSSFCell.CELL_TYPE_STRING);
        // _cell.setEncoding(HSSFCell.ENCODING_UTF_16 );//
        _cell.setCellValue(str_value);
    }

    short idx = -1;
    if (style_name != null) {
        idx = getStyleIdxByName(style_name, ExcelStyleIF.STYLE_FAMILY_TABLE_CELL);
    }

    if (idx < 0) {
        Short short_idx = (Short) getDefaultParams("style");
        if (short_idx != null) {
            idx = short_idx.shortValue();
        }
    }

    if (idx > -1) {
        _cell.setCellStyle(wb.getCellStyleAt(idx));
    }
    // calculates the col with according to the first row
    if (currentRow == 0 && idx > -1) {
        short colStyleWidth = 0;
        HSSFCellStyle style = wb.getCellStyleAt(idx);
        int f_i = style.getFontIndex();
        HSSFFont font = wb.getFontAt((short) f_i);
        // character size
        short size = font.getFontHeightInPoints();
        if (columns.size() > currentCell) {
            RowColumnDefinition column = columns.get(currentCell);
            String column_style_name = column.getStyleName() == null ? "" : column.getStyleName();
            ExcelStyleIF definedStyle = getStyleByName(column_style_name, ExcelStyleIF.STYLE_FAMILY_TABLE_CELL);
            if (definedStyle != null) {
                colStyleWidth = definedStyle.getColumnWidth();
            }
        }
        short width = (short) (_sheet.getDefaultColumnWidth() * size * 25);
        if (colStyleWidth > 0) {
            width = colStyleWidth;
        } else if (str_value.length() > 0) {
            width = (short) (str_value.length() * size * 50);
        }
        _sheet.setColumnWidth(currentCell, width);
    }
    currentCell = _cell.getColumnIndex() + 1;
    // System.out.println("Cell" + currentCell+ "-" + value);
}

From source file:net.sourceforge.msscodefactory.cflib.v1_11.CFLib.CFLibXmlUtil.java

public static String formatOptionalInt16(String separator, String attrName, Short val) {
    final String S_ProcName = "formatOptionalInt16";
    if ((attrName == null) || (attrName.length() <= 0)) {
        throw CFLib.getDefaultExceptionFactory().newNullArgumentException(CFLibXmlUtil.class, S_ProcName, 1,
                "attrName");
    }/*  www  .j a  v a 2s . co m*/
    String retval;
    if (val != null) {
        retval = formatRequiredInt16(separator, attrName, val.shortValue());
    } else {
        retval = S_emptyString;
    }
    return (retval);
}

From source file:com.redhat.lightblue.metadata.parser.JSONMetadataParserTest.java

License:asdf

@Test
public void putValueSohrt() {
    ObjectNode parent = new ObjectNode(factory);
    String name = "foo";
    Short value = 123;/*from  w w  w.ja  v  a 2 s. c o m*/

    parser.putValue(parent, name, value);

    JsonNode x = parent.get(name);

    Assert.assertNotNull(x);
    Assert.assertEquals(value.shortValue(), x.shortValue());
}