litesoft
@ 947
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 |
// This Source Code is in the Public Domain per: http://unlicense.org package org.litesoft.orsup.selection.nonpublic; import org.litesoft.orsup.selection.*; /** * An abstract representation of a SQL <i>WHERE</i> clause that supports a * column and two or more "equal" values.<p> * <a href="../../../Licence.txt">Licence</a><br> * <p/> * This <b>WhereClause</b> is <a href="WhereClauseNotable.html"><b>NOT</b><i>able</i></a>.<p> * <p/> * This form of <b>WhereClause</b> primarily exists to support AnyOf.<p> * <p/> * See <a href="WhereClause.html">WhereClause</a><br> * See <a href="WhereClauseFactory.html">WhereClauseFactory</a><p> * <p/> * 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.0 07/07/08 */ public abstract class AbstractWhereClauseColumnAnd_N_Values extends AbstractWhereClauseColumnReference { private Object[] mValues; /** * Constructor that associates two or more !null "equal" values with * a column.<p> * <p/> * Note: Both the type of the Column and the types of the values should * be comparable. For the SQL generation, the object's toString() * method is used for <i>conversion</i>.<p> * * @param pType the Type for this WhereClause. * @param pColumnDefinition Column Definition (!null). * @param pValues Values (two or more !null). */ protected AbstractWhereClauseColumnAnd_N_Values( WhereClauseType pType, SimpleColumnDefinition pColumnDefinition, Object... pValues ) { super( pType, pColumnDefinition ); if ( (pValues == null) || (pValues.length == 0) ) { throw new IllegalArgumentException( "No Values" ); } if ( pValues.length < 2 ) { throw new IllegalArgumentException( "Not Two Values" ); } for ( int i = 0; i < pValues.length; i++ ) { if ( pValues[i] == null ) { throw new IllegalArgumentException( "Values[" + i + "] was null" ); } } mValues = pValues; } /** * Accessor for the two or more "equal" values (!null).<p> * * @return the two or more "equal" values (!null). */ public final Object[] getValues() { return mValues; } @Override protected void toStringHelper( StringBuilder pSB ) { toStringColumnReference( pSB ); pSB.append( ' ' ); pSB.append( isNot() ? getType().getToNotStr() : getType().getToStr() ); Object[] zValues = getValues(); WhereClauseColumnSupport.makeStringValue( pSB, getColumnDefinition(), zValues[0] ); for ( int i = 1; i < zValues.length; i++ ) { pSB.append( ',' ); WhereClauseColumnSupport.makeStringValue( pSB, getColumnDefinition(), zValues[i] ); } pSB.append( ')' ); } @Override protected void toSqlHelper( WCtoSqlHelper pWCtoSqlHelper, StringBuilder pSB ) { if ( !pWCtoSqlHelper.preRender( this, pSB ) ) { toSqlColumnReference( pSB ); pSB.append( ' ' ); pSB.append( isNot() ? getType().getToNotSql() : getType().getToSql() ); Object[] zValues = getValues(); WhereClauseColumnSupport.makeSqlValue( pSB, getColumnDefinition(), true, zValues[0] ); for ( int i = 1; i < zValues.length; i++ ) { pSB.append( ',' ); WhereClauseColumnSupport.makeSqlValue( pSB, getColumnDefinition(), true, zValues[i] ); } pSB.append( ')' ); pWCtoSqlHelper.postRender( this, pSB ); } } } |
Commits for litesoft/trunk/Java/core/Server/src/org/litesoft/orsup/selection/nonpublic/AbstractWhereClauseColumnAnd_N_Values.java
Revision | Author | Commited | Message |
---|---|---|---|
947 Diff | GeorgeS | Fri 06 Jun, 2014 23:36:56 +0000 | Correct Spelling of package! |
151 Diff | GeorgeS | Thu 17 Mar, 2011 04:16:22 +0000 | |
49 Diff | GeorgeS | Mon 12 Apr, 2010 02:59:10 +0000 | License Text |
24 Diff | GeorgeS | Wed 24 Feb, 2010 01:51:38 +0000 | |
2 | GeorgeS | Sun 07 Feb, 2010 12:50:58 +0000 |