1 /* -*- Mode: Java; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
20 import com
.sun
.star
.beans
.XPropertySet
;
21 import com
.sun
.star
.container
.XIndexAccess
;
22 import com
.sun
.star
.container
.XNameAccess
;
23 import com
.sun
.star
.io
.XInputStream
;
24 import com
.sun
.star
.sdbc
.SQLException
;
25 import com
.sun
.star
.sdbc
.XArray
;
26 import com
.sun
.star
.sdbc
.XBlob
;
27 import com
.sun
.star
.sdbc
.XClob
;
28 import com
.sun
.star
.sdbc
.XRef
;
29 import com
.sun
.star
.sdbc
.XRow
;
30 import com
.sun
.star
.sdbc
.XRowSet
;
31 import com
.sun
.star
.sdbc
.XRowSetListener
;
32 import com
.sun
.star
.sdbcx
.XColumnsSupplier
;
33 import com
.sun
.star
.uno
.UnoRuntime
;
34 import com
.sun
.star
.uno
.XComponentContext
;
35 import com
.sun
.star
.util
.Date
;
36 import com
.sun
.star
.util
.DateTime
;
37 import com
.sun
.star
.util
.Time
;
39 public class RowSet
implements XRowSet
, XRow
41 private XRowSet m_rowSet
;
43 private XPropertySet m_rowSetProps
;
45 public RowSet( XComponentContext _context
, String _dataSource
, int _commandType
, String _command
)
49 m_rowSetProps
= UnoRuntime
.queryInterface(
50 XPropertySet
.class, _context
.getServiceManager().createInstanceWithContext( "com.sun.star.sdb.RowSet", _context
) );
51 m_rowSetProps
.setPropertyValue( "DataSourceName", _dataSource
);
52 m_rowSetProps
.setPropertyValue( "CommandType", Integer
.valueOf( _commandType
) );
53 m_rowSetProps
.setPropertyValue( "Command", _command
);
55 m_rowSet
= UnoRuntime
.queryInterface( XRowSet
.class, m_rowSetProps
);
56 m_row
= UnoRuntime
.queryInterface( XRow
.class, m_rowSetProps
);
60 e
.printStackTrace(System
.err
);
61 throw new java
.lang
.InstantiationError();
66 public int getColumnCount()
68 XColumnsSupplier suppCols
= UnoRuntime
.queryInterface(
69 XColumnsSupplier
.class, m_rowSet
);
70 XIndexAccess columns
= UnoRuntime
.queryInterface(
71 XIndexAccess
.class, suppCols
.getColumns() );
72 return columns
.getCount();
76 public void execute() throws SQLException
81 public void addRowSetListener( XRowSetListener _listener
)
83 m_rowSet
.addRowSetListener( _listener
);
86 public void removeRowSetListener( XRowSetListener _listener
)
88 m_rowSet
.removeRowSetListener( _listener
);
91 public boolean next() throws SQLException
93 return m_rowSet
.next();
96 public boolean isBeforeFirst() throws SQLException
98 return m_rowSet
.isBeforeFirst();
101 public boolean isAfterLast() throws SQLException
103 return m_rowSet
.isAfterLast();
106 public boolean isFirst() throws SQLException
108 return m_rowSet
.isFirst();
111 public boolean isLast() throws SQLException
113 return m_rowSet
.isLast();
116 public void beforeFirst() throws SQLException
118 m_rowSet
.beforeFirst();
121 public void afterLast() throws SQLException
123 m_rowSet
.afterLast();
126 public boolean first() throws SQLException
128 return m_rowSet
.first();
131 public boolean last() throws SQLException
133 return m_rowSet
.last();
136 public int getRow() throws SQLException
138 return m_rowSet
.getRow();
141 public boolean absolute(int i
) throws SQLException
143 return m_rowSet
.absolute(i
);
146 public boolean relative(int i
) throws SQLException
148 return m_rowSet
.relative(i
);
151 public boolean previous() throws SQLException
153 return m_rowSet
.previous();
156 public void refreshRow() throws SQLException
158 m_rowSet
.refreshRow();
161 public boolean rowUpdated() throws SQLException
163 return m_rowSet
.rowUpdated();
166 public boolean rowInserted() throws SQLException
168 return m_rowSet
.rowInserted();
171 public boolean rowDeleted() throws SQLException
173 return m_rowSet
.rowDeleted();
177 public Object
getStatement() throws SQLException
179 return m_rowSet
.getStatement();
182 public boolean wasNull() throws SQLException
184 return m_row
.wasNull();
187 public String
getString(int i
) throws SQLException
189 return m_row
.getString(i
);
192 public boolean getBoolean(int i
) throws SQLException
194 return m_row
.getBoolean(i
);
197 public byte getByte(int i
) throws SQLException
199 return m_row
.getByte(i
);
202 public short getShort(int i
) throws SQLException
204 return m_row
.getShort(i
);
207 public int getInt(int i
) throws SQLException
209 return m_row
.getInt(i
);
212 public long getLong(int i
) throws SQLException
214 return m_row
.getLong(i
);
217 public float getFloat(int i
) throws SQLException
219 return m_row
.getFloat(i
);
222 public double getDouble(int i
) throws SQLException
224 return m_row
.getDouble(i
);
227 public byte[] getBytes(int i
) throws SQLException
229 return m_row
.getBytes(i
);
232 public Date
getDate(int i
) throws SQLException
234 return m_row
.getDate(i
);
237 public Time
getTime(int i
) throws SQLException
239 return m_row
.getTime(i
);
242 public DateTime
getTimestamp(int i
) throws SQLException
244 return m_row
.getTimestamp(i
);
247 public XInputStream
getBinaryStream(int i
) throws SQLException
249 return m_row
.getBinaryStream(i
);
252 public XInputStream
getCharacterStream(int i
) throws SQLException
254 return m_row
.getCharacterStream(i
);
257 public Object
getObject(int i
, XNameAccess xNameAccess
) throws SQLException
259 return m_row
.getObject(i
, xNameAccess
);
262 public XRef
getRef(int i
) throws SQLException
264 return m_row
.getRef(i
);
267 public XBlob
getBlob(int i
) throws SQLException
269 return m_row
.getBlob(i
);
272 public XClob
getClob(int i
) throws SQLException
274 return m_row
.getClob(i
);
277 public XArray
getArray(int i
) throws SQLException
279 return m_row
.getArray(i
);
283 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */