EMMA Coverage Report (generated Mon Aug 23 17:21:34 CEST 2010)
[all classes][dmg.cells.nucleus]

COVERAGE SUMMARY FOR SOURCE FILE [UOID.java]

nameclass, %method, %block, %line, %
UOID.java100% (1/1)57%  (4/7)39%  (39/101)37%  (7/19)

COVERAGE BREAKDOWN BY CLASS AND METHOD

nameclass, %method, %block, %line, %
     
class UOID100% (1/1)57%  (4/7)39%  (39/101)37%  (7/19)
clone (): Object 0%   (0/1)0%   (0/2)0%   (0/1)
equals (Object): boolean 0%   (0/1)0%   (0/29)0%   (0/4)
main (String []): void 0%   (0/1)0%   (0/31)0%   (0/7)
<static initializer> 100% (1/1)100% (6/6)100% (1/1)
UOID (): void 100% (1/1)100% (10/10)100% (4/4)
hashCode (): int 100% (1/1)100% (6/6)100% (1/1)
toString (): String 100% (1/1)100% (17/17)100% (1/1)

1package dmg.cells.nucleus;
2 
3import java.io.Serializable;
4import java.util.Date;
5import java.util.concurrent.atomic.AtomicLong;
6 
7/**
8 * uoid is the 'Unique Message Identifier'.
9 *
10 *
11 * @author Patrick Fuhrmann
12 * @version 0.1, 15 Feb 1998
13 *
14 * WARNING : This Class is designed to be immutable. All other class rely on that
15 * fact and a lot of things may fail at runtime if this design item is changed.
16 */
17 
18public class UOID implements Serializable, Cloneable {
19 
20    static final long serialVersionUID = -5940693996555861085L;
21 
22    private static final AtomicLong __counter = new AtomicLong(100);
23 
24    private final long _counter;
25    private final long _time;
26 
27    /**
28     * The constructor creates an instance of an uoid which is assumed to be
29     * different from all other uoid's created before that time and after. This
30     * behavior is guaranteed for all uoids created inside of one virtual
31     * machine and very likely for all others.
32     */
33    public UOID() {
34        _time = System.currentTimeMillis();
35        _counter = __counter.incrementAndGet();
36    }
37 
38    @Override
39    public Object clone() {
40        // it's safe to do so, UOID is immutable
41        return this;
42    }
43 
44    /**
45     * creates a hashcode which is more optimal then the object hashCode.
46     */
47    @Override
48    public int hashCode() {
49        // System.out.println( " hashCode called " ) ;
50        return (int) (_counter & 0xffffffff);
51    }
52 
53    /**
54     * compares two uoids and overwrites Object.equals.
55     */
56    @Override
57    public boolean equals(Object x) {
58        if( x == this ) return true;
59        if (!(x instanceof UOID)) return false;
60        UOID u = (UOID) x;
61        return (u._counter == _counter) && (u._time == _time);
62    }
63 
64    @Override
65    public String toString() {
66        return "<" + _time + ":" + _counter + ">";
67    }
68 
69    public static void main(String[] args) {
70        if (args.length == 0) {
71            UOID a = new UOID();
72            System.out.println(" UOID : " + a);
73        } else {
74            Date date = new Date(Long.parseLong(args[0]));
75            System.out.println(date.toString());
76        }
77 
78    }
79}

[all classes][dmg.cells.nucleus]
EMMA 2.0.5312 (C) Vladimir Roubtsov