Skip to main content
aboutsummaryrefslogtreecommitdiffstats
blob: e53bb99fb3e9164ac1cb0f1d833c8e06c47263b9 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
/*******************************************************************************
 * Copyright (c) 2006 IBM Corporation and others.
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 * 
 * Contributors:
 *     IBM Corporation - initial API and implementation
 *******************************************************************************/
package org.eclipse.core.internal.registry;

/**
 * Aggregated registry timestamp. Corresponds to the current contents of the registry.
 * <p>
 * This class may be instantiated.
 * </p><p>
 * This class is not indended to be subclassed.
 * </p>
 * @since org.eclipse.equinox.registry 3.3
 */
public final class RegistryTimestamp {
	/**
	 * Current aggregated timestamp
	 */
	private long aggregateTimestamp;

	private boolean modified;

	/**
	 * Public constructor.
	 */
	public RegistryTimestamp() {
		reset();
	}

	/**
	 * Returns value of the aggregated timestamp.
	 * @return value of the aggregated timestamp
	 */
	public long getContentsTimestamp() {
		return aggregateTimestamp;
	}

	/**
	 * Set value of the aggregated timestamp.
	 * @param timestamp the aggregated timestamp of the current registry contents 
	 */
	public void set(long timestamp) {
		aggregateTimestamp = timestamp;
		modified = false;
	}

	/**
	 * Sets aggregated timestamp to the value corresponding to an empty registry.
	 */
	public void reset() {
		aggregateTimestamp = 0;
		modified = false;
	}

	/**
	 * Determines if the aggregate timestamp was modified using add() or remove()
	 * methods.
	 * @return true: the timestamp was modified after the last set/reset 
	 */
	public boolean isModifed() {
		return modified;
	}

	/**
	 * Add individual contribution timestamp to the aggregated timestamp. 
	 * @param timestamp the time stamp of the contribution being added to the registry
	 */
	public void add(long timestamp) {
		aggregateTimestamp ^= timestamp;
		modified = true;
	}

	/**
	 * Remove individual contribution timestamp from the aggregated timestamp.
	 * @param timestamp the time stamp of the contribution being removed from the registry
	 */
	public void remove(long timestamp) {
		aggregateTimestamp ^= timestamp;
		modified = true;
	}
}

Back to the top