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.lwes.serializer.StringParserTest.java

@Test
public void testFromStringINT16() {
    try {/*from w ww  .ja  v a  2s.  c  o m*/
        Short s = (Short) StringParser.fromStringINT16("12");
        assertNotNull(s);
        assertEquals("fromStringINT16 failed", (short) 12, s.shortValue());
    } catch (EventSystemException e) {
        log.error(e.getMessage(), e);
        fail(e.getMessage());
    }
}

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

public boolean isEditValid() {
    final String S_ProcName = "isEditValid";
    if (!hasValue()) {
        setValue(null);//from   ww  w. j  a v a 2 s.  c  o m
        return (true);
    }

    boolean retval = super.isEditValid();
    if (retval) {
        try {
            commitEdit();
        } catch (ParseException e) {
            throw CFLib.getDefaultExceptionFactory().newRuntimeException(getClass(), S_ProcName,
                    "Field is not valid - " + e.getMessage(), e);

        }
        Object obj = getValue();
        if (obj == null) {
            retval = false;
        } else if (obj instanceof Short) {
            Short s = (Short) obj;
            short v = s.shortValue();
            if ((v < getMinValue()) || (v > getMaxValue())) {
                retval = false;
            }
        } else if (obj instanceof Integer) {
            Integer i = (Integer) obj;
            int v = i.intValue();
            if ((v < getMinValue()) || (v > getMaxValue())) {
                retval = false;
            }
        } else if (obj instanceof Long) {
            Long l = (Long) obj;
            long v = l.longValue();
            if ((v < getMinValue()) || (v > getMaxValue())) {
                retval = false;
            }
        } else if (obj instanceof Number) {
            Number n = (Number) obj;
            long v = n.longValue();
            if ((v < getMinValue()) || (v > getMaxValue())) {
                retval = false;
            }
        } else {
            throw CFLib.getDefaultExceptionFactory().newUnsupportedClassException(getClass(), S_ProcName,
                    "EditedValue", obj, "Short, Integer, Long, or Number");
        }
    }
    return (retval);
}

From source file:z.tool.util.ToStringBuilder.java

public ToStringBuilder add(String key, Short value) {
    if (null != key && null != value) {
        getOrTryInitBuff().append(key).append(":").append(value.shortValue()).append(SEP);
    }// ww w .  j  a  va  2  s  .co  m
    return this;
}

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

public Short getInt16Value() {
    final String S_ProcName = "getInt16Value";
    Short retval;/*from www.j  av a  2s .  c om*/
    String text = getText();
    if ((text == null) || (text.length() <= 0)) {
        retval = null;
    } else {
        if (!isEditValid()) {
            throw CFLib.getDefaultExceptionFactory().newInvalidArgumentException(getClass(), S_ProcName,
                    "Field is not valid");
        }
        try {
            commitEdit();
        } catch (ParseException e) {
            throw CFLib.getDefaultExceptionFactory().newRuntimeException(getClass(), S_ProcName,
                    "Field is not valid - " + e.getMessage(), e);

        }
        Object obj = getValue();
        if (obj == null) {
            retval = null;
        } else if (obj instanceof Short) {
            Short s = (Short) obj;
            short v = s.shortValue();
            if ((v < getMinValue()) || (v > getMaxValue())) {
                throw CFLib.getDefaultExceptionFactory().newArgumentRangeException(getClass(), S_ProcName, 0,
                        "EditedValue", v, getMinValue(), getMaxValue());
            }
            retval = (Short) s;
        } else if (obj instanceof Integer) {
            Integer i = (Integer) obj;
            int v = i.intValue();
            if ((v < getMinValue()) || (v > getMaxValue())) {
                throw CFLib.getDefaultExceptionFactory().newArgumentRangeException(getClass(), S_ProcName, 0,
                        "EditedValue", v, getMinValue(), getMaxValue());
            }
            retval = new Short(i.shortValue());
        } else if (obj instanceof Long) {
            Long l = (Long) obj;
            long v = l.longValue();
            if ((v < getMinValue()) || (v > getMaxValue())) {
                throw CFLib.getDefaultExceptionFactory().newArgumentRangeException(getClass(), S_ProcName, 0,
                        "EditedValue", v, getMinValue(), getMaxValue());
            }
            retval = new Short(l.shortValue());
        } else if (obj instanceof Number) {
            Number n = (Number) obj;
            long v = n.longValue();
            if ((v < getMinValue()) || (v > getMaxValue())) {
                throw CFLib.getDefaultExceptionFactory().newArgumentRangeException(getClass(), S_ProcName, 0,
                        "EditedValue", v, getMinValue(), getMaxValue());
            }
            retval = new Short(n.shortValue());
        } else {
            throw CFLib.getDefaultExceptionFactory().newUnsupportedClassException(getClass(), S_ProcName,
                    "EditedValue", obj, "Short, Integer, Long, or Number");
        }
    }
    return (retval);
}

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

