EMMA Coverage Report (generated Wed Jun 27 17:43:42 CEST 2012)
[all classes][aarddict]

COVERAGE SUMMARY FOR SOURCE FILE [LookupWord.java]

nameclass, %method, %block, %line, %
LookupWord.java100% (1/1)90%  (9/10)73%  (169/232)76%  (32,8/43)

COVERAGE BREAKDOWN BY CLASS AND METHOD

nameclass, %method, %block, %line, %
     
class LookupWord100% (1/1)90%  (9/10)73%  (169/232)76%  (32,8/43)
LookupWord (): void 0%   (0/1)0%   (0/3)0%   (0/2)
mergeNameSpace (): void 100% (1/1)23%  (5/22)50%  (2/4)
isEmpty (): boolean 100% (1/1)50%  (6/12)50%  (0,5/1)
toString (): String 100% (1/1)53%  (23/43)54%  (4,8/9)
splitWordSimple (String): LookupWord 100% (1/1)81%  (55/68)93%  (7,4/8)
splitWord (String): LookupWord 100% (1/1)88%  (28/32)83%  (5/6)
<static initializer> 100% (1/1)100% (4/4)100% (1/1)
LookupWord (String, String, String): void 100% (1/1)100% (12/12)100% (5/5)
isEmpty (String): boolean 100% (1/1)100% (10/10)100% (1/1)
splitWordAsURI (String): LookupWord 100% (1/1)100% (26/26)100% (6/6)

1/* This file is part of Aard Dictionary for Android <http://aarddict.org>.
2 * 
3 * This program is free software: you can redistribute it and/or modify
4 * it under the terms of the GNU General Public License version 3
5 * as published by the Free Software Foundation.
6 *
7 * This program is distributed in the hope that it will be useful,
8 * but WITHOUT ANY WARRANTY; without even the implied warranty of
9 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
10 * GNU General Public License <http://www.gnu.org/licenses/gpl-3.0.txt>
11 * for more details.
12 * 
13 * Copyright (C) 2010 Igor Tkach
14*/
15 
16package aarddict;
17 
18import java.net.URI;
19import java.net.URISyntaxException;
20 
21import android.util.Log;
22 
23public class LookupWord {
24 
25        final static String TAG = LookupWord.class.getName(); 
26        
27        public String nameSpace;
28        public String word;
29        public String section;
30                
31        public LookupWord() {                
32        }
33        
34        public LookupWord(String nameSpace, String word, String section) {
35                this.nameSpace = nameSpace;
36                this.word = word;
37                this.section = section;
38        }        
39        
40        void mergeNameSpace() {
41            if (!isEmpty(nameSpace)) {
42                word = nameSpace + ":" + word;
43                nameSpace = null;
44            }            
45        }
46        
47    public static LookupWord splitWord(String word) {
48        if (word == null || word.equals("") || word.equals("#")) {
49            return new LookupWord();
50        }
51                try {
52                        return splitWordAsURI(word);
53                } catch (URISyntaxException e) {
54                        Log.d(TAG, "Word is not proper URI: " + word);
55                        return splitWordSimple(word);
56                }                                
57    }
58 
59    static LookupWord splitWordAsURI(String word) throws URISyntaxException {
60                URI uri = new URI(word);
61                String nameSpace = uri.getScheme();
62                String lookupWord = uri.getSchemeSpecificPart();
63                lookupWord = lookupWord.replace("_", " ");
64                String section = uri.getFragment();
65                return new LookupWord(nameSpace, lookupWord, section);             
66    }
67    
68    static LookupWord splitWordSimple(String word) {    
69        String[] parts = word.split("#", 2);
70        String section = parts.length == 1 ? null : parts[1];
71        String nsWord = (!isEmpty(parts[0]) || !isEmpty(section)) ? parts[0] : word;
72        String[] nsParts = nsWord.split(":", 2);      
73        String lookupWord = nsParts.length == 1 ? nsParts[0] : nsParts[1];
74        lookupWord = lookupWord.replace("_", " ");
75        String nameSpace = nsParts.length == 1 ? null : nsParts[0];
76        return new LookupWord(nameSpace, lookupWord, section);                                    
77    }
78        
79    @Override
80    public String toString() {
81        StringBuilder s = new StringBuilder();
82        if (!isEmpty(nameSpace)) {
83            s.append(nameSpace);
84            s.append(":");
85        }               
86        s.append(word == null ? "" : word);
87        if (!isEmpty(section)) {
88            s.append("#");
89            s.append(section);
90        }
91            return s.toString();            
92    }
93    
94    public boolean isEmpty() {
95            return isEmpty(word) && isEmpty(section); 
96    }
97    
98    static boolean isEmpty(String s) {
99        return s == null || s.equals("");
100    }    
101}

[all classes][aarddict]
EMMA 0.0.0 (unsupported private build) (C) Vladimir Roubtsov