edu.rice.cs.drjava.model.definitions.indent
Class IndentRuleWithTrace

java.lang.Object
  extended by edu.rice.cs.drjava.model.definitions.indent.IndentRuleWithTrace
All Implemented Interfaces:
IndentRule
Direct Known Subclasses:
IndentRuleAction, IndentRuleQuestion

public abstract class IndentRuleWithTrace
extends Object
implements IndentRule

This class does almost all the work for keeping an indent tree trace. IndentRuleQuestion also does some of the work, and any subclass may substitute its own version of getRuleName() Note: traceing is disabled by default

Version:
$Id: IndentRuleWithTrace.java 4658 2008-08-26 20:11:39Z rcartwright $

Field Summary
static String NO
           
static String TERMINUS_RULE
           
static String YES
           
 
Constructor Summary
IndentRuleWithTrace()
           
 
Method Summary
protected static void _addToIndentTrace(String ruleName, String direction, boolean terminus)
          This rule just adds to the trace kept in trace
 String getRuleName()
          The rule name to report to _addToIndentTrace
 boolean indentLine(AbstractDJDocument doc, Indenter.IndentReason reason)
          This method does not indent the current line!
 boolean indentLine(AbstractDJDocument doc, int pos, Indenter.IndentReason reason)
          Properly indents the line identified by pos.
static void printLastIndentTrace(PrintStream ps)
           
static void setRuleTraceEnabled(boolean ruleTraceEnabled)
           
 boolean testIndentLine(AbstractDJDocument doc, Indenter.IndentReason reason)
          Convenience method that wraps calls on indentLine in a write lock.
 boolean testIndentLine(AbstractDJDocument doc, int pos, Indenter.IndentReason reason)
          Convenience method that wraps calls on indentLine in a write lock.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

YES

public static final String YES
See Also:
Constant Field Values

NO

public static final String NO
See Also:
Constant Field Values

TERMINUS_RULE

public static final String TERMINUS_RULE
See Also:
Constant Field Values
Constructor Detail

IndentRuleWithTrace

public IndentRuleWithTrace()
Method Detail

printLastIndentTrace

public static void printLastIndentTrace(PrintStream ps)

setRuleTraceEnabled

public static void setRuleTraceEnabled(boolean ruleTraceEnabled)

_addToIndentTrace

protected static void _addToIndentTrace(String ruleName,
                                        String direction,
                                        boolean terminus)
This rule just adds to the trace kept in trace


indentLine

public boolean indentLine(AbstractDJDocument doc,
                          int pos,
                          Indenter.IndentReason reason)
Properly indents the line identified by pos. Replaces all whitespace characters at the beginning of the line with the appropriate spacing or characters.

Parameters:
doc - the AbstractDJDocument containing the line to be indented.
pos - the position identifying the line to be indented
reason - the reason that the indentation is taking place
Returns:
true if the caller should update the current location itself, false if the indenter has already handled it

indentLine

public boolean indentLine(AbstractDJDocument doc,
                          Indenter.IndentReason reason)
This method does not indent the current line!

Specified by:
indentLine in interface IndentRule
Parameters:
doc - AbstractDJDocument containing the line to be indented.
reason - The reason that indentation was initiated, specified in Indenter
Returns:
true if the caller should update the current location itself, false if the indenter has already handled it

testIndentLine

public boolean testIndentLine(AbstractDJDocument doc,
                              int pos,
                              Indenter.IndentReason reason)
Convenience method that wraps calls on indentLine in a write lock. Only used in testing.


testIndentLine

public boolean testIndentLine(AbstractDJDocument doc,
                              Indenter.IndentReason reason)
Convenience method that wraps calls on indentLine in a write lock. Only used in testing.


getRuleName

public String getRuleName()
The rule name to report to _addToIndentTrace