KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > cocoon > util > BlobHelper


1 /*
2  * Copyright 1999-2004 The Apache Software Foundation.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */

16 package org.apache.cocoon.util;
17
18 import java.sql.Blob JavaDoc;
19 import java.io.InputStream JavaDoc;
20 import java.io.OutputStream JavaDoc;
21
22 /**
23  * A minimal implementation just enough to send a BLOB to a
24  * database. Advanced methods and all methods for modifying the BLOB
25  * are not implemented.
26  *
27  * @version CVS $Id: BlobHelper.java 30932 2004-07-29 17:35:38Z vgritsenko $
28  */

29 public class BlobHelper implements Blob JavaDoc{
30
31     InputStream JavaDoc in = null;
32     long length = 0;
33
34     public BlobHelper(InputStream JavaDoc is, long len) {
35         this.in = is;
36         this.length = len;
37     }
38
39     public InputStream JavaDoc getBinaryStream() {
40         return this.in;
41     }
42
43     public long length() {
44         return length;
45     }
46
47     /**
48      * Not implemented.
49      */

50     public byte[] getBytes(long pos, int length) {
51         System.out.println("BlobHelper ** NOT IMPLEMENTED ** getBytes");
52         return null;
53     }
54
55     /**
56      * Not implemented.
57      */

58     public long position(Blob JavaDoc pattern, long start) {
59         System.out.println("BlobHelper ** NOT IMPLEMENTED ** position(blog,long)");
60         return -1; // we don't implement this
61
}
62
63     /**
64      * Not implemented.
65      */

66     public long position(byte[] pattern, long start) {
67         System.out.println("BlobHelper ** NOT IMPLEMENTED ** position(byte[],long)");
68         return -1; // we don't implement this
69
}
70
71
72     // if ever implemented.... the following are the JDBC3 methods
73
// since not implemented anyway, included in JDBC2 builds as well.
74
// @JDBC3_START@
75
// @JDBC3_END@
76

77
78     /**
79      * Not implemented.
80      */

81     public OutputStream JavaDoc setBinaryStream(long pos) {
82         System.out.println("BlobHelper ** NOT IMPLEMENTED ** setBinaryStream");
83         return null;
84     }
85
86     /**
87      * Not implemented.
88      */

89     public int setBytes(long pos, byte[] bytes) {
90         System.out.println("BlobHelper ** NOT IMPLEMENTED ** setBytes(long,byte[])");
91         return 0;
92     }
93
94     /**
95      * Not implemented.
96      */

97     public int setBytes(long pos, byte[] bytes, int offset, int len) {
98         System.out.println("BlobHelper ** NOT IMPLEMENTED ** setBytes(long,byte[],int,int)");
99         return 0;
100     }
101
102     /**
103      * Not implemented.
104      */

105     public void truncate(long len) {
106         System.out.println("BlobHelper ** NOT IMPLEMENTED ** truncate");
107     }
108
109
110 }
111
112
Popular Tags