public Integer getInt32Value() {
    final String S_ProcName = "getInt32Value";
    Integer retval;/*  w  ww.j  a va 2 s  .  com*/
    String text = getText();
    if ((text == null) || (text.length() <= 0)) {
        retval = null;
    } else {
        if (!isEditValid()) {
            throw CFLib.getDefaultExceptionFactory().newInvalidArgumentException(getClass(), S_ProcName,
                    "Field is not valid");
        }
        try {
            commitEdit();
        } catch (ParseException e) {
            throw CFLib.getDefaultExceptionFactory().newRuntimeException(getClass(), S_ProcName,
                    "Field is not valid - " + e.getMessage(), e);

        }
        Object obj = getValue();
        if (obj == null) {
            retval = null;
        } else if (obj instanceof Short) {
            Short s = (Short) obj;
            short v = s.shortValue();
            if ((v < getMinValue()) || (v > getMaxValue())) {
                throw CFLib.getDefaultExceptionFactory().newArgumentRangeException(getClass(), S_ProcName, 0,
                        "EditedValue", v, getMinValue(), getMaxValue());
            }
            retval = new Integer((int) v);
        } else if (obj instanceof Integer) {
            Integer i = (Integer) obj;
            int v = i.intValue();
            if ((v < getMinValue()) || (v > getMaxValue())) {
                throw CFLib.getDefaultExceptionFactory().newArgumentRangeException(getClass(), S_ProcName, 0,
                        "EditedValue", v, getMinValue(), getMaxValue());
            }
            retval = i;
        } else if (obj instanceof Long) {
            Long l = (Long) obj;
            long v = l.longValue();
            if ((v < getMinValue()) || (v > getMaxValue())) {
                throw CFLib.getDefaultExceptionFactory().newArgumentRangeException(getClass(), S_ProcName, 0,
                        "EditedValue", v, getMinValue(), getMaxValue());
            }
            retval = new Integer(l.intValue());
        } else if (obj instanceof Number) {
            Number n = (Number) obj;
            long v = n.longValue();
            if ((v < getMinValue()) || (v > getMaxValue())) {
                throw CFLib.getDefaultExceptionFactory().newArgumentRangeException(getClass(), S_ProcName, 0,
                        "EditedValue", v, getMinValue(), getMaxValue());
            }
            retval = new Integer(n.intValue());
        } else {
            throw CFLib.getDefaultExceptionFactory().newUnsupportedClassException(getClass(), S_ProcName,
                    "EditedValue", obj, "Short, Integer, Long, or Number");
        }
    }
    return (retval);
}

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

