blobimpl.java

来自「Speedframework--基于类型元数据的羽量级ORM.完全基于Java类」· Java 代码 · 共 84 行

JAVA
84
字号
package org.speedframework.entity;

import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.sql.Blob;
import java.sql.SQLException;

/**
 * Blob 类型实现 
 * @author lizf
 *
 */
public class BlobImpl implements Blob {
	
	private InputStream stream;
	private int length;
	private boolean needsReset = false;
	
	public BlobImpl(byte[] bytes) {
		this.stream = new ByteArrayInputStream(bytes);
		this.length = bytes.length;
	}

	public BlobImpl(InputStream stream, int length) {
		this.stream = stream;
		this.length = length;
	}

	public long length() throws SQLException {
		return length;
	}

	public void truncate(long len) throws SQLException {
		// TODO 自动生成方法存根

	}

	public byte[] getBytes(long pos, int length) throws SQLException {
		// TODO 自动生成方法存根
		return null;
	}

	public int setBytes(long pos, byte[] bytes) throws SQLException {
		// TODO 自动生成方法存根
		return 0;
	}

	public int setBytes(long pos, byte[] bytes, int offset, int len)
			throws SQLException {
		// TODO 自动生成方法存根
		return 0;
	}

	public long position(byte[] pattern, long start) throws SQLException {
		// TODO 自动生成方法存根
		return 0;
	}

	public InputStream getBinaryStream() throws SQLException {
		// TODO 自动生成方法存根
		try {
			if (needsReset) stream.reset();
		}
		catch (IOException ioe) {
			throw new SQLException("could not reset reader");
		}
		needsReset = true;
		return stream;
	}

	public OutputStream setBinaryStream(long pos) throws SQLException {
		// TODO 自动生成方法存根
		return null;
	}

	public long position(Blob pattern, long start) throws SQLException {
		// TODO 自动生成方法存根
		return 0;
	}

}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?