org.jmlspecs.models
Class JMLString
java.lang.Object
org.jmlspecs.models.JMLString
- All Implemented Interfaces:
- Cloneable, Comparable, JMLComparable, JMLType, Serializable
- public class JMLString
- extends Object
- implements JMLComparable
A reflection of String
that implements JMLType
.
- Version:
- $Revision: 1.24 $
- Author:
- Gary T. Leavens
- See Also:
String
,
JMLType
Class Specifications |
public invariant this.theString != null;
protected invariant this.str_ != null;
public invariant this.owner == null;
protected represents theString <- this.str_; |
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))); |
Constructor Summary |
JMLString()
Initialize the contents of this object to be the empty string. |
JMLString(non_null String s)
Initialize the contents of this object to be the given string. |
theString
public String theString
- The contents of this object.
- Specifications:
datagroup contains: str_
str_
protected String str_
- Specifications:
is in groups: theString
EMPTY
public static final JMLString EMPTY
- The empty JMLString.
- See Also:
JMLString()
JMLString
public JMLString()
- Initialize the contents of this object to be the empty string.
- See Also:
EMPTY
- Specifications: (class)pure
-
public normal_behavior
assignable theString, owner;
ensures this.theString.equals("");
JMLString
public JMLString(non_null String s)
throws IllegalArgumentException
- Initialize the contents of this object to be the given string.
- Throws:
IllegalArgumentException
- Specifications: (class)pure
-
public normal_behavior
requires s != null;
assignable theString, owner;
ensures this.theString.equals(s);
clone
public Object clone()
- Return a clone of this string.
- Specified by:
clone
in interface JMLType
- Overrides:
clone
in class Object
- Specifications: (class)pure
- also
-
public normal_behavior
ensures \result == this;
- Specifications inherited from overridden method in class Object:
non_null -
protected normal_behavior
requires this instanceof java.lang.Cloneable;
assignable \nothing;
ensures \result != null;
ensures \typeof(\result ) == \typeof(this);
ensures (* \result is a clone of this *);
- also
-
protected normal_behavior
requires this.getClass().isArray();
assignable \nothing;
ensures \elemtype(\typeof(\result )) == \elemtype(\typeof(this));
ensures ((java.lang.Object[])\result ).length == ((java.lang.Object[])this).length;
ensures ( \forall int i; 0 <= i&&i < ((java.lang.Object[])this).length; ((java.lang.Object[])\result )[i] == ((java.lang.Object[])this)[i]);
- also
-
requires this.getClass().isArray();
assignable \nothing;
ensures \elemtype(\typeof(\result )) == \elemtype(\typeof(this));
ensures java.lang.reflect.Array.getLength(\result ) == java.lang.reflect.Array.getLength(this);
ensures ( \forall int i; 0 <= i&&i < java.lang.reflect.Array.getLength(this); ( \exists java.lang.Object result_i; result_i == java.lang.reflect.Array.get(\result ,i); (result_i == null&&java.lang.reflect.Array.get(this,i) == null)||(result_i != null&&result_i.equals(java.lang.reflect.Array.get(this,i)))));
- also
-
protected exceptional_behavior
requires !(this instanceof java.lang.Cloneable);
assignable \nothing;
signals_only java.lang.CloneNotSupportedException;
- also
-
protected normal_behavior
requires \elemtype(\typeof(this)) <: \type(java.lang.Object);
assignable \nothing;
ensures \elemtype(\typeof(\result )) == \elemtype(\typeof(this));
ensures ((java.lang.Object[])\result ).length == ((java.lang.Object[])this).length;
ensures ( \forall int i; 0 <= i&&i < ((java.lang.Object[])this).length; ((java.lang.Object[])\result )[i] == ((java.lang.Object[])this)[i]);
- also
-
protected normal_behavior
requires \elemtype(\typeof(this)) == \type(int);
assignable \nothing;
ensures \elemtype(\typeof(\result )) == \elemtype(\typeof(this));
ensures ((int[])\result ).length == ((int[])this).length;
ensures ( \forall int i; 0 <= i&&i < ((int[])this).length; ((int[])\result )[i] == ((int[])this)[i]);
- also
-
protected normal_behavior
requires \elemtype(\typeof(this)) == \type(byte);
assignable \nothing;
ensures \elemtype(\typeof(\result )) == \elemtype(\typeof(this));
ensures ((byte[])\result ).length == ((byte[])this).length;
ensures ( \forall int i; 0 <= i&&i < ((byte[])this).length; ((byte[])\result )[i] == ((byte[])this)[i]);
- also
-
protected normal_behavior
requires \elemtype(\typeof(this)) == \type(char);
assignable \nothing;
ensures \elemtype(\typeof(\result )) == \elemtype(\typeof(this));
ensures ((char[])\result ).length == ((char[])this).length;
ensures ( \forall int i; 0 <= i&&i < ((char[])this).length; ((char[])\result )[i] == ((char[])this)[i]);
- also
-
protected normal_behavior
requires \elemtype(\typeof(this)) == \type(long);
assignable \nothing;
ensures \elemtype(\typeof(\result )) == \elemtype(\typeof(this));
ensures ((long[])\result ).length == ((long[])this).length;
ensures ( \forall int i; 0 <= i&&i < ((long[])this).length; ((long[])\result )[i] == ((long[])this)[i]);
- also
-
protected normal_behavior
requires \elemtype(\typeof(this)) == \type(short);
assignable \nothing;
ensures \elemtype(\typeof(\result )) == \elemtype(\typeof(this));
ensures ((short[])\result ).length == ((short[])this).length;
ensures ( \forall int i; 0 <= i&&i < ((short[])this).length; ((short[])\result )[i] == ((short[])this)[i]);
- also
-
protected normal_behavior
requires \elemtype(\typeof(this)) == \type(boolean);
assignable \nothing;
ensures \elemtype(\typeof(\result )) == \elemtype(\typeof(this));
ensures ((boolean[])\result ).length == ((boolean[])this).length;
ensures ( \forall int i; 0 <= i&&i < ((boolean[])this).length; ((boolean[])\result )[i] == ((boolean[])this)[i]);
- also
-
protected normal_behavior
requires \elemtype(\typeof(this)) == \type(float);
assignable \nothing;
ensures \elemtype(\typeof(\result )) == \elemtype(\typeof(this));
ensures ((float[])\result ).length == ((float[])this).length;
ensures ( \forall int i; 0 <= i&&i < ((float[])this).length; (java.lang.Float.isNaN(((float[])\result )[i])&&java.lang.Float.isNaN(((float[])this)[i]))||((float[])\result )[i] == ((float[])this)[i]);
- also
-
protected normal_behavior
requires \elemtype(\typeof(this)) == \type(double);
assignable \nothing;
ensures \elemtype(\typeof(\result )) == \elemtype(\typeof(this));
ensures ((double[])\result ).length == ((double[])this).length;
ensures ( \forall int i; 0 <= i&&i < ((double[])this).length; (java.lang.Double.isNaN(((double[])\result )[i])&&java.lang.Double.isNaN(((double[])this)[i]))||((double[])\result )[i] == ((double[])this)[i]);
- Specifications inherited from overridden method in interface JMLType:
pure- also
-
public normal_behavior
ensures \result != null;
ensures \result instanceof org.jmlspecs.models.JMLType;
ensures ((org.jmlspecs.models.JMLType)\result ).equals(this);
- implies_that
-
ensures \result != null&&\typeof(\result ) <: \type(org.jmlspecs.models.JMLType);
compareTo
public int compareTo(non_null Object op2)
throws ClassCastException,
NullPointerException
- Compare this to op2, returning a comparison code.
- Specified by:
compareTo
in interface JMLComparable
- Parameters:
op2
- the object this is compared to.
- Throws:
ClassCastException
- when o is not a JMLString.
NullPointerException
- when o is null.- See Also:
equals(Object)
,
compareTo(JMLString)
- Specifications: (class)pure
- also
-
public normal_behavior
requires op2 instanceof org.jmlspecs.models.JMLString;
ensures \result == this.theString.compareTo(((org.jmlspecs.models.JMLString)op2).theString);
- also
-
public exceptional_behavior
requires op2 == null;
requires_redundantly !(op2 instanceof org.jmlspecs.models.JMLString);
signals_only java.lang.NullPointerException;
- also
-
public exceptional_behavior
requires op2 != null&&!(op2 instanceof org.jmlspecs.models.JMLString);
signals_only java.lang.ClassCastException;
- Specifications inherited from overridden method compareTo(Object o) in interface JMLComparable:
(class)pure- also
-
public behavior
requires o != null;
ensures (* o is an instance of a comparable class *);
ensures (* if this is equal to o, then \result is 0 *)&&(* if this is less than o, then \result is negative *)&&(* if this is greater than o, then \result is positive *);
signals_only java.lang.ClassCastException;
signals (java.lang.ClassCastException) (* o is not an instance of a comparable class *);
- 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 JMLString another)
- Compares this to another.
- See Also:
equals(Object)
,
compareTo(Object)
- Specifications: (class)pure
-
public normal_behavior
requires another != null;
ensures \result == this.theString.compareTo(another.theString);
- Specifications inherited from overridden method compareTo(Object o) in interface JMLComparable:
(class)pure- also
-
public behavior
requires o != null;
ensures (* o is an instance of a comparable class *);
ensures (* if this is equal to o, then \result is 0 *)&&(* if this is less than o, then \result is negative *)&&(* if this is greater than o, then \result is positive *);
signals_only java.lang.ClassCastException;
signals (java.lang.ClassCastException) (* o is not an instance of a comparable class *);
- 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);
equals
public boolean equals(nullable Object s)
- Tell if these two strings are equal.
- Specified by:
equals
in interface JMLType
- Overrides:
equals
in class Object
- See Also:
equalsIgnoreCase(String)
,
equalsIgnoreCase(JMLString)
,
compareTo(Object)
,
compareTo(JMLString)
- Specifications: (class)pure
- also
-
public normal_behavior
{|-
requires s != null&&s instanceof org.jmlspecs.models.JMLString;
ensures \result == ((org.jmlspecs.models.JMLString)s).theString.equals(this.theString);
- also
-
requires s == null||!(s instanceof org.jmlspecs.models.JMLString);
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 ;
- Specifications inherited from overridden method equals(Object ob2) in interface JMLType:
pure- also
-
public normal_behavior
ensures \result ==> ob2 != null&&(* ob2 is not distinguishable from this, except by using mutation or == *);
- implies_that
-
public normal_behavior
{|-
requires ob2 != null&&ob2 instanceof org.jmlspecs.models.JMLType;
ensures ((org.jmlspecs.models.JMLType)ob2).equals(this) == \result ;
- also
-
requires ob2 == this;
ensures \result <==> true;
- |}
equalsIgnoreCase
public boolean equalsIgnoreCase(non_null JMLString another)
- Are these strings equal, except for case?
- See Also:
equals(java.lang.Object)
,
equalsIgnoreCase(String)
,
compareTo(Object)
,
compareTo(JMLString)
- Specifications: (class)pure
-
public normal_behavior
requires another != null;
ensures \result == this.theString.equalsIgnoreCase(another.theString);
equalsIgnoreCase
public boolean equalsIgnoreCase(non_null String another)
- Are these strings equal, except for case?
- See Also:
equals(java.lang.Object)
,
equalsIgnoreCase(JMLString)
,
compareTo(Object)
,
compareTo(JMLString)
- Specifications: (class)pure
-
public normal_behavior
requires another != null;
ensures \result == this.theString.equalsIgnoreCase(another);
hashCode
public int hashCode()
- Return a hash code for this object.
- Specified by:
hashCode
in interface JMLType
- Overrides:
hashCode
in class Object
- Specifications: (class)pure
- 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;
- Specifications inherited from overridden method in interface JMLType:
pure
toString
public String toString()
- Return theString.
- Overrides:
toString
in class Object
- Specifications: (class)pure
- also
-
public normal_behavior
ensures \result .equals(this.theString);
- 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;
concat
public JMLString concat(JMLString s)
- Produce a new JMLString that is the concatentation of two JMLStrings.
- Specifications: (class)pure
concat
public JMLString concat(String s)
- Produce a new JMLString that is the concatentation of the JMLString
and a String.
- Specifications: (class)pure
concat
public JMLString concat(char c)
- Produce a new JMLString that is the concatentation of the JMLString
and a char.
- Specifications: (class)pure
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.