Rakesh API

biz.wedoit4u.databeans
Class ContentHelper

java.lang.Object
  extended by biz.wedoit4u.databeans.ContentHelper

final class ContentHelper
extends java.lang.Object

A helper class that provides convenient methods to interact with the contents table. This class is meant to be used from the DatabaseHelper class, or other classes in this package only.

Copyright 2003, Rakesh Vidyadharan and wedoit4u.biz

Version:
$Id: ContentHelper.java,v 1.3 2004/05/26 11:42:31 rakesh Exp $
Author:
Rakesh Vidyadharan 21st October 2003

Field Summary
(package private) static java.lang.String ALL_CONTENTS
          The statement that is executed to fetch all the records from the contents table.
(package private) static java.lang.String CONTENT_ID_SEQUENCE
          The sequence set in the database for the content_id primary key column.
(package private) static java.lang.String DELETE_CONTENTS
          The delete statement that is executed to delete a record in the contents table identified by the primary key value.
(package private) static java.lang.String FIND_BY_CATEGORY
          The statement that is executed to fetch all the records from the contents table that are associated with the specified category_id.
(package private) static java.lang.String INSERT_CONTENTS
          The statement that is executed to insert a new record into the contents table.
(package private) static java.lang.String NULL_BODY
          The statement that is used to empty the contents of the body column prior to updating it.
(package private) static java.lang.String SELECT_CONTENTS
          The statement that is executed to fetch a specific record from the contents table.
(package private) static java.lang.String UPDATE_BODY
          The statement that is used to set the value of the body column.
(package private) static java.lang.String UPDATE_CONTENTS
          The update statement to be executed to update a record in the content_types table.
 
Constructor Summary
private ContentHelper()
          Default constructor.
 
Method Summary
(package private) static void delete(int contentId)
          Delete the record from the database identified by the primary key value specified.
(package private) static java.util.Collection findAll()
          Return a Collection of Integer values that represent all the primary key values in the contents table.
(package private) static java.util.Collection findByCategory(int categoryId)
          Return a Collection of Integer values that represent all the primary key values in the contents table that are associated with the specified category_id.
(package private) static int insert(int contentId, int categoryId, java.lang.String title, java.lang.String brief, java.lang.String picture, java.lang.String body)
          Insert a new record into the contents table with the values specified.
(package private) static void nullBody(int contentId)
          Reset the contents of the body column to an empty string.
(package private) static void select(ContentBean cb)
          Select the specified record from the contents table.
(package private) static void update(ContentBean cb)
          Update the values in the contents table with the specified values.
(package private) static void updateBody(int contentId, java.lang.String body)
          Write the specified string as the contents of the body column.
(package private) static void writeBody(int contentId, java.lang.String body)
          Write the specified contents to the body column of the specified content record.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

CONTENT_ID_SEQUENCE

static final java.lang.String CONTENT_ID_SEQUENCE
The sequence set in the database for the content_id primary key column.

See Also:
Constant Field Values

ALL_CONTENTS

static final java.lang.String ALL_CONTENTS
The statement that is executed to fetch all the records from the contents table.

See Also:
Constant Field Values

FIND_BY_CATEGORY

static final java.lang.String FIND_BY_CATEGORY
The statement that is executed to fetch all the records from the contents table that are associated with the specified category_id.

See Also:
Constant Field Values

INSERT_CONTENTS

static final java.lang.String INSERT_CONTENTS
The statement that is executed to insert a new record into the contents table.

See Also:
Constant Field Values

SELECT_CONTENTS

static final java.lang.String SELECT_CONTENTS
The statement that is executed to fetch a specific record from the contents table.

See Also:
Constant Field Values

UPDATE_CONTENTS

static final java.lang.String UPDATE_CONTENTS
The update statement to be executed to update a record in the content_types table.

See Also:
Constant Field Values

DELETE_CONTENTS

static final java.lang.String DELETE_CONTENTS
The delete statement that is executed to delete a record in the contents table identified by the primary key value.

See Also:
Constant Field Values

NULL_BODY

static final java.lang.String NULL_BODY
The statement that is used to empty the contents of the body column prior to updating it.

See Also:
Constant Field Values

UPDATE_BODY

static final java.lang.String UPDATE_BODY
The statement that is used to set the value of the body column.

See Also:
Constant Field Values
Constructor Detail

ContentHelper

private ContentHelper()
Default constructor. Cannot be instantiated.

