001    /*
002     * Sonar, open source software quality management tool.
003     * Copyright (C) 2009 SonarSource SA
004     * mailto:contact AT sonarsource DOT com
005     *
006     * Sonar is free software; you can redistribute it and/or
007     * modify it under the terms of the GNU Lesser General Public
008     * License as published by the Free Software Foundation; either
009     * version 3 of the License, or (at your option) any later version.
010     *
011     * Sonar is distributed in the hope that it will be useful,
012     * but WITHOUT ANY WARRANTY; without even the implied warranty of
013     * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
014     * Lesser General Public License for more details.
015     *
016     * You should have received a copy of the GNU Lesser General Public
017     * License along with Sonar; if not, write to the Free Software
018     * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02
019     */
020    package org.sonar.api.web.gwt.client.webservices;
021    
022    import java.util.Date;
023    import java.util.Map;
024    import java.util.TreeMap;
025    
026    public class Measure {
027      private String metric;
028      private String metricName;
029      private Double value;
030      private String formattedValue;
031      private String data;
032    
033      private String ruleKey;
034      private String ruleName;
035      private String ruleCategory;
036      private String rulePriority;
037      
038      private Date date;
039    
040      public Measure() {
041      }
042    
043      public Measure(String metric, Double value, String formattedValue) {
044        this.metric = metric;
045        this.value = value;
046        this.formattedValue = formattedValue;
047      }
048    
049      public String getMetric() {
050        return metric;
051      }
052    
053      public void setMetric(String metric) {
054        this.metric = metric;
055      }
056    
057      public Double getValue() {
058        return value;
059      }
060    
061      public void setValue(Double value) {
062        this.value = value;
063      }
064    
065      public String getFormattedValue() {
066        return formattedValue;
067      }
068    
069      public void setFormattedValue(String formattedValue) {
070        this.formattedValue = formattedValue;
071      }
072    
073      public String getData() {
074        return data;
075      }
076    
077      public Map<String, String> getDataAsMap() {
078        Map<String, String> map = new TreeMap<String, String>();
079        if (data != null) {
080          String[] strings = data.split(";");
081          for (String string : strings) {
082            String[] keyValue = string.split("=");
083            map.put(keyValue[0], keyValue[1]);
084          }
085        }
086        return map;
087    
088      }
089    
090      public void setData(String data) {
091        this.data = data;
092      }
093    
094      public String getMetricName() {
095        return metricName;
096      }
097    
098      public void setMetricName(String metricName) {
099        this.metricName = metricName;
100      }
101    
102      public String getRuleKey() {
103        return ruleKey;
104      }
105    
106      public void setRuleKey(String s) {
107        this.ruleKey = s;
108      }
109    
110      public String getRuleName() {
111        return ruleName;
112      }
113    
114      public void setRuleName(String ruleName) {
115        this.ruleName = ruleName;
116      }
117    
118      public String getRuleCategory() {
119        return ruleCategory;
120      }
121    
122      public void setRuleCategory(String s) {
123        this.ruleCategory = s;
124      }
125    
126      public String getRulePriority() {
127        return rulePriority;
128      }
129    
130      public void setRulePriority(String rulePriority) {
131        this.rulePriority = rulePriority;
132      }
133      
134      public Date getDate() {
135        return date;
136      }
137    
138      public void setDate(Date date) {
139        this.date = date;
140      }
141    
142      @Override
143      public String toString() {
144        return "Measure{" +
145            "metric='" + metric + '\'' +
146            ", metric_name='" + metricName + '\'' +
147            ", val='" + value + '\'' +
148            ", f_val='" + formattedValue + '\'' +
149            '}';
150      }
151    
152    }