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

COVERAGE SUMMARY FOR SOURCE FILE [FormattedProperties.java]

nameclass, %method, %block, %line, %
FormattedProperties.java100% (1/1)80%  (8/10)74%  (95/128)71%  (26.9/38)

COVERAGE BREAKDOWN BY CLASS AND METHOD

nameclass, %method, %block, %line, %
     
class FormattedProperties100% (1/1)80%  (8/10)74%  (95/128)71%  (26.9/38)
FormattedProperties (Properties): void 0%   (0/1)0%   (0/6)0%   (0/3)
save (OutputStream, String): void 0%   (0/1)0%   (0/21)0%   (0/7)
store (OutputStream, String): void 100% (1/1)64%  (9/14)75%  (3/4)
<static initializer> 100% (1/1)92%  (11/12)91%  (0.9/1)
FormattedProperties (): void 100% (1/1)100% (5/5)100% (3/3)
defaultDelim (): void 100% (1/1)100% (4/4)100% (2/2)
getFormatDelimeter (): char 100% (1/1)100% (3/3)100% (1/1)
myStore (String, String, PrintStream): void 100% (1/1)100% (12/12)100% (5/5)
setFormatDelimeter (char): void 100% (1/1)100% (17/17)100% (4/4)
writeOut (OutputStream, String): void 100% (1/1)100% (34/34)100% (8/8)

1/*
2 * $Id: FormattedProperties.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 
15import java.io.IOException;
16import java.io.OutputStream;
17import java.io.PrintStream;
18import java.util.Arrays;
19import java.util.Properties;
20import java.util.Set;
21import java.util.logging.Level;
22import java.util.logging.Logger;
23 
24/**
25 * @author Adam
26 *
27 * To change the template for this generated type comment go to
28 * Window&gt;Preferences&gt;Java&gt;Code Generation&gt;Code and Comments
29 */
30public class FormattedProperties extends Properties {
31 
32        public FormattedProperties() {
33                super();
34                defaultDelim();
35        }
36 
37        public FormattedProperties(Properties arg0) {
38                super(arg0);
39                defaultDelim();
40        }
41        
42        private void defaultDelim() {
43                m_delimeter = DEFAULT_DELIMETER;
44        }
45        
46        public void setFormatDelimeter(char delimeter){
47                if (delimeter == EQUAL_SIGN ||
48                        delimeter == DEFAULT_DELIMETER ||
49                        delimeter == COLON){
50                        m_delimeter = delimeter;                
51                } else {
52                        m_delimeter = DEFAULT_DELIMETER;
53                }
54        }
55        
56        public char getFormatDelimeter(){
57                return m_delimeter;        
58        }
59        
60        public void store(OutputStream out, String header) throws IOException{
61                if (m_delimeter == EQUAL_SIGN) {
62                        super.store(out, header);
63                } else {
64                        writeOut(out, header);
65                }
66        }
67        
68        /**
69         * @deprecated this mutes IOException use store instead.
70         */
71        public void save(OutputStream out, String header){
72                if (m_delimeter == EQUAL_SIGN) {
73                        super.save(out, header);
74                } else {
75                        try{
76                                writeOut(out, header);
77                        } catch (IOException e) {
78                                logger.log(Level.FINE, "save", "Threw an IOException that is muted" +
79                                " by the construct of save.  Caller should use store instead.");
80                        }
81                }
82        }
83        
84        private void writeOut(OutputStream out, String header)
85                throws IOException {
86                PrintStream ps = new PrintStream(out);
87                Set keys = keySet();
88                Object[] keys_a = keys.toArray();
89                Arrays.sort(keys_a);
90                for (int i = 0; i < keys_a.length; i++) {
91                        String key = (String)keys_a[i]; 
92                        myStore(key, getProperty(key), ps);
93                }
94        }
95        
96        private void myStore(String key, String value, PrintStream ps) throws IOException {
97                ps.print(key);
98                ps.print(": ");
99                ps.print(value);
100                ps.println();
101        }
102        
103        private char m_delimeter;
104        
105        public static final char EQUAL_SIGN = '=';
106        public static final char DEFAULT_DELIMETER = EQUAL_SIGN;
107        public static final char COLON = ':';
108        static Logger logger = Logger.getLogger(FormattedProperties.class.getName());
109}

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