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