Open Source Repository

Home /hibernate/hibernate-3.2.4.ga | Repository Home



org/hibernate/lob/SerializableClob.java
//$Id: SerializableClob.java 5986 2005-03-02 11:43:36Z oneovthafew $
package org.hibernate.lob;

import java.io.InputStream;
import java.io.OutputStream;
import java.io.Reader;
import java.io.Serializable;
import java.io.Writer;
import java.sql.Clob;
import java.sql.SQLException;

/**
 @author Gavin King
 */
public class SerializableClob implements Serializable, Clob {

  private transient final Clob clob;
  
  public SerializableClob(Clob blob) {
    this.clob = blob;
  }

  public Clob getWrappedClob() {
    if clob==null ) {
      throw new IllegalStateException("Clobs may not be accessed after serialization");
    }
    else {
      return clob;
    }
  }
  
  public long length() throws SQLException {
    return getWrappedClob().length();
  }

  public String getSubString(long pos, int lengththrows SQLException {
    return getWrappedClob().getSubString(pos, length);
  }

  public Reader getCharacterStream() throws SQLException {
    return getWrappedClob().getCharacterStream();
  }

  public InputStream getAsciiStream() throws SQLException {
    return getWrappedClob().getAsciiStream();
  }

  public long position(String searchstr, long startthrows SQLException {
    return getWrappedClob().position(searchstr, start);
  }

  public long position(Clob searchstr, long startthrows SQLException {
    return getWrappedClob().position(searchstr, start);
  }

  public int setString(long pos, String strthrows SQLException {
    return getWrappedClob().setString(pos, str);
  }

  public int setString(long pos, String str, int offset, int lenthrows SQLException {
    return getWrappedClob().setString(pos, str, offset, len);
  }

  public OutputStream setAsciiStream(long posthrows SQLException {
    return getWrappedClob().setAsciiStream(pos);
  }

  public Writer setCharacterStream(long posthrows SQLException {
    return getWrappedClob().setCharacterStream(pos);
  }

  public void truncate(long lenthrows SQLException {
    getWrappedClob().truncate(len);
  }

}