01: /**********************************************************************
02: Copyright (c) 2005 Andy Jefferson and others. All rights reserved.
03: Licensed under the Apache License, Version 2.0 (the "License");
04: you may not use this file except in compliance with the License.
05: You may obtain a copy of the License at
06:
07: http://www.apache.org/licenses/LICENSE-2.0
08:
09: Unless required by applicable law or agreed to in writing, software
10: distributed under the License is distributed on an "AS IS" BASIS,
11: WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12: See the License for the specific language governing permissions and
13: limitations under the License.
14:
15:
16: Contributors:
17: ...
18: **********************************************************************/package org.jpox.util;
19:
20: import javax.jdo.datastore.Sequence;
21:
22: /**
23: * Simple implementation of a sequence that counts from 0 and increments
24: * by 1 every time. Allocation is not necessary because it increments
25: * a long value internally.
26: *
27: * @version $Revision: 1.3 $
28: */
29: public class SimpleSequence implements Sequence {
30: String name;
31: long current = 0;
32:
33: public SimpleSequence(String name) {
34: this .name = name;
35: }
36:
37: /**
38: *
39: * @see javax.jdo.datastore.Sequence#getName()
40: */
41: public String getName() {
42: return name;
43: }
44:
45: /**
46: *
47: * @see javax.jdo.datastore.Sequence#next()
48: */
49: public Object next() {
50: current++;
51: return new Long(current);
52: }
53:
54: /**
55: *
56: * @see javax.jdo.datastore.Sequence#nextValue()
57: */
58: public long nextValue() {
59: current++;
60: return current;
61: }
62:
63: /**
64: *
65: * @see javax.jdo.datastore.Sequence#allocate(int)
66: */
67: public void allocate(int arg0) {
68: }
69:
70: /**
71: *
72: * @see javax.jdo.datastore.Sequence#current()
73: */
74: public Object current() {
75: return new Long(current);
76: }
77:
78: /**
79: *
80: * @see javax.jdo.datastore.Sequence#currentValue()
81: */
82: public long currentValue() {
83: return current;
84: }
85: }
|