01: /*
02: * Licensed to the Apache Software Foundation (ASF) under one
03: * or more contributor license agreements. See the NOTICE file
04: * distributed with this work for additional information
05: * regarding copyright ownership. The ASF licenses this file
06: * to you under the Apache License, Version 2.0 (the
07: * "License"); you may not use this file except in compliance
08: * with the License. You may obtain a copy of the License at
09: *
10: * http://www.apache.org/licenses/LICENSE-2.0
11: *
12: * Unless required by applicable law or agreed to in writing,
13: * software distributed under the License is distributed on an
14: * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15: * KIND, either express or implied. See the License for the
16: * specific language governing permissions and limitations
17: * under the License.
18: */
19: package org.apache.openjpa.persistence;
20:
21: import org.apache.openjpa.kernel.DelegatingSeq;
22: import org.apache.openjpa.kernel.Seq;
23: import org.apache.openjpa.kernel.StoreContext;
24: import org.apache.openjpa.meta.ClassMetaData;
25:
26: /**
27: * Represents a store sequence.
28: *
29: * @author Abe White
30: * @since 0.4.1
31: * @nojavadoc
32: */
33: public class GeneratorImpl implements Generator {
34:
35: private final DelegatingSeq _seq;
36: private final String _name;
37: private final StoreContext _ctx;
38: private final ClassMetaData _meta;
39:
40: /**
41: * Constructor; supply delegate.
42: */
43: public GeneratorImpl(Seq seq, String name, StoreContext ctx,
44: ClassMetaData meta) {
45: _seq = new DelegatingSeq(seq, PersistenceExceptions.TRANSLATOR);
46: _name = name;
47: _ctx = ctx;
48: _meta = meta;
49: }
50:
51: /**
52: * Delegate.
53: */
54: public Seq getDelegate() {
55: return _seq.getDelegate();
56: }
57:
58: public String getName() {
59: return _name;
60: }
61:
62: public Object next() {
63: return _seq.next(_ctx, _meta);
64: }
65:
66: public Object current() {
67: return _seq.current(_ctx, _meta);
68: }
69:
70: public void allocate(int additional) {
71: _seq.allocate(additional, _ctx, _meta);
72: }
73:
74: public int hashCode() {
75: return _seq.hashCode();
76: }
77:
78: public boolean equals(Object other) {
79: if (other == this )
80: return true;
81: if (!(other instanceof GeneratorImpl))
82: return false;
83: return _seq.equals(((GeneratorImpl) other)._seq);
84: }
85: }
|