Java Utililty Methods Short Number Create

List of utility methods to do Short Number Create

Description

The list of methods to do Short Number Create are organized into topic(s).

Method

shorttoShort(int unsignedShort)
Converts an int containing an unsigned short value to the corresponding signed short value and returns the result as a short
if (unsignedShort < 0 || unsignedShort > MAX_SHORT) {
    throw new IllegalArgumentException(String.format(
            "Unsigned byte values should be in the range 0..%1$d, got: %2$d", MAX_SHORT, unsignedShort));
return (short) unsignedShort;
shorttoShort(long l)
to Short
if (l < Short.MIN_VALUE || l > Short.MAX_VALUE)
    throw new ArithmeticException("Value (" + l + ") cannot fit into short");
return (short) l;
shorttoShort(long n)
to Short
if (n < Short.MIN_VALUE || Short.MAX_VALUE < n) {
    throw new IllegalArgumentException("value out of range: " + n);
return (short) n;
ShorttoShort(Number num)
Convert the given number into a Short instance.
return (num == null) ? null : Short.valueOf(num.shortValue());
ShorttoShort(Number value)
to Short
if (value == null) {
    return null;
} else if (value instanceof Short) {
    return (Short) value;
} else {
    return Short.valueOf(value.shortValue());
ShorttoShort(Object o)
to Short
if (o == null)
    return null;
if (o.getClass() == Short.class)
    return (Short) o;
if (o.getClass() == Boolean.class)
    return booleanToShort((Boolean) o);
if (o.getClass() == Byte.class)
    return (short) ((Byte) o).byteValue();
...
ShorttoShort(Object ob, Short defaultShort)
to Short
if (ob == null) {
    return defaultShort;
if (ob instanceof Integer) {
    return ((Integer) ob).shortValue();
} else if (ob instanceof Float) {
    return ((Float) ob).shortValue();
} else if (ob instanceof Double) {
...
shorttoShort(Object obj)
Convert object returned from server to short.
return (short) toLong(obj);
shorttoShort(Object obj)
to Short
return toShort(obj, (byte) 0);
shorttoShort(Object obj)
Get the short value of this object, only if the object is an instance of Number
return (obj instanceof Number) ? ((Number) obj).shortValue() : 0;