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

Quick Search    Search Deep

Source code: com/further/jaudit/ValueGettingVisitor.java


1   /*
2    * ValueGettingVisitor.java
3    * Copyright (c) 2001, Kristopher Wehner
4    * Created on September 16, 2001, 9:16 PM
5    */
6   
7   package com.further.jaudit;
8   
9   /**
10   * The value getting visitor is the exact opposite of the value 
11   * setting visitor. This class performs the complementary operation
12   * to setting the value, which is getting the value as a string. This
13   * handles the formatting issues related to the concrete subclasses
14   * of SourceMetric.
15   *
16   * @author Kris Wehner <kris@further.com>
17   * @version $Id: ValueGettingVisitor.java,v 1.1.1.1 2001/10/11 16:42:08 krisw Exp $
18   * @since 1.0
19   */
20  public class ValueGettingVisitor implements SourceMetricVisitor {
21      /**
22       * The formatted string version of the metric's value
23       */
24      private String stringValue;
25          
26      /** 
27       * Create a new ValueGettingVisitor. The constructor takes
28       * no arguments, the object is stateless until it completes
29       * its visit.
30       */
31      public ValueGettingVisitor() {
32      }
33      
34      /**
35       * Get the string value of the metric, after calling metric.accept(this).
36       * This string value will be formatted in a fashion that it can be parsed
37       * by the ValueSettingVisitor
38       *
39       * @return The string value of the metric
40       */
41      public String getStringValue() {
42          return stringValue;
43      }
44  
45      /**
46       * Visit the given boolean source metric.
47       *
48       * @param booleanMetric The boolean metric to visit.
49       */
50      public void visitMetric(BooleanMetric booleanMetric) {
51          boolean metricValue = booleanMetric.getMetricValue();
52          stringValue = (metricValue ? "true" : "false");
53      }
54      
55      /**
56       * Visit the given fixed range metric.
57       *
58       * @param fixedRangeMetric The fixed range metric to visit
59       */
60      public void visitMetric(FixedRangeMetric fixedRangeMetric) {
61          double metricValue = fixedRangeMetric.getMetricValue();
62          stringValue = Double.toString(metricValue);
63      }
64      
65      /**
66       * Visit the enumerated type metric.
67       *
68       * @param enumeratedTypeMetric The enumerated type metric to visit
69       */
70      public void visitMetric(EnumeratedTypeMetric enumeratedTypeMetric) {
71          stringValue = enumeratedTypeMetric.getMetricValue();
72      }
73      
74  }