JML

java.lang
Class Long

java.lang.Object
  extended byjava.lang.Number
      extended byjava.lang.Long
All Implemented Interfaces:
Comparable, Serializable

public final class Long
extends Number
implements Comparable

JML's specification of java.lang.Long.

Version:
$Revision: 1.22 $
Author:
Brandon Shilling, Gary T. Leavens

Class Specifications

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)));

Model Field Summary
 long theLong
           
 
Model fields inherited from class java.lang.Object
_getClass, objectState, theString
 
Ghost Field Summary
 
Ghost fields inherited from class java.lang.Object
objectTimesFinalized, owner
 
Field Summary
static long MAX_VALUE
           
static long MIN_VALUE
           
static Class TYPE
           
 
Constructor Summary
Long(String s)
           
Long(long value)
           
 
Model Method Summary
static boolean decodeable(String nm)
           
static boolean parseable(String s)
           
static boolean parseable(String s, int r)
           
 
Model methods inherited from class java.lang.Object
hashValue
 
Model methods inherited from interface java.lang.Comparable
definedComparison, sgn
 
Method Summary
 byte byteValue()
           
 int compareTo(non_null Long anotherLong)
           
 int compareTo(non_null Object o)
           
static Long decode(non_null String nm)
           
 double doubleValue()
           
 boolean equals(nullable Object obj)
           
 float floatValue()
           
static Long getLong(String nm)
           
static Long getLong(String nm, Long val)
           
static Long getLong(String nm, long val)
           
 int hashCode()
           
 int intValue()
           
 long longValue()
           
static long parseLong(String s)
           
static long parseLong(String s, int radix)
           
 short shortValue()
           
static String toBinaryString(long i)
           
static String toHexString(long i)
           
static String toOctalString(long i)
           
 String toString()
           
static String toString(long i)
           
static String toString(long i, int radix)
           
static Long valueOf(String s)
           
static Long valueOf(String s, int radix)
           
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Model Field Detail

theLong

public long theLong
Field Detail

MIN_VALUE

public static final long MIN_VALUE

MAX_VALUE

public static final long MAX_VALUE

TYPE

public static final Class TYPE
Specifications: non_null
Constructor Detail

Long

public Long(long value)
Specifications: (class)pure
public normal_behavior
assignable theLong;
ensures this.theLong == value;

Long

public Long(String s)
     throws NumberFormatException
Throws:
NumberFormatException
Specifications: (class)pure
public normal_behavior
requires parseable(s);
assignable theLong;
ensures this.theLong == parseLong(s);
     also
public exceptional_behavior
requires !parseable(s);
signals (java.lang.NumberFormatException) true;
Model Method Detail

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.length() > 0;
{|
requires (nm.length() >= 2&&nm.charAt(0) == 79&&nm.charAt(1) == 120);
ensures \result == parseable(nm.substring(2),16);
also
requires (nm.length() >= 3&&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.length() >= 2&&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.length() >= 2&&nm.charAt(0) == 45&&nm.charAt(1) == 79);
ensures \result == parseable(nm.substring(2),8);
also
requires !((nm.length() >= 2&&nm.charAt(0) == 79&&nm.charAt(1) == 120)||(nm.length() >= 3&&nm.charAt(0) == 45&&nm.charAt(1) == 79&&nm.charAt(2) == 120)||(nm.charAt(0) == 35)||(nm.length() >= 2&&nm.charAt(0) == 45&&nm.charAt(1) == 35)||(nm.charAt(0) == 79)||(nm.length() >= 2&&nm.charAt(0) == 45&&nm.charAt(1) == 79));
ensures \result == parseable(nm);
|}
Method Detail

toString

public static String toString(long i,
                              int radix)
Specifications: pure non_null
public normal_behavior
{|
requires (2 <= radix&&radix <= 36);
{|
requires i < 0;
ensures \result != null&&\result .length() >= 2&&\result .charAt(0) == 45&&\result .charAt(1) != 48&&i == parseLong(\result ,radix);
also
requires i > 0;
ensures \result != null&&\result .length() >= 1&&\result .charAt(0) != 48&&i == parseLong(\result ,radix);
also
requires i == 0;
ensures \result != null&&\result .length() >= 1&&\result .charAt(0) == 48&&\result .length() == 1;
|}
also
requires (2 > radix&&radix > 36);
{|
requires i < 0;
ensures \result != null&&\result .length() >= 2&&\result .charAt(0) == 45&&\result .charAt(1) != 48&&i == parseLong(\result ,10);
also
requires i > 0;
ensures \result != null&&\result .length() >= 1&&\result .charAt(0) != 48&&i == parseLong(\result ,10);
also
requires i == 0;
ensures \result != null&&\result .length() == 1&&\result .charAt(0) == 48;
|}
|}
    implies_that
public normal_behavior
ensures (* \result is a string representation of i in specified radix or default radix *);
    for_example
public normal_example
requires i == -34;
ensures \result != null&&\result .equals("-34");

toHexString

public static String toHexString(long i)
Specifications: pure non_null
public normal_behavior
{|
old long mask_i = (long)(i+2);
requires i < 0;
ensures \result != null&&\result .length() >= 1&&\result .charAt(1) != 48&&i == parseLong(\result ,16);
ensures_redundantly \result .substring(1,\result .length()).equals(toHexString(mask_i));
also
requires i == 0;
ensures \result != null&&\result .length() == 1&&\result .charAt(0) == 48;
also
requires i > 0;
ensures \result != null&&\result .length() >= 1&&\result .charAt(0) != 48&&i == parseLong(\result ,16);
|}
    implies_that
