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

java.lang.Object
  |
  +--edu.rice.cs.drjava.model.definitions.indent.IndentRuleQuestion
All Implemented Interfaces:
IndentRule
Direct Known Subclasses:
QuestionBraceIsCurly, QuestionBraceIsParenOrBracket, QuestionCurrLineEmpty, QuestionCurrLineStartsWith, QuestionCurrLineStartsWithSkipComments, QuestionExistsCharInStmt, QuestionHasCharPrecedingOpenBrace, QuestionInsideComment, QuestionLineContains, QuestionNewParenPhrase, QuestionPrevLineStartsComment, QuestionPrevLineStartsWith, QuestionStartAfterOpenBrace, QuestionStartingNewStmt

public abstract class IndentRuleQuestion
extends Object
implements IndentRule

A question node in the decision tree for the indentation system. Calls to indentLine on an IndentRuleQuestion will make a decision based on context and call the same method on one of its children. The leaves of the tree are represented by IndentRuleAction objects.

Version:
$Id: IndentRuleQuestion.java,v 1.5 2002/04/02 07:11:37 csreis Exp $

Field Summary
private  IndentRule _noRule
          Node in decision tree to use if the rule does not hold in this context.
private  IndentRule _yesRule
          Node in decision tree to use if the rule holds in this context.
 
Constructor Summary
IndentRuleQuestion(IndentRule yesRule, IndentRule noRule)
          Constructs a new Question indent rule using the two given children.
 
Method Summary
(package private) abstract  boolean applyRule(DefinitionsDocument doc)
          Determines if the given rule holds in this context.
(package private)  boolean applyRule(DefinitionsDocument doc, int pos)
          Determines if the given rule holds in this context.
 void indentLine(DefinitionsDocument doc)
          Determines if the given rule holds in this context and calls the same method on one of its child nodes.
 void indentLine(DefinitionsDocument doc, int pos)
          Properly indents the line that the current position is on.
 
Methods inherited from class java.lang.Object
, clone, equals, finalize, getClass, hashCode, notify, notifyAll, registerNatives, toString, wait, wait, wait
 

Field Detail

_yesRule

private final IndentRule _yesRule
Node in decision tree to use if the rule holds in this context.

_noRule

private final IndentRule _noRule
Node in decision tree to use if the rule does not hold in this context.
Constructor Detail

IndentRuleQuestion

public IndentRuleQuestion(IndentRule yesRule,
                          IndentRule noRule)
Constructs a new Question indent rule using the two given children.
Parameters:
yesRule - Rule to use if this rule holds
noRule - Rule to use if this rule does not hold
Method Detail

applyRule

abstract boolean applyRule(DefinitionsDocument doc)
Determines if the given rule holds in this context.
Parameters:
doc - DefinitionsDocument containing the line to be indented.
Returns:
true if this node's rule holds.

applyRule

boolean applyRule(DefinitionsDocument doc,
                  int pos)
Determines if the given rule holds in this context.
Parameters:
doc - DefinitionsDocument containing the line to be indented.
pos - Position within line to be indented.
Returns:
true if this node's rule holds.

indentLine

public void indentLine(DefinitionsDocument doc)
Determines if the given rule holds in this context and calls the same method on one of its child nodes.
Specified by:
indentLine in interface IndentRule
Parameters:
doc - DefinitionsDocument containing the line to be indented.
reducedModel - reduced model used by the document.

indentLine

public void indentLine(DefinitionsDocument doc,
                       int pos)
Properly indents the line that the current position is on. Replaces all whitespace characters at the beginning of the line with the appropriate spacing or characters.
Parameters:
doc - DefinitionsDocument containing the line to be indented.