KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > mckoi > database > jdbc > MClob


1 /**
2  * com.mckoi.database.jdbc.MClob 31 Jan 2003
3  *
4  * Mckoi SQL Database ( http://www.mckoi.com/database )
5  * Copyright (C) 2000, 2001, 2002 Diehl and Associates, Inc.
6  *
7  * This program is free software; you can redistribute it and/or
8  * modify it under the terms of the GNU General Public License
9  * Version 2 as published by the Free Software Foundation.
10  *
11  * This program is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  * GNU General Public License Version 2 for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * Version 2 along with this program; if not, write to the Free Software
18  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
19  *
20  * Change Log:
21  *
22  *
23  */

24
25 package com.mckoi.database.jdbc;
26
27 import java.sql.SQLException JavaDoc;
28 import java.sql.Clob JavaDoc;
29 import java.io.StringReader JavaDoc;
30 import java.io.Reader JavaDoc;
31
32 /**
33  * An implementation of java.sql.Clob over a java.util.String object.
34  *
35  * @author Tobias Downer
36  */

37
38 class MClob implements Clob JavaDoc {
39
40   /**
41    * The string the Clob is based on.
42    */

43   private String JavaDoc str;
44
45   /**
46    * Constructs the Clob implementation.
47    */

48   public MClob(String JavaDoc str) {
49     this.str = str;
50   }
51
52   // ---------- Implemented from Clob ----------
53

54   public long length() throws SQLException JavaDoc {
55     return str.length();
56   }
57
58   public String JavaDoc getSubString(long pos, int length) throws SQLException JavaDoc {
59     int p = (int) (pos - 1);
60     return str.substring(p, p + length);
61   }
62
63   public Reader JavaDoc getCharacterStream() throws SQLException JavaDoc {
64     return new StringReader JavaDoc(str);
65   }
66
67   public java.io.InputStream JavaDoc getAsciiStream() throws SQLException JavaDoc {
68     return new AsciiInputStream(getCharacterStream());
69   }
70
71   public long position(String JavaDoc searchstr, long start) throws SQLException JavaDoc {
72     throw MSQLException.unsupported();
73   }
74   
75   public long position(Clob JavaDoc searchstr, long start) throws SQLException JavaDoc {
76     throw MSQLException.unsupported();
77   }
78
79   //#IFDEF(JDBC3.0)
80

81   //---------------------------- JDBC 3.0 -----------------------------------
82

83   public int setString(long pos, String JavaDoc str) throws SQLException JavaDoc {
84     throw MSQLException.unsupported();
85   }
86
87   public int setString(long pos, String JavaDoc str, int offset, int len)
88                                                           throws SQLException JavaDoc {
89     throw MSQLException.unsupported();
90   }
91
92   public java.io.OutputStream JavaDoc setAsciiStream(long pos) throws SQLException JavaDoc {
93     throw MSQLException.unsupported();
94   }
95
96   public java.io.Writer JavaDoc setCharacterStream(long pos) throws SQLException JavaDoc {
97     throw MSQLException.unsupported();
98   }
99
100   public void truncate(long len) throws SQLException JavaDoc {
101     throw MSQLException.unsupported();
102   }
103
104   //#ENDIF
105

106 }
107
108
Popular Tags