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.Blob;
020: import java.io.InputStream;
021: import java.io.OutputStream;
022:
023: /**
024: * A minimal implementation just enough to send a BLOB to a
025: * database. Advanced methods and all methods for modifying the BLOB
026: * are not implemented.
027: *
028: * @version CVS $Id: BlobHelper.java 476958 2006-11-19 22:36:03Z anathaniel $
029: */
030: public class BlobHelper implements Blob {
031:
032: InputStream in = null;
033: long length = 0;
034:
035: public BlobHelper(InputStream is, long len) {
036: this .in = is;
037: this .length = len;
038: }
039:
040: public InputStream getBinaryStream() {
041: return this .in;
042: }
043:
044: public long length() {
045: return length;
046: }
047:
048: /**
049: * Not implemented.
050: */
051: public byte[] getBytes(long pos, int length) {
052: System.out.println("BlobHelper ** NOT IMPLEMENTED ** getBytes");
053: return null;
054: }
055:
056: /**
057: * Not implemented.
058: */
059: public long position(Blob pattern, long start) {
060: System.out
061: .println("BlobHelper ** NOT IMPLEMENTED ** position(blog,long)");
062: return -1; // we don't implement this
063: }
064:
065: /**
066: * Not implemented.
067: */
068: public long position(byte[] pattern, long start) {
069: System.out
070: .println("BlobHelper ** NOT IMPLEMENTED ** position(byte[],long)");
071: return -1; // we don't implement this
072: }
073:
074: // if ever implemented.... the following are the JDBC3 methods
075: // since not implemented anyway, included in JDBC2 builds as well.
076: // @JDBC3_START@
077: // @JDBC3_END@
078:
079: /**
080: * Not implemented.
081: */
082: public OutputStream setBinaryStream(long pos) {
083: System.out
084: .println("BlobHelper ** NOT IMPLEMENTED ** setBinaryStream");
085: return null;
086: }
087:
088: /**
089: * Not implemented.
090: */
091: public int setBytes(long pos, byte[] bytes) {
092: System.out
093: .println("BlobHelper ** NOT IMPLEMENTED ** setBytes(long,byte[])");
094: return 0;
095: }
096:
097: /**
098: * Not implemented.
099: */
100: public int setBytes(long pos, byte[] bytes, int offset, int len) {
101: System.out
102: .println("BlobHelper ** NOT IMPLEMENTED ** setBytes(long,byte[],int,int)");
103: return 0;
104: }
105:
106: /**
107: * Not implemented.
108: */
109: public void truncate(long len) {
110: System.out.println("BlobHelper ** NOT IMPLEMENTED ** truncate");
111: }
112:
113: /**
114: * Not implemented (Java6 extension).
115: */
116: public void free() {
117: System.out.println("BlobHelper ** NOT IMPLEMENTED ** free");
118: }
119:
120: /**
121: * Not implemented (Java6 extension).
122: */
123: public InputStream getBinaryStream(long pos, long length) {
124: System.out
125: .println("BlobHelper ** NOT IMPLEMENTED ** getBinaryStream(long,long");
126: return null;
127: }
128: }
|