org.eclipse.cdt.core.parser
Class CodeReaderCache

java.lang.Object
  extended by org.eclipse.cdt.core.parser.CodeReaderCache
All Implemented Interfaces:
org.eclipse.cdt.core.parser.ICodeReaderCache

public class CodeReaderCache
extends java.lang.Object
implements org.eclipse.cdt.core.parser.ICodeReaderCache

This is the CodeReaderBuffer used to cache CodeReaders for the ICodeReaderFactory when working with saved copies (primarily SavedCodeReaderFactory).

Author:
dsteffle

Field Summary
static java.lang.String CODE_READER_BUFFER
          The string used to identify this CodeReaderCache.
static int DEFAULT_CACHE_SIZE_IN_MB
          The default size of the cache in MB.
static java.lang.String DEFAULT_CACHE_SIZE_IN_MB_STRING
          A String value of the default size of the cache.
 
Constructor Summary
CodeReaderCache(int size)
          Creates a CodeReaderCache and sets the size of the CodeReaderCache in MB.
 
Method Summary
 void flush()
           
 org.eclipse.cdt.core.parser.CodeReader get(java.lang.String key)
          Get a CodeReader from the cache.
 int getCurrentSpace()
          Returns the current size of the cache.
 org.eclipse.cdt.core.parser.CodeReader remove(java.lang.String key)
          Removes the CodeReader from the cache corresponding to the path specified by the key and returns the CodeReader that was removed.
 void setCacheSize(int size)
          Sets the max cache size of this cache in terms of MB.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

CODE_READER_BUFFER

public static final java.lang.String CODE_READER_BUFFER
The string used to identify this CodeReaderCache. Mainly used for preferences.

See Also:
Constant Field Values

DEFAULT_CACHE_SIZE_IN_MB

public static final int DEFAULT_CACHE_SIZE_IN_MB
The default size of the cache in MB.

See Also:
Constant Field Values

DEFAULT_CACHE_SIZE_IN_MB_STRING

public static final java.lang.String DEFAULT_CACHE_SIZE_IN_MB_STRING
A String value of the default size of the cache.

Constructor Detail

CodeReaderCache

public CodeReaderCache(int size)
Creates a CodeReaderCache and sets the size of the CodeReaderCache in MB. Creating a new CodeReaderCache also adds an UpdateCodeReaderCacheListener to the workspace so that when a resource is changed then the CodeReader for that resource is removed from this cache.

Parameters:
size - initial size of the CodeReaderCache in terms of MB
Method Detail

get

public org.eclipse.cdt.core.parser.CodeReader get(java.lang.String key)
Get a CodeReader from the cache. The key is the char[] filename of the CodeReader to retrieve.

Specified by:
get in interface org.eclipse.cdt.core.parser.ICodeReaderCache
Parameters:
key - the path of the CodeReader to retrieve
Returns:

setCacheSize

public void setCacheSize(int size)
Sets the max cache size of this cache in terms of MB.

Parameters:
size -

remove

public org.eclipse.cdt.core.parser.CodeReader remove(java.lang.String key)
Removes the CodeReader from the cache corresponding to the path specified by the key and returns the CodeReader that was removed. If no CodeReader is removed then null is returned.

Specified by:
remove in interface org.eclipse.cdt.core.parser.ICodeReaderCache
Parameters:
key -

getCurrentSpace

public int getCurrentSpace()
Returns the current size of the cache. For the CodeReaderCache this is in MB.

Specified by:
getCurrentSpace in interface org.eclipse.cdt.core.parser.ICodeReaderCache
Returns:

flush

public void flush()
Specified by:
flush in interface org.eclipse.cdt.core.parser.ICodeReaderCache