blob: fbd2a4a2e5733fc2e9ee41f98c16c3d1ff26b7fd [file] [log] [blame]
Umesh Krishnaswamy345ee992012-12-13 20:29:48 -08001/**
2* Copyright 2011, Big Switch Networks, Inc.
3* Originally created by David Erickson, Stanford University
4*
5* Licensed under the Apache License, Version 2.0 (the "License"); you may
6* not use this file except in compliance with the License. You may obtain
7* a copy of the License at
8*
9* http://www.apache.org/licenses/LICENSE-2.0
10*
11* Unless required by applicable law or agreed to in writing, software
12* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
13* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
14* License for the specific language governing permissions and limitations
15* under the License.
16**/
17
18package net.floodlightcontroller.storage;
19
20import java.util.Date;
21import java.util.Map;
22
23/** Interface to iterate over the results from a storage query.
24 *
25 * @author rob
26 *
27 */
28public interface IResultSet extends Iterable<IResultSet> {
29
30 /** This should be called when the client is done using the result set.
31 * This will release any underlying resources (e.g. a database connection),
32 * which you don't want to wait for or rely on finalizers to release.
33 */
34 public void close();
35
36 /** Advance to the next row in the result set.
37 * @return Returns true if there are more rows to process
38 * (i.e. if there's a valid current row) and false if there are no more
39 * rows in the result set.
40 */
41 public boolean next();
42
43 /** Save/commit any pending updates to the data in the result set.
44 * This must be called after any calls to the set methods or deleting rows
45 * for the changes to be applied/committed to the storage source. Note that
46 * this doesn't need to be called after each set method or even after each
47 * row. It is typically called at the end after updating all of the
48 * rows in the result set.
49 */
50 public void save();
51
52 /** Get the current row in the result set. This returns all of the
53 * columns in the current row.
54 * @return Map containing all of the columns in the current row, indexed
55 * by the column name.
56 */
57 public Map<String,Object> getRow();
58
59 /** Delete the current row in the result set.
60 */
61 public void deleteRow();
62
63 public boolean containsColumn(String columnName);
64
65 public String getString(String columnName);
66 public short getShort(String columnName);
67 public int getInt(String columnName);
68 public long getLong(String columnName);
69 public float getFloat(String columnName);
70 public double getDouble(String columnName);
71 public boolean getBoolean(String columnName);
72 public byte getByte(String columnName);
73 public byte[] getByteArray(String columnName);
74 public Date getDate(String columnName);
75
76 public Short getShortObject(String columnName);
77 public Integer getIntegerObject(String columnName);
78 public Long getLongObject(String columnName);
79 public Float getFloatObject(String columnName);
80 public Double getDoubleObject(String columnName);
81 public Boolean getBooleanObject(String columnName);
82 public Byte getByteObject(String columnName);
83
84 public boolean isNull(String columnName);
85
86 public void setString(String columnName, String value);
87 public void setShort(String columnName, short value);
88 public void setInt(String columnName, int value);
89 public void setLong(String columnName, long value);
90 public void setFloat(String columnName, float value);
91 public void setDouble(String columnName, double value);
92 public void setBoolean(String columnName, boolean value);
93 public void setByte(String columnName, byte value);
94 public void setByteArray(String columnName, byte[] byteArray);
95 public void setDate(String columnName, Date date);
96
97 public void setShortObject(String columnName, Short value);
98 public void setIntegerObject(String columnName, Integer value);
99 public void setLongObject(String columnName, Long value);
100 public void setFloatObject(String columnName, Float value);
101 public void setDoubleObject(String columnName, Double value);
102 public void setBooleanObject(String columnName, Boolean value);
103 public void setByteObject(String columnName, Byte value);
104
105 public void setNull(String columnName);
106}