Coverage Test Results


Class sampleproject.util.UniqueString$UniqueInner

NameProbesExecutedCoverage
UniqueString$UniqueInner200.00%

Methods

NameProbesExecutedCoverage
<init>(Lsampleproject/util/UniqueString;)V100.00%
toString()Ljava/lang/String;100.00%

Source

1
/* Created or Modified by J.M. Kruithof jmkf@users.sourceforge.net (c) 2002,
2
 * This software may be based in whole, in part or not at all on software
3
 * contributed to the Apache Software Foundation. It is licensed under exact
4
 * the same license.
5
 * The Apache Software foundation may or may not consider this software
6
 * a voluntary contribution. This is at the opinion of the Apache Software
7
 * foundation.
8
 *
9
 * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
10
 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
11
 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
12
 * DISCLAIMED.  IN NO EVENT SHALL THE CONTRIBUTORS OF THIS SOFTWARE
13
 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
14
 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
15
 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
16
 * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
17
 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
18
 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
19
 * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
20
 * SUCH DAMAGE.
21
 *
22
 * Licensed under the following conditions:
23
 */
24
/*
25
 * The Apache Software License, Version 1.1
26
 *
27
 * Copyright (c) 2000 The Apache Software Foundation.  All rights
28
 * reserved.
29
 *
30
 * Redistribution and use in source and binary forms, with or without
31
 * modification, are permitted provided that the following conditions
32
 * are met:
33
 *
34
 * 1. Redistributions of source code must retain the above copyright
35
 *    notice, this list of conditions and the following disclaimer.
36
 *
37
 * 2. Redistributions in binary form must reproduce the above copyright
38
 *    notice, this list of conditions and the following disclaimer in
39
 *    the documentation and/or other materials provided with the
40
 *    distribution.
41
 *
42
 * 3. The end-user documentation included with the redistribution, if
43
 *    any, must include the following acknowlegement:
44
 *       "This product includes software developed by the
45
 *        Apache Software Foundation (http://www.apache.org/)."
46
 *    Alternately, this acknowlegement may appear in the software itself,
47
 *    if and wherever such third-party acknowlegements normally appear.
48
 *
49
 * 4. The names "The Jakarta Project", "Ant", and "Apache Software
50
 *    Foundation" must not be used to endorse or promote products derived
51
 *    from this software without prior written permission. For written
52
 *    permission, please contact apache@apache.org.
53
 *
54
 * 5. Products derived from this software may not be called "Apache"
55
 *    nor may "Apache" appear in their names without prior written
56
 *    permission of the Apache Group.
57
 *
58
 * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
59
 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
60
 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
61
 * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
62
 * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
63
 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
64
 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
65
 * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
66
 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
67
 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
68
 * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
69
 * SUCH DAMAGE.
70
 * ====================================================================
71
 *
72
 * This software consists of voluntary contributions made by many
73
 * individuals on behalf of the Apache Software Foundation.  For more
74
 * information on the Apache Software Foundation, please see
75
 * <http://www.apache.org/>.
76
 */
77

78
package sampleproject.util;
79

80
/**
81
 *
82
 * @author  jkf
83
 * @version 
84
 */
85
public class UniqueString implements java.io.Serializable {
86

87
    private java.lang.String myUniqueString;
88
    
89
    private static java.util.HashMap myUniqueMap = new java.util.HashMap();
90
    
91
    /** Creates new Unique */
92
    private UniqueString(String unique) {
93
        myUniqueString = new String(unique);
94
        myUniqueMap.put(myUniqueString, this);
95
    }
96
    
97
    public static UniqueString getUniqueString(java.lang.String unique) {
98
        if (myUniqueMap.containsKey(unique)) 
99
        {
100
            return (UniqueString) myUniqueMap.get(unique);
101
        } else {
102
            return new UniqueString(unique);
103
        }
104
    }
105
    
106
    public int hashCode() {
107
        return myUniqueString.hashCode();
108
    }
109
    
110
    public boolean equals(Object obj) {
111
        if (obj == this) {
112
            return true;
113
        } else if (obj instanceof UniqueString) 
114
        {
115
            return myUniqueString.equals(((UniqueString)obj).myUniqueString);
116
        } else {
117
            return myUniqueString.equals(obj);
118
        }
119
    }
120
    
121
    public String toString() {
122
        return myUniqueString;
123
    }
124

125
    private Object readResolve() throws java.io.ObjectStreamException {
126
        return getUniqueString(myUniqueString);
127
    }
128

129
    public class UniqueInner {
130
        public String toString() {
131
            return myUniqueString;
132
        }
133
    }
134
}