001    package org.maltparser.parser.history;
002    
003    import org.maltparser.core.exception.MaltChainedException;
004    import org.maltparser.parser.history.action.GuideUserAction;
005    /**
006     * 
007     * @author Johan Hall
008    */
009    public class HistoryListNode implements HistoryNode {
010            private HistoryNode previousNode;
011            private GuideUserAction action;
012    //      private double score;
013            private int position;
014            
015            public HistoryListNode(HistoryNode previousNode, GuideUserAction action) {
016                    setPreviousNode(previousNode);
017                    setAction(action);
018    //              setScore(score);
019                    if (previousNode != null) {
020                            setPosition(previousNode.getPosition()+1);
021                    } else {
022                            setPosition(1);
023                    }
024            }
025            
026    //      public HistoryListNode(HistoryNode previousNode, GuideUserAction action, double score) {
027    //              setPreviousNode(previousNode);
028    //              setAction(action);
029    //              setScore(score);
030    //              if (previousNode != null) {
031    //                      setPosition(previousNode.getPosition()+1);
032    //              } else {
033    //                      setPosition(1);
034    //              }       
035    //      }
036            
037            public HistoryNode getPreviousNode() {
038                    return previousNode;
039            }
040    
041            public GuideUserAction getAction() {
042                    return action;
043            }
044    
045            public void setPreviousNode(HistoryNode node) {
046                    this.previousNode = node;
047            }
048    
049            public void setAction(GuideUserAction action) {
050                    this.action = action;
051            }
052            
053    //      public double getScore() {
054    //              return score;
055    //      }
056    //
057    //      public void setScore(double score) {
058    //              this.score = score;
059    //      }
060    
061            private void setPosition(int p) {
062                    position = p;
063            }
064            
065            public int getPosition() {
066                    return position;
067            }
068            
069            public void clear() throws MaltChainedException {
070                    setPreviousNode(null);
071                    setAction(null);
072            }
073            
074            public String toString() {
075                    final StringBuilder sb = new StringBuilder();
076                    sb.append(action);
077                    return sb.toString();
078            } 
079            
080    }