package org.litesoft.orsup.selection; import org.litesoft.util.IllegalArgument; // Copyright Status: // // All Software available from LiteSoft.org (including this file) is // hereby released into the public domain. // // It is free! As in, you may use it freely in both commercial and // non-commercial applications, bundle it with your software // distribution, include it on a CD-ROM, list the source code in a book, // mirror the documentation at your own web site, or use it in any other // way you see fit. // // NO Warranty! // // All software is provided "as is". // // There is ABSOLUTELY NO WARRANTY OF ANY KIND: not for the design, fitness // (for a particular purpose), level of errors (or lack thereof), or // applicability of this software. The entire risk as to the quality // and performance of this software is with you. Should this software // prove defective, you assume the cost of all necessary servicing, repair // or correction. // // In no event unless required by applicable law or agreed to in writing // will any party who created or may modify and/or redistribute this // software, be liable to you for damages, including any general, // special, incidental or consequential damages arising out of the use or // inability to use this software (including but not limited to loss of // data or data being rendered inaccurate or losses sustained by you or // third parties or a failure of this software to operate with any // other programs), even if such holder or other party has been advised // of the possibility of such damages. // // NOTE: Should you discover a bug, have a recogmendation for a change, wish // to submit modifications, or wish to add new classes/functionality, // please email them to: // // changes44@litesoft.org // /** * An abstract representation of a SQL WHERE clause that supports a * column and comparison value.

* * This WhereClause is NOTable.

* * This form of WhereClause is currently used to support: * EQUALS, LESSTHAN, and GREATERTHAN.

* * See WhereClause
* See WhereClauseFactory

* * Exceptions: All problems caught when the parameter(s) are checked (as * indicated/implied in the @param tags) will generate an IllegalArgumentException, * and means the API user has a problem. If a NullPointerException (or some * others, like: ClassCastException or ArrayIndexOutOfBoundsException) is thrown, * it means the API developer has a problem. Any Exception that is explicitly * thrown in the API, but unrelated to a parameter, will be listed in the throws * clause (and hopefully in the tag @throws). These may (but probably won't) be * checked Exceptions. * * @author George Smith * @version 1.03 02/07/02 Exception Policy, Use of IllegalArgument class. * @version 1.02 11/05/01 Completed? JavaDocs * @version 1.0 10/07/01 */ public abstract class AbstractWhereClauseColumnAndValue extends AbstractWhereClauseColumnReference { private Object zValue; private String zRegOperatorString; // "==" private String zRegOperatorSql; // "=" private String zNotOperatorString; // "!=" private String zNotOperatorSql; // "<>" /** * Constructor that supports a Column and comparison value SQL WHERE clause.

* * Note: Both the type of the Column and the type of the Value should be * comparable. For the SQL generation, the Value object's toString() * method is used for conversion.

* * @param pType The Type (EQUALS, LESSTHAN, and GREATERTHAN) for this WhereClause. * @param pColumnDefinition Column Definition (!null). * @param pRegOperatorString Regular (!not) Operator for toString() method (!null). eg "==" * @param pRegOperatorSql Regular (!not) Operator for toSQL() (!null). eg "=" * @param pNotOperatorString Not Operator for toString() (!null). eg "!=" * @param pNotOperatorSql Not Operator for toSQL() (!null). eg "<>" * @param pValue Value to be used for comparison checking (!null). */ protected AbstractWhereClauseColumnAndValue( int pType , SimpleColumnDefinition pColumnDefinition , String pRegOperatorString , String pRegOperatorSql , String pNotOperatorString , String pNotOperatorSql , Object pValue ) { super( pType , pColumnDefinition ); IllegalArgument.ifNull( "RegOperatorString" , zRegOperatorString = pRegOperatorString); IllegalArgument.ifNull( "RegOperatorSql" , zRegOperatorSql = pRegOperatorSql); IllegalArgument.ifNull( "NotOperatorString" , zNotOperatorString = pNotOperatorString); IllegalArgument.ifNull( "NotOperatorSql" , zNotOperatorSql = pNotOperatorSql); IllegalArgument.ifNull( "Value" , zValue = pValue); } /** * Accessor for the comparison value.

* * @return the comparison value (!null). */ public final Object getValue() { return zValue; } /** * Helper method for toString() that provides a more efficient * mechanism for the recursive decent of a WhereClause tree.

* * @param pSB the StringBuffer to build the WhereClause into.

* * @see WhereClause#toString() */ protected void toStringHelper( StringBuffer pSB ) { toStringColumnReference( pSB ); pSB.append( ' ' ); pSB.append( isNot() ? zNotOperatorString : zRegOperatorString ); pSB.append( ' ' ); WhereClauseColumnSupport.makeStringValue( pSB , getColumnDefinition() , getValue() ); } /** * Helper method for toSQL() that provides a more efficient * mechanism for the recursive decent of a WhereClause tree.

* * Note: May need to override to get proper result for SQL.

* * @param pSB the StringBuffer to build the WhereClause into.

* * @see WhereClause#toSQL() */ protected void toSqlHelper( StringBuffer pSB ) { toSqlColumnReference( pSB ); pSB.append( ' ' ); pSB.append( isNot() ? zNotOperatorSql : zRegOperatorSql ); pSB.append( ' ' ); WhereClauseColumnSupport.makeSqlValue( pSB , getColumnDefinition() , getValue() ); } }