01: /*
02: * <copyright>
03: *
04: * Copyright 1997-2004 BBNT Solutions, LLC
05: * under sponsorship of the Defense Advanced Research Projects
06: * Agency (DARPA).
07: *
08: * You can redistribute this software and/or modify it under the
09: * terms of the Cougaar Open Source License as published on the
10: * Cougaar Open Source Website (www.cougaar.org).
11: *
12: * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
13: * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
14: * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
15: * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
16: * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
17: * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
18: * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
19: * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
20: * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
21: * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
22: * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
23: *
24: * </copyright>
25: */
26:
27: package org.cougaar.core.blackboard;
28:
29: /**
30: * The creation time and most recent modification time for a
31: * {@link org.cougaar.core.util.UniqueObject} on the blackboard.
32: * <p>
33: * This class is immutable.
34: *
35: * @see TimestampSubscription
36: */
37: public final class TimestampEntry implements java.io.Serializable {
38:
39: /**
40: * The "unknown time" is used when the time was not
41: * recorded.
42: */
43: public static final long UNKNOWN_TIME = -1;
44:
45: private long creationTime;
46: private final long lastModTime;
47:
48: public TimestampEntry(long creationTime, long lastModTime) {
49: this .creationTime = creationTime;
50: this .lastModTime = lastModTime;
51: }
52:
53: /**
54: * Get the creation time.
55: */
56: public long getCreationTime() {
57: return creationTime;
58: }
59:
60: /**
61: * Get the most recent modification time, or the creation
62: * time if the object has never been modified.
63: */
64: public long getModificationTime() {
65: return lastModTime;
66: }
67:
68: /**
69: * Package-private modifier for the creation time -- for
70: * infrastructure use only!.
71: * <p>
72: * This is only used before the instance is released
73: * to the clients, after which the instance is no longer
74: * modified and presents an immutable API.
75: */
76: void private_setCreationTime(long creationTime) {
77: this .creationTime = creationTime;
78: }
79:
80: public String toString() {
81: return "(" + creationTime + " + "
82: + (lastModTime - creationTime) + ")";
83: }
84:
85: private static final long serialVersionUID = -1209831829038126385L;
86: }
|