Overview | Package | Class | Use | Tree | Deprecated | Index | Help
| 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
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## javafe.reader
Class CachedReader

    java.lang.Object
      javafe.reader.Reader
          javafe.reader.CachedReader

Direct Known Subclasses:
  RefinementCachedReader

public class CachedReader
extends Reader

CachedReader takes a uncached Reader and produces a cached version of it using a simple implementation of caching via a HashTable.

Reads from GenericFiles with null canonicalIDs are not cached.

Field Summary
`protected java.util.Hashtable` | `cache` Our cache; maps the non-null canonicalID (if it has one) of a GenericFile (see GenericFile.getCanonicalID) to either a CompilationUnit or a CachedReader_Null.
`protected Reader` | `underlyingReader` The underlying Reader whose results we are caching.

Constructor Summary
`CachedReader(Reader reader)` Creating a cached version of a Reader:

Method Summary
`void` | `flushAll()` Flush all cached information for this Reader.
`void` | `flushTarget(GenericFile target)` Flush the saved info (if any) for target for this Reader.
`protected java.lang.Object` | `get(GenericFile target)` Lookup a non-null GenericFile in the cache.
`boolean` | `isCached(GenericFile target)` Is the result of read on target cached for this Reader?
`protected void` | `put(GenericFile target, CompilationUnit value)` Store information about a non-null GenericFile in the cache; this has no effect if the GenericFile has a null canonicalID.
`CompilationUnit` | `read(GenericFile target, boolean avoidSpec)` Attempt to read and parse a CompilationUnit from target.

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Field Detail

### underlyingReader

    protected Reader underlyingReader

  The underlying Reader whose results we are caching.

### cache

    protected java.util.Hashtable cache

  Our cache; maps the non-null canonicalID (if it has one) of a GenericFile (see GenericFile.getCanonicalID) to either a CompilationUnit or a CachedReader_Null.

Constructor Detail

### CachedReader

    public CachedReader(Reader reader)

  Creating a cached version of a Reader:

Method Detail

### get

    protected final java.lang.Object get(GenericFile target)

  Lookup a non-null GenericFile in the cache.

### put

    protected final void put(GenericFile target,
                             CompilationUnit value)

  Store information about a non-null GenericFile in the cache; this has no effect if the GenericFile has a null canonicalID.

### isCached

    public boolean isCached(GenericFile target)

  Is the result of read on target cached for this Reader?

  Target must be non-null.

### flushTarget

    public void flushTarget(GenericFile target)

  Flush the saved info (if any) for target for this Reader. Target must be non-null.

### flushAll

    public void flushAll()

  Flush all cached information for this Reader.

### read

    public CompilationUnit read(GenericFile target,
                                boolean avoidSpec)

  Attempt to read and parse a CompilationUnit from 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 attempt to return a non-spec, although this may not always be possible.

  The results of this function (including null results, but not the action of reporting error messages) are cached. Only the value of avoidSpec used the first time a given file is read is used. 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

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
| 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
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

The ESC/Java2 Project Homepage