www.element4solution.com

e4s.db
Class E4DBFilter

java.lang.Object
  extended by e4s.util.E4Object
      extended by e4s.db.E4DBFilter
Direct Known Subclasses:
E4DBFilterAnd, E4DBFilterOr

public abstract class E4DBFilter
extends E4Object

Baseclass for definition for a SQL-WHERE construct.

Since:
JDK 1.4
See Also:
E4DBFilterAnd, E4DBFilterOr, E4DBFilter_Intf

Field Summary
static int COMP_EMPTY
           
static int COMP_EQUALS
           
static int COMP_GREATER
           
static int COMP_GREATER_EQUAL
           
protected static int COMP_IN
           
static int COMP_IS_NOT_NULL
           
static int COMP_IS_NULL
           
static int COMP_LESS
           
static int COMP_LESS_EQUAL
           
static int COMP_LIKE
           
static int COMP_NOT_EMPTY
           
static int COMP_NOT_EQUALS
           
protected static int COMP_NOT_IN
           
static int COMP_NOT_LIKE
           
 
Fields inherited from class e4s.util.E4Object
CRLF, E4S_CORE_SYSTEM_LANGUAGE, NBSP, NULLSTR, URL_ENCODING_CHARSET
 
Constructor Summary
E4DBFilter()
           
E4DBFilter(E4ApplObj_Intf applobj)
           
 
Method Summary
static java.lang.String _getSVNVersionString()
           