Method Detail

findAll

static final java.util.Collection findAll()
                                   throws java.sql.SQLException,
                                          javax.naming.NamingException
Return a Collection of Integer values that represent all the primary key values in the contents table.

Returns:
Collection - The collection of primary key values.
Throws:
java.sql.SQLException - - If errors are encountered while fetching the records from the database.
javax.naming.NamingException - - If errors are encountered while getting a connection from the connection pool.

findByCategory

static final java.util.Collection findByCategory(int categoryId)
                                          throws java.sql.SQLException,
                                                 javax.naming.NamingException
Return a Collection of Integer values that represent all the primary key values in the contents table that are associated with the specified category_id.

Parameters:
categoryId - - The category_id value.
Returns:
Collection - The collection of primary key values.
Throws:
java.sql.SQLException - - If errors are encountered while fetching the records from the database.
javax.naming.NamingException - - If errors are encountered while getting a connection from the connection pool.

select

static final void select(ContentBean cb)
                  throws java.sql.SQLException,
                         javax.naming.NamingException
Select the specified record from the contents table. The values selected from the database are used to set the values of the bean fields.

Parameters:
cb - - The java bean instance that represents the record. The primary key value to use to look up the record is obtained from this bean.
Throws:
java.sql.SQLException - - If errors are encountered while fetching the record from the database.
javax.naming.NamingException - - If errors are encountered while getting a connection from the connection pool.

insert

static final int insert(int contentId,
                        int categoryId,
                        java.lang.String title,
                        java.lang.String brief,
                        java.lang.String picture,
                        java.lang.String body)
                 throws java.sql.SQLException,
                        javax.naming.NamingException
Insert a new record into the contents table with the values specified.

Parameters:
contentId - - The primary key values to use. If this is 0, then the next value from the CONTENT_ID_SEQUENCE is used.
categoryId - - The category_id value.
title - - The title value.
brief - - The brief value.
picture - - The picture value.
body - - The body value.
Throws:
java.sql.SQLException - - If database errors are encountered while writing to the database.
javax.naming.NamingException - - If errors are encountered while getting a connection from the connection pool.

update

static final void update(ContentBean cb)
                  throws java.sql.SQLException,
                         javax.naming.NamingException
Update the values in the contents table with the specified values.

Parameters:
cb - - The java bean that represents a record in the database.
Throws:
java.sql.SQLException - - If database errors are encountered while writing to the database.
javax.naming.NamingException - - If errors are encountered while getting a connection from the connection pool.

writeBody

static final void writeBody(int contentId,
                            java.lang.String body)
                     throws java.sql.SQLException,
                            javax.naming.NamingException
Write the specified contents to the body column of the specified content record.

Parameters:
contentId - - The primary key value whose body is to be updated.
body - - The new body value.
Throws:
java.sql.SQLException - - If errors are encountered while writing to the database.
javax.naming.NamingException - - If errors are encountered while getting a connection from the connection pool.
See Also:
nullBody( int ), updateBody( int, String )

nullBody

static final void nullBody(int contentId)
                    throws java.sql.SQLException,
                           javax.naming.NamingException
Reset the contents of the body column to an empty string.

Parameters:
contentId - - The primary key value whose body is to be updated.
Throws:
java.sql.SQLException - - If errors are encountered while writing to the database.
javax.naming.NamingException - - If errors are encountered while getting a connection from the connection pool.

updateBody

static final void updateBody(int contentId,
                             java.lang.String body)
                      throws java.sql.SQLException,
                             javax.naming.NamingException
Write the specified string as the contents of the body column.

Note: You must truncate any existing content in the body column prior to using this method to ensure that you get the expected results. Just calling this method will simply replace the first body.length() characters with the characters from the specified body.

Parameters:
contentId - - The primary key value whose body is to be updated.
body - - The new body value.
Throws:
java.sql.SQLException - - If errors are encountered while writing to the database.
javax.naming.NamingException - - If errors are encountered while getting a connection from the connection pool.

delete

static final void delete(int contentId)
                  throws java.sql.SQLException,
                         javax.naming.NamingException
Delete the record from the database identified by the primary key value specified.

Parameters:
contentId - - The content_id primary key value.
Throws:
java.sql.SQLException - - If database errors are encountered while writing to the database.
javax.naming.NamingException - - If errors are encountered while getting a connection from the connection pool.

Rakesh API

Copyright © 2002-2005 - Rakesh Vidyadharan