Coverage Report - org.apache.maven.doxia.module.rtf.RomanNumerals
 
Classes in this File Line Coverage Branch Coverage Complexity
RomanNumerals
0%
0/12
0%
0/6
2,5
 
 1  
 package org.apache.maven.doxia.module.rtf;
 2  
 
 3  
 /*
 4  
  * Licensed to the Apache Software Foundation (ASF) under one
 5  
  * or more contributor license agreements.  See the NOTICE file
 6  
  * distributed with this work for additional information
 7  
  * regarding copyright ownership.  The ASF licenses this file
 8  
  * to you under the Apache License, Version 2.0 (the
 9  
  * "License"); you may not use this file except in compliance
 10  
  * with the License.  You may obtain a copy of the License at
 11  
  *
 12  
  *   http://www.apache.org/licenses/LICENSE-2.0
 13  
  *
 14  
  * Unless required by applicable law or agreed to in writing,
 15  
  * software distributed under the License is distributed on an
 16  
  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
 17  
  * KIND, either express or implied.  See the License for the
 18  
  * specific language governing permissions and limitations
 19  
  * under the License.
 20  
  */
 21  
 
 22  
 /**
 23  
  * @version $Id: RomanNumerals.java 703394 2008-10-10 10:53:51Z vsiveton $
 24  
  */
 25  0
 class RomanNumerals
 26  
 {
 27  0
     private static final int[] NUMBERS = {1000, 900, 500, 400, 100, 90, 50, 40, 10, 9, 5, 4, 1};
 28  
 
 29  0
     private static final String[] UPPER_CASE_LETTERS =
 30  
         {"M", "CM", "D", "CD", "C", "XC", "L", "XL", "X", "IX", "V", "IV", "I"};
 31  
 
 32  0
     private static final String[] LOWER_CASE_LETTERS =
 33  
         {"m", "cm", "d", "cd", "c", "xc", "l", "xl", "x", "ix", "v", "iv", "i"};
 34  
 
 35  
     // -----------------------------------------------------------------------
 36  
 
 37  
     static String toString( int n )
 38  
     {
 39  0
         return toString( n, false );
 40  
     }
 41  
 
 42  
     static String toString( int n, boolean lowerCase )
 43  
     {
 44  0
         StringBuffer roman = new StringBuffer();
 45  0
         String[] letters = lowerCase ? LOWER_CASE_LETTERS : UPPER_CASE_LETTERS;
 46  
 
 47  0
         for ( int i = 0; i < NUMBERS.length; ++i )
 48  
         {
 49  0
             while ( n >= NUMBERS[i] )
 50  
             {
 51  0
                 roman.append( letters[i] );
 52  0
                 n -= NUMBERS[i];
 53  
             }
 54  
         }
 55  
 
 56  0
         return roman.toString();
 57  
     }
 58  
 }