All Packages Class Hierarchy This Package Previous Next Index
Class com.expershop.esapi.DbObject
java.lang.Object
|
+----com.expershop.esapi.DbObject
- public class DbObject
- extends Object
-
addColumn(String, int, String)
- Add a new column to this DbObject.
-
clearValues()
- Reset all column values: Numeric columns are set to 0, String columns are
set to "" (empty string).
-
deleteQuery(String)
- Generate a DELETE SQL request, and return it as a String.
The request is for later use, deleteQuery() DOES NOT AFFECT the database.
-
get(String)
- Retrieve a column's value, as a String.
-
getDouble(String)
- Retrieve a column's value, as a double.
-
insertQuery()
- Generate an INSERT SQL request to create the current object in the
database, and return it as a String.
The request is for later use, insertQuery() DOES NOT AFFECT the database.
-
present(String)
- Check if a column exists (is present).
-
saveChanges(String)
- Update the database so it reflects the changes in the current DbObject.
This method WILL ISSUE AN UPDATE REQUEST TO THE DATABASE, so it will
certainly affect the database content.
This method uses the updateQuery() method to generate the UPDATE query.
-
set(String, double)
- Set a column's value, for columns of type double.
-
set(String, int)
- Set a column's value, for columns of type int.
-
set(String, long)
- Set a column's value, for columns of type long.
-
set(String, String)
- Set a column's value, for columns of type String.
-
setFromRequest(ServletRequest)
- Set column's values according to parameters in a ServletRequest.
Column names and ServletRequest parameter names are matched: when a
ServletRequest parameter's name matches a writable column's name, the
column's value is set according to the ServletRequest parameter's value.
-
setSqlEncode(boolean)
- Decide to implicitly SQL-encode column values when they are set, or not;
By default, implicit SQL-encoding is enabled.
This method influences the behavoiur of the set() methods.
SQL encoding replaces special characters, like quotes, with characters
accepted in database column values.
SQL encoding rules are specified in the application's configuration file
(sqlencode.Substitutions property).
Rules syntax: c1=s1;c2=s2;...cn=sn (replace char1 with string1, etc...)
-
setWritable(String, boolean)
- Tell if a column is writable or not: by default, columns are writable.
-
updateQuery(String)
- Generate an UPDATE SQL request that reflects the current object's changes,
and return it as a String.
The request is for later use, updateQuery() DOES NOT AFFECT the
database.
If you need to update the database, you may want to use the saveChanges()
method instead.
setSqlEncode
public void setSqlEncode(boolean s)
- Decide to implicitly SQL-encode column values when they are set, or not;
By default, implicit SQL-encoding is enabled.
This method influences the behavoiur of the set() methods.
SQL encoding replaces special characters, like quotes, with characters
accepted in database column values.
SQL encoding rules are specified in the application's configuration file
(sqlencode.Substitutions property).
Rules syntax: c1=s1;c2=s2;...cn=sn (replace char1 with string1, etc...)
- Parameters:
- s - true to SQL-encode values, false otherwise
setWritable
public void setWritable(String name,
boolean w)
- Tell if a column is writable or not: by default, columns are writable.
- Parameters:
- name - The column name.
- w - true if writable, false if not.
get
public String get(String name) throws SQLException
- Retrieve a column's value, as a String.
- Parameters:
- name - The column name.
- Returns:
- The column value.
getDouble
public double getDouble(String name) throws SQLException
- Retrieve a column's value, as a double.
- Parameters:
- name - The column name.
- Returns:
- The column value.
set
public void set(String name,
String val)
- Set a column's value, for columns of type String.
- Parameters:
- name - The column name.
- val - The column value.
set
public void set(String name,
int val)
- Set a column's value, for columns of type int.
- Parameters:
- name - The column name.
- val - The column value.
set
public void set(String name,
long val)
- Set a column's value, for columns of type long.
- Parameters:
- name - The column name.
- val - The column value.
set
public void set(String name,
double val)
- Set a column's value, for columns of type double.
- Parameters:
- name - The column name.
- val - The column value.
present
public boolean present(String col)
- Check if a column exists (is present).
- Parameters:
- col - The column name.
- Returns:
- true if present, false if not.
setFromRequest
public void setFromRequest(ServletRequest req)
- Set column's values according to parameters in a ServletRequest.
Column names and ServletRequest parameter names are matched: when a
ServletRequest parameter's name matches a writable column's name, the
column's value is set according to the ServletRequest parameter's value.
- Parameters:
- req - A ServletRequest
addColumn
public void addColumn(String name,
int type,
String val)
- Add a new column to this DbObject.
- Parameters:
- name - The column name.
- type - The column type: any type defined in java.sql.Types (examples:
Types.INTEGER, Types.DOUBLE, Types.VARCHAR).
- val - The column value, as a String.
saveChanges
public void saveChanges(String where) throws SQLException
- Update the database so it reflects the changes in the current DbObject.
This method WILL ISSUE AN UPDATE REQUEST TO THE DATABASE, so it will
certainly affect the database content.
This method uses the updateQuery() method to generate the UPDATE query.
- Parameters:
- where - An SQL "where" clause (for example, "id=1" will result in
an "update ... where id=1" SQL request to be issued).
clearValues
public void clearValues()
- Reset all column values: Numeric columns are set to 0, String columns are
set to "" (empty string).
deleteQuery
public String deleteQuery(String where)
- Generate a DELETE SQL request, and return it as a String.
The request is for later use, deleteQuery() DOES NOT AFFECT the database.
- Parameters:
- where - An SQL "where" clause (for example, "id=1" will result in
a "delete ... where id=1" SQL request to be generated).
updateQuery
public String updateQuery(String where)
- Generate an UPDATE SQL request that reflects the current object's changes,
and return it as a String.
The request is for later use, updateQuery() DOES NOT AFFECT the
database.
If you need to update the database, you may want to use the saveChanges()
method instead.
- Parameters:
- where - An SQL "where" clause (for example, "id=1" will result in
an "update ... where id=1" SQL request).
insertQuery
public String insertQuery()
- Generate an INSERT SQL request to create the current object in the
database, and return it as a String.
The request is for later use, insertQuery() DOES NOT AFFECT the database.
- Parameters:
- where - An SQL "where" clause (for example, "id=1" will result in
an "insert ..." SQL request).
All Packages Class Hierarchy This Package Previous Next Index