ESC/Java2
© 2003,2004,2005 David Cok and Joseph Kiniry
© 2005 UCD Dublin
© 2003,2004 Radboud University Nijmegen
© 1999,2000 Compaq Computer Corporation
© 1997,1998,1999 Digital Equipment Corporation
All Rights Reserved

javafe.reader
Class TypeReader

java.lang.Object
  extended byjavafe.reader.Reader
      extended byjavafe.reader.TypeReader
Direct Known Subclasses:
StandardTypeReader

public abstract class TypeReader
extends Reader

A TypeReader is an extended Reader that understands how to read in Java reference types given either a fully-qualified name or a source file (in the form of a GenericFile). A TypeReader can also determine cheaply if a Java reference type exists or if a Java package is accessible.

TypeReaders encapsulate how to map from fully-qualified names to the data for the Java reference types.

TypeReaders are responsible for ensuring that all reads from a given source yield the same CompilationUnit, regardless of whether the duplicate reads occur through read() or readType().


Constructor Summary
TypeReader()
           
 
Method Summary
abstract  boolean accessable(java.lang.String[] P)
          Return true iff the package P is "accessible".
abstract  boolean exists(java.lang.String[] P, java.lang.String T)
          Return true iff the fully-qualified outside type P.T exists.
 java.io.FilenameFilter filter()
           
abstract  java.util.ArrayList findFiles(java.lang.String[] P)
          Returns an enumeration of the GenericFile objects in the given package P.
abstract  GenericFile findType(java.lang.String[] P, java.lang.String T)
          Returns a (source or binary) file for the given type.
abstract  CompilationUnit read(GenericFile target, boolean avoidSpec)
          Attempt to read and parse a CompilationUnit from *source file* target.
abstract  CompilationUnit read(java.lang.String[] P, java.lang.String T, boolean avoidSpec)
          Attempt to read and parse a CompilationUnit for the fully-qualified outside type P.T.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

TypeReader

public TypeReader()
Method Detail

accessable

public abstract boolean accessable(java.lang.String[] P)
Return true iff the package P is "accessible".

Warning: the definition of accessible is host system dependent and may in fact be defined as always true.


exists

public abstract boolean exists(java.lang.String[] P,
                               java.lang.String T)
Return true iff the fully-qualified outside type P.T exists.


findType

public abstract GenericFile findType(java.lang.String[] P,
                                     java.lang.String T)
Returns a (source or binary) file for the given type.


read

public abstract CompilationUnit read(GenericFile target,
                                     boolean avoidSpec)
Attempt to read and parse a CompilationUnit from *source file* target. Any errors encountered are reported via javafe.util.ErrorSet. Null is returned iff an error was encountered.

By default, we attempt to read only a spec (e.g., specOnly is set in the resulting CompilationUnit) to save time. If avoidSpec is true, we return a non-spec, except in the case where we have previously read in the same source file with avoidSpec false. (See notes on caching below.)

There are 2 safe ways to ensure source files yield non-spec files: (1) always use avoidSpec, or (2) read all desired non-spec's at the beginning with avoidSpec set. [these instructions apply to both versions of read.]

The result of this function is cached. Note that read(String[], ...) may implicitly call this function, resulting in caching of source files.

Only the value of avoidSpec used the first time a given file is read is used (including implicit calls). This may result in a spec being returned unnecessarily when avoidSpec is true.

Target must be non-null.

Specified by:
read in class Reader
Parameters:
target - The source to be read
avoidSpec - If true, then bodies are parsed as well, if possible; if false, no method bodies are parsed.
Returns:
The resulting compilation unit, or null if an error occurred during parsing

read

public abstract CompilationUnit read(java.lang.String[] P,
                                     java.lang.String T,
                                     boolean avoidSpec)
Attempt to read and parse a CompilationUnit for the fully-qualified outside type P.T. Any errors encountered are reported via javafe.util.ErrorSet. Null is returned if no data for P.T exists or if an error occurs.

By default, we attempt to read only a spec (e.g., specOnly is set in the resulting CompilationUnit) to save time. If avoidSpec is true, a spec is only returned if no source is available or if the source file containing the type was read in earlier with avoidSpec false.

Thus, there are 2 safe ways to ensure source files yield non-spec files: (1) always use avoidSpec, or (2) read all desired non-spec's at the beginning with avoidSpec set.

[these instructions apply to both versions of read.]

This routine is partially cached, in that it uses read(GenericFile,...) (implicitly) to read source files.

If the resulting CompilationUnit is non-null, then it is always complete, having no stubs.

This routine is responsible for such issues as out-of-date binaries.


findFiles

public abstract java.util.ArrayList findFiles(java.lang.String[] P)
Returns an enumeration of the GenericFile objects in the given package P.


filter

public java.io.FilenameFilter filter()

ESC/Java2
© 2003,2004,2005 David Cok and Joseph Kiniry
© 2005 UCD Dublin
© 2003,2004 Radboud University Nijmegen
© 1999,2000 Compaq Computer Corporation
© 1997,1998,1999 Digital Equipment Corporation
All Rights Reserved

The ESC/Java2 Project Homepage