001: /*
002: * Copyright (c) 1998-2008 Caucho Technology -- all rights reserved
003: *
004: * This file is part of Resin(R) Open Source
005: *
006: * Each copy or derived work must preserve the copyright notice and this
007: * notice unmodified.
008: *
009: * Resin Open Source is free software; you can redistribute it and/or modify
010: * it under the terms of the GNU General Public License as published by
011: * the Free Software Foundation; either version 2 of the License, or
012: * (at your option) any later version.
013: *
014: * Resin Open Source is distributed in the hope that it will be useful,
015: * but WITHOUT ANY WARRANTY; without even the implied warranty of
016: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE, or any warranty
017: * of NON-INFRINGEMENT. See the GNU General Public License for more
018: * details.
019: *
020: * You should have received a copy of the GNU General Public License
021: * along with Resin Open Source; if not, write to the
022: *
023: * Free Software Foundation, Inc.
024: * 59 Temple Place, Suite 330
025: * Boston, MA 02111-1307 USA
026: *
027: * @author Scott Ferguson
028: */
029: package com.caucho.db.sql;
030:
031: import com.caucho.db.store.BlobInputStream;
032: import com.caucho.db.store.Store;
033: import com.caucho.util.L10N;
034:
035: import java.io.InputStream;
036: import java.io.OutputStream;
037: import java.io.Reader;
038: import java.io.Writer;
039: import java.sql.Clob;
040: import java.sql.SQLException;
041:
042: /**
043: * The JDBC clob implementation.
044: */
045: public class ClobImpl implements java.sql.Clob {
046: private static final L10N L = new L10N(ClobImpl.class);
047:
048: private Store _store;
049: private byte[] _inode = new byte[128];
050:
051: ClobImpl() {
052: }
053:
054: void setStore(Store store) {
055: _store = store;
056: }
057:
058: byte[] getInode() {
059: return _inode;
060: }
061:
062: /**
063: * Returns the clob as a stream.
064: */
065: public InputStream getAsciiStream() throws SQLException {
066: // XXX: lie, since this is utf8
067: return new BlobInputStream(_store, _inode, 0);
068: }
069:
070: /**
071: * Returns a subset of the bytes.
072: */
073: public Reader getCharacterStream() throws SQLException {
074: throw new UnsupportedOperationException();
075: }
076:
077: /**
078: * Returns a copy of the specified substring.
079: */
080: public String getSubString(long pos, int length)
081: throws SQLException {
082: throw new UnsupportedOperationException();
083: }
084:
085: /**
086: * Returns the length of the clob
087: */
088: public long length() throws SQLException {
089: return BlobInputStream.readLong(_inode, 0);
090: }
091:
092: /**
093: * Returns the position in the clob where the pattern starts.
094: */
095: public long position(Clob pattern, long start) throws SQLException {
096: throw new UnsupportedOperationException();
097: }
098:
099: /**
100: * Returns the position in the clob where the pattern starts.
101: */
102: public long position(String pattern, long start)
103: throws SQLException {
104: throw new UnsupportedOperationException();
105: }
106:
107: /**
108: * Returns a stream to write to the clob.
109: */
110: public OutputStream setAsciiStream(long pos) throws SQLException {
111: throw new UnsupportedOperationException();
112: }
113:
114: /**
115: * Returns a stream to write to the clob.
116: */
117: public Writer setCharacterStream(long pos) throws SQLException {
118: throw new UnsupportedOperationException();
119: }
120:
121: /**
122: * Sets a subset of bytes.
123: */
124: public int setString(long pos, String string) throws SQLException {
125: throw new UnsupportedOperationException();
126: }
127:
128: /**
129: * Sets a subset of bytes.
130: */
131: public int setString(long pos, String string, int offset, int len)
132: throws SQLException {
133: throw new UnsupportedOperationException();
134: }
135:
136: /**
137: * Truncates the clob
138: */
139: public void truncate(long length) throws SQLException {
140: throw new UnsupportedOperationException();
141: }
142:
143: public String toString() {
144: return "ClobImpl[]";
145: }
146:
147: public void free() throws SQLException {
148: throw new UnsupportedOperationException("Not supported yet.");
149: }
150:
151: public Reader getCharacterStream(long pos, long length)
152: throws SQLException {
153: throw new UnsupportedOperationException("Not supported yet.");
154: }
155: }
|