summaryrefslogtreecommitdiff
path: root/connectivity/com/sun/star/sdbcx/comp
diff options
context:
space:
mode:
Diffstat (limited to 'connectivity/com/sun/star/sdbcx/comp')
-rw-r--r--connectivity/com/sun/star/sdbcx/comp/hsqldb/FileSystemRuntimeException.java73
-rw-r--r--connectivity/com/sun/star/sdbcx/comp/hsqldb/NativeInputStreamHelper.java74
-rw-r--r--connectivity/com/sun/star/sdbcx/comp/hsqldb/NativeLibraries.java80
-rw-r--r--connectivity/com/sun/star/sdbcx/comp/hsqldb/NativeOutputStreamHelper.java48
-rw-r--r--connectivity/com/sun/star/sdbcx/comp/hsqldb/NativeStorageAccess.java80
-rw-r--r--connectivity/com/sun/star/sdbcx/comp/hsqldb/StorageAccess.java171
-rw-r--r--connectivity/com/sun/star/sdbcx/comp/hsqldb/StorageFileAccess.java107
-rw-r--r--connectivity/com/sun/star/sdbcx/comp/hsqldb/StorageNativeInputStream.java53
-rw-r--r--connectivity/com/sun/star/sdbcx/comp/hsqldb/StorageNativeOutputStream.java143
-rw-r--r--connectivity/com/sun/star/sdbcx/comp/hsqldb/makefile.mk65
10 files changed, 894 insertions, 0 deletions
diff --git a/connectivity/com/sun/star/sdbcx/comp/hsqldb/FileSystemRuntimeException.java b/connectivity/com/sun/star/sdbcx/comp/hsqldb/FileSystemRuntimeException.java
new file mode 100644
index 000000000000..af8bced79837
--- /dev/null
+++ b/connectivity/com/sun/star/sdbcx/comp/hsqldb/FileSystemRuntimeException.java
@@ -0,0 +1,73 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+
+// NOTE:
+// This class does not yet exist before 1.8.0.8. When we move our shipped
+// version to 1.8.0.8 or higher, this file here can be removed from CVS.
+
+package org.hsqldb.lib;
+
+/** is a RuntimeException which indicates failure during basic IO
+ * operations in a FileAccess implementation.
+ *
+ * @author frank.schoenheit@sun.com
+ *
+ * @version 1.8.0.8
+ * @since 1.8.0.8
+ */
+public class FileSystemRuntimeException extends java.lang.RuntimeException {
+
+ public static final int fileAccessRemoveElementFailed = 1;
+ public static final int fileAccessRenameElementFailed = 2;
+
+ private final int errorCode;
+
+ public FileSystemRuntimeException(int _errorCode) {
+ super();
+ errorCode = _errorCode;
+ }
+
+ public FileSystemRuntimeException(String _message, int _errorCode) {
+ super(_message);
+ errorCode = _errorCode;
+ }
+
+ public FileSystemRuntimeException(String _message, java.lang.Throwable _cause, int _errorCode) {
+ super(_message, _cause);
+ errorCode = _errorCode;
+ }
+
+ public FileSystemRuntimeException(java.lang.Throwable _cause, int _errorCode) {
+ super(_cause);
+ errorCode = _errorCode;
+ }
+
+ public final int getErrorCode() {
+ return errorCode;
+ }
+} \ No newline at end of file
diff --git a/connectivity/com/sun/star/sdbcx/comp/hsqldb/NativeInputStreamHelper.java b/connectivity/com/sun/star/sdbcx/comp/hsqldb/NativeInputStreamHelper.java
new file mode 100644
index 000000000000..fa14c7f5649a
--- /dev/null
+++ b/connectivity/com/sun/star/sdbcx/comp/hsqldb/NativeInputStreamHelper.java
@@ -0,0 +1,74 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+ /*
+ * NativeInputStreamHelper.java
+ *
+ * Created on 9. September 2004, 11:51
+ */
+
+package com.sun.star.sdbcx.comp.hsqldb;
+
+/**
+ *
+ * @author Ocke
+ */
+public class NativeInputStreamHelper extends java.io.InputStream{
+ private String key;
+ private String file;
+ private StorageNativeInputStream in;
+ /** Creates a new instance of NativeInputStreamHelper */
+ public NativeInputStreamHelper(String key,String _file) {
+ file = _file;
+ this.key = key;
+ in = new StorageNativeInputStream(key,file);
+ }
+
+ public int read() throws java.io.IOException {
+ return in.read(key,file);
+ }
+
+ public int read(byte[] b, int off, int len) throws java.io.IOException {
+ return in.read(key,file,b,off,len);
+ }
+
+ public void close() throws java.io.IOException {
+ in.close(key,file);
+ }
+
+ public long skip(long n) throws java.io.IOException {
+ return in.skip(key,file,n);
+ }
+
+ public int available() throws java.io.IOException {
+ return in.available(key,file);
+ }
+
+ public int read(byte[] b) throws java.io.IOException {
+ return in.read(key,file,b);
+ }
+
+}
diff --git a/connectivity/com/sun/star/sdbcx/comp/hsqldb/NativeLibraries.java b/connectivity/com/sun/star/sdbcx/comp/hsqldb/NativeLibraries.java
new file mode 100644
index 000000000000..451dc6b1e325
--- /dev/null
+++ b/connectivity/com/sun/star/sdbcx/comp/hsqldb/NativeLibraries.java
@@ -0,0 +1,80 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+package com.sun.star.sdbcx.comp.hsqldb;
+
+import java.io.File;
+import java.net.URL;
+import java.net.URLClassLoader;
+
+final class NativeLibraries {
+ public static void load() {
+ if (System.getProperty( "os.name" ).startsWith("Windows")) {
+ loadLibrary("msvcr71");
+ loadLibrary("uwinapi");
+ loadLibrary("sal3");
+ loadLibrary("dbtoolsmi");
+ }
+ loadLibrary("hsqldb");
+ }
+
+ private static void loadLibrary(String libname) {
+ // At least on Mac OS X Tiger, System.loadLibrary("hsqldb2") does not
+ // find the hsqldb2 library one directory above sdbc_hsqldb.jar, even
+ // though ".." is on the jar's Class-Path; however, the alternative
+ // code (needing Java 1.5, which is given for Mac OS X Tiger) works
+ // there:
+ try {
+ System.loadLibrary(libname);
+ } catch (UnsatisfiedLinkError e) {
+ ClassLoader cl = NativeLibraries.class.getClassLoader();
+ if (cl instanceof URLClassLoader) {
+ URL url = ((URLClassLoader) cl).findResource(
+ System.mapLibraryName(libname));
+ if (url != null) {
+ try {
+ System.load(
+ ((File) File.class.getConstructor(
+ new Class[] {
+ ClassLoader.getSystemClassLoader().
+ loadClass("java.net.URI") }).
+ newInstance(
+ new Object[] {
+ URL.class.getMethod("toURI", new Class[0]).
+ invoke(url, (java.lang.Object[])null) })).
+ getAbsolutePath());
+ } catch (Throwable t) {
+ throw new UnsatisfiedLinkError(
+ e.toString()+ " - " + t.toString());
+ }
+ }
+ }
+ }
+ }
+
+ private NativeLibraries() {}
+}
diff --git a/connectivity/com/sun/star/sdbcx/comp/hsqldb/NativeOutputStreamHelper.java b/connectivity/com/sun/star/sdbcx/comp/hsqldb/NativeOutputStreamHelper.java
new file mode 100644
index 000000000000..cc4faaa3cedf
--- /dev/null
+++ b/connectivity/com/sun/star/sdbcx/comp/hsqldb/NativeOutputStreamHelper.java
@@ -0,0 +1,48 @@
+/*
+ * NativeOutputStreamHelper.java
+ *
+ * Created on 1. September 2004, 10:39
+ */
+
+package com.sun.star.sdbcx.comp.hsqldb;
+
+/**
+ *
+ * @author oj93728
+ */
+public class NativeOutputStreamHelper extends java.io.OutputStream{
+
+ private String key;
+ private String file;
+ private StorageNativeOutputStream out;
+ /** Creates a new instance of NativeOutputStreamHelper */
+ public NativeOutputStreamHelper(String key,String _file) {
+ file = _file;
+ this.key = key;
+ out = new StorageNativeOutputStream(file,key);
+ }
+
+ public void write(byte[] b, int off, int len) throws java.io.IOException{
+ out.write(key,file,b, off, len);
+ }
+
+ public void write(byte[] b) throws java.io.IOException{
+ out.write(key,file,b);
+ }
+
+ public void close() throws java.io.IOException{
+ out.close(key,file);
+ }
+
+ public void write(int b) throws java.io.IOException{
+ out.write(key,file,b);
+ }
+
+ public void flush() throws java.io.IOException{
+ out.flush(key,file);
+ }
+
+ public void sync() throws java.io.IOException{
+ out.sync(key,file);
+ }
+}
diff --git a/connectivity/com/sun/star/sdbcx/comp/hsqldb/NativeStorageAccess.java b/connectivity/com/sun/star/sdbcx/comp/hsqldb/NativeStorageAccess.java
new file mode 100644
index 000000000000..276119e947b6
--- /dev/null
+++ b/connectivity/com/sun/star/sdbcx/comp/hsqldb/NativeStorageAccess.java
@@ -0,0 +1,80 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+/*
+ * StorageAccess.java
+ *
+ * Created on 17. August 2004, 13:32
+ */
+
+package com.sun.star.sdbcx.comp.hsqldb;
+
+/**
+ *
+ * @author oj93728
+ */
+
+public class NativeStorageAccess {
+ static { NativeLibraries.load(); }
+
+ public static final int READ = 1;
+ public static final int SEEKABLE = 2;
+ public static final int SEEKABLEREAD = 3;
+ public static final int WRITE = 4;
+ public static final int READWRITE = 7;
+ public static final int TRUNCATE = 8;
+
+ /** Creates a new instance of StorageAccess */
+ public NativeStorageAccess(String name,String _mode,Object key) throws java.io.IOException{
+ try {
+ int mode = NativeStorageAccess.SEEKABLEREAD;
+ if ( _mode.equals("rw") )
+ mode = NativeStorageAccess.READWRITE | NativeStorageAccess.SEEKABLE;
+
+ openStream(name, (String)key, mode);
+ } catch(Exception e){
+ throw new java.io.IOException();
+ }
+ }
+ public native void openStream(String name,String key, int mode);
+ public native void close(String name,String key) throws java.io.IOException;
+
+ public native long getFilePointer(String name,String key) throws java.io.IOException;
+
+ public native long length(String name,String key) throws java.io.IOException;
+
+ public native int read(String name,String key) throws java.io.IOException;
+
+ public native int read(String name,String key,byte[] b, int off, int len) throws java.io.IOException;
+
+ public native int readInt(String name,String key) throws java.io.IOException;
+
+ public native void seek(String name,String key,long position) throws java.io.IOException;
+
+ public native void write(String name,String key,byte[] b, int offset, int length) throws java.io.IOException;
+
+ public native void writeInt(String name,String key,int v) throws java.io.IOException;
+}
diff --git a/connectivity/com/sun/star/sdbcx/comp/hsqldb/StorageAccess.java b/connectivity/com/sun/star/sdbcx/comp/hsqldb/StorageAccess.java
new file mode 100644
index 000000000000..9471275e7e44
--- /dev/null
+++ b/connectivity/com/sun/star/sdbcx/comp/hsqldb/StorageAccess.java
@@ -0,0 +1,171 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+/*
+ * StorageAccess.java
+ *
+ * Created on 17. August 2004, 13:32
+ */
+
+package com.sun.star.sdbcx.comp.hsqldb;
+
+/**
+ *
+ * @author oj93728
+ */
+
+public class StorageAccess implements org.hsqldb.lib.Storage {
+ String key;
+ String name;
+ boolean readonly;
+ NativeStorageAccess access;
+// public SimpleLog appLog;
+ /** Creates a new instance of StorageAccess */
+ public StorageAccess(String name,Boolean readonly,Object key) throws java.io.IOException{
+ this.key = (String)key;
+ this.name = name;
+ this.readonly = readonly.booleanValue();
+ try {
+ access = new NativeStorageAccess(name,
+ this.readonly ? "r" : "rw"
+ ,key);
+ } catch(Exception e){
+ throw new java.io.IOException();
+ }
+ // appLog = new SimpleLog(name +".app3.log", true);
+ }
+ public void close() throws java.io.IOException{
+ //appLog.sendLine("NIOScaledRAFile.close() ");
+ //appLog.close();
+ access.close(name,key);
+ }
+
+ public long getFilePointer() throws java.io.IOException{
+ //appLog.sendLine("NIOScaledRAFile.getFilePointer() ");
+ return access.getFilePointer(name,key);
+ }
+
+ public long length() throws java.io.IOException{
+ //appLog.sendLine("NIOScaledRAFile.length() ");
+ return access.length(name,key);
+ }
+
+ public int read() throws java.io.IOException{
+ //appLog.sendLine("NIOScaledRAFile.read() ");
+ return access.read(name,key);
+ }
+
+ public void read(byte[] b, int off, int len) throws java.io.IOException{
+ //appLog.sendLine("NIOScaledRAFile.read(" + b + ","+ off +","+len + ") ");
+ access.read(name,key,b,off,len);
+ }
+
+ // fredt - this is based on the same code that reads an int from the .data file in HSQLDB
+ public int readInt() throws java.io.IOException{
+ //appLog.sendLine("NIOScaledRAFile.readInt() ");
+ byte [] tmp = new byte [4];
+
+ int count = access.read(name,key,tmp,0, 4);
+
+ if (count != 4){
+ throw new java.io.IOException();
+ }
+
+ count = 0;
+ int ch0 = tmp[count++] & 0xff;
+ int ch1 = tmp[count++] & 0xff;
+ int ch2 = tmp[count++] & 0xff;
+ int ch3 = tmp[count] & 0xff;
+
+ return ((ch0 << 24) + (ch1 << 16) + (ch2 << 8) + (ch3));
+
+/*
+ int ch [] = new int[4];
+ for(int i = 0;i < 4; ++i){
+ ch[i] = tmp[i];
+ if (ch[i] < 0 ){
+ ch[i] = 256 + ch[i];
+ }
+ }
+
+ if ((ch[0] | ch[1] | ch[2] | ch[3]) < 0)
+ throw new java.io.IOException();
+ return ((ch[0] << 24) + (ch[1] << 16) + (ch[2] << 8) + (ch[3] << 0));
+ //return access.readInt(name,key);
+*/
+ }
+
+ public void seek(long position) throws java.io.IOException{
+ //appLog.sendLine("NIOScaledRAFile.seek("+position +") ");
+ access.seek(name,key,position);
+ }
+
+ public void write(byte[] b, int offset, int length) throws java.io.IOException{
+ //appLog.sendLine("NIOScaledRAFile.write(" + b + "," + offset +","+length+") ");
+ access.write(name,key,b,offset,length);
+ }
+
+ public void writeInt(int v) throws java.io.IOException{
+ //appLog.sendLine("NIOScaledRAFile.writeInt(" +v+") ");
+ byte [] oneByte = new byte [4];
+ oneByte[0] = (byte) ((v >>> 24) & 0xFF);
+ oneByte[1] = (byte) ((v >>> 16) & 0xFF);
+ oneByte[2] = (byte) ((v >>> 8) & 0xFF);
+ oneByte[3] = (byte) ((v >>> 0) & 0xFF);
+
+ write(oneByte,0,4);
+ }
+
+ public boolean isReadOnly() {
+ return readonly;
+ }
+
+ // fredt - minor change of brackets
+ public long readLong() throws java.io.IOException {
+ // return ((long)(readInt()) << 32) + (readInt() & 0xFFFFFFFFL);
+ return (((long) readInt()) << 32) + (((long) readInt()) & 0xFFFFFFFFL);
+ }
+
+ public boolean wasNio() {
+ return false;
+ }
+
+ public void writeLong(long v) throws java.io.IOException {
+ //appLog.sendLine("NIOScaledRAFile.writeLong(" +v+") ");
+ byte [] oneByte = new byte [8];
+
+ oneByte[0] = (byte) ((v >>> 56) & 0xFF);
+ oneByte[1] = (byte) ((v >>> 48) & 0xFF);
+ oneByte[2] = (byte) ((v >>> 40) & 0xFF);
+ oneByte[3] = (byte) ((v >>> 32) & 0xFF);
+ oneByte[4] = (byte) ((v >>> 24) & 0xFF);
+ oneByte[5] = (byte) ((v >>> 16) & 0xFF);
+ oneByte[6] = (byte) ((v >>> 8) & 0xFF);
+ oneByte[7] = (byte) ((v >>> 0) & 0xFF);
+
+ write(oneByte,0,8);
+ }
+}
diff --git a/connectivity/com/sun/star/sdbcx/comp/hsqldb/StorageFileAccess.java b/connectivity/com/sun/star/sdbcx/comp/hsqldb/StorageFileAccess.java
new file mode 100644
index 000000000000..4e24cd4c9385
--- /dev/null
+++ b/connectivity/com/sun/star/sdbcx/comp/hsqldb/StorageFileAccess.java
@@ -0,0 +1,107 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+/*
+ * StorageFileAccess.java
+ *
+ * Created on 31. August 2004, 11:56
+ */
+
+package com.sun.star.sdbcx.comp.hsqldb;
+import org.hsqldb.lib.FileAccess;
+import org.hsqldb.lib.FileSystemRuntimeException;
+
+/**
+ *
+ * @author oj93728
+ */
+public class StorageFileAccess implements org.hsqldb.lib.FileAccess{
+ static { NativeLibraries.load(); }
+
+ String ds_name;
+ String key;
+ /** Creates a new instance of StorageFileAccess */
+ public StorageFileAccess(Object key) throws java.lang.Exception{
+ this.key = (String)key;
+ }
+
+ public void createParentDirs(java.lang.String filename) {
+ }
+
+ public boolean isStreamElement(java.lang.String elementName) {
+ return isStreamElement(key,elementName);
+ }
+
+ public java.io.InputStream openInputStreamElement(java.lang.String streamName) throws java.io.IOException {
+ return new NativeInputStreamHelper(key,streamName);
+ }
+
+ public java.io.OutputStream openOutputStreamElement(java.lang.String streamName) throws java.io.IOException {
+ return new NativeOutputStreamHelper(key,streamName);
+ }
+
+ public void removeElement(java.lang.String filename) throws java.util.NoSuchElementException {
+ try {
+ if ( isStreamElement(key,filename) )
+ removeElement(key,filename);
+ } catch (java.io.IOException e) {
+ throw new FileSystemRuntimeException( e, FileSystemRuntimeException.fileAccessRemoveElementFailed );
+ }
+ }
+
+ public void renameElement(java.lang.String oldName, java.lang.String newName) throws java.util.NoSuchElementException {
+ try {
+ if ( isStreamElement(key,oldName) ){
+ removeElement(key,newName);
+ renameElement(key,oldName, newName);
+ }
+ } catch (java.io.IOException e) {
+ throw new FileSystemRuntimeException( e, FileSystemRuntimeException.fileAccessRenameElementFailed );
+ }
+ }
+
+ public class FileSync implements FileAccess.FileSync
+ {
+ NativeOutputStreamHelper os;
+ FileSync(NativeOutputStreamHelper _os) throws java.io.IOException
+ {
+ os = _os;
+ }
+ public void sync() throws java.io.IOException
+ {
+ os.sync();
+ }
+ }
+
+ public FileAccess.FileSync getFileSync(java.io.OutputStream os) throws java.io.IOException
+ {
+ return new FileSync((NativeOutputStreamHelper)os);
+ }
+
+ static native boolean isStreamElement(java.lang.String key,java.lang.String elementName);
+ static native void removeElement(java.lang.String key,java.lang.String filename) throws java.util.NoSuchElementException, java.io.IOException;
+ static native void renameElement(java.lang.String key,java.lang.String oldName, java.lang.String newName) throws java.util.NoSuchElementException, java.io.IOException;
+}
diff --git a/connectivity/com/sun/star/sdbcx/comp/hsqldb/StorageNativeInputStream.java b/connectivity/com/sun/star/sdbcx/comp/hsqldb/StorageNativeInputStream.java
new file mode 100644
index 000000000000..2ac4d2dbede8
--- /dev/null
+++ b/connectivity/com/sun/star/sdbcx/comp/hsqldb/StorageNativeInputStream.java
@@ -0,0 +1,53 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+/*
+ * StorageNativeInputStream.java
+ *
+ * Created on 9. September 2004, 11:52
+ */
+
+package com.sun.star.sdbcx.comp.hsqldb;
+
+/**
+ *
+ * @author Ocke
+ */
+public class StorageNativeInputStream {
+ static { NativeLibraries.load(); }
+
+ /** Creates a new instance of StorageNativeInputStream */
+ public StorageNativeInputStream(String key,String _file) {
+ openStream(key,_file, NativeStorageAccess.READ);
+ }
+ public native void openStream(String key,String name, int mode);
+ public native int read(String key,String name) throws java.io.IOException;
+ public native int read(String key,String name,byte[] b, int off, int len) throws java.io.IOException;
+ public native void close(String key,String name) throws java.io.IOException;
+ public native long skip(String key,String name,long n) throws java.io.IOException;
+ public native int available(String key,String name) throws java.io.IOException;
+ public native int read(String key,String name,byte[] b) throws java.io.IOException;
+}
diff --git a/connectivity/com/sun/star/sdbcx/comp/hsqldb/StorageNativeOutputStream.java b/connectivity/com/sun/star/sdbcx/comp/hsqldb/StorageNativeOutputStream.java
new file mode 100644
index 000000000000..6b9a4db50153
--- /dev/null
+++ b/connectivity/com/sun/star/sdbcx/comp/hsqldb/StorageNativeOutputStream.java
@@ -0,0 +1,143 @@
+/*
+ * StorageNativeOutputStream.java
+ *
+ * Created on 1. September 2004, 10:20
+ */
+
+package com.sun.star.sdbcx.comp.hsqldb;
+
+/**
+ *
+ * @author oj93728
+ */
+public class StorageNativeOutputStream {
+ static { NativeLibraries.load(); }
+
+ String name;
+ Object key;
+
+ /** Creates a new instance of StorageNativeOutputStream */
+ public StorageNativeOutputStream(String _name,Object _key) {
+ name = _name;
+ key = _key;
+ openStream(name, (String)key, NativeStorageAccess.WRITE | NativeStorageAccess.TRUNCATE);
+ }
+
+ public native void openStream(String name,String key, int mode);
+ /**
+ * Writes <code>len</code> bytes from the specified byte array
+ * starting at offset <code>off</code> to this output stream.
+ * The general contract for <code>write(b, off, len)</code> is that
+ * some of the bytes in the array <code>b</code> are written to the
+ * output stream in order; element <code>b[off]</code> is the first
+ * byte written and <code>b[off+len-1]</code> is the last byte written
+ * by this operation.
+ * <p>
+ * The <code>write</code> method of <code>OutputStream</code> calls
+ * the write method of one argument on each of the bytes to be
+ * written out. Subclasses are encouraged to override this method and
+ * provide a more efficient implementation.
+ * <p>
+ * If <code>b</code> is <code>null</code>, a
+ * <code>NullPointerException</code> is thrown.
+ * <p>
+ * If <code>off</code> is negative, or <code>len</code> is negative, or
+ * <code>off+len</code> is greater than the length of the array
+ * <code>b</code>, then an <tt>IndexOutOfBoundsException</tt> is thrown.
+ * @param key The name of the data source.
+ * @param _file The name of the file to write to.
+ * @param b the data.
+ * @param off the start offset in the data.
+ * @param len the number of bytes to write.
+ * @exception IOException if an I/O error occurs. In particular,
+ * an <code>IOException</code> is thrown if the output
+ * stream is closed.
+ */
+ public native void write(String key,String _file,byte[] b, int off, int len) throws java.io.IOException;
+
+ /**
+ * Writes <code>b.length</code> bytes from the specified byte array
+ * to this output stream. The general contract for <code>write(b)</code>
+ * is that it should have exactly the same effect as the call
+ * <code>write(b, 0, b.length)</code>.
+ *
+ * @param b the data.
+ * @exception IOException if an I/O error occurs.
+ * @see java.io.OutputStream#write(byte[], int, int)
+ */
+ public native void write(String key,String _file,byte[] b) throws java.io.IOException;
+
+ /**
+ * Closes this output stream and releases any system resources
+ * associated with this stream. The general contract of <code>close</code>
+ * is that it closes the output stream. A closed stream cannot perform
+ * output operations and cannot be reopened.
+ * <p>
+ * The <code>close</code> method of <code>OutputStream</code> does nothing.
+ * @param key The name of the data source.
+ * @param _file The name of the file to write to.
+ *
+ * @exception IOException if an I/O error occurs.
+ */
+ public native void close(String key,String _file) throws java.io.IOException;
+
+ /**
+ * Writes the specified byte to this output stream. The general
+ * contract for <code>write</code> is that one byte is written
+ * to the output stream. The byte to be written is the eight
+ * low-order bits of the argument <code>b</code>. The 24
+ * high-order bits of <code>b</code> are ignored.
+ * <p>
+ * Subclasses of <code>OutputStream</code> must provide an
+ * implementation for this method.
+ *
+ * @param key The name of the data source.
+ * @param _file The name of the file to write to.
+ * @param b the <code>byte</code>.
+ * @exception IOException if an I/O error occurs. In particular,
+ * an <code>IOException</code> may be thrown if the
+ * output stream has been closed.
+ */
+ public native void write(String key,String _file,int b) throws java.io.IOException;
+
+ /**
+ * Flushes this output stream and forces any buffered output bytes
+ * to be written out. The general contract of <code>flush</code> is
+ * that calling it is an indication that, if any bytes previously
+ * written have been buffered by the implementation of the output
+ * stream, such bytes should immediately be written to their
+ * intended destination.
+ * <p>
+ * The <code>flush</code> method of <code>OutputStream</code> does nothing.
+ * @param key The name of the data source.
+ * @param _file The name of the file to write to.
+ *
+ * @exception IOException if an I/O error occurs.
+ */
+ public native void flush(String key,String _file) throws java.io.IOException;
+
+ /**
+ * Force all system buffers to synchronize with the underlying
+ * device. This method returns after all modified data and
+ * attributes have been written to the relevant device(s).
+ *
+ * sync is meant to be used by code that requires physical
+ * storage (such as a file) to be in a known state For
+ * example, a class that provided a simple transaction facility
+ * might use sync to ensure that all changes to a file caused
+ * by a given transaction were recorded on a storage medium.
+ *
+ * sync only affects buffers downstream. If
+ * any in-memory buffering is being done by the application (for
+ * example, by a BufferedOutputStream object), those buffers must
+ * be flushed (for example, by invoking
+ * OutputStream.flush) before that data will be affected by sync.
+ *
+ * @exception IOException
+ * Thrown when the buffers cannot be flushed,
+ * or because the system cannot guarantee that all the
+ * buffers have been synchronized with physical media.
+ */
+ public native void sync(String key,String _file) throws java.io.IOException;
+
+}
diff --git a/connectivity/com/sun/star/sdbcx/comp/hsqldb/makefile.mk b/connectivity/com/sun/star/sdbcx/comp/hsqldb/makefile.mk
new file mode 100644
index 000000000000..ce9581b93458
--- /dev/null
+++ b/connectivity/com/sun/star/sdbcx/comp/hsqldb/makefile.mk
@@ -0,0 +1,65 @@
+#*************************************************************************
+#
+# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+#
+# Copyright 2000, 2010 Oracle and/or its affiliates.
+#
+# OpenOffice.org - a multi-platform office productivity suite
+#
+# This file is part of OpenOffice.org.
+#
+# OpenOffice.org is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Lesser General Public License version 3
+# only, as published by the Free Software Foundation.
+#
+# OpenOffice.org is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Lesser General Public License version 3 for more details
+# (a copy is included in the LICENSE file that accompanied this code).
+#
+# You should have received a copy of the GNU Lesser General Public License
+# version 3 along with OpenOffice.org. If not, see
+# <http://www.openoffice.org/license.html>
+# for a copy of the LGPLv3 License.
+#
+#*************************************************************************
+PRJ = ..$/..$/..$/..$/..$/..
+PRJNAME = connectivity
+PACKAGE = com$/sun$/star$/sdbcx$/comp$/hsqldb
+TARGET = sdbc_hsqldb
+
+SECONDARY_PACKAGE = org$/hsqldb$/lib
+
+# --- Settings -----------------------------------------------------
+.INCLUDE: settings.mk
+
+# --- Files --------------------------------------------------------
+
+
+.IF "$(SYSTEM_HSQLDB)" == "YES"
+EXTRAJARFILES = $(HSQLDB_JAR)
+.ELSE
+JARFILES = hsqldb.jar
+.ENDIF
+
+JAVAFILES =\
+ NativeInputStreamHelper.java\
+ NativeOutputStreamHelper.java\
+ NativeStorageAccess.java\
+ StorageAccess.java\
+ StorageFileAccess.java\
+ StorageNativeInputStream.java\
+ StorageNativeOutputStream.java\
+ FileSystemRuntimeException.java\
+ NativeLibraries.java
+
+JAVACLASSFILES = $(foreach,i,$(JAVAFILES) $(CLASSDIR)$/$(PACKAGE)$/$(i:b).class)
+
+JARCOMPRESS = TRUE
+JARCLASSDIRS = $(PACKAGE) $(SECONDARY_PACKAGE)
+JARTARGET = $(TARGET).jar
+JARCLASSPATH = $(JARFILES) $(EXTRAJARFILES) ..
+
+# --- Targets ------------------------------------------------------
+.INCLUDE : target.mk