edu.rice.cs.drjava.model
Class DefaultLightWeightParsingControl

java.lang.Object
  extended by edu.rice.cs.drjava.model.DefaultLightWeightParsingControl
All Implemented Interfaces:
LightWeightParsingControl

public final class DefaultLightWeightParsingControl
extends java.lang.Object
implements LightWeightParsingControl

Default light-weight parsing control. This class is declared final because it cannot be robustly subclassed because the constructor starts a thread.

Version:
$Id: DefaultLightWeightParsingControl.java 5236 2010-04-27 01:43:36Z mgricken $

Field Summary
private  long _beginUpdates
          The time at which updates may be performed.
private  java.util.HashMap<OpenDefinitionsDocument,java.lang.String> _enclosingClassNames
          Enclosing class names for the documents.
private  long _lastDelay
          The time at which the last delay operation was performed.
private  java.util.HashMap<OpenDefinitionsDocument,java.lang.Long> _lastUpdates
          Last updates for the documents.
private  java.util.LinkedList<LightWeightParsingListener> _listeners
          List of listeners.
private static Log _log
          Log file.
private  AbstractGlobalModel _model
          The model.
private  java.lang.Object _restart
          Monitor to restart automatic updates.
private  boolean _running
          Flag to stop automatic updates.
private  java.lang.Thread _updater
          Thread to perform automatic updates.
private  java.lang.ThreadGroup _updaterThreadGroup
          Thread group for the updater.
 
Constructor Summary
DefaultLightWeightParsingControl(AbstractGlobalModel model)
          Create the default light-weight parsing control.
 
Method Summary
 void addListener(LightWeightParsingListener l)
          Add the listener to this controller.
 void delay()
          Delay the next update.
 java.lang.String getEnclosingClassName(OpenDefinitionsDocument doc)
          Return the last enclosing class name for the specified document, "" if not inside a class, or null if unknown.
 java.util.List<LightWeightParsingListener> getListeners()
           
 void removeAllListeners()
          Remove all listeners from this controller.
 void removeListener(LightWeightParsingListener l)
          Remove the listener from this controller.
 void reset()
          Reset light-weight parsing.
 void setAutomaticUpdates(boolean b)
          Start or stop automatic updates.
 void update(OpenDefinitionsDocument doc)
          Perform light-weight parsing.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

_model

private AbstractGlobalModel _model
The model.


_beginUpdates

private long _beginUpdates
The time at which updates may be performed.


_lastDelay

private long _lastDelay
The time at which the last delay operation was performed.


_lastUpdates

private java.util.HashMap<OpenDefinitionsDocument,java.lang.Long> _lastUpdates
Last updates for the documents.


_enclosingClassNames

private java.util.HashMap<OpenDefinitionsDocument,java.lang.String> _enclosingClassNames
Enclosing class names for the documents.


_running

private volatile boolean _running
Flag to stop automatic updates.


_restart

private java.lang.Object _restart
Monitor to restart automatic updates.


_listeners

private java.util.LinkedList<LightWeightParsingListener> _listeners
List of listeners.


_log

private static final Log _log
Log file.


_updaterThreadGroup

private java.lang.ThreadGroup _updaterThreadGroup
Thread group for the updater.


_updater

private java.lang.Thread _updater
Thread to perform automatic updates.

Constructor Detail

DefaultLightWeightParsingControl

public DefaultLightWeightParsingControl(AbstractGlobalModel model)
Create the default light-weight parsing control. Starts a new thread.

Parameters:
model - the model
Method Detail

update

public void update(OpenDefinitionsDocument doc)
Perform light-weight parsing.

Specified by:
update in interface LightWeightParsingControl
Parameters:
doc - the document to parse.

setAutomaticUpdates

public void setAutomaticUpdates(boolean b)
Start or stop automatic updates.

Specified by:
setAutomaticUpdates in interface LightWeightParsingControl
Parameters:
b - true to start or false to stop automatic updates

delay

public void delay()
Delay the next update.

Specified by:
delay in interface LightWeightParsingControl

reset

public void reset()
Reset light-weight parsing. Forget everything.

Specified by:
reset in interface LightWeightParsingControl

getEnclosingClassName

public java.lang.String getEnclosingClassName(OpenDefinitionsDocument doc)
Return the last enclosing class name for the specified document, "" if not inside a class, or null if unknown. WARNING: In long source files and when contained in anonymous inner classes, this function might take a LONG time.

Specified by:
getEnclosingClassName in interface LightWeightParsingControl
Parameters:
doc - the document for which we want the information
Returns:
the enclosing class name

addListener

public void addListener(LightWeightParsingListener l)
Add the listener to this controller.

Specified by:
addListener in interface LightWeightParsingControl
Parameters:
l - listener to add

removeListener

public void removeListener(LightWeightParsingListener l)
Remove the listener from this controller.

Specified by:
removeListener in interface LightWeightParsingControl

removeAllListeners

public void removeAllListeners()
Remove all listeners from this controller.

Specified by:
removeAllListeners in interface LightWeightParsingControl

getListeners

public java.util.List<LightWeightParsingListener> getListeners()
Specified by:
getListeners in interface LightWeightParsingControl
Returns:
a copy of the list of listeners.