001: /*
002: * Licensed to the Apache Software Foundation (ASF) under one or more
003: * contributor license agreements. See the NOTICE file distributed with
004: * this work for additional information regarding copyright ownership.
005: * The ASF licenses this file to You under the Apache License, Version 2.0
006: * (the "License"); you may not use this file except in compliance with
007: * the License. You may obtain a copy of the License at
008: *
009: * http://www.apache.org/licenses/LICENSE-2.0
010: *
011: * Unless required by applicable law or agreed to in writing, software
012: * distributed under the License is distributed on an "AS IS" BASIS,
013: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014: * See the License for the specific language governing permissions and
015: * limitations under the License.
016: */
017: package org.apache.cocoon.util;
018:
019: import java.sql.Clob;
020: import java.io.InputStream;
021: import java.io.Reader;
022: import java.io.BufferedReader;
023: import java.io.InputStreamReader;
024: import java.io.OutputStream;
025: import java.io.Writer;
026:
027: /**
028: * A minimal implementation just enough to send a CLOB to a
029: * database. Advanced methods and all methods for modifying the CLOB
030: * are not implemented.
031: *
032: * @version CVS $Id: ClobHelper.java 476958 2006-11-19 22:36:03Z anathaniel $
033: */
034: public class ClobHelper implements Clob {
035:
036: InputStream in = null;
037: long length = 0;
038:
039: public ClobHelper(InputStream is, long len) {
040: this .in = is;
041: this .length = len;
042: }
043:
044: public InputStream getAsciiStream() {
045: return this .in;
046: }
047:
048: public Reader getCharacterStream() {
049: return new BufferedReader(new InputStreamReader(this .in));
050: }
051:
052: public long length() {
053: return length;
054: }
055:
056: /**
057: * Not implemented.
058: */
059: public String getSubString(long pos, int length) {
060: System.out
061: .println("ClobHelper ** NOT IMPLEMENTED ** getSubString");
062: return "";
063: }
064:
065: /**
066: * Not implemented.
067: */
068: public long position(Clob searchstr, long start) {
069: System.out
070: .println("ClobHelper ** NOT IMPLEMENTED ** position(clob,long)");
071: return -1; // we don't implement this
072: }
073:
074: /**
075: * Not implemented.
076: */
077: public long position(String searchstr, long start) {
078: System.out
079: .println("ClobHelper ** NOT IMPLEMENTED ** position(str,long)");
080: return -1; // we don't implement this
081: }
082:
083: // if ever implemented.... the following are the JDBC3 methods
084: // since not implemented anyway, included in JDBC2 builds as well.
085: // @JDBC3_START@
086: // @JDBC3_END@
087:
088: /**
089: * Not implemented.
090: */
091: public OutputStream setAsciiStream(long pos) {
092: System.out
093: .println("ClobHelper ** NOT IMPLEMENTED ** setAsciiStream");
094: return null;
095: }
096:
097: /**
098: * Not implemented.
099: */
100: public Writer setCharacterStream(long pos) {
101: System.out
102: .println("ClobHelper ** NOT IMPLEMENTED ** setCharacterStream");
103: return null;
104: }
105:
106: /**
107: * Not implemented.
108: */
109: public int setString(long pos, String str) {
110: System.out
111: .println("ClobHelper ** NOT IMPLEMENTED ** setString(long,str)");
112: return 0;
113: }
114:
115: /**
116: * Not implemented.
117: */
118: public int setString(long pos, String str, int offset, int len) {
119: System.out
120: .println("ClobHelper ** NOT IMPLEMENTED ** setString(long,str,int,int)");
121: return 0;
122: }
123:
124: /**
125: * Not implemented.
126: */
127: public void truncate(long len) {
128: System.out.println("ClobHelper ** NOT IMPLEMENTED ** truncate");
129: }
130:
131: /**
132: * Not implemented (Java6 extension).
133: */
134: public void free() {
135: System.out.println("BlobHelper ** NOT IMPLEMENTED ** free");
136: }
137:
138: /**
139: * Not implemented (Java6 extension).
140: */
141: public Reader getCharacterStream(long pos, long length) {
142: System.out
143: .println("BlobHelper ** NOT IMPLEMENTED ** getCharacterStream(long,long");
144: return null;
145: }
146: }
|