clobimpl.java
来自「Speedframework--基于类型元数据的羽量级ORM.完全基于Java类」· Java 代码 · 共 95 行
JAVA
95 行
package org.speedframework.entity;
import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.io.Reader;
import java.io.StringReader;
import java.io.Writer;
import java.sql.Clob;
import java.sql.SQLException;
/**
* Clob 类型实现
* @author lizf
*
*/
public class ClobImpl implements Clob {
private Reader reader;
private int length;
private boolean needsReset = false;
public ClobImpl(String string) {
reader = new StringReader(string);
length = string.length();
}
public ClobImpl(Reader reader, int length) {
this.reader = reader;
this.length = length;
}
public long length() throws SQLException {
return length;
}
public void truncate(long len) throws SQLException {
}
public InputStream getAsciiStream() throws SQLException {
try {
if (needsReset) reader.reset();
}
catch (IOException ioe) {
throw new SQLException("could not reset reader");
}
needsReset = true;
return new ByteArrayInputStream(reader.toString().getBytes());
}
public OutputStream setAsciiStream(long pos) throws SQLException {
return null;
}
public Reader getCharacterStream() throws SQLException {
try {
if (needsReset) reader.reset();
}
catch (IOException ioe) {
throw new SQLException("could not reset reader");
}
needsReset = true;
return reader;
}
public Writer setCharacterStream(long pos) throws SQLException {
return null;
}
public String getSubString(long pos, int length) throws SQLException {
return null;
}
public int setString(long pos, String str) throws SQLException {
return 0;
}
public int setString(long pos, String str, int offset, int len)
throws SQLException {
return 0;
}
public long position(String searchstr, long start) throws SQLException {
return 0;
}
public long position(Clob searchstr, long start) throws SQLException {
return 0;
}
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?