Clover Coverage Report
Coverage timestamp: Fri May 9 2008 10:54:27 EST
../../../../img/srcFileCovDistChart9.png 37% of files have more coverage
117   102   39   39
16   80   0.33   3
3     13  
1    
 
  English       Line # 20 117 39 87.5% 0.875
 
  (1)
 
1    package org.apache.lucene.util;
2   
3    /**
4    * Copyright 2004 The Apache Software Foundation
5    *
6    * Licensed under the Apache License, Version 2.0 (the "License");
7    * you may not use this file except in compliance with the License.
8    * You may obtain a copy of the License at
9    *
10    * http://www.apache.org/licenses/LICENSE-2.0
11    *
12    * Unless required by applicable law or agreed to in writing, software
13    * distributed under the License is distributed on an "AS IS" BASIS,
14    * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15    * See the License for the specific language governing permissions and
16    * limitations under the License.
17    */
18   
19   
 
20    public class English {
21   
 
22  145595 toggle public static String intToEnglish(int i) {
23  145597 StringBuffer result = new StringBuffer();
24  145600 intToEnglish(i, result);
25  145514 return result.toString();
26    }
27   
 
28  168400 toggle public static void intToEnglish(int i, StringBuffer result) {
29  168400 if (i == 0) {
30  1228 result.append("zero");
31  1228 return;
32    }
33  167172 if (i < 0) {
34  0 result.append("minus ");
35  0 i = -i;
36    }
37  167172 if (i >= 1000000000) { // billions
38  0 intToEnglish(i/1000000000, result);
39  0 result.append("billion, ");
40  0 i = i%1000000000;
41    }
42  167172 if (i >= 1000000) { // millions
43  0 intToEnglish(i/1000000, result);
44  0 result.append("million, ");
45  0 i = i%1000000;
46    }
47  167172 if (i >= 1000) { // thousands
48  0 intToEnglish(i/1000, result);
49  0 result.append("thousand, ");
50  0 i = i%1000;
51    }
52  167172 if (i >= 100) { // hundreds
53  22800 intToEnglish(i/100, result);
54  22800 result.append("hundred ");
55  22800 i = i%100;
56    }
57  167172 if (i >= 20) {
58  116480 switch (i/10) {
59  14560 case 9 : result.append("ninety"); break;
60  14560 case 8 : result.append("eighty"); break;
61  14560 case 7 : result.append("seventy"); break;
62  14560 case 6 : result.append("sixty"); break;
63  14560 case 5 : result.append("fifty"); break;
64  14560 case 4 : result.append("forty"); break;
65  14560 case 3 : result.append("thirty"); break;
66  14560 case 2 : result.append("twenty"); break;
67    }
68  116479 i = i%10;
69  116480 if (i == 0)
70  11648 result.append(" ");
71    else
72  104832 result.append("-");
73    }
74  167109 switch (i) {
75  1456 case 19 : result.append("nineteen "); break;
76  1456 case 18 : result.append("eighteen "); break;
77  1456 case 17 : result.append("seventeen "); break;
78  1456 case 16 : result.append("sixteen "); break;
79  1456 case 15 : result.append("fifteen "); break;
80  1456 case 14 : result.append("fourteen "); break;
81  1456 case 13 : result.append("thirteen "); break;
82  1456 case 12 : result.append("twelve "); break;
83  1456 case 11 : result.append("eleven "); break;
84  1456 case 10 : result.append("ten "); break;
85  15504 case 9 : result.append("nine "); break;
86  15503 case 8 : result.append("eight "); break;
87  15504 case 7 : result.append("seven "); break;
88  15504 case 6 : result.append("six "); break;
89  15504 case 5 : result.append("five "); break;
90  15804 case 4 : result.append("four "); break;
91  15804 case 3 : result.append("three "); break;
92  15804 case 2 : result.append("two "); break;
93  15804 case 1 : result.append("one "); break;
94  11876 case 0 : result.append(""); break;
95    }
96    }
97   
 
98  0 toggle public static void main(String[] args) {
99  0 System.out.println(intToEnglish(Integer.parseInt(args[0])));
100    }
101   
102    }