View Javadoc

1   /*
2    * @(#)$Id: JdomBatchResult.java 689 2009-07-22 00:10:27Z bsigner $
3    *
4    * Author       :   Ueli Kurmann, igesture@uelikurmann.ch
5    *
6    * Purpose      : 	XML support for the BatchResult class.
7    *
8    * -----------------------------------------------------------------------
9    *
10   * Revision Information:
11   *
12   * Date             Who         Reason
13   *
14   * Dec 26, 2006     ukurmann    Initial Release
15   * Mar 22, 2007     bsigner     Cleanup
16   *
17   * -----------------------------------------------------------------------
18   *
19   * Copyright 1999-2009 ETH Zurich. All Rights Reserved.
20   *
21   * This software is the proprietary information of ETH Zurich.
22   * Use is subject to license terms.
23   * 
24   */
25  
26  
27  package org.ximtec.igesture.batch.jdom;
28  
29  import org.jdom.Element;
30  import org.sigtec.jdom.element.JdomDoubleElement;
31  import org.sigtec.jdom.element.JdomIntegerElement;
32  import org.ximtec.igesture.batch.BatchResult;
33  import org.ximtec.igesture.batch.Statistic;
34  import org.ximtec.igesture.configuration.jdom.JdomConfiguration;
35  
36  
37  /**
38   * XML support for the BatchResult class.
39   * 
40   * @version 1.0 Dec 2006
41   * @author Ueli Kurmann, igesture@uelikurmann.ch
42   * @author Beat Signer, signer@inf.ethz.ch
43   */
44  public class JdomBatchResult extends Element {
45  
46     public static final String RUNNING_TIME = "runningTime";
47  
48     private static final String PRECISION = "precision";
49  
50     public static final String RECALL = "recall";
51  
52     public static final String NUMBER_OF_SAMPLES = "numberOfSamples";
53  
54     public static final String NUMBER_OF_NOISE = "numberOfNoise";
55  
56     public static final String NUMBER_OF_REJECT_CORRECT = "numberOfRejectCorrect";
57  
58     public static final String NUMBER_OF_REJECT_ERROR = "numberOfRejectError";
59  
60     public static final String NUMBER_OF_ERRORS = "numberOfErrors";
61  
62     public static final String NUMBER_OF_CORRECTS = "numberOfCorrects";
63  
64     public static final String ROOT_TAG = "batchResult";
65  
66     public static final String NAME_ATTRIBUTE = "name";
67  
68     public static final String UUID_ATTRIBUTE = "id";
69  
70  
71     public JdomBatchResult(BatchResult result) {
72        super(ROOT_TAG);
73        this.addContent(new JdomIntegerElement(NUMBER_OF_CORRECTS, result
74              .getNumberOfCorrects()));
75        this.addContent(new JdomIntegerElement(NUMBER_OF_ERRORS, result
76              .getNumberOfErrors()));
77        this.addContent(new JdomIntegerElement(NUMBER_OF_REJECT_CORRECT, result
78              .getNumberOfRejectCorrect()));
79        this.addContent(new JdomIntegerElement(NUMBER_OF_REJECT_ERROR, result
80              .getNumberOfRejectError()));
81        this.addContent(new JdomIntegerElement(NUMBER_OF_SAMPLES, result
82              .getNumberOfSamples()));
83        this.addContent(new JdomIntegerElement(NUMBER_OF_NOISE, result
84              .getNumberOfNoise()));
85        this.addContent(new JdomDoubleElement(RECALL, result.getRecall()));
86        this.addContent(new JdomDoubleElement(PRECISION, result.getPrecision()));
87        this.addContent(new JdomDoubleElement(RUNNING_TIME, result
88              .getRunningTime()));
89        this.addContent(new JdomConfiguration(result.getConfiguration()));
90  
91        for (final Statistic statistic : result.getStatistics()) {
92           this.addContent(new JdomClassStatistic(statistic));
93        }
94  
95     }
96  
97  }