JML

java.net
Class URI

java.lang.Object
  extended byjava.net.URI
All Implemented Interfaces:
Comparable, Serializable

public final class URI
extends Object
implements Comparable, Serializable

JML's specification of java.net.URI. [[[This specification is incomplete.]]]

Author:
Denise Bacher, Katie Becker, Gary T. Leavens

Class Specifications
public invariant this.isOpaque() ==> this.userInfo == null&&this.host == null&&this.path == null&&this.query_ == null&&this.authority == null&&this.port == -1;
public represents needsBrackets <- ((this.host.indexOf(58) >= 0)&&!this.host.startsWith("[")&&!this.host.endsWith("]")&&(!this.isOpaque())&&(this.host != null));

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
 String authority
           
 String fragment
           
 String host
           
 boolean needsBrackets
           
 String path
           
 int port
           
 String query_
           
 String scheme
           
 String ssp
           
 String userInfo
           
 
Model fields inherited from class java.lang.Object
_getClass, objectState, theString
 
Ghost Field Summary
 
Ghost fields inherited from class java.lang.Object
objectTimesFinalized, owner
 
Constructor Summary
URI(non_null String str)
           
URI(non_null String scheme, non_null String ssp, non_null String fragment)
           
URI(non_null String scheme, non_null String userInfo, non_null String host, int port, non_null String path, non_null String query_, non_null String fragment)
           
URI(non_null String scheme, non_null String host, non_null String path, non_null String fragment)
           
URI(non_null String scheme, non_null String authority, non_null String path, non_null String query_, non_null String fragment)
           
 
Model Method Summary
 String asASCII(non_null String str)
           
 String fromASCII(non_null String str)
           
 String pathNormalize(non_null String path)
           
 
Model methods inherited from class java.lang.Object
hashValue
 
Model methods inherited from interface java.lang.Comparable
definedComparison, sgn
 
Method Summary
 int compareTo(non_null Object ob)
           
static URI create(non_null String str)
           
 boolean equals(nullable Object ob)
           
 String getAuthority()
           
 String getFragment()
           
 String getHost()
           
 String getPath()
           
 int getPort()
           
 String getQuery()
           
 String getRawAuthority()
           
 String getRawFragment()
           
 String getRawPath()
           
 String getRawQuery()
           
 String getRawSchemeSpecificPart()
           
 String getRawUserInfo()
           
 String getScheme()
           
 String getSchemeSpecificPart()
           
 String getUserInfo()
           
 int hashCode()
           
 boolean isAbsolute()
           
 boolean isOpaque()
           
 URI normalize()
           
 URI parseServerAuthority()
           
 URI relativize(non_null URI uri)
           
 URI resolve(non_null String str)
           
 URI resolve(non_null URI uri)
           
 String toASCIIString()
           
 String toString()
           
 URL toURL()
           
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Model Field Detail

scheme

public String scheme
Specifications: non_null

ssp

public String ssp
Specifications: non_null

fragment

public String fragment
Specifications: non_null

userInfo

public String userInfo
Specifications: non_null

host

public String host
Specifications: non_null

path

public String path
Specifications: non_null

query_

public String query_
Specifications: non_null

authority

public String authority
Specifications: non_null

port

public int port

needsBrackets

public boolean needsBrackets
Constructor Detail

URI

public URI(non_null String str)
    throws URISyntaxException
Throws:
URISyntaxException

URI

public URI(non_null String scheme,
           non_null String userInfo,
           non_null String host,
           int port,
           non_null String path,
           non_null String query_,
           non_null String fragment)
    throws URISyntaxException
Throws:
URISyntaxException
Specifications:
public behavior
assignable scheme, userInfo, host, port, path, query_, fragment, ssp, authority;
ensures org.jmlspecs.models.JMLNullSafe.equals(this.scheme,scheme)&&org.jmlspecs.models.JMLNullSafe.equals(this.userInfo,userInfo)&&org.jmlspecs.models.JMLNullSafe.equals(this.host,host)&&this.port == port&&org.jmlspecs.models.JMLNullSafe.equals(this.path,path)&&org.jmlspecs.models.JMLNullSafe.equals(this.query_,query_)&&org.jmlspecs.models.JMLNullSafe.equals(this.fragment,fragment);
ensures this.authority == null&&this.ssp == null;
ensures (scheme == null) ==> host != null&&((host.startsWith("/")||host.equals("")));
signals_only java.net.URISyntaxException;

URI

public URI(non_null String scheme,
           non_null String authority,
           non_null String path,
           non_null String query_,
           non_null String fragment)
    throws URISyntaxException
Throws:
URISyntaxException
Specifications:
public behavior
assignable scheme, userInfo, host, port, path, query_, fragment, ssp, authority;
ensures org.jmlspecs.models.JMLNullSafe.equals(this.scheme,scheme)&&org.jmlspecs.models.JMLNullSafe.equals(this.authority,authority)&&org.jmlspecs.models.JMLNullSafe.equals(this.path,path)&&org.jmlspecs.models.JMLNullSafe.equals(this.query_,query_)&&org.jmlspecs.models.JMLNullSafe.equals(this.fragment,fragment);
ensures this.userInfo == null&&this.host == null&&this.port == -1&&this.ssp == null;
ensures (scheme == null) ==> path != null&&((path.startsWith("/")||path.equals("")));
signals_only java.net.URISyntaxException;

URI

public URI(non_null String scheme,
           non_null String host,
           non_null String path,
           non_null String fragment)
    throws URISyntaxException
Throws:
URISyntaxException
Specifications:
public behavior
assignable scheme, userInfo, host, port, path, query_, fragment, ssp, authority;
ensures org.jmlspecs.models.JMLNullSafe.equals(this.scheme,scheme)&&org.jmlspecs.models.JMLNullSafe.equals(this.host,host)&&org.jmlspecs.models.JMLNullSafe.equals(this.path,path)&&org.jmlspecs.models.JMLNullSafe.equals(this.fragment,fragment);
ensures this.userInfo == null&&this.authority == null&&this.port == -1&&this.query_ == null&&this.ssp == null;
ensures (scheme == null) ==> path != null&&((path.startsWith("/")||path.equals("")));
signals_only java.net.URISyntaxException;

URI

public URI(non_null String scheme,
           non_null String ssp,
           non_null String fragment)
    throws URISyntaxException
Throws:
URISyntaxException
Specifications:
public behavior
assignable scheme, userInfo, host, port, path, query_, fragment, ssp, authority;
ensures org.jmlspecs.models.JMLNullSafe.equals(this.scheme,scheme)&&org.jmlspecs.models.JMLNullSafe.equals(this.ssp,ssp)&&org.jmlspecs.models.JMLNullSafe.equals(this.fragment,fragment);
ensures this.userInfo == null&&this.host == null&&this.port == -1&&this.authority == null&&this.query_ == null&&this.ssp == null;
signals_only java.net.URISyntaxException;
Model Method Detail

pathNormalize

public String pathNormalize(non_null String path)
Specifications: pure non_null

asASCII

public String asASCII(non_null String str)
Specifications: pure non_null

fromASCII

public String fromASCII(non_null String str)
Specifications: pure non_null
Method Detail

create

public static URI create(non_null String str)
Specifications: pure non_null
public behavior
requires str != null;
signals (java.lang.IllegalArgumentException) (* the given string violates RFC 2396 *);
signals_only java.lang.IllegalArgumentException;

parseServerAuthority

public URI parseServerAuthority()
                         throws URISyntaxException
Throws:
URISyntaxException
Specifications: pure non_null
public normal_behavior
requires this.authority == null;
ensures \result .equals(this);
     also
public behavior
requires (this.authority != null);
signals_only java.net.URISyntaxException;

normalize

public URI normalize()
Specifications: non_null
requires this.isOpaque();
ensures \result == this;
     also
requires !this.isOpaque();
ensures \result .path.equals(this.pathNormalize(this.path));

resolve

public URI resolve(non_null URI uri)
Specifications: pure non_null
public normal_behavior
requires uri.isAbsolute()||this.isOpaque();
assignable \nothing;
ensures \result == uri;
     also
public normal_behavior
requires uri.fragment != null&&(uri.path != null||uri.path.equals(""))&&uri.scheme == null&&uri.authority == null&&uri.query_ == null;
requires_redundantly !uri.isAbsolute();
ensures \result .fragment.equals(uri.fragment)&&\result .ssp.equals(this.ssp)&&\result .scheme.equals(this.scheme)&&\result .userInfo.equals(this.userInfo)&&\result .host.equals(this.host)&&\result .path.equals(this.path)&&\result .query_.equals(this.query_)&&\result .port == this.port&&\result .authority.equals(this.authority);
     also
public normal_behavior
requires !(uri.isAbsolute()||this.isOpaque())&&!(uri.fragment != null&&(uri.path != null||uri.path.equals(""))&&uri.scheme == null&&uri.authority == null&&uri.query_ == null);
{|
requires uri.authority != null;
ensures \result .scheme.equals(this.scheme)&&\result .query_.equals(uri.query_)&&\result .fragment.equals(uri.fragment)&&\result .authority.equals(uri.authority)&&\result .path.equals(uri.path);
also
requires uri.authority == null;
{|
ensures \result .scheme.equals(this.scheme)&&\result .query_.equals(uri.query_)&&\result .fragment.equals(uri.fragment)&&\result .authority.equals(this.authority);
also
{|
requires uri.path != null&&uri.path.length() > 0&&uri.path.charAt(0) == 47;
ensures \result .path.equals(uri.path);
also
old java.lang.String thispath = (this.path == null ? "" : this.path);
requires uri.path == null||uri.path.length() == 0||uri.path.charAt(0) != 47;
ensures \result .path.equals(this.pathNormalize((thispath.indexOf(47) != -1 ? "" : this.path.substring(0,this.path.lastIndexOf("/")))+uri.path));
|}
|}
|}
    implies_that
requires this.isAbsolute()||uri.isAbsolute();
ensures \result .isAbsolute();
     also
requires !(this.isAbsolute()||uri.isAbsolute());
ensures !\result .isAbsolute();

resolve

public URI resolve(non_null String str)
Specifications: pure non_null
public behavior
ensures \result == this.resolve(java.net.URI.create(str));

relativize

public URI relativize(non_null URI uri)
Specifications: pure non_null
public normal_behavior
requires (this.isOpaque()||uri.isOpaque())||(!this.scheme.equals(uri.scheme)&&!this.authority.equals(uri.authority))||!uri.path.startsWith(this.path);
ensures \result == uri;
     also
public normal_behavior
requires !(this.isOpaque()&&uri.isOpaque())&&(this.scheme.equals(uri.scheme)||this.authority.equals(uri.authority))&&uri.path.startsWith(this.path);
ensures \result .query_.equals(uri.query_)&&\result .fragment.equals(this.fragment)&&\result .path.equals(uri.path.substring(this.path.length()));

toURL

public URL toURL()
          throws MalformedURLException
Throws:
MalformedURLException
Specifications: pure non_null
public normal_behavior
requires this.isAbsolute();
     also
public behavior
signals_only java.net.MalformedURLException;

getScheme

public String getScheme()
Specifications: pure non_null
public normal_behavior
requires this.scheme == null;
ensures \result == null;
     also
public normal_behavior
requires this.scheme != null;
ensures \result != null&&\result .equals(this.scheme);

isAbsolute

public boolean isAbsolute()
Specifications: pure
public normal_behavior
ensures \result <==> this.scheme != null;

isOpaque

public boolean isOpaque()
Specifications: pure
public normal_behavior
ensures \result <==> this.scheme != null&&!this.ssp.startsWith("/");

getRawSchemeSpecificPart

public String getRawSchemeSpecificPart()
Specifications: pure non_null
public normal_behavior
requires this.ssp != null;
ensures \result != null;

getSchemeSpecificPart

public String getSchemeSpecificPart()
Specifications: pure non_null
public normal_behavior
ensures \result != null;

getRawAuthority

public String getRawAuthority()
Specifications: pure non_null
public normal_behavior
requires this.authority == null;
ensures \result == null;
     also
public normal_behavior
requires this.authority != null;
ensures \result != null;

getAuthority

public String getAuthority()
Specifications: pure non_null
public normal_behavior
requires this.authority == null;
ensures \result == null;
     also
public normal_behavior
requires this.authority != null;
ensures \result != null;

getRawUserInfo

public String getRawUserInfo()
Specifications: pure non_null
public normal_behavior
requires this.userInfo == null;
ensures \result == null;
     also
public normal_behavior
requires this.userInfo != null;
ensures \result != null;

getUserInfo

public String getUserInfo()
Specifications: pure non_null
public normal_behavior
requires this.userInfo == null;
ensures \result == null;
     also
public normal_behavior
requires this.userInfo != null;
ensures \result != null;

getHost

public String getHost()
Specifications: pure non_null
public normal_behavior
requires this.host == null;
ensures \result == null;
     also
public normal_behavior
requires this.host != null;
ensures \result != null&&\result .equals(this.host);

getPort

public int getPort()
Specifications: pure
public normal_behavior
ensures \result == this.port;

getRawPath

public String getRawPath()
Specifications: pure non_null
public normal_behavior
requires this.path == null;
ensures \result == null;
     also
public normal_behavior
requires this.path != null;
ensures \result != null&&\result .equals(this.path);

getPath

public String getPath()
Specifications: pure non_null
public normal_behavior
requires this.path == null;
ensures \result == null;
     also
public normal_behavior
requires this.path != null;
ensures \result != null;

getRawQuery

public String getRawQuery()
Specifications: pure non_null
public normal_behavior
requires this.query_ == null;
ensures \result == null;
     also
public normal_behavior
requires this.query_ != null;
ensures \result != null;

getQuery

public String getQuery()
Specifications: pure non_null
public normal_behavior
requires this.query_ == null;
ensures \result == null;
     also
public normal_behavior
requires this.query_ != null;
ensures \result != null;

getRawFragment

public String getRawFragment()
Specifications: pure non_null
public normal_behavior
requires this.fragment == null;
ensures \result == null;
     also
public normal_behavior
requires this.fragment != null;
ensures \result != null;

getFragment

public String getFragment()
Specifications: pure non_null
public normal_behavior
requires this.fragment == null;
ensures \result == null;
     also
public normal_behavior
requires this.fragment != null;
ensures \result != null;

equals

public boolean equals(nullable Object ob)
Overrides:
equals in class Object
Specifications: pure
     also
public normal_behavior
requires !(ob instanceof java.net.URI);
ensures !\result ;
     also
public normal_behavior
old java.net.URI uri = (java.net.URI)ob;
requires ob instanceof java.net.URI;
{|
requires this.isOpaque();
ensures \result <==> uri.isOpaque()&&this.getRawSchemeSpecificPart().equals(uri.getRawSchemeSpecificPart());
also
requires !this.isOpaque();
ensures \result <==> this.getRawPath().equals(uri.getRawPath())&&(this.getRawQuery().equals(uri.getRawQuery())||(this.getRawQuery() == null&&uri.getRawQuery() == null));
|}
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 ;

hashCode

public int hashCode()
Overrides:
hashCode in class 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;

compareTo

public int compareTo(non_null Object ob)
Specified by:
compareTo in interface Comparable
Specifications: (inherited)pure
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 exceptional_behavior
requires o == null;
signals_only java.lang.NullPointerException;
     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);

toString

public String toString()
Overrides:
toString in class Object
Specifications: pure non_null
     also
old java.lang.String prefix = (this.scheme != null ? this.scheme : "");
old java.lang.String suffix = (this.fragment != null ? "#"+this.fragment : "");
{|
requires this.isOpaque();
ensures \result .equals(prefix+this.ssp+suffix);
also
old java.lang.String pq = (this.path != null ? this.path : "")+(this.query_ != null ? "?"+this.query_ : "");
requires !this.isOpaque();
{|
requires this.host != null;
ensures \result .equals(prefix+"//"+(this.userInfo != null ? this.userInfo+"@" : "")+(this.needsBrackets ? "[" : "")+this.host+(this.needsBrackets ? "]" : "")+(this.port != -1 ? ":"+this.port : "")+pq+suffix);
also
requires this.host == null;
ensures \result .equals(prefix+(this.authority != null ? "//"+this.authority : "")+pq+suffix);
|}
|}
Specifications inherited from overridden method in class Object:
       non_null
public normal_behavior
assignable objectState;
ensures \result != null;
ensures \result == 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;

toASCIIString

public String toASCIIString()
Specifications: pure non_null
public behavior
ensures \result == this.asASCII(this.toString());

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.