EMMA Coverage Report (generated Mon Nov 29 14:43:38 PST 2010)
[all classes][com.jeantessier.dependencyfinder]

COVERAGE SUMMARY FOR SOURCE FILE [Version.java]

nameclass, %method, %block, %line, %
Version.java100% (1/1)50%  (7/14)34%  (66/195)42%  (25/60)

COVERAGE BREAKDOWN BY CLASS AND METHOD

nameclass, %method, %block, %line, %
     
class Version100% (1/1)50%  (7/14)34%  (66/195)42%  (25/60)
getImplementationVendor (): String 0%   (0/1)0%   (0/12)0%   (0/4)
getJarName (): String 0%   (0/1)0%   (0/3)0%   (0/1)
getResourceURL (): String 0%   (0/1)0%   (0/3)0%   (0/1)
getSpecificationDate (): String 0%   (0/1)0%   (0/12)0%   (0/4)
getSpecificationTitle (): String 0%   (0/1)0%   (0/12)0%   (0/4)
getSpecificationVendor (): String 0%   (0/1)0%   (0/12)0%   (0/4)
getSpecificationVersion (): String 0%   (0/1)0%   (0/12)0%   (0/4)
Version (): void 100% (1/1)42%  (24/57)50%  (7/14)
getCopyrightDate (): String 100% (1/1)58%  (7/12)75%  (3/4)
getCopyrightHolder (): String 100% (1/1)58%  (7/12)75%  (3/4)
getImplementationDate (): String 100% (1/1)58%  (7/12)75%  (3/4)
getImplementationTitle (): String 100% (1/1)58%  (7/12)75%  (3/4)
getImplementationURL (): String 100% (1/1)58%  (7/12)75%  (3/4)
getImplementationVersion (): String 100% (1/1)58%  (7/12)75%  (3/4)

1/*
2 *  Copyright (c) 2001-2009, Jean Tessier
3 *  All rights reserved.
4 *  
5 *  Redistribution and use in source and binary forms, with or without
6 *  modification, are permitted provided that the following conditions
7 *  are met:
8 *  
9 *      * Redistributions of source code must retain the above copyright
10 *        notice, this list of conditions and the following disclaimer.
11 *  
12 *      * Redistributions in binary form must reproduce the above copyright
13 *        notice, this list of conditions and the following disclaimer in the
14 *        documentation and/or other materials provided with the distribution.
15 *  
16 *      * Neither the name of Jean Tessier nor the names of his contributors
17 *        may be used to endorse or promote products derived from this software
18 *        without specific prior written permission.
19 *  
20 *  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
21 *  "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
22 *  LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
23 *  A PARTICULAR PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR
24 *  CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
25 *  EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
26 *  PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
27 *  PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
28 *  LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
29 *  NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
30 *  SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31 */
32 
33package com.jeantessier.dependencyfinder;
34 
35import java.io.*;
36import java.util.jar.*;
37 
38import org.apache.log4j.*;
39 
40public class Version {
41    public static final String DEFAULT_URL              = "http://depfind.sourceforge.net/";
42    public static final String DEFAULT_TITLE            = "Dependency Finder";
43    public static final String DEFAULT_VERSION          = "<i>unknown</i>";
44    public static final String DEFAULT_VENDOR           = "Jean Tessier";
45    public static final String DEFAULT_DATE             = "<i>unknown</i>";
46    public static final String DEFAULT_COPYRIGHT_HOLDER = "Jean Tessier";
47    public static final String DEFAULT_COPYRIGHT_DATE   = "2001-2009";
48 
49    private String resourceURL = null;
50    private String jarName     = null;
51 
52    private Attributes attributes = null;
53    
54    public Version() {
55        resourceURL = getClass().getResource("Version.class").toString();
56        
57        if (resourceURL.startsWith("jar:file:")) {
58            jarName = resourceURL.substring(9, resourceURL.indexOf(".jar!") + 4);
59 
60            try {
61                JarFile  jar      = new JarFile(jarName);
62                Manifest manifest = jar.getManifest();
63                
64                attributes = manifest.getMainAttributes();
65            } catch (IOException ex) {
66                Logger.getLogger(getClass()).error("Could not get version information, using defaults", ex);
67            }
68        }
69    }
70    
71    public String getResourceURL() {
72        return resourceURL;
73    }
74 
75    public String getJarName() {
76        return jarName;
77    }
78 
79    public String getImplementationURL() {
80        String result = DEFAULT_URL;
81 
82        if (attributes != null) {
83            result = attributes.getValue("Implementation-URL");
84        }
85 
86        return result;
87    }
88 
89    public String getImplementationTitle() {
90        String result = DEFAULT_TITLE;
91 
92        if (attributes != null) {
93            result = attributes.getValue("Implementation-Title");
94        }
95 
96        return result;
97    }
98 
99    public String getImplementationVersion() {
100        String result = DEFAULT_VERSION;
101 
102        if (attributes != null) {
103            result = attributes.getValue("Implementation-Version");
104        }
105 
106        return result;
107    }
108 
109    public String getImplementationVendor() {
110        String result = DEFAULT_VENDOR;
111 
112        if (attributes != null) {
113            result = attributes.getValue("Implementation-Vendor");
114        }
115 
116        return result;
117    }
118 
119    public String getImplementationDate() {
120        String result = DEFAULT_DATE;
121 
122        if (attributes != null) {
123            result = attributes.getValue("Implementation-Date");
124        }
125 
126        return result;
127    }
128 
129    public String getSpecificationTitle() {
130        String result = DEFAULT_TITLE;
131 
132        if (attributes != null) {
133            result = attributes.getValue("Specification-Title");
134        }
135 
136        return result;
137    }
138 
139    public String getSpecificationVersion() {
140        String result = DEFAULT_VERSION;
141 
142        if (attributes != null) {
143            result = attributes.getValue("Specification-Version");
144        }
145 
146        return result;
147    }
148 
149    public String getSpecificationVendor() {
150        String result = DEFAULT_VENDOR;
151 
152        if (attributes != null) {
153            result = attributes.getValue("Specification-Vendor");
154        }
155 
156        return result;
157    }
158 
159    public String getSpecificationDate() {
160        String result = DEFAULT_DATE;
161 
162        if (attributes != null) {
163            result = attributes.getValue("Specification-Date");
164        }
165 
166        return result;
167    }
168 
169    public String getCopyrightHolder() {
170        String result = DEFAULT_COPYRIGHT_HOLDER;
171 
172        if (attributes != null) {
173            result = attributes.getValue("Copyright-Holder");
174        }
175 
176        return result;
177    }
178 
179    public String getCopyrightDate() {
180        String result = DEFAULT_COPYRIGHT_DATE;
181 
182        if (attributes != null) {
183            result = attributes.getValue("Copyright-Date");
184        }
185 
186        return result;
187    }
188}

[all classes][com.jeantessier.dependencyfinder]
EMMA 2.0.5312 (C) Vladimir Roubtsov