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.wsclient.services; 021 022 import java.util.LinkedHashMap; 023 import java.util.Map; 024 025 public class Measure extends Model { 026 027 private String metricKey; 028 private String metricName; 029 private Double value; 030 private String formattedValue; 031 private String data; 032 private String characteristicKey; 033 private String characteristicName; 034 035 private Integer trend; 036 private Integer var; 037 038 private String ruleKey; 039 private String ruleName; 040 private String ruleCategory; 041 private String rulePriority; 042 043 public String getMetricKey() { 044 return metricKey; 045 } 046 047 public Measure setMetricKey(String metricKey) { 048 this.metricKey = metricKey; 049 return this; 050 } 051 052 public String getMetricName() { 053 return metricName; 054 } 055 056 public Measure setMetricName(String metricName) { 057 this.metricName = metricName; 058 return this; 059 } 060 061 public Double getValue() { 062 return value; 063 } 064 065 public Integer getIntValue() { 066 if (value==null) { 067 return null; 068 } 069 return value.intValue(); 070 } 071 072 public Measure setValue(Double value) { 073 this.value = value; 074 return this; 075 } 076 077 public String getFormattedValue() { 078 return formattedValue; 079 } 080 081 public String getFormattedValue(String defaultValue) { 082 if (formattedValue==null) { 083 return defaultValue; 084 } 085 return formattedValue; 086 } 087 088 public Measure setFormattedValue(String formattedValue) { 089 this.formattedValue = formattedValue; 090 return this; 091 } 092 093 public String getData() { 094 return data; 095 } 096 097 public Map<String,String> getDataAsMap() { 098 return getDataAsMap(","); 099 } 100 101 public Map<String,String> getDataAsMap(String separator) { 102 if (data==null) { 103 return null; 104 } 105 Map<String,String> map = new LinkedHashMap<String,String>(); 106 String[] parts = data.split(separator); 107 for (String part : parts) { 108 String[] kv = part.split("="); 109 map.put(kv[0], kv[1]); 110 } 111 return map; 112 } 113 114 public Measure setData(String data) { 115 this.data = data; 116 return this; 117 } 118 119 public Integer getTrend() { 120 return trend; 121 } 122 123 public Measure setTrend(Integer trend) { 124 this.trend = trend; 125 return this; 126 } 127 128 public Integer getVar() { 129 return var; 130 } 131 132 public Measure setVar(Integer var) { 133 this.var = var; 134 return this; 135 } 136 137 public String getRuleKey() { 138 return ruleKey; 139 } 140 141 public Measure setRuleKey(String ruleKey) { 142 this.ruleKey = ruleKey; 143 return this; 144 } 145 146 public String getRuleName() { 147 return ruleName; 148 } 149 150 public Measure setRuleName(String ruleName) { 151 this.ruleName = ruleName; 152 return this; 153 } 154 155 public String getRuleCategory() { 156 return ruleCategory; 157 } 158 159 public Measure setRuleCategory(String ruleCategory) { 160 this.ruleCategory = ruleCategory; 161 return this; 162 } 163 164 public String getRulePriority() { 165 return rulePriority; 166 } 167 168 public Measure setRulePriority(String rulePriority) { 169 this.rulePriority = rulePriority; 170 return this; 171 } 172 173 public String getCharacteristicKey() { 174 return characteristicKey; 175 } 176 177 public String getCharacteristicName() { 178 return characteristicName; 179 } 180 181 public Measure setCharacteristicKey(String s) { 182 this.characteristicKey = s; 183 return this; 184 } 185 186 public Measure setCharacteristicName(String s) { 187 this.characteristicName = s; 188 return this; 189 } 190 191 @Override 192 public String toString() { 193 return new StringBuilder().append("Measure{") 194 .append("metricKey='").append(metricKey).append('\'') 195 .append(", metricName='").append(metricName).append('\'') 196 .append(", value=").append(value) 197 .append(", formattedValue='").append(formattedValue).append('\'') 198 .append(", data='").append(data).append('\'') 199 .append(", characteristicKey='").append(characteristicKey).append('\'') 200 .append(", characteristicName='").append(characteristicName).append('\'') 201 .append(", trend=").append(trend).append(", var=").append(var) 202 .append(", ruleKey='").append(ruleKey).append('\'') 203 .append(", ruleName='").append(ruleName).append('\'') 204 .append(", ruleCategory='").append(ruleCategory).append('\'') 205 .append(", rulePriority='").append(rulePriority).append('\'') 206 .append('}').toString(); 207 } 208 }