KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > netbeans > modules > piagetproject > property > LongProperty


1 /*
2  * LongProperty.java
3  *
4  * Created on July 27, 2005, 4:28 PM
5  *
6  * To change this template, choose Tools | Options and locate the template under
7  * the Source Creation and Management node. Right-click the template and choose
8  * Open. You can then make changes to the template in the Source Editor.
9  */

10
11 package org.netbeans.modules.piagetproject.property;
12
13 /**
14  *
15  * @author loicsegapelli
16  */

17 public class LongProperty extends Property{
18     
19     long value;
20     
21     /** Creates a new instance of LongProperty */
22     public LongProperty(String JavaDoc key, String JavaDoc name, String JavaDoc value, String JavaDoc table) {
23         super(key, table, name);
24         this.value = Long.parseLong(value);
25     }
26     
27     public Object JavaDoc getValue(int counter) {
28         long average = value / counter;
29         return prettyTime(average);
30     }
31     
32     protected void combineProperties(String JavaDoc key, String JavaDoc value) {
33         long l = Long.parseLong(value);
34         this.value += l;
35     }
36     
37     private static String JavaDoc prettyTime(long l){
38         int i = new Long JavaDoc(l/1000).intValue();
39         int h = i/3600;
40         String JavaDoc hs = new Integer JavaDoc(h).toString();
41         if(h<10) hs = "0"+hs;
42         int m = (i%3600)/60;
43         String JavaDoc ms = new Integer JavaDoc(m).toString();
44         if(m<10) ms = "0"+ms;
45         int s = i%60;
46         String JavaDoc ss = new Integer JavaDoc(s).toString();
47         if(s<10) ss = "0"+ss;
48         return hs+":"+ms+":"+ss;
49     }
50     
51 }
52
Popular Tags