protected static class HopCount.DocumentNode
extends java.lang.Object
Modifier and Type | Field and Description |
---|---|
protected HopCount.Answer |
bestPossibleAnswer
The best (lowest) possible answer value for this node.
|
protected java.util.Map |
childReferences
Child node references.
|
protected int |
databaseAnswerValue
This is the original answer (if any), which is the current value in the database
|
protected java.lang.Long |
databaseRow
The original database row, if any
|
protected boolean |
isComplete
Answer complete flag.
|
protected java.util.Map |
parentsWhoCare
Parent nodes who care (i.e.
|
protected HopCount.Question |
question
The question.
|
protected HopCount.Answer |
startingAnswer
The answer, as calculated up to the level of all the completed children, which will
not include incomplete child references of this node.
|
protected HopCount.Answer |
trialAnswer
The current best answer.
|
protected boolean |
writeNeeded
This flag is meaningful only if the complete flag is set.
|
Constructor and Description |
---|
DocumentNode(HopCount.Question question)
Create a document node.
|
Modifier and Type | Method and Description |
---|---|
void |
addChild(HopCount.NodeReference childRef)
Add a child reference.
|
void |
addParent(HopCount.DocumentNode parent)
Add a parent who should be notified if this node's answer changes.
|
void |
clearChildReferences()
Clear child references.
|
void |
clearWriteNeeded()
Clear the 'write needed' flag, to prevent another write.
|
HopCount.Answer |
getBestPossibleAnswer()
Get best possible answer
|
java.util.Iterator |
getCurrentChildren()
Iterate through current children.
|
java.util.Iterator |
getCurrentParents()
Iterate through all current parents.
|
java.lang.Long |
getDatabaseRow()
Get the database row
|
int |
getDatabaseValue()
Get the database answer value
|
int |
getFinalAnswer()
Get an answer that's final.
|
HopCount.Question |
getQuestion()
Get the question.
|
HopCount.Answer |
getStartingAnswer()
Get the starting (base) answer.
|
HopCount.Answer |
getTrialAnswer()
Get the current best answer.
|
boolean |
hasChildren()
Check if there are children.
|
boolean |
isAnswerComplete()
Check if the answer is complete.
|
boolean |
isAnswerNeeded()
Check if answer is still needed.
|
boolean |
isComplete()
Check if the node is complete, given the question it represents.
|
boolean |
isWriteNeeded()
Check if a write of the answer is needed to the database
|
void |
makeComplete()
Mark the node as being "complete", with a write needed.
|
void |
makeCompleteNoWrite()
Mark the answer as being "complete", and not needing a write.
|
void |
removeChild(HopCount.NodeReference childRef)
Remove a child reference.
|
void |
removeParent(HopCount.DocumentNode parent)
Remove a parent.
|
void |
reset()
Reset back to an "unknown" state.
|
void |
setBestPossibleAnswer(HopCount.Answer answer)
Set best possible answer
|
void |
setSource(java.lang.Long rowID,
int answerValue)
Set the database row and answer value
|
void |
setStartingAnswer(HopCount.Answer answer)
Set the starting (base) answer.
|
void |
setTrialAnswer(HopCount.Answer answer)
Set the answer for this node.
|
protected HopCount.Question question
protected int databaseAnswerValue
protected java.lang.Long databaseRow
protected HopCount.Answer startingAnswer
protected HopCount.Answer trialAnswer
protected HopCount.Answer bestPossibleAnswer
protected boolean isComplete
protected boolean writeNeeded
protected java.util.Map parentsWhoCare
protected java.util.Map childReferences
public DocumentNode(HopCount.Question question)
public HopCount.Question getQuestion()
public void reset()
public void clearChildReferences()
public boolean hasChildren()
public int getFinalAnswer()
public boolean isAnswerComplete()
public boolean isComplete()
public boolean isWriteNeeded()
public boolean isAnswerNeeded()
public HopCount.Answer getBestPossibleAnswer()
public void setBestPossibleAnswer(HopCount.Answer answer)
public HopCount.Answer getTrialAnswer()
public void setTrialAnswer(HopCount.Answer answer)
public HopCount.Answer getStartingAnswer()
public void setStartingAnswer(HopCount.Answer answer)
public void makeComplete()
public void makeCompleteNoWrite()
public void addParent(HopCount.DocumentNode parent)
public void clearWriteNeeded()
public void addChild(HopCount.NodeReference childRef)
childRef
- is the child node reference to add.public void removeChild(HopCount.NodeReference childRef)
childRef
- is the child node reference to remove.public void removeParent(HopCount.DocumentNode parent)
public java.util.Iterator getCurrentParents()
public java.util.Iterator getCurrentChildren()
public void setSource(java.lang.Long rowID, int answerValue)
public java.lang.Long getDatabaseRow()
public int getDatabaseValue()