KickJava   Java API By Example, From Geeks To Geeks.

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


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.Clob JavaDoc;
19 import java.io.InputStream JavaDoc;
20 import java.io.Reader JavaDoc;
21 import java.io.BufferedReader JavaDoc;
22 import java.io.InputStreamReader JavaDoc;
23 import java.io.OutputStream JavaDoc;
24 import java.io.Writer JavaDoc;
25
26 /**
27  * A minimal implementation just enough to send a CLOB to a
28  * database. Advanced methods and all methods for modifying the CLOB
29  * are not implemented.
30  *
31  * @version CVS $Id: ClobHelper.java 30932 2004-07-29 17:35:38Z vgritsenko $
32  */

33 public class ClobHelper implements Clob JavaDoc{
34
35     InputStream JavaDoc in = null;
36     long length = 0;
37
38     public ClobHelper(InputStream JavaDoc is, long len) {
39         this.in = is;
40         this.length = len;
41     }
42
43     public InputStream JavaDoc getAsciiStream() {
44         return this.in;
45     }
46
47     public Reader JavaDoc getCharacterStream() {
48         return new BufferedReader JavaDoc(new InputStreamReader JavaDoc(this.in));
49     }
50
51     public long length() {
52         return length;
53     }
54
55     /**
56      * Not implemented.
57      */

58     public String JavaDoc getSubString(long pos, int length) {
59         System.out.println("ClobHelper ** NOT IMPLEMENTED ** getSubString");
60         return "";
61     }
62
63     /**
64      * Not implemented.
65      */

66     public long position(Clob JavaDoc searchstr, long start) {
67         System.out.println("ClobHelper ** NOT IMPLEMENTED ** position(clob,long)");
68         return -1; // we don't implement this
69
}
70
71     /**
72      * Not implemented.
73      */

74     public long position(String JavaDoc searchstr, long start) {
75         System.out.println("ClobHelper ** NOT IMPLEMENTED ** position(str,long)");
76         return -1; // we don't implement this
77
}
78
79
80     // if ever implemented.... the following are the JDBC3 methods
81
// since not implemented anyway, included in JDBC2 builds as well.
82
// @JDBC3_START@
83
// @JDBC3_END@
84

85
86     /**
87      * Not implemented.
88      */

89     public OutputStream JavaDoc setAsciiStream(long pos) {
90         System.out.println("ClobHelper ** NOT IMPLEMENTED ** setAsciiStream");
91         return null;
92     }
93
94     /**
95      * Not implemented.
96      */

97     public Writer JavaDoc setCharacterStream(long pos) {
98         System.out.println("ClobHelper ** NOT IMPLEMENTED ** setCharacterStream");
99         return null;
100     }
101
102     /**
103      * Not implemented.
104      */

105     public int setString(long pos, String JavaDoc str){
106         System.out.println("ClobHelper ** NOT IMPLEMENTED ** setString(long,str)");
107         return 0;
108     }
109
110     /**
111      * Not implemented.
112      */

113     public int setString(long pos, String JavaDoc str, int offset, int len){
114         System.out.println("ClobHelper ** NOT IMPLEMENTED ** setString(long,str,int,int)");
115         return 0;
116     }
117
118     /**
119      * Not implemented.
120      */

121     public void truncate(long len){
122         System.out.println("ClobHelper ** NOT IMPLEMENTED ** truncate");
123     }
124
125
126 }
127
128
Popular Tags