|
© 2002 BEA Systems, Inc. | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--com.bea.p13n.content.document.ref.RefSQLGenerator
A class which generate and execute SQL based upon the reference document management implementation.
Inner Class Summary | |
static class |
RefSQLGenerator.Info
The generated SQL and information about the Search. |
Field Summary | |
static short |
AND_TYPE
The LogicalAnd/LogicalMulitAnd expression type. |
static short |
COLLECTION_CONTAINS_ALL_TYPE
The CollectionContainsAll expression type. |
static short |
COLLECTION_CONTAINS_TYPE
The CollectionContains expression type. |
static java.text.DateFormat |
dateFormat
A date formatter for "MM/dd/yyyy HH:mm:ss z" (02/28/2000 15:58:35 MST). |
static java.util.Map |
defPropertyColumnMap
The default map of property name to document table column name. |
static java.util.Map |
defPropertyTypeMap
The default map of property names to valid value class. |
java.lang.String |
docMDTable
The document_metadata table name this should use. |
java.lang.String |
docTable
The document table name this should use. |
static short |
EQUALS_TYPE
The Equals expression type. |
boolean |
failOnNonExplicit
Control what happens if docMDTable is null and a property is
found that isn't in propertyColumnMap . |
static short |
GREATER_OR_EQUALS_TYPE
The GreaterOrEquals expression type. |
static short |
GREATER_THAN_TYPE
The GreaterThan expression type. |
static RefSQLGenerator |
instance
A default static instance. |
static short |
LESS_OR_EQUALS_TYPE
The LessOrEquals expression type. |
static short |
LESS_THAN_TYPE
The LessThan expression type. |
static short |
LIKE_TYPE
The StringLike expression type. |
static short |
NOT_EQUALS_TYPE
The NotEquals expression type. |
static short |
NOT_TYPE
The LogicalNot expression type. |
static short |
OR_TYPE
The LogicalOr/LogicalMulitOr expression type. |
java.util.Map |
propertyColumnMap
The map of Criteria property to table column name this should use. |
java.util.Map |
propertyTypeMap
The map of property to valid value class this should use. |
boolean |
sortExplicitOnly
Control if sorting should happen on explicit properties only. |
Constructor Summary | |
RefSQLGenerator()
|
Method Summary | |
protected void |
createBranchInfo(java.lang.StringBuffer buf,
Expression expr,
java.util.List params,
boolean supportsLikeEscapeClause)
Utility to convert a branch expression into a SQL expression. |
protected java.lang.String |
createInfo(Expression expr,
java.util.List params,
boolean supportsLikeEscapeClause)
Utility method to convert an Expression into a SQL expression. |
protected void |
createInfo(java.lang.StringBuffer buf,
Expression expr,
java.util.List params,
boolean supportsLikeEscapeClause)
Utility method to convert an Expression into a SQL expression. |
protected void |
createLeafInfo(java.lang.StringBuffer buf,
Expression expr,
java.util.List params,
boolean supportsLikeEscapeClause)
Utility to convert a valid leaf Expression into a SQL expression. |
java.lang.String |
getExpressionString(short type)
Get the expression string for the specified expression type. |
short |
getExpressionType(Expression expr)
Get a type constant for the given expression. |
protected static PropertyRef |
getLeftHandSide(Expression expr)
Get the left-hand-side of an expression. |
protected static java.lang.Object |
getRightHandSide(Expression expr)
Get the right-hand-side of an expression. |
RefSQLGenerator.Info |
getSearchInfo(java.lang.String baseSql,
Search params,
boolean supportsLikeEscapeClause)
Utility method to get an Info object from the Search params. |
java.lang.String |
getSQLOperator(short type)
Return the corresponding SQL operator for the given expression type. |
protected static Expression |
getSubExpression(Expression expr,
int count)
Get the specified subexpression. |
boolean |
isLegalSingleValueExpressionType(short type)
Determine if a comparator is legal, single-value attribute comparator. |
java.sql.PreparedStatement |
prepare(java.sql.Connection con,
RefSQLGenerator.Info info)
Prepare a JDBC statement from the specified information on the given database connection. |
void |
sort(java.util.List list,
RefSQLGenerator.Info info)
Sort a list of DocumentMetadataDefs based upon the info's sort criteria. |
java.lang.Object |
toSQLLike(java.lang.Object obj,
boolean supportsLikeEscapeClause)
Deprecated. |
java.lang.Object |
toSQLLike(java.lang.Object obj,
boolean patternMatchIgnoreCase,
boolean supportsLikeEscapeClause)
Convert an object, which might be a string, to a SQL like string. |
java.lang.String |
toSQLLike(java.lang.String like,
boolean supportsLikeEscapeClause)
Deprecated. |
java.lang.String |
toSQLLike(java.lang.String like,
boolean patternMatchIgnoreCase,
boolean supportsLikeEscapeClause)
Convert a query LIKE value to a SQL LIKE value. |
Methods inherited from class java.lang.Object |
clone,
equals,
finalize,
getClass,
hashCode,
notify,
notifyAll,
toString,
wait,
wait,
wait |
Field Detail |
public static final RefSQLGenerator instance
This can be used to access any of the default utility method implementations:
Those methods exist as instance methods to allow for subclasses to override behavior.public static final short NOT_EQUALS_TYPE
getExpressionType(com.bea.p13n.expression.Expression)
public static final short EQUALS_TYPE
getExpressionType(com.bea.p13n.expression.Expression)
public static final short GREATER_THAN_TYPE
getExpressionType(com.bea.p13n.expression.Expression)
public static final short LESS_THAN_TYPE
getExpressionType(com.bea.p13n.expression.Expression)
public static final short GREATER_OR_EQUALS_TYPE
getExpressionType(com.bea.p13n.expression.Expression)
public static final short LESS_OR_EQUALS_TYPE
getExpressionType(com.bea.p13n.expression.Expression)
public static final short LIKE_TYPE
getExpressionType(com.bea.p13n.expression.Expression)
public static final short COLLECTION_CONTAINS_TYPE
getExpressionType(com.bea.p13n.expression.Expression)
public static final short COLLECTION_CONTAINS_ALL_TYPE
getExpressionType(com.bea.p13n.expression.Expression)
public static final short AND_TYPE
getExpressionType(com.bea.p13n.expression.Expression)
public static final short OR_TYPE
getExpressionType(com.bea.p13n.expression.Expression)
public static final short NOT_TYPE
getExpressionType(com.bea.p13n.expression.Expression)
public static final java.util.Map defPropertyColumnMap
public static final java.util.Map defPropertyTypeMap
public static final java.text.DateFormat dateFormat
public java.lang.String docTable
RefDocumentProvider.DOC_TABLE
public java.lang.String docMDTable
Set this to null for this to only handle explicit properties. In
this case, if a property is found that is not in the
propertyColumnMap
, this will either produce SQL that will never
match (if failOnNonExplicit
is false) or throw an exception (if
failOnNonExplicit
is true).
RefDocumentProvider.DOC_MD_TABLE
public java.util.Map propertyColumnMap
If the property name from the expression is in this map, then the
associated value will be the document table column
name in the resulting SQL statement. If the property name is not in
this map, then it is assumed the property is from the
document_metadata table (unless
docMDTable
is set null, in which case an exception is
raised). For example, if the property name is "identifier" and the
associated value in the map is "ID", then all expressions written
against "identifier" will get converted into SQL statements againsts
the "ID" column of the document table.
public java.util.Map propertyTypeMap
If the property name from the expression is in propertyColumnMap, it
also needs to be in this map. The associated value is the Class object
minimum type that the literal in the expression being compared to the
property must have. For example, if the property name "size" is mapped
to the "DOCUMENT_SIZE" column in propertyColumnMap
and mapped
to Number.class
here, then, in the expression, all
comparisions to "size" must be against numbers (e.g. "size != 1024",
"size < 10000.0").
public boolean sortExplicitOnly
Explicit properties are those that are mapped to
document table columns in propertyColumnMap
.
If the sortBy of a Search contains a non-explicit property reference
and docMDTable
is not null, this will control what happens. If
this is false (the default), then the SortCriteria will be assigned to
the Info instance and no database level sorting will occur;
something else should handle the sorting (the sort(java.util.List, com.bea.p13n.content.document.ref.RefSQLGenerator.Info)
method can
be used to sort a List of DocumentMetadataDefs). If this is
true, then the property will be skipped for the sort and all sorting
will occur in the database.
public boolean failOnNonExplicit
docMDTable
is null and a property is
found that isn't in propertyColumnMap
.
If this is true, an exception will be thrown; otherwise, SQL that will never match any document will be generated (default).
Constructor Detail |
public RefSQLGenerator()
Method Detail |
public java.sql.PreparedStatement prepare(java.sql.Connection con, RefSQLGenerator.Info info) throws java.sql.SQLException
public void sort(java.util.List list, RefSQLGenerator.Info info) throws DocumentException
public RefSQLGenerator.Info getSearchInfo(java.lang.String baseSql, Search params, boolean supportsLikeEscapeClause) throws DocumentException
baseSql
- the base select part of the sql (no from, no where).params
- the list to add the prepared statement parameters to.supportsLikeEscapeClause
- tells if the SQL statement can use the
LIKE ESCAPE clause.protected java.lang.String createInfo(Expression expr, java.util.List params, boolean supportsLikeEscapeClause) throws DocumentException
expr
- the expression object.params
- the prepared statement input parameters list (will be
appended to).supportsLikeEscapeClause
- tells if the SQL statement can use the
LIKE ESCAPE clause.protected void createInfo(java.lang.StringBuffer buf, Expression expr, java.util.List params, boolean supportsLikeEscapeClause) throws DocumentException
buf
- the string buffer to write into.expr
- the expression object.params
- the prepared statement input parameters list (will be
appended to).supportsLikeEscapeClause
- tells if the SQL statement can use the
LIKE ESCAPE clause.protected static Expression getSubExpression(Expression expr, int count) throws DocumentException
ExpressionHelper.getSubExpression(com.bea.p13n.expression.Expression, int)
protected static PropertyRef getLeftHandSide(Expression expr) throws DocumentException
ExpressionHelper.getLeftHandSide(com.bea.p13n.expression.Expression)
protected static java.lang.Object getRightHandSide(Expression expr) throws DocumentException
ExpressionHelper.getRightHandSide(com.bea.p13n.expression.Expression)
protected void createLeafInfo(java.lang.StringBuffer buf, Expression expr, java.util.List params, boolean supportsLikeEscapeClause) throws DocumentException
buf
- the string buffer to write into.expr
- the expression object.params
- the prepared statement input parameters list (will be
appended to).supportsLikeEscapeClause
- tells if the SQL statement can use the
LIKE ESCAPE clause.protected void createBranchInfo(java.lang.StringBuffer buf, Expression expr, java.util.List params, boolean supportsLikeEscapeClause) throws DocumentException
buf
- the string buffer to write into.expr
- the branch expression.params
- the prepared statement input parameters list (will be
appended to).supportsLikeEscapeClause
- tells if the SQL statement can use the
LIKE ESCAPE clause.public short getExpressionType(Expression expr) throws DocumentException
NOT_EQUALS_TYPE
,
EQUALS_TYPE
,
GREATER_THAN_TYPE
,
LESS_THAN_TYPE
,
GREATER_OR_EQUALS_TYPE
,
LESS_OR_EQUALS_TYPE
,
LIKE_TYPE
,
COLLECTION_CONTAINS_TYPE
,
COLLECTION_CONTAINS_ALL_TYPE
,
AND_TYPE
,
OR_TYPE
,
NOT_TYPE
public java.lang.String getExpressionString(short type) throws DocumentException
NOT_EQUALS_TYPE
,
EQUALS_TYPE
,
GREATER_THAN_TYPE
,
LESS_THAN_TYPE
,
GREATER_OR_EQUALS_TYPE
,
LESS_OR_EQUALS_TYPE
,
LIKE_TYPE
,
COLLECTION_CONTAINS_TYPE
,
COLLECTION_CONTAINS_ALL_TYPE
,
AND_TYPE
,
OR_TYPE
,
NOT_TYPE
public boolean isLegalSingleValueExpressionType(short type)
public java.lang.String getSQLOperator(short type) throws DocumentException
op
- the comparator (one from TypesHelper).public java.lang.String toSQLLike(java.lang.String like, boolean supportsLikeEscapeClause)
public java.lang.Object toSQLLike(java.lang.Object obj, boolean supportsLikeEscapeClause)
public java.lang.String toSQLLike(java.lang.String like, boolean patternMatchIgnoreCase, boolean supportsLikeEscapeClause)
public java.lang.Object toSQLLike(java.lang.Object obj, boolean patternMatchIgnoreCase, boolean supportsLikeEscapeClause)
|
© 2002 BEA Systems, Inc. | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |