JML

org.multijava.util.compiler
Class TokenReference

java.lang.Object
  extended byorg.multijava.util.compiler.TokenReference

public class TokenReference
extends Object

This class defines objets that hold a reference to a file and a position in the file.


Field Summary
private  String cachedName
          The name of the file referred to by this token, calculated lazily.
private  int column
           
private static int DEF_COLUMN
          The default column number when none is specified
private  File file
           
private static TokenReference last
           
private  int line
           
static TokenReference NO_REF
           
static String UNKNOWN
           
 
Constructor Summary
private TokenReference(File file, int line)
          Construct a file and line reference
private TokenReference(File file, int line, int column)
          Construct a file, line, and column reference
 
Method Summary
static TokenReference build(File file, int line)
          Construct a file and line reference
static TokenReference build(File file, int line, int column)
          Construct a file, line, and column reference.
 int column()
          Returns the column number of reference
 File file()
          Returns the file to which this token reference refers.
 int line()
          Returns the line number of reference
 String name()
          Returns the short file name of this reference (without any path name).
private  String relativeFilePath()
           
 String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

UNKNOWN

public static final String UNKNOWN

DEF_COLUMN

private static final int DEF_COLUMN
The default column number when none is specified


NO_REF

public static TokenReference NO_REF

last

private static TokenReference last

file

private final File file

line

private final int line

column

private final int column

cachedName

private String cachedName
The name of the file referred to by this token, calculated lazily. The value is interned.

 private invariant (* cachedName != null ==> name() == cachedName *);
 

See Also:
String.intern()
Constructor Detail

TokenReference

private TokenReference(File file,
                       int line)
Construct a file and line reference

Parameters:
file - the file
line - the line number

TokenReference

private TokenReference(File file,
                       int line,
                       int column)
Construct a file, line, and column reference

Parameters:
file - the file
line - the line number
Method Detail

build

public static TokenReference build(File file,
                                   int line)
Construct a file and line reference

Parameters:
file - the file
line - the line number WARNING: DOES NOT LIKE MULTITHREADING

build

public static TokenReference build(File file,
                                   int line,
                                   int column)
Construct a file, line, and column reference.

Parameters:
file - the file
line - the line number
column - the column number WARNING: DOES NOT LIKE MULTITHREADING

file

public final File file()
Returns the file to which this token reference refers.


name

public final String name()
Returns the short file name of this reference (without any path name). Result is cached for efficient access.

 assignable cachedName;
 ensures file() != null ==> \result.equals(file().getName());
 ensures file() == null ==> \result == UNKNOWN;
 


line

public final int line()
Returns the line number of reference


column

public final int column()
Returns the column number of reference


toString

public String toString()
Overrides:
toString in class Object

relativeFilePath

private String relativeFilePath()

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.