Title: Precatory words

Can you add functionality for Wrapper creation?

For example:
I want to create UnmovableResultSet.
I will implements ResultSet and use follow
/**
 * Wrapper on {@link java.sql.ResultSet ResultSet}, that not allow you change state of ResultSet.
 * Read only allowed.
 * @author Alexey Efimov
 */
public class UnmoveableResultSet implements ResultSet {
  private ResultSet rs;

  public UnmoveableResultSet(ResultSet rs) {
    this.rs = rs;
  }

  public boolean next() throws SQLException {
    throw new UnsupportedOperationException();
  }

  public void close() throws SQLException {
    throw new UnsupportedOperationException();
  }

  public boolean wasNull() throws SQLException {
    return rs.wasNull();
  }

  public String getString(int columnIndex) throws SQLException {
    return rs.getString(columnIndex);
  }

  // ...
}

So, 540 line stupid code :))) generic wrapper.
If you see, and do Refactor Comand for it - it will create Wrapers by one second :)

class WapperClass implements Interface {
  private Interface wrapperObject;
  public WapperClass(Interface wrapperObject) {
    this.wrappedObject = wrappedObject;
  }

  // And than all method inplemented from Interface code like follow
  public Object getObject(int i, boolean b) {
    return wrappedObject.getObject(I, b);
  }
  public void save(String path) {
    wrappedObject.save(path);
  }
  // …
  // etc
}

PS. Sorry for previos BIG message...

Reply via email to