Coverage Report - com.sdmetrics.metrics.DescriptionLocator - www.sdmetrics.com
 
Classes in this File Line Coverage Branch Coverage Complexity
DescriptionLocator
100%
18/18
N/A
1
 
 1  15
 /*
 2  
  * SDMetrics Open Core for UML design measurement
 3  
  * Copyright (c) Juergen Wuest
 4  
  * To contact the author, see <http://www.sdmetrics.com/Contact.html>.
 5  
  * 
 6  
  * This file is part of the SDMetrics Open Core.
 7  
  * 
 8  
  * SDMetrics Open Core is free software: you can redistribute it and/or modify
 9  
  * it under the terms of the GNU Affero General Public License as
 10  
  * published by the Free Software Foundation, either version 3 of the
 11  
  * License, or (at your option) any later version.
 12  
     
 13  
  * SDMetrics Open Core is distributed in the hope that it will be useful,
 14  
  * but WITHOUT ANY WARRANTY; without even the implied warranty of
 15  
  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 16  
  * GNU Affero General Public License for more details.
 17  
  *
 18  
  * You should have received a copy of the GNU Affero General Public License
 19  
  * along with SDMetrics Open Core.  If not, see <http://www.gnu.org/licenses/>.
 20  
  *
 21  
  */
 22  
 package com.sdmetrics.metrics;
 23  
 
 24  
 /**
 25  
  * Enumerates the locators for metrics, rules, and so forth in descriptions in
 26  
  * the metric definition files.
 27  
  * <p>
 28  
  * Locators are used to cross-reference metrics, rules, matrices, literature
 29  
  * references and glossary items in the documentation of these items. Because of
 30  
  * their hyperlink character, locators are constructed like URLs. The string
 31  
  * "metric://class/NumOps/" for example references the design metric "NumOps"
 32  
  * for elements of type "class".
 33  
  * <p>
 34  
  * We call the "metric://" part of the locator its prefix (rather than protocol
 35  
  * as there is no communication protocol implied). The "class/NumOps/" part are
 36  
  * the parameters of the locator. Each locator has a fixed number of parameters.
 37  
  */
 38  2
 public enum DescriptionLocator {
 39  
 
 40  2
         /**
 41  
          * Locator for metrics. Has two parameters "element type" and "metric name".
 42  
          */
 43  2
         METRIC("metric://", 2),
 44  2
         /** Locator for rules. Has two parameters "element type" and "rule name". */
 45  2
         RULE("rule://", 2),
 46  2
         /** Locator for matrices. Has one parameter "matrix name". */
 47  2
         MATRIX("matrix://", 1),
 48  2
         /** Locator for literature references. Has one parameter "citation handle". */
 49  2
         REFERENCE("ref://", 1),
 50  2
         /** Locator for glossary entries. Has two parameters "term" and "link text". */
 51  2
         GLOSSARY("glossary://", 2);
 52  
 
 53  
         private final String prefix;
 54  
         private final int parameterCount;
 55  
 
 56  10
         private DescriptionLocator(String prefix, int parameterCount) {
 57  10
                 this.prefix = prefix;
 58  10
                 this.parameterCount = parameterCount;
 59  10
         }
 60  
 
 61  
         /**
 62  
          * Gets the prefix of this locator.
 63  
          * 
 64  
          * @return Prefix of the locators.
 65  
          */
 66  
         public String getPrefix() {
 67  161
                 return prefix;
 68  
         }
 69  
 
 70  
         /**
 71  
          * Gets the number of parameters this locator expects following the prefix.
 72  
          * 
 73  
          * @return Number of parameters of the locator.
 74  
          */
 75  
         public int getParameterCount() {
 76  17
                 return parameterCount;
 77  
         }
 78  
 }