1 /*
2 Copyright (c) 2013 James Ahlborn
3
4 Licensed under the Apache License, Version 2.0 (the "License");
5 you may not use this file except in compliance with the License.
6 You may obtain a copy of the License at
7
8 http://www.apache.org/licenses/LICENSE-2.0
9
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 com.healthmarketscience.jackcess;
18
19 import java.math.BigDecimal;
20 import java.time.LocalDateTime;
21 import java.util.Date;
22 import java.util.Map;
23
24 import com.healthmarketscience.jackcess.complex.ComplexValueForeignKey;
25 import com.healthmarketscience.jackcess.util.OleBlob;
26
27
28 /**
29 * A row of data as column name->value pairs. Values are strongly typed, and
30 * column names are case sensitive.
31 *
32 * @author James Ahlborn
33 * @usage _general_class_
34 */
35 public interface Row extends Map<String,Object>
36 {
37 /**
38 * @return the id of this row
39 */
40 public RowId getId();
41
42 /**
43 * Convenience method which gets the value for the row with the given name,
44 * casting it to a String (DataTypes TEXT, MEMO, GUID).
45 */
46 public String getString(String name);
47
48 /**
49 * Convenience method which gets the value for the row with the given name,
50 * casting it to a Boolean (DataType BOOLEAN).
51 */
52 public Boolean getBoolean(String name);
53
54 /**
55 * Convenience method which gets the value for the row with the given name,
56 * casting it to a Byte (DataType BYTE).
57 */
58 public Byte getByte(String name);
59
60 /**
61 * Convenience method which gets the value for the row with the given name,
62 * casting it to a Short (DataType INT).
63 */
64 public Short getShort(String name);
65
66 /**
67 * Convenience method which gets the value for the row with the given name,
68 * casting it to a Integer (DataType LONG).
69 */
70 public Integer getInt(String name);
71
72 /**
73 * Convenience method which gets the value for the row with the given name,
74 * casting it to a BigDecimal (DataTypes MONEY, NUMERIC).
75 */
76 public BigDecimal getBigDecimal(String name);
77
78 /**
79 * Convenience method which gets the value for the row with the given name,
80 * casting it to a Float (DataType FLOAT).
81 */
82 public Float getFloat(String name);
83
84 /**
85 * Convenience method which gets the value for the row with the given name,
86 * casting it to a Double (DataType DOUBLE).
87 */
88 public Double getDouble(String name);
89
90 /**
91 * Convenience method which gets the value for the row with the given name,
92 * casting it to a Date (DataType SHORT_DATE_TIME).
93 * @deprecated this is only valid for Database instances configured for the
94 * legacy {@link DateTimeType#DATE}. Prefer using
95 * {@link DateTimeType#LOCAL_DATE_TIME} and the corresponding
96 * {@link #getLocalDateTime} method. Using Date is being phased
97 * out and will eventually be removed.
98 */
99 @Deprecated
100 public Date getDate(String name);
101
102 /**
103 * Convenience method which gets the value for the row with the given name,
104 * casting it to a LocalDateTime (DataType SHORT_DATE_TIME or
105 * EXT_DATE_TIME). This method will only work for Database instances
106 * configured for {@link DateTimeType#LOCAL_DATE_TIME}.
107 */
108 public LocalDateTime getLocalDateTime(String name);
109
110 /**
111 * Convenience method which gets the value for the row with the given name,
112 * casting it to a byte[] (DataTypes BINARY, OLE).
113 */
114 public byte[] getBytes(String name);
115
116 /**
117 * Convenience method which gets the value for the row with the given name,
118 * casting it to a {@link ComplexValueForeignKey} (DataType COMPLEX_TYPE).
119 */
120 public ComplexValueForeignKey getForeignKey(String name);
121
122 /**
123 * Convenience method which gets the value for the row with the given name,
124 * converting it to an {@link OleBlob} (DataTypes OLE).
125 * <p>
126 * Note, <i>the OleBlob should be closed after use</i>.
127 */
128 public OleBlob getBlob(String name);
129 }