KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > core > internal > registry > RegistryTimestamp


1 /*******************************************************************************
2  * Copyright (c) 2006 IBM Corporation and others.
3  * All rights reserved. This program and the accompanying materials
4  * are made available under the terms of the Eclipse Public License v1.0
5  * which accompanies this distribution, and is available at
6  * http://www.eclipse.org/legal/epl-v10.html
7  *
8  * Contributors:
9  * IBM Corporation - initial API and implementation
10  *******************************************************************************/

11 package org.eclipse.core.internal.registry;
12
13 /**
14  * Aggregated registry timestamp. Corresponds to the current contents of the registry.
15  * <p>
16  * This class may be instantiated.
17  * </p><p>
18  * This class is not indended to be subclassed.
19  * </p>
20  * @since org.eclipse.equinox.registry 3.3
21  */

22 public final class RegistryTimestamp {
23     /**
24      * Current aggregated timestamp
25      */

26     private long aggregateTimestamp;
27
28     private boolean modified;
29
30     /**
31      * Public constructor.
32      */

33     public RegistryTimestamp() {
34         reset();
35     }
36
37     /**
38      * Returns value of the aggregated timestamp.
39      * @return value of the aggregated timestamp
40      */

41     public long getContentsTimestamp() {
42         return aggregateTimestamp;
43     }
44
45     /**
46      * Set value of the aggregated timestamp.
47      * @param timestamp the aggregated timestamp of the current registry contents
48      */

49     public void set(long timestamp) {
50         aggregateTimestamp = timestamp;
51         modified = false;
52     }
53
54     /**
55      * Sets aggregated timestamp to the value corresponding to an empty registry.
56      */

57     public void reset() {
58         aggregateTimestamp = 0;
59         modified = false;
60     }
61
62     /**
63      * Determines if the aggregate timestamp was modified using add() or remove()
64      * methods.
65      * @return true: the timestamp was modified after the last set/reset
66      */

67     public boolean isModifed() {
68         return modified;
69     }
70
71     /**
72      * Add individual contribution timestamp to the aggregated timestamp.
73      * @param timestamp the time stamp of the contribution being added to the registry
74      */

75     public void add(long timestamp) {
76         aggregateTimestamp ^= timestamp;
77         modified = true;
78     }
79
80     /**
81      * Remove individual contribution timestamp from the aggregated timestamp.
82      * @param timestamp the time stamp of the contribution being removed from the registry
83      */

84     public void remove(long timestamp) {
85         aggregateTimestamp ^= timestamp;
86         modified = true;
87     }
88 }
89
Popular Tags