1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 
23 /*
24  * StorageAccess.java
25  *
26  * Created on 17. August 2004, 13:32
27  */
28 
29 package com.sun.star.sdbcx.comp.hsqldb;
30 
31 /**
32  *
33  * @author  oj93728
34  */
35 
36 public class NativeStorageAccess {
NativeLibraries.load()37     static { NativeLibraries.load(); }
38 
39     public static final int READ            = 1;
40     public static final int SEEKABLE        = 2;
41     public static final int SEEKABLEREAD    = 3;
42     public static final int WRITE           = 4;
43     public static final int READWRITE       = 7;
44     public static final int TRUNCATE        = 8;
45 
46     /** Creates a new instance of StorageAccess */
NativeStorageAccess(String name,String _mode,Object key)47     public NativeStorageAccess(String name,String _mode,Object key) throws java.io.IOException{
48         try {
49             int mode = NativeStorageAccess.SEEKABLEREAD;
50             if ( _mode.equals("rw") )
51                 mode = NativeStorageAccess.READWRITE | NativeStorageAccess.SEEKABLE;
52 
53             openStream(name, (String)key, mode);
54         } catch(Exception e){
55             throw new java.io.IOException();
56         }
57     }
openStream(String name,String key, int mode)58     public native void openStream(String name,String key, int mode);
close(String name,String key)59     public native void close(String name,String key) throws java.io.IOException;
60 
getFilePointer(String name,String key)61     public native long getFilePointer(String name,String key) throws java.io.IOException;
62 
length(String name,String key)63     public native long length(String name,String key) throws java.io.IOException;
64 
read(String name,String key)65     public native int read(String name,String key) throws java.io.IOException;
66 
read(String name,String key,byte[] b, int off, int len)67     public native int read(String name,String key,byte[] b, int off, int len) throws java.io.IOException;
68 
readInt(String name,String key)69     public native int readInt(String name,String key) throws java.io.IOException;
70 
seek(String name,String key,long position)71     public native void seek(String name,String key,long position) throws java.io.IOException;
72 
write(String name,String key,byte[] b, int offset, int length)73     public native void write(String name,String key,byte[] b, int offset, int length) throws java.io.IOException;
74 
writeInt(String name,String key,int v)75     public native void writeInt(String name,String key,int v) throws java.io.IOException;
76 }
77