1 23 24 package org.objectweb.clif.storage.api; 25 26 import org.objectweb.clif.storage.api.BladeEvent; 27 import java.util.Map ; 28 import java.util.HashMap ; 29 30 39 abstract public class AbstractEvent implements BladeEvent 40 { 41 static private Map eventFieldLabels = new HashMap (); 42 43 44 54 static protected synchronized void registerEventFieldLabels( 55 String event_label, 56 String [] field_labels) 57 { 58 if (! eventFieldLabels.containsKey(event_label)) 59 { 60 eventFieldLabels.put(event_label, field_labels); 61 } 62 else 63 { 64 throw new Error ("Duplicate event type label declaration for " + event_label); 65 } 66 } 67 68 69 74 static public String [] getEventFieldLabels(String event_label) 75 { 76 return (String [])eventFieldLabels.get(event_label); 77 } 78 79 80 protected long date; 81 protected String bladeId; 82 83 84 public AbstractEvent() 85 { 86 this(System.currentTimeMillis(), null); 87 } 88 89 90 public AbstractEvent(long date, String bladeId) 91 { 92 this.date = date; 93 this.bladeId = bladeId; 94 } 95 96 97 public long getDate() 98 { 99 return date; 100 } 101 102 103 public void setDate(long date) 104 { 105 this.date = date; 106 } 107 108 109 public String getBladeId() 110 { 111 return bladeId; 112 } 113 114 115 public void setBladeId(String newId) 116 { 117 this.bladeId = newId; 118 } 119 120 121 125 126 130 public int compareTo(Object obj) 131 throws ClassCastException 132 { 133 int diff = (int)(date - ((BladeEvent)obj).getDate()); 134 return diff == 0 ? hashCode() - obj.hashCode() : diff; 135 } 136 } 137 | Popular Tags |