KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > daffodilwoods > rmi > RmiBlob


1 package com.daffodilwoods.rmi;
2
3  import java.sql.*;
4  import java.rmi.*;
5  import com.daffodilwoods.rmi.interfaces.*;
6  import java.io.*;
7 public class RmiBlob implements Blob,Serializable{
8
9   _RmiBlob blob_interface;
10   private long length = Integer.MIN_VALUE;
11   public RmiBlob(_RmiBlob blob_interface) {
12     this.blob_interface = blob_interface;
13   }
14
15   public long length() throws SQLException {
16         try {
17           if(length == Integer.MIN_VALUE)
18             length = blob_interface.length();
19           return length;
20         }
21         catch (RemoteException re) {
22             throw new RuntimeException JavaDoc(re.getMessage());
23         }
24   }
25
26   public byte[] getBytes(long pos, int length) throws SQLException {
27         try {
28           return blob_interface.getBytes(pos,length);
29         }
30         catch (RemoteException re) {
31             throw new RuntimeException JavaDoc(re.getMessage());
32         }
33   }
34   public InputStream getBinaryStream() throws SQLException {
35         try {
36            return new RmiInputStream( blob_interface.getBinaryStream());
37         }
38         catch (RemoteException re) {
39             throw new RuntimeException JavaDoc(re.getMessage());
40         }
41   }
42
43   public long position(byte pattern[], long start) throws SQLException {
44         try {
45             return blob_interface.position(pattern,start);
46         }
47         catch (RemoteException re) {
48             throw new RuntimeException JavaDoc(re.getMessage());
49         }
50   }
51   public long position(Blob pattern, long start) throws SQLException {
52         try {
53            return blob_interface.position(pattern,start);
54         }
55         catch (RemoteException re) {
56             throw new RuntimeException JavaDoc(re.getMessage());
57         }
58   }
59
60   public int setBytes(long pos, byte[] bytes) throws SQLException {
61         try {
62           return blob_interface.setBytes(pos,bytes,1,(int)length());
63         }
64         catch (RemoteException re) {
65             throw new RuntimeException JavaDoc(re.getMessage());
66         }
67   }
68
69   public int setBytes(long pos, byte[] bytes, int offset, int len) throws SQLException {
70         try {
71           return blob_interface.setBytes(pos,bytes,offset,len);
72         }
73         catch (RemoteException re) {
74             throw new RuntimeException JavaDoc(re.getMessage());
75         }
76   }
77
78
79   public OutputStream setBinaryStream(long pos) throws SQLException {
80         try {
81            return new RmiOutputStream( blob_interface.setBinaryStream(pos));
82         }
83         catch (RemoteException re) {
84             throw new RuntimeException JavaDoc(re.getMessage());
85         }
86   }
87
88   public void truncate(long len) throws SQLException {
89         try {
90             blob_interface.truncate(len);
91         }
92         catch (RemoteException re) {
93             throw new RuntimeException JavaDoc(re.getMessage());
94         }
95   }
96
97 }
98
Popular Tags