ModeShape Distribution 3.0.0.Beta2

org.modeshape.jcr.value.binary
Class Database

java.lang.Object
  extended by org.modeshape.jcr.value.binary.Database

public class Database
extends Object

Helper class for manipulation with database.

Author:
kulikov

Constructor Summary
Database(Connection connection)
           
 
Method Summary
static InputStream asStream(ResultSet rs)
          Provides access to query data
static String asString(ResultSet rs)
          Provides access to query data
protected  String blobType(Connection connection, int size)
          Determine the database-specific BLOB column type.
 void createTable()
          Creates table for storage.
static void execute(PreparedStatement sql)
          Executes specifies statement.
static ResultSet executeQuery(PreparedStatement sql)
          Runs SQL statement
static void executeUpdate(PreparedStatement sql)
          Executes specifies update statement.
 PreparedStatement insertContentSQL(BinaryKey key, InputStream stream)
          Create statement for store content.
 PreparedStatement markUnusedSQL(BinaryKey key)
          Generates SQL statement which marks content as not used.
 PreparedStatement removeExpiredContentSQL(long deadline)
          Generates SQL statement which removes expired content.
 PreparedStatement retrieveContentSQL(BinaryKey key)
          Generates SQL statement for content retrieve.
 PreparedStatement retrieveExtTextSQL(BinaryKey key)
          Generate SQL statement which returns extracted text.
 PreparedStatement retrieveMimeTypeSQL(BinaryKey key)
          Generates SQL statement for mime type retrieve.
 boolean tableExists()
          Checks database for CONTENT_STORE table
 PreparedStatement updateExtTextSQL(BinaryKey key, String text)
          Generates SQL statement which updates extracted text field.
 PreparedStatement updateMimeTypeSQL(BinaryKey key, String mimeType)
          Generates SQL statement which modifies mime type value.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Database

public Database(Connection connection)
Method Detail

insertContentSQL

public PreparedStatement insertContentSQL(BinaryKey key,
                                          InputStream stream)
                                   throws BinaryStoreException
Create statement for store content.

Parameters:
key - unique content identifier
stream - content to store
Returns:
SQL statement.
Throws:
BinaryStoreException

retrieveContentSQL

public PreparedStatement retrieveContentSQL(BinaryKey key)
                                     throws BinaryStoreException
Generates SQL statement for content retrieve.

Parameters:
key - content id
Returns:
executable SQL statement
Throws:
BinaryStoreException

markUnusedSQL

public PreparedStatement markUnusedSQL(BinaryKey key)
                                throws BinaryStoreException
Generates SQL statement which marks content as not used.

Parameters:
key - the content id.
Returns:
SQL statement.
Throws:
BinaryStoreException

removeExpiredContentSQL

public PreparedStatement removeExpiredContentSQL(long deadline)
                                          throws BinaryStoreException
Generates SQL statement which removes expired content.

Parameters:
deadline - expire time
Returns:
SQL statement.
Throws:
BinaryStoreException

retrieveMimeTypeSQL

public PreparedStatement retrieveMimeTypeSQL(BinaryKey key)
                                      throws BinaryStoreException
Generates SQL statement for mime type retrieve.

Parameters:
key - content id
Returns:
SQL statement.
Throws:
BinaryStoreException

updateMimeTypeSQL

public PreparedStatement updateMimeTypeSQL(BinaryKey key,
                                           String mimeType)
                                    throws BinaryStoreException
Generates SQL statement which modifies mime type value.

Parameters:
key - content id
mimeType - the new value for mime type
Returns:
SQL statement
Throws:
BinaryStoreException

retrieveExtTextSQL

public PreparedStatement retrieveExtTextSQL(BinaryKey key)
                                     throws BinaryStoreException
Generate SQL statement which returns extracted text.

Parameters:
key - content id
Returns:
SQL statement
Throws:
BinaryStoreException

updateExtTextSQL

public PreparedStatement updateExtTextSQL(BinaryKey key,
                                          String text)
                                   throws BinaryStoreException
Generates SQL statement which updates extracted text field.

Parameters:
key - content id
text - new value for the extracted text
Returns:
SQL statement
Throws:
BinaryStoreException

execute

public static void execute(PreparedStatement sql)
                    throws BinaryStoreException
Executes specifies statement.

Parameters:
sql - the statement to execute
Throws:
BinaryStoreException

executeQuery

public static ResultSet executeQuery(PreparedStatement sql)
                              throws BinaryStoreException
Runs SQL statement

Parameters:
sql - SQL statement
Returns:
result of statement execution
Throws:
BinaryStoreException

executeUpdate

public static void executeUpdate(PreparedStatement sql)
                          throws BinaryStoreException
Executes specifies update statement.

Parameters:
sql - the statement to execute
Throws:
BinaryStoreException

asStream

public static InputStream asStream(ResultSet rs)
                            throws BinaryStoreException
Provides access to query data

Parameters:
rs - retrieved single value
Returns:
result as input stream.
Throws:
BinaryStoreException

asString

public static String asString(ResultSet rs)
                       throws BinaryStoreException
Provides access to query data

Parameters:
rs - retrieved query result
Returns:
result as string.
Throws:
BinaryStoreException

tableExists

public boolean tableExists()
                    throws BinaryStoreException
Checks database for CONTENT_STORE table

Returns:
true if table exists
Throws:
BinaryStoreException

createTable

public void createTable()
                 throws BinaryStoreException
Creates table for storage.

Throws:
BinaryStoreException

blobType

protected String blobType(Connection connection,
                          int size)
                   throws BinaryStoreException
Determine the database-specific BLOB column type.

Parameters:
connection - the connection
size - the size of the column
Returns:
the type of BLOB column; never null but possibly empty
Throws:
BinaryStoreException

ModeShape Distribution 3.0.0.Beta2

Copyright © 2008-2012 JBoss, a division of Red Hat. All Rights Reserved.