public Long getInt64Value() {
    final String S_ProcName = "getInt64Value";
    Long retval;/*from   w  w w. j  a  va2  s.  c  o m*/
    String text = getText();
    if ((text == null) || (text.length() <= 0)) {
        retval = null;
    } else {
        if (!isEditValid()) {
            throw CFLib.getDefaultExceptionFactory().newInvalidArgumentException(getClass(), S_ProcName,
                    "Field is not valid");
        }
        try {
            commitEdit();
        } catch (ParseException e) {
            throw CFLib.getDefaultExceptionFactory().newRuntimeException(getClass(), S_ProcName,
                    "Field is not valid - " + e.getMessage(), e);

        }
        Object obj = getValue();
        if (obj == null) {
            retval = null;
        } else if (obj instanceof Short) {
            Short s = (Short) obj;
            short v = s.shortValue();
            if ((v < getMinValue()) || (v > getMaxValue())) {
                throw CFLib.getDefaultExceptionFactory().newArgumentRangeException(getClass(), S_ProcName, 0,
                        "EditedValue", v, getMinValue(), getMaxValue());
            }
            retval = new Long((long) v);
        } else if (obj instanceof Integer) {
            Integer i = (Integer) obj;
            int v = i.intValue();
            if ((v < getMinValue()) || (v > getMaxValue())) {
                throw CFLib.getDefaultExceptionFactory().newArgumentRangeException(getClass(), S_ProcName, 0,
                        "EditedValue", v, getMinValue(), getMaxValue());
            }
            retval = new Long((long) v);
        } else if (obj instanceof Long) {
            Long l = (Long) obj;
            long v = l.longValue();
            if ((v < getMinValue()) || (v > getMaxValue())) {
                throw CFLib.getDefaultExceptionFactory().newArgumentRangeException(getClass(), S_ProcName, 0,
                        "EditedValue", v, getMinValue(), getMaxValue());
            }
            retval = l;
        } else if (obj instanceof Number) {
            Number n = (Number) obj;
            long v = n.longValue();
            if ((v < getMinValue()) || (v > getMaxValue())) {
                throw CFLib.getDefaultExceptionFactory().newArgumentRangeException(getClass(), S_ProcName, 0,
                        "EditedValue", v, getMinValue(), getMaxValue());
            }
            retval = new Long(n.longValue());
        } else {
            throw CFLib.getDefaultExceptionFactory().newUnsupportedClassException(getClass(), S_ProcName,
                    "EditedValue", obj, "Short, Integer, Long, or Number");
        }
    }
    return (retval);
}

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

public Integer getUInt16Value() {
    final String S_ProcName = "getUInt16Value";
    Integer retval;//from   www  .  j a  v  a  2  s. c o  m
    String text = getText();
    if ((text == null) || (text.length() <= 0)) {
        retval = null;
    } else {
        if (!isEditValid()) {
            throw CFLib.getDefaultExceptionFactory().newInvalidArgumentException(getClass(), S_ProcName,
                    "Field is not valid");
        }
        try {
            commitEdit();
        } catch (ParseException e) {
            throw CFLib.getDefaultExceptionFactory().newRuntimeException(getClass(), S_ProcName,
                    "Field is not valid - " + e.getMessage(), e);

        }
        Object obj = getValue();
        if (obj == null) {
            retval = null;
        } else if (obj instanceof Short) {
            Short s = (Short) obj;
            short v = s.shortValue();
            if ((v < getMinValue()) || (v > getMaxValue())) {
                throw CFLib.getDefaultExceptionFactory().newArgumentRangeException(getClass(), S_ProcName, 0,
                        "EditedValue", v, getMinValue(), getMaxValue());
            }
            retval = new Integer((int) v);
        } else if (obj instanceof Integer) {
            Integer i = (Integer) obj;
            int v = i.intValue();
            if ((v < getMinValue()) || (v > getMaxValue())) {
                throw CFLib.getDefaultExceptionFactory().newArgumentRangeException(getClass(), S_ProcName, 0,
                        "EditedValue", v, getMinValue(), getMaxValue());
            }
            retval = i;
        } else if (obj instanceof Long) {
            Long l = (Long) obj;
            long v = l.longValue();
            if ((v < getMinValue()) || (v > getMaxValue())) {
                throw CFLib.getDefaultExceptionFactory().newArgumentRangeException(getClass(), S_ProcName, 0,
                        "EditedValue", v, getMinValue(), getMaxValue());
            }
            retval = new Integer(l.intValue());
        } else if (obj instanceof Number) {
            Number n = (Number) obj;
            long v = n.longValue();
            if ((v < getMinValue()) || (v > getMaxValue())) {
                throw CFLib.getDefaultExceptionFactory().newArgumentRangeException(getClass(), S_ProcName, 0,
                        "EditedValue", v, getMinValue(), getMaxValue());
            }
            retval = new Integer(n.intValue());
        } else {
            throw CFLib.getDefaultExceptionFactory().newUnsupportedClassException(getClass(), S_ProcName,
                    "EditedValue", obj, "Short, Integer, Long, or Number");
        }
    }
    return (retval);
}

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

