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