Clover Coverage Report - KS Contract Documentation Generator 0.0.1-SNAPSHOT
Coverage timestamp: Wed Dec 31 1969 19:00:00 EST
../../../../../img/srcFileCovDistChart0.png 0% of files have more coverage
27   73   9   9
12   45   0.33   3
3     3  
1    
 
  JavaEnumConstantCalculator       Line # 22 27 0% 9 42 0% 0.0
 
No Tests
 
1    /*
2    * Copyright 2010 The Kuali Foundation
3    *
4    * Licensed under the Educational Community License, Version 2.0 (the "License");
5    * you may not use this file except in compliance with the License.
6    * You may obtain a copy of the License at
7    *
8    * http://www.osedu.org/licenses/ECL-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,
12    * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13    * See the License for the specific language governing permissions and
14    * limitations under the License.
15    */
16    package org.kuali.student.contract.writer;
17   
18    /**
19    *
20    * @author nwright
21    */
 
22    public class JavaEnumConstantCalculator {
23   
24    private String name;
25   
 
26  0 toggle public JavaEnumConstantCalculator(String name) {
27  0 this.name = name;
28    }
29   
 
30  0 toggle public String calc() {
31  0 StringBuilder buf = new StringBuilder(name.length() + 3);
32    // do the first character so we don't prepend the first with a _ if it is upper
33  0 char c = Character.toUpperCase(name.charAt(0));
34  0 buf.append(c);
35  0 boolean lastUpper = Character.isUpperCase(c);
36  0 for (int i = 1; i < name.length(); i++) {
37  0 c = name.charAt(i);
38  0 if (Character.isUpperCase(c)) {
39  0 if (!lastUpper) {
40  0 buf.append('_');
41    }
42  0 lastUpper = true;
43    } else {
44  0 lastUpper = false;
45    }
46   
47  0 buf.append(Character.toUpperCase(c));
48    }
49   
50  0 return buf.toString();
51    }
52   
 
53  0 toggle public String reverse() {
54  0 StringBuffer buf = new StringBuffer(name.length());
55  0 boolean uppercase = true;
56  0 for (int i = 0; i < name.length(); i++) {
57  0 char c = name.charAt(i);
58  0 if (uppercase) {
59  0 c = Character.toUpperCase(c);
60  0 uppercase = false;
61    } else {
62  0 c = Character.toLowerCase(c);
63    }
64  0 if (c == '_') {
65  0 uppercase = true;
66  0 continue;
67    }
68  0 buf.append(c);
69    }
70   
71  0 return buf.toString();
72    }
73    }