Docjar: A Java Source and Docuemnt Enginecom.*    java.*    javax.*    org.*    all    new    plug-in

Quick Search    Search Deep

Source code: marf/Storage/Result.java


1   package marf.Storage;
2   
3   import java.io.Serializable;
4   
5   
6   /**
7    * <p>Represents a single classification result - ID and some value
8    * indicating either certain distance from the sample being recognized
9    * or a probability.</p>
10   *
11   * <p>$Id: Result.java,v 1.20 2005/08/13 16:28:49 mokhov Exp $</p>
12   *
13   * @author Serguei Mokhov
14   * @version $Revision: 1.20 $
15   * @since 0.0.1
16   */
17  public class Result
18  implements Serializable
19  {
20    /**
21     * Identified subject's ID.
22     */
23    protected int iID = 0;
24  
25    /**
26     * Textual result description.
27     * @since 0.3.0
28     */
29    protected String strDescription = "";
30  
31    /**
32     * Distance/probability.
33     * @since 0.3.0
34     */
35    protected double dOutcome = 0.0;
36  
37    /**
38     * For serialization versioning.
39     * When adding new members or make other structural
40     * changes regenerate this number with the
41     * <code>serialver</code> tool that comes with JDK.
42     * @since 0.3.0.4
43     */
44    private static final long serialVersionUID = 5289013996325438809L;
45  
46    /**
47     * Default Constructor.
48     * Equivalent to <code>Result(0)</code>
49     */
50    public Result()
51    {
52      this(0);
53    }
54  
55    /**
56     * ID Constructor. Equivalent to <code>Result(piID, 0, "")</code>.
57     * @param piID integer ID of the speaker
58     */
59    public Result(final int piID)
60    {
61      this(piID, 0, "");
62    }
63  
64    /**
65     * ID/outcome Constructor. Equivalent to <code>Result(piID, pdOutcome, "")</code>.
66     * @param piID integer ID of the subject
67     * @param pdOutcome distance/probability of the result
68     * @since 0.3.0
69     */
70    public Result(final int piID, final double pdOutcome)
71    {
72      this(piID, pdOutcome, "");
73    }
74  
75    /**
76     * ID/description Constructor.
77     * Equivalent to <code>Result(piID, 0, pstrDescription)</code>.
78     * @param piID integer ID of the subject
79     * @param pstrDescription textual description of the result
80     * @since 0.3.0
81     */
82    public Result(final int piID, final String pstrDescription)
83    {
84      this(piID, 0, pstrDescription);
85    }
86  
87    /**
88     * Outcome/description Constructor.
89     * Equivalent to <code>Result(0, pdOutcome, pstrDescription)</code>.
90     * @param pdOutcome distance/probability of the result
91     * @param pstrDescription textual description of the result
92     * @since 0.3.0
93     */
94    public Result(final double pdOutcome, final String pstrDescription)
95    {
96      this(0, pdOutcome, pstrDescription);
97    }
98  
99    /**
100    * General ID/outcome/description Constructor.
101    * @param piID integer ID of the subject
102    * @param pdOutcome distance/probability of the result
103    * @param pstrDescription textual description of the result
104    * @since 0.3.0
105    */
106   public Result(final int piID, final double pdOutcome, final String pstrDescription)
107   {
108     this.iID = piID;
109     this.dOutcome = pdOutcome;
110     this.strDescription = pstrDescription;
111   }
112 
113   /**
114    * Returns result's ID.
115    * @return ID of an entity (speaker, instrument, language, etc)
116    */
117   public final int getID()
118   {
119     return this.iID;
120   }
121 
122   /**
123    * Retrieves the outcome value.
124    * @return distance/probability of the result
125    * @since 0.3.0
126    */
127   public final double getOutcome()
128   {
129     return this.dOutcome;
130   }
131 
132   /**
133    * Retrieves textual description of the result.
134    * @return string describing the result
135    * @since 0.3.0
136    */
137   public final String getDescription()
138   {
139     return this.strDescription;
140   }
141 
142   /**
143    * Retrieves the result values in a form of string, which is
144    * of the following form: [ID:outcome:description].
145    * @return string representation of the Result object
146    * @since 0.3.0
147    */
148   public String toString()
149   {
150     return
151       "[" + this.iID + ":" +
152       this.dOutcome + ":" +
153       this.strDescription + "]";
154   }
155 
156   /**
157    * Sets ID, should only be called by a Classification module.
158    * @param piID ID of the subject classified
159    */
160   public final void setID(final int piID)
161   {
162     this.iID = piID;
163   }
164 
165   /**
166    * Sets outcome value.
167    * @param pdOutcome resulting outcome
168    * @since 0.3.0.2
169    */
170   public final void setOutcome(double pdOutcome)
171   {
172     this.dOutcome = pdOutcome;
173   }
174 
175   /**
176    * Sets description of the result.
177    * @param pstrDescription description string
178    * @since 0.3.0.2
179    */
180   public final void setDescription(String pstrDescription)
181   {
182     this.strDescription = pstrDescription;
183   }
184 
185   /**
186    * Returns source code revision information.
187    * @return revision string
188    * @since 0.3.0.2
189    */
190   public static String getMARFSourceCodeRevision()
191   {
192     return "$Revision: 1.20 $";
193   }
194 }
195 
196 // EOF