001    package org.maltparser.parser.history.kbest;
002    
003    
004    /**
005     * A candidate in the k-best list. 
006     * 
007     * @author Johan Hall
008     * @since 1.1
009    */
010    public class Candidate  {
011            /**
012             * The integer representation of the predicted action
013             */
014            protected int actionCode;
015            
016            /**
017             * Constructs a candidate object
018             */
019            public Candidate() {
020                    reset();
021            }
022    
023            /**
024             * Returns an integer representation of the predicted action
025             * 
026             * @return an integer representation of the predicted action
027             */
028            public int getActionCode() {
029                    return actionCode;
030            }
031    
032            /**
033             * Sets the integer representation of the predicted action
034             * 
035             * @param actionCode an integer representation of the predicted action
036             */
037            public void setActionCode(int actionCode) {
038                    this.actionCode = actionCode;
039            }
040    
041            
042            /**
043             * Resets the candidate object
044             */
045            public void reset() {
046                    this.actionCode = -1;
047            }
048            
049            /* (non-Javadoc)
050             * @see java.lang.Object#equals(java.lang.Object)
051             */
052            public boolean equals(Object obj) {
053                    if (this == obj) return true;
054                    if (!(obj instanceof Candidate)) {
055                            return false;
056                    }
057                    Candidate item = (Candidate)obj;
058                    return (actionCode == item.getActionCode());
059            }
060            
061    
062            public int hashCode() {
063                    return 31 * 7 + actionCode;
064            }
065    
066            /* (non-Javadoc)
067             * @see java.lang.Object#toString()
068             */
069            public String toString() {
070                    return Integer.toString(actionCode);
071            }
072    }
073