01: /*
02: * Copyright 2004-2006 the original author or authors.
03: *
04: * Licensed under the Apache License, Version 2.0 (the "License");
05: * you may not use this file except in compliance with the License.
06: * You may obtain a copy of the License at
07: *
08: * http://www.apache.org/licenses/LICENSE-2.0
09: *
10: * Unless required by applicable law or agreed to in writing, software
11: * distributed under the License is distributed on an "AS IS" BASIS,
12: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13: * See the License for the specific language governing permissions and
14: * limitations under the License.
15: */
16:
17: package org.compass.gps.device.jdbc.snapshot;
18:
19: import java.io.Serializable;
20: import java.util.HashMap;
21: import java.util.Iterator;
22:
23: /**
24: * An alias (usually <code>ResultSet</code>) level snapshot. Holds a
25: * collection of
26: * {@link org.compass.gps.device.jdbc.snapshot.JdbcAliasRowSnapshot}s.
27: *
28: * @author kimchy
29: */
30: public class JdbcAliasSnapshot implements Serializable {
31:
32: private static final long serialVersionUID = 8610812620723482815L;
33:
34: private String alias;
35:
36: private HashMap rowEntries = new HashMap();
37:
38: public JdbcAliasSnapshot(String alias) {
39: this .alias = alias;
40: }
41:
42: public String getAlias() {
43: return alias;
44: }
45:
46: public void setAlias(String alias) {
47: this .alias = alias;
48: }
49:
50: public void putRow(JdbcAliasRowSnapshot rowSnapshot) {
51: this .rowEntries.put(rowSnapshot, rowSnapshot);
52: }
53:
54: public JdbcAliasRowSnapshot getRow(JdbcAliasRowSnapshot rowSnapshot) {
55: return (JdbcAliasRowSnapshot) this .rowEntries.get(rowSnapshot);
56: }
57:
58: public Iterator rowSnapshotIt() {
59: return this .rowEntries.values().iterator();
60: }
61:
62: public String toString() {
63: StringBuffer sb = new StringBuffer();
64: sb.append("alias [" + alias + "]");
65: for (Iterator it = rowEntries.values().iterator(); it.hasNext();) {
66: sb.append(it.next());
67: sb.append(", ");
68: }
69: return sb.toString();
70: }
71: }
|