EMMA Coverage Report (generated Wed Dec 16 17:19:59 CET 2009)
[all classes][org.sourceforge.xradar.util]

COVERAGE SUMMARY FOR SOURCE FILE [XRadarUtils.java]

nameclass, %method, %block, %line, %
XRadarUtils.java100% (1/1)25%  (1/4)50%  (54/109)35%  (7/20)

COVERAGE BREAKDOWN BY CLASS AND METHOD

nameclass, %method, %block, %line, %
     
class XRadarUtils100% (1/1)25%  (1/4)50%  (54/109)35%  (7/20)
XRadarUtils (): void 0%   (0/1)0%   (0/3)0%   (0/1)
normalizeFileName (String): String 0%   (0/1)0%   (0/39)0%   (0/7)
removeDiskNameIfRunningOnWindows (String): String 0%   (0/1)0%   (0/11)0%   (0/4)
isRunningOnWindowsOS (): boolean 100% (1/1)96%  (54/56)88%  (7/8)

1/**
2 * BSD-style license; for more info see http://xradar.sourceforge.net/license.html
3 */
4package org.sourceforge.xradar.util;
5 
6import java.util.logging.Logger;
7 
8import org.sourceforge.xradar.statics.Report;
9 
10/**
11 * @author Romain PELISSE, belaran@gmail.com
12 */
13public final class XRadarUtils {
14 
15        private static boolean isRunningOnWindows;
16 
17        // should not be instantiated
18        private XRadarUtils(){}
19 
20        /**
21         * On windows, some filename may have both '\' and '/' resulting to some
22         * bad concatenation. This method fixes the issues.
23         *
24         * @param filename
25         * @return
26         */
27        public static String normalizeFileName(String file) {
28                Logger logger = Logger.getLogger(XRadarUtils.class.getSimpleName());
29                logger.finest("Entering normalize filename with" + file);
30                XRadarUtils.isRunningOnWindows = XRadarUtils.isRunningOnWindowsOS();
31                if ( isRunningOnWindows && file.contains("\\") ) //!&& file.contains("/") )
32                {
33                        logger.finest("Normalizing filename:" + file);
34                        // We replace only the '\\' by '/'
35                        file = file.replace('\\', '/');
36                        //                        // If this is an absolute path, we remove the drive
37                        //                        Pattern pattern = Pattern.compile("^[A-Za-z]:.*$");
38                        //                        if ( pattern.matcher(file).matches() )
39                        //                        {
40                        //                                file = file.substring(2,file.length());
41                        //                                logger.finest("Normalized to:" + file);
42                        //                        }
43                        //                        else
44                        //                                logger.finest("Normalizing failed for:" + file);
45                        //
46                }
47                return file;
48        }
49 
50        /**
51         * <p>Handy method to see if xradar is running on Windows or one real OS.</p>
52         * 
53         * @return
54         */
55        public static boolean isRunningOnWindowsOS()
56        {
57                boolean status = false;
58                String[] windows = { "Windows 98", "Windows ME", "Windows 2000", "Windows XP", "Windows Vista", "Windows 2003", "Windows 7" };
59 
60                int idWindows;
61                String os = System.getProperty("os.name");
62                if (os != null )
63                        for ( idWindows = 0; idWindows < windows.length; idWindows++ )
64                                if ( os.startsWith(windows[idWindows]) )
65                                        status = true;
66 
67                return status;
68        }
69 
70        public static String removeDiskNameIfRunningOnWindows(String filename) {
71                String result = filename;
72                if ( XRadarUtils.isRunningOnWindowsOS()) {
73                        result = filename.replaceFirst("^[A-Za-z]:", "");
74                }
75                return result;
76        }
77        
78}

[all classes][org.sourceforge.xradar.util]
EMMA 2.0.5312 (C) Vladimir Roubtsov