01: // ResourceStoreState.java
02: // $Id: ResourceStoreState.java,v 1.3 2000/08/16 21:37:55 ylafon Exp $
03: // (c) COPYRIGHT MIT and INRIA, 1996.
04: // Please first read the full copyright statement in file COPYRIGHT.html
05:
06: package org.w3c.tools.resources.store;
07:
08: import org.w3c.tools.resources.Attribute;
09: import org.w3c.tools.resources.AttributeHolder;
10: import org.w3c.tools.resources.AttributeRegistry;
11: import org.w3c.tools.resources.IntegerAttribute;
12:
13: public class ResourceStoreState extends AttributeHolder {
14: protected static int ATTR_RSKEY = -1;
15:
16: static {
17: Attribute a = null;
18: Class c = null;
19: try {
20: c = Class
21: .forName("org.w3c.tools.resources.store.ResourceStoreState");
22: } catch (Error er) {
23: er.printStackTrace();
24: } catch (Exception ex) {
25: ex.printStackTrace();
26: System.exit(1);
27: }
28: // The rskey attribute:
29: a = new IntegerAttribute("rskey", new Integer(0),
30: Attribute.COMPUTED);
31: ATTR_RSKEY = AttributeRegistry.registerAttribute(c, a);
32: }
33:
34: public synchronized int getNextKey() {
35: int rskey = getInt(ATTR_RSKEY, 0);
36: setInt(ATTR_RSKEY, rskey + 1);
37: return rskey;
38: }
39:
40: public synchronized int getCurrentKey() {
41: return getInt(ATTR_RSKEY, 0);
42: }
43:
44: public ResourceStoreState() {
45: this (0);
46: }
47:
48: public ResourceStoreState(int id) {
49: super ();
50: setValue(ATTR_RSKEY, new Integer(id));
51: }
52: }
|