static java.lang.String Escape(E4String s)
          Escapes the single quote character (') by two single quote characters ('').
static java.lang.String Escape(java.lang.String s)
          Escapes the single quote character (') by two single quote characters ('').
 void finalize()
           
 E4ApplObj_Intf getApplObj()
          Get the application object.
 E4Client getClient()
          Get the client based on the application object.
protected  java.lang.String getSession()
           
protected  java.lang.String getWhere(java.lang.String logical_connex)
           
 boolean isWhereDefined()
          Check, if the WHERE clause of the SQL statement contains any definitions - except those for E4Client.
static java.lang.String OP(int comparsion_operator)
          Converts a predefined compersion operator symbol into an sql comparsion operator.
 void resetWhere()
          Reset the SQL-WHERE clause as far as it was defined.
 void setFilter_IN(E4DBColumnName columnname, E4DBSelectDistinct selection)
           
 void setFilter_IN(java.lang.String logical_connex, E4DBColumnName fieldname, E4Long[] filter)
           
 void setFilter_IN(java.lang.String logical_connex, E4DBColumnName fieldname, E4String[] filter)
           
protected  void setFilter_IN(java.lang.String logical_connex, E4DBColumnName fieldname, long[] filter)
           
 void setFilter_IN(java.lang.String logical_connex, E4DBColumnName fieldname, java.lang.String[] filter)
           
 void setFilter_NOT_IN(E4DBColumnName columnname, E4DBSelectDistinct selection)
           
 void setFilter_NOT_IN(java.lang.String logical_connex, E4DBColumnName fieldname, E4Long[] filter)
           
 void setFilter_NOT_IN(java.lang.String logical_connex, E4DBColumnName fieldname, E4String[] filter)
           
protected  void setFilter_NOT_IN(java.lang.String logical_connex, E4DBColumnName fieldname, long[] filter)
           
protected  void setFilter_NOT_IN(java.lang.String logical_connex, E4DBColumnName fieldname, java.lang.String[] filter)
           
 void setFilter(E4DBFilter_Intf filter)
          Add a sub-filter to the current filter, it will be expanded in the getWhere(String) function given a logical_connex which is either "OR" or "AND".
protected  void setFilter(java.lang.String logical_connex, E4DBColumnName fieldname, int comp_operator, java.lang.String filter, boolean quote)
           
 void setWhere(java.lang.String sql)
          Set a SQL-WHERE clause explicit.
 java.lang.String toString(java.lang.String logical_connex)
          Return the SQL clause.
 
Methods inherited from class e4s.util.E4Object
Calendar, CName, CName, E4LabelApp, E4LabelApp, E4LabelApp, E4LabelApp, E4LabelApp, E4LabelApp, E4LabelNone, E4LabelNone, E4LabelNone, E4LabelNone, E4LabelSys, E4LabelSys, e4sCopyright, e4sVersion, encode, encode, encode, encodeHtml, encodeHtml, encodeHtml, encodeURL, encodeURL, encodeURL, getLINE, getTRACE, getTRACE, getTRACE, getTRACE, getTRACE, getTRACE, getTraceMemory, HtmlEncode, HtmlEncode, HtmlEncode, isdecimal, isdigit, isnotok, isnotok, isnumeric, isok, isok, isok, isok, lastCallingFunction, lastCallingFunction, lastCallingFunction, lastCallingFunction, lastCallingStack, mkdirs, null2nbsp, null2nbsp, null2nbsp, ok, ok, ok, ok, outPrintln, setLogFile4Trace, setTraceMemory, STACKTRACE, toDebug, toDouble, toFloat, toFloat, toString, TRACE_CALLS, TRACE, TRACE, TRACE, TRACE, TRACE, TRACE, TRACE, TRACE, TRACE, TRACE, TRACE, TRACE, wait
 
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

COMP_IS_NULL

public static final int COMP_IS_NULL
See Also:
Constant Field Values

COMP_IS_NOT_NULL

public static final int COMP_IS_NOT_NULL
See Also:
Constant Field Values

COMP_EQUALS

public static final int COMP_EQUALS
See Also:
Constant Field Values

COMP_NOT_EQUALS

public static final int COMP_NOT_EQUALS
See Also:
Constant Field Values

COMP_LESS

public static final int COMP_LESS
See Also:
Constant Field Values

COMP_GREATER

public static final int COMP_GREATER
See Also:
Constant Field Values

COMP_LESS_EQUAL

public static final int COMP_LESS_EQUAL
See Also:
Constant Field Values

COMP_GREATER_EQUAL

public static final int COMP_GREATER_EQUAL
See Also:
Constant Field Values

COMP_LIKE

public static final int COMP_LIKE
See Also:
Constant Field Values

COMP_NOT_LIKE

public static final int COMP_NOT_LIKE
See Also:
Constant Field Values

COMP_EMPTY

public static final int COMP_EMPTY
See Also:
Constant Field Values

COMP_NOT_EMPTY

public static final int COMP_NOT_EMPTY
See Also:
Constant Field Values

COMP_IN

protected static final int COMP_IN
See Also:
Constant Field Values

COMP_NOT_IN

protected static final int COMP_NOT_IN
See Also:
Constant Field Values
Constructor Detail

E4DBFilter

public E4DBFilter(E4ApplObj_Intf applobj)

E4DBFilter

public E4DBFilter()
Method Detail

getWhere

protected java.lang.String getWhere(java.lang.String logical_connex)

setWhere

public void setWhere(java.lang.String sql)
Set a SQL-WHERE clause explicit.

Parameters:
sql - the sql where clause without the word "WHERE"

resetWhere

public void resetWhere()
Reset the SQL-WHERE clause as far as it was defined.


Escape

public static java.lang.String Escape(E4String s)
Escapes the single quote character (') by two single quote characters (''). Note, that this is not a double quote ("), just two single quotes. This enables strings that contain single quote characters to be treatened in SQL statements.

Parameters:
s - the string where single quotes need to be replaced, e.g. "Mc' Donald's"
Returns:
the string with the replacements, e.g. "Mc'' Donald''s"
See Also:
Escape(String)

Escape

public static java.lang.String Escape(java.lang.String s)
Escapes the single quote character (') by two single quote characters (''). Note, that this is not a double quote ("), just two single quotes. This enables strings that contain single quote characters to be treatened in SQL statements.

Parameters:
s - the string where single quotes need to be replaced, e.g. "McDonald's"
Returns:
the string with the replacements, e.g. "McDonald''s"
See Also:
Escape(E4String)

OP

public static java.lang.String OP(int comparsion_operator)
                           throws E4DBException
Converts a predefined compersion operator symbol into an sql comparsion operator.

COMP_IS_NULLis null
COMP_IS_NOT_NULLis not null
COMP_EQUALS=
COMP_NOT_EQUALS!=
COMP_LESS<
COMP_GREATER>
COMP_LESS_EQUAL<=
COMP_GREATER_EQUAL>=
COMP_LIKElike

Parameters:
comparsion_operator - the comparsion operator as symbol (see above table, left column).
Returns:
the sql operator (see above table, right column)
Throws:
E4DBException

setFilter

protected void setFilter(java.lang.String logical_connex,
                         E4DBColumnName fieldname,
                         int comp_operator,
                         java.lang.String filter,
                         boolean quote)
                  throws E4DBException
Throws:
E4DBException

setFilter

public void setFilter(E4DBFilter_Intf filter)
Add a sub-filter to the current filter, it will be expanded in the getWhere(String) function given a logical_connex which is either "OR" or "AND". The sub-filter will be included in brackets "(..)".

Parameters:
filter - a sub-filter
See Also:
E4DBFilterOr, E4DBFilterAnd

setFilter_IN

protected void setFilter_IN(java.lang.String logical_connex,
                            E4DBColumnName fieldname,
                            long[] filter)
                     throws E4DBException
Throws:
E4DBException

setFilter_IN

public void setFilter_IN(java.lang.String logical_connex,
                         E4DBColumnName fieldname,
                         E4Long[] filter)
                  throws E4DBException
Throws:
E4DBException

setFilter_IN

public void setFilter_IN(E4DBColumnName columnname,
                         E4DBSelectDistinct selection)

setFilter_NOT_IN

public void setFilter_NOT_IN(E4DBColumnName columnname,
                             E4DBSelectDistinct selection)

setFilter_NOT_IN

protected void setFilter_NOT_IN(java.lang.String logical_connex,
                                E4DBColumnName fieldname,
                                long[] filter)
                         throws E4DBException
Throws:
E4DBException

setFilter_NOT_IN

public void setFilter_NOT_IN(java.lang.String logical_connex,
                             E4DBColumnName fieldname,
                             E4Long[] filter)
                      throws E4DBException
Throws:
E4DBException

setFilter_IN

public void setFilter_IN(java.lang.String logical_connex,
                         E4DBColumnName fieldname,
                         java.lang.String[] filter)
                  throws E4DBException
Throws:
E4DBException

setFilter_IN

public void setFilter_IN(java.lang.String logical_connex,
                         E4DBColumnName fieldname,
                         E4String[] filter)
                  throws E4DBException
Throws:
E4DBException

setFilter_NOT_IN

protected void setFilter_NOT_IN(java.lang.String logical_connex,
                                E4DBColumnName fieldname,
                                java.lang.String[] filter)
                         throws E4DBException
Throws:
E4DBException

setFilter_NOT_IN

public void setFilter_NOT_IN(java.lang.String logical_connex,
                             E4DBColumnName fieldname,
                             E4String[] filter)
                      throws E4DBException
Throws:
E4DBException

isWhereDefined

public boolean isWhereDefined()
Check, if the WHERE clause of the SQL statement contains any definitions - except those for E4Client. You could also use getWhere() == null as condition, but this would always return a value of not null as the application object is defined.

Returns:
true if any filter is defined.

getApplObj

public E4ApplObj_Intf getApplObj()
Get the application object. The application object holds information such as E4Client, E4User-Name, etc..

Returns:
the application object
See Also:
E4ServletImplementation_Intf.getApplObj(), E4ServletImplementation_Intf.setApplicationObject(e4s.application.E4ApplObj_Intf)

getSession

protected java.lang.String getSession()

getClient

public E4Client getClient()
Get the client based on the application object.

Returns:
the client object
See Also:
getApplObj()

toString

public java.lang.String toString(java.lang.String logical_connex)
Return the SQL clause.


finalize

public void finalize()
Overrides:
finalize in class E4Object

_getSVNVersionString

public static java.lang.String _getSVNVersionString()

www.element4solution.com