public normal_behavior
ensures (* \result is a string representation of i in hexidecimal *);

toOctalString

public static String toOctalString(long i)
Specifications: pure non_null
public normal_behavior
{|
old long mask_i = (long)(i+2);
requires i < 0;
ensures \result != null&&\result .length() >= 1&&\result .charAt(1) != 48&&i == parseLong(\result ,8);
ensures_redundantly \result .substring(1,\result .length()).equals(toOctalString(mask_i));
also
requires i == 0;
ensures \result != null&&\result .length() >= 1&&\result .charAt(0) == 48&&\result .length() == 1;
also
requires i > 0;
ensures \result != null&&\result .length() >= 1&&\result .charAt(0) != 48&&i == parseLong(\result ,8);
|}
    implies_that
public normal_behavior
ensures (* \result is a string representation of i in octal *);

toBinaryString

public static String toBinaryString(long i)
Specifications: pure non_null
public normal_behavior
{|
old long mask_i = (long)(i+2);
requires i < 0;
ensures \result != null&&\result .length() >= 1&&\result .charAt(1) != 48&&i == parseLong(\result ,2);
ensures_redundantly \result .substring(1,\result .length()).equals(toBinaryString(mask_i));
also
requires i == 0;
ensures \result != null&&\result .length() == 1&&\result .charAt(0) == 48;
also
requires i > 0;
ensures \result != null&&\result .length() >= 1&&\result .charAt(0) != 48&&i == parseLong(\result ,2);
|}
    implies_that
public normal_behavior
ensures (* \result is a string representation of i in binary *);

toString

public static String toString(long i)
Specifications: pure non_null
public normal_behavior
ensures \result .equals(toString(i,10));

parseLong

public static long parseLong(String s,
                             int radix)
                      throws NumberFormatException
Throws:
NumberFormatException
Specifications: pure
public normal_behavior
requires parseable(s,radix);
ensures (* \result is the long of the string representation in the specified radix *);
     also
public exceptional_behavior
requires !parseable(s,radix);
signals_only java.lang.NumberFormatException;
    for_example
public normal_example
requires s.equals("342")&&radix == 37;
ensures \result == 342;

parseLong

public static long parseLong(String s)
                      throws NumberFormatException
Throws:
NumberFormatException
Specifications: pure
public normal_behavior
requires parseable(s);
ensures \result == parseLong(s,10);
     also
public exceptional_behavior
requires !parseable(s);
signals_only java.lang.NumberFormatException;

valueOf

public static Long valueOf(String s,
                           int radix)
                    throws NumberFormatException
Throws:
NumberFormatException
Specifications: pure non_null
public normal_behavior
requires parseable(s,radix);
ensures \fresh(\result );
     also
public exceptional_behavior
requires !parseable(s,radix);
signals_only java.lang.NumberFormatException;

valueOf

public static Long valueOf(String s)
                    throws NumberFormatException
Throws:
NumberFormatException
Specifications: pure non_null
public normal_behavior
requires parseable(s);
ensures \fresh(\result );
     also
public exceptional_behavior
requires !parseable(s);
signals_only java.lang.NumberFormatException;

decode

public static Long decode(non_null String nm)
                   throws NumberFormatException
Throws:
NumberFormatException
Specifications: pure non_null
public normal_behavior
requires decodeable(nm);
ensures (* \result is a Long 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.theLong;
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 == (short)this.theLong;
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 == (int)this.theLong;
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.theLong;
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.theLong;
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.theLong;
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 == (int)(this.longValue()^(this.longValue() >>> 32))&&(* \result is a hash code for theLong *);
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.Long);
ensures \result == (this.theLong == ((java.lang.Long)obj).longValue());
     also
public normal_behavior
requires obj == null||!(obj instanceof java.lang.Long);
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 ;

getLong

public static Long getLong(String nm)
Specifications: pure non_null
public normal_behavior
ensures \result .equals(getLong(nm,null));

getLong

public static Long getLong(String nm,
                           long val)
Specifications: pure non_null
public normal_behavior
ensures \result .equals(getLong(nm,new java.lang.Long(val)));

getLong

public static Long getLong(String nm,
                           Long val)
Specifications: pure non_null
public normal_behavior
requires nm != null&&!nm.equals("")&&java.lang.System.getProperty(nm) != null&&decodeable(java.lang.System.getProperty(nm));
ensures \result .equals(decode(java.lang.System.getProperty(nm)));
     also
public normal_behavior
requires nm == null||nm.equals("")||java.lang.System.getProperty(nm) == null||!decodeable(java.lang.System.getProperty(nm));
ensures \result .equals(val);
    implies_that
ensures val != null ==> \result != null;

compareTo

public int compareTo(non_null Long anotherLong)
Specifications: (class)pure
public normal_behavior
requires anotherLong != null;
{|
requires this.theLong == anotherLong.longValue();
ensures \result == 0;
also
requires this.theLong < anotherLong.longValue();
ensures \result < 0;
also
requires this.theLong > anotherLong.longValue();
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)
Specified by:
compareTo in interface Comparable
Specifications: (class)pure
     also
public normal_behavior
requires o != null&&(o instanceof java.lang.Long);
ensures \result == this.compareTo((java.lang.Long)o);
     also
public exceptional_behavior
requires o == null&&!(o instanceof java.lang.Long);
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

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.