PageRenderTime 47ms CodeModel.GetById 41ms app.highlight 4ms RepoModel.GetById 1ms app.codeStats 1ms

/eclipse-plugin/plugins/com.google.test.metric.eclipse.core/src/main/java/com/google/test/metric/eclipse/internal/util/TestabilityExplorerMessageRetriever.java

http://testability-explorer.googlecode.com/
Java | 52 lines | 25 code | 7 blank | 20 comment | 0 complexity | 8f7ca31567ad0a006bcf32f56efd1011 MD5 | raw file
 1/*
 2 * Copyright 2009 Google Inc.
 3 * 
 4 * Licensed under the Apache License, Version 2.0 (the "License"); you may not
 5 * use this file except in compliance with the License. You may obtain a copy of
 6 * the License at
 7 * 
 8 * http://www.apache.org/licenses/LICENSE-2.0
 9 * 
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
12 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
13 * License for the specific language governing permissions and limitations under
14 * the License.
15 */
16package com.google.test.metric.eclipse.internal.util;
17
18import com.google.test.metric.report.issues.IssueSubType;
19import com.google.test.metric.report.issues.IssueType;
20
21import java.io.IOException;
22import java.util.Properties;
23
24/**
25 * Helper class which retrieves the suggestions for various issues and their subtypes
26 * from the Testability Explorer messages bundle.
27 * @author shyamseshadri@google.com (Shyam Seshadri)
28 */
29public class TestabilityExplorerMessageRetriever {
30
31  private final Logger logger = new Logger();
32  private final Properties properties = new Properties();
33  public static final String PROPERTY_PREFIX = "report.explain.class.";
34  public static final String PROPERTY_SUFFIX = ".suggest";
35  
36  public TestabilityExplorerMessageRetriever() {
37    try {
38      properties.load(getClass().getResourceAsStream("/messages.properties"));
39    } catch (IOException e) {
40      logger.logException(e);
41    }
42  }
43  
44  public String convertTypeSubTypeToString(IssueType type, IssueSubType subType) {
45    return type.toString().replace("_", "").toLowerCase() + "." + subType.toString().toLowerCase();
46  }
47
48  public String getSuggestion(IssueType type, IssueSubType subType) {
49    return properties.getProperty(PROPERTY_PREFIX + convertTypeSubTypeToString(type, subType)
50        + PROPERTY_SUFFIX);
51  }
52}