Android Open Source - SQLDroid S Q L Droid Blob






From Project

Back to project page SQLDroid.

License

The source code is released under:

MIT License

If you think the Android project SQLDroid listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.

Java Source Code

package org.sqldroid;
/*from  w  w  w. j  a  va2  s. c  o m*/
import java.io.InputStream;
import java.io.OutputStream;
import java.sql.Blob;
import java.sql.SQLException;

public class SQLDroidBlob implements Blob {

  byte [] b;
  
  public SQLDroidBlob(byte [] b) {
    this.b = b;
  }
  
  @Override
  public InputStream getBinaryStream() throws SQLException {
    System.err.println(" ********************* not implemented @ " + DebugPrinter.getFileName() + " line " + DebugPrinter.getLineNumber());
    return null;
  }

  @Override
  public byte[] getBytes(long pos, int length) throws SQLException {
    return b;
  }

  @Override
  public long length() throws SQLException {
    
    return b.length;
  }

  @Override
  public long position(Blob pattern, long start) throws SQLException {
    System.err.println(" ********************* not implemented @ " + DebugPrinter.getFileName() + " line " + DebugPrinter.getLineNumber());
    return 0;
  }

  @Override
  public long position(byte[] pattern, long start) throws SQLException {
    System.err.println(" ********************* not implemented @ " + DebugPrinter.getFileName() + " line " + DebugPrinter.getLineNumber());
    return 0;
  }

  @Override
  public OutputStream setBinaryStream(long pos) throws SQLException {
    System.err.println(" ********************* not implemented @ " + DebugPrinter.getFileName() + " line " + DebugPrinter.getLineNumber());
    return null;
  }

  @Override
  public int setBytes(long pos, byte[] theBytes) throws SQLException {
    System.err.println(" ********************* not implemented @ " + DebugPrinter.getFileName() + " line " + DebugPrinter.getLineNumber());
    return 0;
  }

  @Override
  public int setBytes(long pos, byte[] theBytes, int offset, int len)
      throws SQLException {
    System.err.println(" ********************* not implemented @ " + DebugPrinter.getFileName() + " line " + DebugPrinter.getLineNumber());
    return 0;
  }

  @Override
  public void truncate(long len) throws SQLException {
    System.err.println(" ********************* not implemented @ " + DebugPrinter.getFileName() + " line " + DebugPrinter.getLineNumber());

  }

  @Override
  public void free() throws SQLException {
    // TODO Auto-generated method stub
    
  }

  @Override
  public InputStream getBinaryStream(long pos, long length)
      throws SQLException {
    // TODO Auto-generated method stub
    return null;
  }

  /** Print the length of the blob along with the first 10 characters.
   * @see java.lang.Object#toString()
   */
  @Override
  public String toString() {
    StringBuffer sb = new StringBuffer();
    if ( b == null ) {
      sb.append("Null Blob");
    }
    sb.append ("Blob length ");
    long length = 0;
    try {
      length = length();
    } catch (SQLException e) {
      // never thrown
    }
    sb.append (length);
    sb.append(" ");
    if ( length > 10 ) {
      length = 10;
    }
    for ( int counter = 0 ; counter < length ; counter++ ) {
      sb.append ("0x");
      sb.append (Integer.toHexString(b[counter]));
      sb.append(" ");
    }
    sb.append("(");
    for ( int counter = 0 ; counter < length ; counter++ ) {
      sb.append (Character.toString((char)b[counter]));
      if ( counter == length-1 ) {
        sb.append(")");
      } else {
        sb.append(" ");
      }
    }
    return sb.toString();
  }


}




Java Source Code List

android.content.ContentValues.java
android.database.AbstractCursor.java
android.database.Cursor.java
android.database.MatrixCursor.java
android.database.MergeCursor.java
android.database.SQLException.java
android.database.SQLite.java
android.database.sqlite.SQLiteDatabaseLockedException.java
android.database.sqlite.SQLiteDatabase.java
android.database.sqlite.SQLiteException.java
android.util.Log.java
org.sqldroid.DebugPrinter.java
org.sqldroid.DroidDataSource.java
org.sqldroid.Log.java
org.sqldroid.SQLDroidBlob.java
org.sqldroid.SQLDroidClob.java
org.sqldroid.SQLDroidConnection.java
org.sqldroid.SQLDroidDatabaseMetaData.java
org.sqldroid.SQLDroidDriver.java
org.sqldroid.SQLDroidPreparedStatement.java
org.sqldroid.SQLDroidResultSetMetaData.java
org.sqldroid.SQLDroidResultSet.java
org.sqldroid.SQLDroidSQLException.java
org.sqldroid.SQLDroidStatement.java
org.sqldroid.SQLiteDatabase.java