EMMA Coverage Report (generated Mon Mar 20 21:34:30 PST 2006)
[all classes][com.moesol.util]

COVERAGE SUMMARY FOR SOURCE FILE [HexFormatter.java]

nameclass, %method, %block, %line, %
HexFormatter.java100% (1/1)75%  (3/4)93%  (38/41)90%  (9/10)

COVERAGE BREAKDOWN BY CLASS AND METHOD

nameclass, %method, %block, %line, %
     
class HexFormatter100% (1/1)75%  (3/4)93%  (38/41)90%  (9/10)
HexFormatter (): void 0%   (0/1)0%   (0/3)0%   (0/1)
appendPaddedHex (StringBuffer, long, int, char): void 100% (1/1)100% (21/21)100% (5/5)
format (long, int): String 100% (1/1)100% (5/5)100% (1/1)
format (long, int, char): String 100% (1/1)100% (12/12)100% (3/3)

1/*
2 * $Id: HexFormatter.java,v 1.1.1.5 2004/05/25 20:23:30 hastings Exp $
3 *
4 * (c) Copyright, Moebius Solutions, Inc., 2004
5 *
6 *                       All Rights Reserved
7 *
8 * This material may be reproduced by or for the U. S. Government
9 * pursuant to the copyright license under the clause at
10 * DFARS 252.227-7014 (OCT 2001).
11 */
12 
13package com.moesol.util;
14 
15/**
16 * Format hex numbers with leading padding if needed.
17 */
18public class HexFormatter {
19        /**
20         * @param value value to format as hex
21         * @param width width of all output
22         * @return hex formatted String
23         */
24        public static String format(long value, int width) {
25                return format(value, width, '0');
26        }
27        /**
28         * 
29         * @param value value to format as hex
30         * @param width width of all output
31         * @param pad_char character to insert if padding is needed
32         * @return hex formatted String
33         */
34        public static String format(long value, int width, char pad_char) {
35                StringBuffer result = new StringBuffer();
36                appendPaddedHex(result, value, width, pad_char);
37                return result.toString();
38        }
39    public static void appendPaddedHex(
40        StringBuffer r,
41        long value,
42        int width,
43        char pad_char) 
44    {
45                String hex = Long.toHexString(value);
46                for (int i = width - hex.length(); i > 0; i--) {
47                        r.append(pad_char);
48                }
49                r.append(hex);
50        }
51}

[all classes][com.moesol.util]
EMMA 2.0.5312 (C) Vladimir Roubtsov