| Method from java.lang.Short Detail: |
public byte byteValue() {
return (byte)value;
}
Returns the value of this {@code Short} as a
{@code byte}. |
public int compareTo(Short anotherShort) {
return this.value - anotherShort.value;
}
Compares two {@code Short} objects numerically. |
public static Short decode(String nm) throws NumberFormatException {
int i = Integer.decode(nm);
if (i < MIN_VALUE || i > MAX_VALUE)
throw new NumberFormatException(
"Value " + i + " out of range from input " + nm);
return (short)i;
}
Decodes a {@code String} into a {@code Short}.
Accepts decimal, hexadecimal, and octal numbers given by
the following grammar:
- DecodableString:
- Signopt DecimalNumeral
- Signopt {@code 0x} HexDigits
- Signopt {@code 0X} HexDigits
- Signopt {@code #} HexDigits
- Signopt {@code 0} OctalDigits
- Sign:
- {@code -}
- {@code +}
DecimalNumeral, HexDigits, and OctalDigits
are defined in §3.10.1
of the Java
Language Specification.
The sequence of characters following an optional
sign and/or radix specifier ("{@code 0x}", "{@code 0X}",
"{@code #}", or leading zero) is parsed as by the {@code
Short.parseShort} method with the indicated radix (10, 16, or
8). This sequence of characters must represent a positive
value or a NumberFormatException will be thrown. The
result is negated if first character of the specified {@code
String} is the minus sign. No whitespace characters are
permitted in the {@code String}. |
public double doubleValue() {
return (double)value;
}
Returns the value of this {@code Short} as a
{@code double}. |
public boolean equals(Object obj) {
if (obj instanceof Short) {
return value == ((Short)obj).shortValue();
}
return false;
}
Compares this object to the specified object. The result is
{@code true} if and only if the argument is not
{@code null} and is a {@code Short} object that
contains the same {@code short} value as this object. |
public float floatValue() {
return (float)value;
}
Returns the value of this {@code Short} as a
{@code float}. |
public int hashCode() {
return (int)value;
}
Returns a hash code for this {@code Short}. |
public int intValue() {
return (int)value;
}
Returns the value of this {@code Short} as an
{@code int}. |
public long longValue() {
return (long)value;
}
Returns the value of this {@code Short} as a
{@code long}. |
public static short parseShort(String s) throws NumberFormatException {
return parseShort(s, 10);
}
Parses the string argument as a signed decimal {@code
short}. The characters in the string must all be decimal
digits, except that the first character may be an ASCII minus
sign {@code '-'} ('\u002D') to indicate a
negative value or an ASCII plus sign {@code '+'}
('\u002B') to indicate a positive value. The
resulting {@code short} value is returned, exactly as if the
argument and the radix 10 were given as arguments to the #parseShort(java.lang.String, int) method. |
public static short parseShort(String s,
int radix) throws NumberFormatException {
int i = Integer.parseInt(s, radix);
if (i < MIN_VALUE || i > MAX_VALUE)
throw new NumberFormatException(
"Value out of range. Value:\"" + s + "\" Radix:" + radix);
return (short)i;
}
Parses the string argument as a signed {@code short} in the
radix specified by the second argument. The characters in the
string must all be digits, of the specified radix (as
determined by whether java.lang.Character#digit(char,
int) returns a nonnegative value) except that the first
character may be an ASCII minus sign {@code '-'}
('\u002D') to indicate a negative value or an
ASCII plus sign {@code '+'} ('\u002B') to
indicate a positive value. The resulting {@code short} value
is returned.
An exception of type {@code NumberFormatException} is
thrown if any of the following situations occurs:
- The first argument is {@code null} or is a string of
length zero.
- The radix is either smaller than java.lang.Character#MIN_RADIX or larger than java.lang.Character#MAX_RADIX .
- Any character of the string is not a digit of the
specified radix, except that the first character may be a minus
sign {@code '-'} (
'\u002D') or plus sign
{@code '+'} ('\u002B') provided that the
string is longer than length 1.
- The value represented by the string is not a value of type
{@code short}.
|
public static short reverseBytes(short i) {
return (short) (((i & 0xFF00) > > 8) | (i < < 8));
}
Returns the value obtained by reversing the order of the bytes in the
two's complement representation of the specified {@code short} value. |
public short shortValue() {
return value;
}
Returns the value of this {@code Short} as a
{@code short}. |
public String toString() {
return String.valueOf((int)value);
}
Returns a {@code String} object representing this
{@code Short}'s value. The value is converted to signed
decimal representation and returned as a string, exactly as if
the {@code short} value were given as an argument to the
java.lang.Short#toString(short) method. |
public static String toString(short s) {
return Integer.toString((int)s, 10);
}
Returns a new {@code String} object representing the
specified {@code short}. The radix is assumed to be 10. |
public static Short valueOf(String s) throws NumberFormatException {
return valueOf(s, 10);
}
Returns a {@code Short} object holding the
value given by the specified {@code String}. The argument
is interpreted as representing a signed decimal
{@code short}, exactly as if the argument were given to
the #parseShort(java.lang.String) method. The result is
a {@code Short} object that represents the
{@code short} value specified by the string.
In other words, this method returns a {@code Short} object
equal to the value of:
{@code new Short(Short.parseShort(s))}
|
public static Short valueOf(short s) {
for(int i = 0; i < cache.length; i++)
cache[i] = new Short((short)(i - 128));
final int offset = 128;
int sAsInt = s;
if (sAsInt >= -128 && sAsInt < = 127) { // must cache
return ShortCache.cache[sAsInt + offset];
}
return new Short(s);
}
Returns a {@code Short} instance representing the specified
{@code short} value.
If a new {@code Short} instance is not required, this method
should generally be used in preference to the constructor
#Short(short) , as this method is likely to yield
significantly better space and time performance by caching
frequently requested values. |
public static Short valueOf(String s,
int radix) throws NumberFormatException {
return new Short(parseShort(s, radix));
}
Returns a {@code Short} object holding the value
extracted from the specified {@code String} when parsed
with the radix given by the second argument. The first argument
is interpreted as representing a signed {@code short} in
the radix specified by the second argument, exactly as if the
argument were given to the #parseShort(java.lang.String,
int) method. The result is a {@code Short} object that
represents the {@code short} value specified by the string.
In other words, this method returns a {@code Short} object
equal to the value of:
{@code new Short(Short.parseShort(s, radix))}
|