EMMA Coverage Report (generated Sun May 02 20:42:29 CEST 2010)
[all classes][hu.netmind.beankeeper.serial]

COVERAGE SUMMARY FOR SOURCE FILE [Serial.java]

nameclass, %method, %block, %line, %
Serial.java100% (1/1)80%  (4/5)69%  (24/35)86%  (6/7)

COVERAGE BREAKDOWN BY CLASS AND METHOD

nameclass, %method, %block, %line, %
     
class Serial100% (1/1)80%  (4/5)69%  (24/35)86%  (6/7)
getDate (): Date 0%   (0/1)0%   (0/11)0%   (0/1)
Serial (Long): void 100% (1/1)100% (6/6)100% (3/3)
getMaxSerial (): Serial 100% (1/1)100% (6/6)100% (1/1)
getSerial (Date): Serial 100% (1/1)100% (9/9)100% (1/1)
getValue (): Long 100% (1/1)100% (3/3)100% (1/1)

1/**
2 * Copyright (C) 2006 NetMind Consulting Bt.
3 *
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 3 of the License, or (at your option) any later version.
8 *
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
12 * Lesser General Public License for more details.
13 *
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library; if not, write to the Free Software
16 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
17 */
18 
19package hu.netmind.beankeeper.serial;
20 
21import java.io.Serializable;
22import java.util.Date;
23import java.util.Calendar;
24 
25/**
26 * A serial number is a unique number based on time, but it is
27 * <strong>not</strong> completely based on time. It has two parts,
28 * one defines the millisecond the serial was created in, and the other
29 * is a sub-millisecond index that makes it possible to have at 
30 * maximum 10.000 distinct serials in every given millisecond.
31 * @author Brautigam Robert
32 * @version Revision: $Revision$
33 */
34public class Serial implements Serializable
35{
36   private Long serial;
37 
38   /**
39    * Construct a serial with it's value.
40    */
41   public Serial(Long serial)
42   {
43      this.serial=serial;
44   }
45 
46   /**
47    * Get the serial value.
48    */
49   public Long getValue()
50   {
51      return serial;
52   }
53 
54   /**
55    * Get the first serial that is created on 
56    * the given date.
57    */
58   public static Serial getSerial(Date date)
59   {
60      return new Serial(date.getTime()*10000L);
61   }
62 
63   /**
64    * Get the millisecond this serial was created on.
65    */
66   public Date getDate()
67   {
68      return new Date(serial/10000L+1);
69   }
70 
71   /**
72    * Get the maximal serial value possible.
73    */
74   public static Serial getMaxSerial()
75   {
76      return new Serial(Long.MAX_VALUE);
77   }
78}
79 
80 

[all classes][hu.netmind.beankeeper.serial]
EMMA 2.0.5312debian (C) Vladimir Roubtsov