java.lang
Class Short
java.lang.Object
java.lang.Number
java.lang.Short
- All Implemented Interfaces:
- Comparable, Serializable
- public final class Short
- extends Number
- implements Comparable
JML's specification of java.lang.Short.
- Version:
- $Revision: 1.17 $
- Author:
- Brandon Shilling, Gary T. Leavens
Class Specifications |
represents theShort <- this.shortValue(); |
Specifications inherited from class Object |
represents objectState <- org.jmlspecs.lang.JMLDataGroup.IT;
public represents _getClass <- \typeof(this); |
Specifications inherited from interface Comparable |
instance public invariant ( \forall java.lang.Comparable x; x != null; x.compareTo(x) == 0);
instance public invariant ( \forall java.lang.Comparable x, y; x != null&&y != null&&this.definedComparison(x,y)&&this.definedComparison(y,x); this.sgn(x.compareTo(y)) == -this.sgn(y.compareTo(x)));
instance public invariant ( \forall int n; n == -1||n == 1; ( \forall java.lang.Comparable x, y, z; x != null&&y != null&&z != null&&this.definedComparison(x,y)&&this.definedComparison(y,z)&&this.definedComparison(x,z); this.sgn(x.compareTo(y)) == n&&this.sgn(y.compareTo(z)) == n ==> this.sgn(x.compareTo(z)) == n));
instance public invariant ( \forall int n; n == -1||n == 1; ( \forall java.lang.Comparable x, y, z; x != null&&y != null&&z != null&&this.definedComparison(x,y)&&this.definedComparison(y,z)&&this.definedComparison(x,z); (this.sgn(x.compareTo(y)) == 0&&this.sgn(y.compareTo(z)) == n||this.sgn(x.compareTo(y)) == n&&this.sgn(y.compareTo(z)) == 0) ==> this.sgn(x.compareTo(z)) == n));
instance public invariant ( \forall java.lang.Comparable x, y, z; x != null&&y != null&&z != null&&this.definedComparison(x,y)&&this.definedComparison(x,z)&&this.definedComparison(y,z); this.sgn(x.compareTo(y)) == 0 ==> this.sgn(x.compareTo(z)) == this.sgn(y.compareTo(z))); |
theShort
public short theShort
MIN_VALUE
public static final short MIN_VALUE
MAX_VALUE
public static final short MAX_VALUE
TYPE
public static final Class TYPE
- Specifications: non_null
Short
public Short(short value)
- Specifications: (class)pure
-
public normal_behavior
assignable theShort;
ensures this.theShort == value;
Short
public Short(String s)
throws NumberFormatException
- Throws:
NumberFormatException
- Specifications: (class)pure
-
public normal_behavior
requires parseable(s);
assignable theShort;
ensures this.theShort == parseShort(s);
- also
-
public exceptional_behavior
requires !parseable(s);
signals (java.lang.NumberFormatException) true;
parseable
public static boolean parseable(String s)
- Specifications: pure
-
public normal_behavior
ensures \result == parseable(s,10);
parseable
public static boolean parseable(String s,
int r)
- Specifications: pure
-
public normal_behavior
requires 2 <= r&&r <= 36;
ensures \result <==> s != null&&!s.equals("")&&( \forall int i; 0 <= i&&i < s.length(); java.lang.Character.digit(s.charAt(i),r) != -1);
- also
-
public normal_behavior
requires 2 <= r&&r <= 36;
ensures \result <==> s != null&&!s.equals("")&&( \forall int i; 1 <= i&&i < s.length()&&s.charAt(0) == 45; java.lang.Character.digit(s.charAt(i),r) != -1);
decodeable
public static boolean decodeable(String nm)
- Specifications: pure
-
public normal_behavior
{|-
requires (nm.charAt(0) == 79&&nm.charAt(1) == 120);
ensures \result == parseable(nm.substring(2),16);
- also
-
requires (nm.charAt(0) == 45&&nm.charAt(1) == 79&&nm.charAt(2) == 120);
ensures \result == parseable(nm.substring(3),16);
- also
-
requires (nm.charAt(0) == 35);
ensures \result == parseable(nm.substring(1),16);
- also
-
requires (nm.charAt(0) == 45&&nm.charAt(1) == 35);
ensures \result == parseable(nm.substring(2),16);
- also
-
requires (nm.charAt(0) == 79);
ensures \result == parseable(nm.substring(1),8);
- also
-
requires (nm.charAt(0) == 45&&nm.charAt(1) == 79);
ensures \result == parseable(nm.substring(2),8);
- also
-
ensures \result == parseable(nm);
- |}
toString
public static String toString(short s)
- Specifications: pure non_null
-
public normal_behavior
{|-
requires s < 0;
ensures \result != null&&\result .charAt(0) == 45&&\result .charAt(1) != 48&&s == parseShort(\result );
- also
-
requires s > 0;
ensures \result != null&&\result .charAt(0) != 48&&s == parseShort(\result );
- also
-
requires s == 0;
ensures \result != null&&\result .charAt(0) == 48&&\result .length() == 1;
- |}
- implies_that
-
public normal_behavior
ensures (* \result is a string representation of s *);
- for_example
-
public normal_example
requires s == -34;
ensures \result != null&&\result .equals("-34");
parseShort
public static short parseShort(String s)
throws NumberFormatException
- Throws:
NumberFormatException
- Specifications: pure
-
public normal_behavior
requires parseable(s);
ensures \result == parseShort(s,10);
- also
-
public exceptional_behavior
requires !parseable(s);
signals_only java.lang.NumberFormatException;
parseShort
public static short parseShort(String s,
int radix)
throws NumberFormatException
- Throws:
NumberFormatException
- Specifications: pure
-
public normal_behavior
requires parseable(s,radix);
ensures (* \result is the short represented by string s with specified radix *);
- also
-
public exceptional_behavior
requires !parseable(s,radix);
signals_only java.lang.NumberFormatException;
- for_example
-
public normal_example
requires s.equals("-34")&&radix == 10;
ensures \result == -34;
valueOf
public static Short valueOf(String s,
int radix)
throws NumberFormatException
- Throws:
NumberFormatException
- Specifications: pure non_null
-
public normal_behavior
requires parseable(s,radix);
ensures \fresh(\result )&&\result .shortValue() == parseShort(s,radix);
- also
-
public exceptional_behavior
requires !parseable(s,radix);
signals_only java.lang.NumberFormatException;
valueOf
public static Short valueOf(String s)
throws NumberFormatException
- Throws:
NumberFormatException
- Specifications: pure non_null
-
public normal_behavior
requires parseable(s);
ensures \fresh(\result )&&\result .shortValue() == parseShort(s);
- also
-
public exceptional_behavior
requires !parseable(s);
signals_only java.lang.NumberFormatException;
decode
public static Short decode(non_null String nm)
throws NumberFormatException
- Throws:
NumberFormatException
- Specifications: pure non_null
-
public normal_behavior
requires decodeable(nm);
ensures (* \result is a Short representation of nm *);
- also
-
public exceptional_behavior
requires !decodeable(nm);
signals (java.lang.NumberFormatException) true;
byteValue
public byte byteValue()
- Overrides:
byteValue
in class Number
- Specifications: (class)pure
- also
-
public normal_behavior
ensures \result == (byte)this.theShort;
- Specifications inherited from overridden method in class Number:
pure -
public normal_behavior
ensures (* \result is an byte approximation to the value of this object *);
shortValue
public short shortValue()
- Overrides:
shortValue
in class Number
- Specifications: (class)pure
- also
-
public normal_behavior
ensures \result == this.theShort;
- Specifications inherited from overridden method in class Number:
pure -
public normal_behavior
ensures (* \result is an short approximation to the value of this object *);
intValue
public int intValue()
- Specifications: (class)pure
- also
-
public normal_behavior
ensures \result == this.theShort;
- Specifications inherited from overridden method in class Number:
pure -
public normal_behavior
ensures (* \result is an int approximation to the value of this object *);
longValue
public long longValue()
- Specifications: (class)pure
- also
-
public normal_behavior
ensures \result == this.theShort;
- Specifications inherited from overridden method in class Number:
pure -
public normal_behavior
ensures (* \result is an long approximation to the value of this object *);
floatValue
public float floatValue()
- Specifications: (class)pure
- also
-
public normal_behavior
ensures \result == this.theShort;
- Specifications inherited from overridden method in class Number:
pure -
public normal_behavior
ensures (* \result is an float approximation to the value of this object *);
doubleValue
public double doubleValue()
- Specifications: (class)pure
- also
-
public normal_behavior
ensures \result == this.theShort;
- Specifications inherited from overridden method in class Number:
pure -
public normal_behavior
ensures (* \result is an double approximation to the value of this object *);
toString
public String toString()
- Overrides:
toString
in class Object
- Specifications: non_null (class)pure
- Specifications inherited from overridden method in class Object:
non_null -
public normal_behavior
assignable objectState;
ensures \result != null&&\result .equals(this.theString);
ensures (* \result is a string representation of this object *);
- also
-
public code normal_behavior
assignable \nothing;
ensures \result != null&&(* \result is the instance's class name, followed by an @, followed by the instance's hashcode in hex *);
- also
-
public code model_program { ... }
- implies_that
-
assignable objectState;
ensures \result != null;
hashCode
public int hashCode()
- Overrides:
hashCode
in class Object
- Specifications: (class)pure
- also
-
public normal_behavior
ensures (* \result is a hash code for this object *);
- Specifications inherited from overridden method in class Object:
-
public behavior
assignable objectState;
ensures (* \result is a hash code for this object *);
- also
-
public code normal_behavior
assignable \nothing;
equals
public boolean equals(nullable Object obj)
- Overrides:
equals
in class Object
- Specifications: (class)pure
- also
-
public normal_behavior
requires obj != null&&(obj instanceof java.lang.Short);
ensures \result == (this.theShort == ((java.lang.Short)obj).shortValue());
- also
-
public normal_behavior
requires obj == null||!(obj instanceof java.lang.Short);
ensures !\result ;
- Specifications inherited from overridden method equals(Object obj) in class Object:
pure -
public normal_behavior
requires obj != null;
ensures (* \result is true when obj is "equal to" this object *);
- also
-
public normal_behavior
requires this == obj;
ensures \result ;
- also
-
public code normal_behavior
requires obj != null;
ensures \result <==> this == obj;
- also
-
diverges false;
ensures obj == null ==> !\result ;
compareTo
public int compareTo(non_null Short anotherShort)
- Specifications: (class)pure
-
public normal_behavior
requires anotherShort != null;
{|-
requires this.theShort == anotherShort.shortValue();
ensures \result == 0;
- also
-
requires this.theShort < anotherShort.shortValue();
ensures \result < 0;
- also
-
requires this.theShort > anotherShort.shortValue();
ensures \result > 0;
- |}
- Specifications inherited from overridden method compareTo(Object o) in interface Comparable:
pure -
public behavior
requires o != null;
ensures (* \result is negative if this is "less than" o *);
ensures (* \result is 0 if this is "equal to" o *);
ensures (* \result is positive if this is "greater than" o *);
signals_only java.lang.ClassCastException;
signals (java.lang.ClassCastException) (* the class of o prohibits it from being compared to this *);
- also
-
public behavior
requires o != null&&o instanceof java.lang.Comparable;
ensures this.definedComparison((java.lang.Comparable)o,this);
ensures o == this ==> \result == 0;
ensures this.sgn(\result ) == -this.sgn(((java.lang.Comparable)o).compareTo(this));
signals (java.lang.ClassCastException) !this.definedComparison((java.lang.Comparable)o,this);
compareTo
public int compareTo(non_null Object o)
throws ClassCastException
- Specified by:
compareTo
in interface Comparable
- Throws:
ClassCastException
- Specifications: (class)pure
- also
-
public normal_behavior
requires o != null&&(o instanceof java.lang.Short);
ensures \result == this.compareTo((java.lang.Short)o);
- also
-
public exceptional_behavior
requires o == null&&!(o instanceof java.lang.Short);
signals (java.lang.ClassCastException) true;
- Specifications inherited from overridden method compareTo(Object o) in interface Comparable:
pure -
public behavior
requires o != null;
ensures (* \result is negative if this is "less than" o *);
ensures (* \result is 0 if this is "equal to" o *);
ensures (* \result is positive if this is "greater than" o *);
signals_only java.lang.ClassCastException;
signals (java.lang.ClassCastException) (* the class of o prohibits it from being compared to this *);
- also
-
public behavior
requires o != null&&o instanceof java.lang.Comparable;
ensures this.definedComparison((java.lang.Comparable)o,this);
ensures o == this ==> \result == 0;
ensures this.sgn(\result ) == -this.sgn(((java.lang.Comparable)o).compareTo(this));
signals (java.lang.ClassCastException) !this.definedComparison((java.lang.Comparable)o,this);
JML is Copyright (C) 1998-2002 by Iowa State University and is distributed under the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This release depends on code from the MultiJava project and is based in part on the Kopi project Copyright (C) 1990-99 DMS Decision Management Systems Ges.m.b.H.