EMMA Coverage Report (generated Tue May 16 15:34:38 CDT 2006)
[all classes][com.mysql.management.util]

COVERAGE SUMMARY FOR SOURCE FILE [Str.java]

nameclass, %method, %block, %line, %
Str.java100% (3/3)85%  (11/13)88%  (115/130)92%  (23/25)

COVERAGE BREAKDOWN BY CLASS AND METHOD

nameclass, %method, %block, %line, %
     
class Str100% (1/1)78%  (7/9)86%  (89/104)90%  (19/21)
newLine (): String 0%   (0/1)0%   (0/3)0%   (0/1)
parseDefaultTrue (Object): boolean 0%   (0/1)0%   (0/12)0%   (0/1)
Str (): void 100% (1/1)100% (7/7)100% (3/3)
classForName (String): Class 100% (1/1)100% (8/8)100% (1/1)
containsIgnoreCase (String, String): boolean 100% (1/1)100% (11/11)100% (1/1)
shortClassName (Class): String 100% (1/1)100% (13/13)100% (3/3)
shortClassName (Object): String 100% (1/1)100% (5/5)100% (1/1)
splitLines (String): String [] 100% (1/1)100% (38/38)100% (9/9)
toStringArray (List): String [] 100% (1/1)100% (7/7)100% (1/1)
     
class Str$1100% (1/1)100% (2/2)100% (13/13)100% (2/2)
Str$1 (Str, String): void 100% (1/1)100% (9/9)100% (1/1)
inner (): Object 100% (1/1)100% (4/4)100% (1/1)
     
class Str$2100% (1/1)100% (2/2)100% (13/13)100% (2/2)
Str$2 (Str, BufferedReader): void 100% (1/1)100% (9/9)100% (1/1)
inner (): String 100% (1/1)100% (4/4)100% (1/1)

1package com.mysql.management.util;
2 
3import java.io.BufferedReader;
4import java.io.IOException;
5import java.io.StringReader;
6import java.util.ArrayList;
7import java.util.List;
8 
9import com.mysql.management.util.Exceptions.Block;
10 
11/*
12 Copyright (C) 2004 MySQL AB
13 
14 This program is free software; you can redistribute it and/or modify
15 it under the terms of the GNU General Public License version 2 as 
16 published by the Free Software Foundation.
17 
18 This program is distributed in the hope that it will be useful,
19 but WITHOUT ANY WARRANTY; without even the implied warranty of
20 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
21 GNU General Public License for more details.
22 
23 You should have received a copy of the GNU General Public License
24 along with this program; if not, write to the Free Software
25 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
26 
27 */
28 
29/**
30 * String utility methods.
31 * 
32 * This class is final simply as a hint to the compiler, it may be un-finalized
33 * safely.
34 * 
35 * @author Eric Herman <eric@mysql.com>
36 * @version $Id: Str.java,v 1.11 2005/08/31 01:21:16 eherman Exp $
37 */
38public final class Str {
39    /* merge with other string utility */
40 
41    private String newLine;
42 
43    public Str() {
44        newLine = System.getProperty("line.separator");
45    }
46 
47    public boolean containsIgnoreCase(String searchIn, String searchFor) {
48 
49        return searchIn.toLowerCase().indexOf(searchFor.toLowerCase()) != -1;
50    }
51 
52    public String newLine() {
53        return newLine;
54    }
55 
56    public String[] toStringArray(List strings) {
57        return (String[]) strings.toArray(new String[strings.size()]);
58    }
59 
60    /**
61     * convienence method:
62     * 
63     * @return shortClassName(obj.getClass());
64     */
65    public String shortClassName(Object obj) {
66        return shortClassName(obj.getClass());
67    }
68 
69    /**
70     * returns the unquallified "short" name of a class (no package info)
71     * returns "String" for java.lang.String.class returns "Bar" for
72     * foo.Bar.class returns "Foo" for Foo.class (in the default package)
73     */
74    public String shortClassName(Class aClass) {
75        String name = aClass.getName();
76        int lastDot = name.lastIndexOf('.');
77        return name.substring(lastDot + 1);
78    }
79 
80    /**
81     * wrapper method for Class.forName(string) which converts
82     * ClassNotFoundException to RuntimeException
83     */
84    public Class classForName(final String className) {
85        return (Class) new Exceptions.Block() {
86            protected Object inner() throws ClassNotFoundException {
87                return Class.forName(className);
88            }
89        }.exec();
90    }
91 
92    /**
93     * returns an array of strings as read via a StringReader
94     */
95    public String[] splitLines(String str) {
96        List lines = new ArrayList();
97        StringReader stringReader = new StringReader(str);
98        final BufferedReader reader = new BufferedReader(stringReader);
99        Exceptions.StringBlock block = new Exceptions.StringBlock() {
100            protected String inner() throws IOException {
101                return reader.readLine();
102            }
103        };
104        while (true) {
105            String line = block.exec();
106            if (line == null) {
107                break;
108            }
109            lines.add(line);
110        }
111        return (String[]) lines.toArray(new String[lines.size()]);
112    }
113 
114    public boolean parseDefaultTrue(Object obj) {
115        return obj == null
116                || !obj.toString().equalsIgnoreCase(Boolean.FALSE.toString());
117    }
118}

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