public Long getUInt32Value() {
    final String S_ProcName = "getUInt32Value";
    Long retval;// www.  ja va 2  s. c  o  m
    String text = getText();
    if ((text == null) || (text.length() <= 0)) {
        retval = null;
    } else {
        if (!isEditValid()) {
            throw CFLib.getDefaultExceptionFactory().newInvalidArgumentException(getClass(), S_ProcName,
                    "Field is not valid");
        }
        try {
            commitEdit();
        } catch (ParseException e) {
            throw CFLib.getDefaultExceptionFactory().newRuntimeException(getClass(), S_ProcName,
                    "Field is not valid - " + e.getMessage(), e);

        }
        Object obj = getValue();
        if (obj == null) {
            retval = null;
        } else if (obj instanceof Short) {
            Short s = (Short) obj;
            short v = s.shortValue();
            if ((v < getMinValue()) || (v > getMaxValue())) {
                throw CFLib.getDefaultExceptionFactory().newArgumentRangeException(getClass(), S_ProcName, 0,
                        "EditedValue", v, getMinValue(), getMaxValue());
            }
            retval = new Long((long) v);
        } else if (obj instanceof Integer) {
            Integer i = (Integer) obj;
            int v = i.intValue();
            if ((v < getMinValue()) || (v > getMaxValue())) {
                throw CFLib.getDefaultExceptionFactory().newArgumentRangeException(getClass(), S_ProcName, 0,
                        "EditedValue", v, getMinValue(), getMaxValue());
            }
            retval = new Long((long) v);
        } else if (obj instanceof Long) {
            Long l = (Long) obj;
            long v = l.longValue();
            if ((v < getMinValue()) || (v > getMaxValue())) {
                throw CFLib.getDefaultExceptionFactory().newArgumentRangeException(getClass(), S_ProcName, 0,
                        "EditedValue", v, getMinValue(), getMaxValue());
            }
            retval = l;
        } else if (obj instanceof Number) {
            Number n = (Number) obj;
            long v = n.longValue();
            if ((v < getMinValue()) || (v > getMaxValue())) {
                throw CFLib.getDefaultExceptionFactory().newArgumentRangeException(getClass(), S_ProcName, 0,
                        "EditedValue", v, getMinValue(), getMaxValue());
            }
            retval = new Long(n.longValue());
        } else {
            throw CFLib.getDefaultExceptionFactory().newUnsupportedClassException(getClass(), S_ProcName,
                    "EditedValue", obj, "Short, Integer, Long, or Number");
        }
    }
    return (retval);
}

From source file:org.mifos.customers.struts.action.CustAction.java

protected boolean isPermissionAllowed(Short newState, UserContext userContext, Short flagSelected,
        Short recordOfficeId, Short recordLoanOfficerId) {
    return ActivityMapper.getInstance().isSavePermittedForCustomer(newState.shortValue(), userContext,
            recordOfficeId, recordLoanOfficerId);
}

From source file:org.lwes.EventTest.java

@Test
public void testEventAccessors() throws EventSystemException, UnknownHostException {
    Event evt = createEvent();/*from   w  w w  .j  av  a 2  s  .  c  o m*/
    evt.setEventName("Test");

    evt.setInt16("int16", (short) 1);
    evt.setInt32("int32", 1337);
    evt.setInt64("int64", 1337133713371337l);
    evt.setBoolean("bool", true);
    evt.setString("str", "string");
    evt.setUInt16("uint16", 1337); // uint16 in java is just an int
    evt.setUInt32("uint32", 0xffffffffL); // uint32 in java is a long
    evt.setUInt64("uint64", 1337133713371337l); // uint64 is a BigInteger
    evt.setIPAddress("ipaddr", InetAddress.getByName("localhost"));

    Short s = evt.getInt16("int16");
    assertNotNull(s);
    assertEquals("int16 wrong", 1, s.shortValue());
    Integer i = evt.getInt32("int32");
    assertNotNull(i);
    assertEquals("int32 wrong", 1337, i.intValue());
    Long l = evt.getInt64("int64");
    assertNotNull(l);
    assertEquals("int64 wrong", 1337133713371337l, l.longValue());
    assertEquals("bool wrong", true, evt.getBoolean("bool"));
    assertEquals("str wrong", "string", evt.getString("str"));
    i = evt.getUInt16("uint16");
    assertNotNull(i);
    assertEquals("uint16 wrong", 1337, i.intValue());
    l = evt.getUInt32("uint32");
    assertEquals("uint32 wrong", 0xffffffffL, l.longValue());
    assertEquals("uint64 wrong", BigInteger.valueOf(1337133713371337l), evt.getUInt64("uint64"));

    final Event evt2 = createEvent();
    evt2.deserialize(evt.serialize());
    assertEquals("Event changed under [de]serialization:\n" + evt + "\n" + evt2, evt, evt2);
}