com.ragic.s3.service.workflow
Class SDBQueryScript

java.lang.Object
  extended by com.ragic.s3.service.workflow.SDBQueryScript
All Implemented Interfaces:
com.ragic.s3.sdb.query.SDBQuery

public class SDBQueryScript
extends java.lang.Object
implements com.ragic.s3.sdb.query.SDBQuery

SDBQueryScript is a class employed by Ragic Workflow application, which allows applications to access Ragic database by multiple approaches and filter those data by customized patterns. This class usually implemented by db.getQuery() in Workflow. A basic strategy to access database is : go -> filter -> next -> dip. SDBQuery Object is sort of like a cursor manipulated by these functions. Going certain field means moving this cursor to that field. All the values of a field is like a list attached to that field. When calling next, this cursor will be moved down one item in the list and next will return last item it pointed. Noted that there are several kinds of filter method in this class, and they can be employed at the same time, that is, you can include multiple patterns to filter data by employing filter function several times. User: liberation Date: 2010/10/5 Time: 10:32:45 am


Constructor Summary
SDBQueryScript(com.ragic.s3.sdb.data.bdb.BDBWorker worker)
          Class constructor specifying a BDBWorker.
 
Method Summary
 void close()
          Deprecated.  
 java.lang.String dip(int domainId)
          Returns the value corresponding to this field ID.
 java.lang.String dipAll(int domainId)
          Returns all the values corresponding to this field ID in a single string.
 java.util.List<com.ragic.s3.sdb.query.SDBNode> dipAllNodes(int domainId)
          Returns all the SDBNode objects corresponding to this field ID in a list.
 com.ragic.s3.sdb.query.SDBNode dipNode(int domainId)
          Returns the SDBNode object corresponding to this field ID.
 java.lang.String dive(int domainId)
          Returns the value corresponding to this field ID.
 void filter(int domainId, java.util.List<java.lang.Integer> list)
          A filter specifying the field possessing this domainId and the pattern.
 void filter(int domainId, java.lang.String value)
          A filter specifying the field possessing this domainId and the pattern.
 void filter(java.util.List<java.lang.Integer> list)
          A filter specifying a list of node ID.
 void filter(com.ragic.s3.sdb.query.SDBQuery conn)
          A filter specifying another SDBQuery instance as the pattern.
 void filter(com.ragic.s3.sdb.query.SDBQuery conn, boolean inverse)
          A filter specifying another SDBQuery instance as the pattern and the specifier about whether or not to reverse the order of filtered data.
 void filter(java.lang.String value)
          A filter specifying the pattern.
 void filterRange(int domainId, java.lang.String hi, java.lang.String low)
          A filter specifying the field possessing this domainId and the range bounded by high value and low value.
 void filterRange(int domainId, java.lang.String hi, java.lang.String low, boolean includeHi, boolean includeLow)
          A filter specifying the field possessing this domainId, the range bounded by high value and low value, and two specifiers about boundaries.
 void filterRange(java.lang.String hi, java.lang.String low)
          A filter specifying the range bounded by high value and low value.
 void filterRange(java.lang.String hi, java.lang.String low, boolean includeHi, boolean includeLow)
          A filter specifying the range bounded by high value and low value and two specifiers about boundaries.
 void filterRegex(int domainId, java.lang.String value)
          A filter specifying the field possessing this domainId and the Regular Expression pattern.
 void filterRegex(java.lang.String value)
          A filter specifying the pattern in Regular Expression .
 java.lang.String getApname()
          Returns the name of AP holding the field that q goes.
 int getDomainId()
          Returns field ID of the current field which this query cursor goes
 java.util.List<com.ragic.s3.sdb.query.SDBNode> getList()
          Returns a list of all nodes corresponding to the current field that the query cursor goes.
 int getParentDomainId()
          Returns the field ID of last querying field.
 int getParentNodeId()
          Returns the node ID of last querying field.
 int getResultSize()
           
 com.ragic.s3.sdb.data.bdb.BDBWorker getWorker()
          Returns the BDBWorker associated with this SDBQueryScript
 void go(int domainId)
          Selects the field of interest to manipulate.
 void goback()
          Goes back to last queried field.
 com.ragic.s3.sdb.query.SDBNode next()
          Shifts to the next SDBNode object of the field this query went and returns last SDBNode it pointed.
 void resetCursor()
           
 void setDelta(int delta)
           
 void setFetchSize(int i)
          Deprecated.  
 void setReverse(boolean reverse)
          Puts the order of values of current field upside down.
 boolean skip(int i)
          Skips given number of nodes.
 void sort(int domainId, int dir)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SDBQueryScript

public SDBQueryScript(com.ragic.s3.sdb.data.bdb.BDBWorker worker)
Class constructor specifying a BDBWorker. This method is never employed in workflow directly because there is no way to construct a BDBWorker in Workflow.

Parameters:
worker -
Method Detail

setDelta

public void setDelta(int delta)

getApname

public java.lang.String getApname()
Returns the name of AP holding the field that q goes.

Specified by:
getApname in interface com.ragic.s3.sdb.query.SDBQuery
Returns:
name of this AP

getWorker

public com.ragic.s3.sdb.data.bdb.BDBWorker getWorker()
Returns the BDBWorker associated with this SDBQueryScript

Specified by:
getWorker in interface com.ragic.s3.sdb.query.SDBQuery
Returns:
the associated BDBWorker object

filter

public void filter(java.lang.String value)
A filter specifying the pattern. Screens all values of the current filed then only keeps those that follow this pattern.

Specified by:
filter in interface com.ragic.s3.sdb.query.SDBQuery
Parameters:
value - the pattern employed by this filter

filterRegex

public void filterRegex(java.lang.String value)
A filter specifying the pattern in Regular Expression . Screens all values of the current field then only keeps those that follow this pattern.

Specified by:
filterRegex in interface com.ragic.s3.sdb.query.SDBQuery
Parameters:
value - the pattern in Regular Expression employed by this filter.

filterRange

public void filterRange(java.lang.String hi,
                        java.lang.String low)
A filter specifying the range bounded by high value and low value. Screens all values of the current field then keeps only ones between this range. This function reads not only pure number but also date. For example, q = db.getQuery((); q.go(DATE_FIELD_ID); q.filter("2012/08/10", "2012/08/06"); then this query keeps only those values of DTE_FIELD_ID are before 2012/08/10 and after 2012/08/06. Noted that no data will be kept if put these two date upside down.

Specified by:
filterRange in interface com.ragic.s3.sdb.query.SDBQuery
Parameters:
hi - upper bound of the filter range.
low - lower bound of the filter range.

filterRange

public void filterRange(java.lang.String hi,
                        java.lang.String low,
                        boolean includeHi,
                        boolean includeLow)
A filter specifying the range bounded by high value and low value and two specifiers about boundaries. Screens all values of the current field then keeps only ones between this range. Includes boundaries to this filter range if specifiers are set true. This function reads not only pure number but also date.

Specified by:
filterRange in interface com.ragic.s3.sdb.query.SDBQuery
Parameters:
hi - upper bound of the filter range.
low - lower bound of the filter range.
includeHi - true includes the upper bound. false otherwise.
includeLow - true includes the lower bound. false otherwise.
See Also:
filterRange(String, String)

filter

public void filter(com.ragic.s3.sdb.query.SDBQuery conn)
A filter specifying another SDBQuery instance as the pattern. Screens all values of the current field then keeps only ones holding by conn. For example, subQ = db.getQuery(); subQ.go(NAME_FIELD); dubQ.filter("cindy"); q = db.getQuery(); q.go(ROOT_FIELD); q.filter(subQ); In this case, q turns out going ROOT_FIELD but filtering data by a pattern of NAME_FIELD. This method is especially useful when your forms become more complicated.

Parameters:
conn - another SDBQuery instance

filter

public void filter(com.ragic.s3.sdb.query.SDBQuery conn,
                   boolean inverse)
A filter specifying another SDBQuery instance as the pattern and the specifier about whether or not to reverse the order of filtered data.

Specified by:
filter in interface com.ragic.s3.sdb.query.SDBQuery
Parameters:
conn - another SDBQuery instance
inverse - specifier
See Also:
filter(com.ragic.s3.sdb.query.SDBQuery)

filter

public void filter(java.util.List<java.lang.Integer> list)
A filter specifying a list of node ID. Screens all values of the root field in the current AP then keeps only ones whose node ID contains in this list.

Specified by:
filter in interface com.ragic.s3.sdb.query.SDBQuery
Parameters:
list - a list of node IDs.

filter

public void filter(int domainId,
                   java.lang.String value)
A filter specifying the field possessing this domainId and the pattern. Filters values of this field by the pattern specified without going to this field.

Specified by:
filter in interface com.ragic.s3.sdb.query.SDBQuery
Parameters:
domainId - ID of the field to be screened
value - the pattern employed by this filter

filterRegex

public void filterRegex(int domainId,
                        java.lang.String value)
A filter specifying the field possessing this domainId and the Regular Expression pattern. Filters values of this field by the pattern specified without going to this field.

Specified by:
filterRegex in interface com.ragic.s3.sdb.query.SDBQuery
Parameters:
domainId - ID of the field to be screened
value - the pattern in regular expression employed by this filter
See Also:
filter(String)

filterRange

public void filterRange(int domainId,
                        java.lang.String hi,
                        java.lang.String low)
A filter specifying the field possessing this domainId and the range bounded by high value and low value. Filters values of this field by the range specified without going to this field.

Specified by:
filterRange in interface com.ragic.s3.sdb.query.SDBQuery
Parameters:
domainId -
hi -
low -
See Also:
filterRange(String, String)

filterRange

public void filterRange(int domainId,
                        java.lang.String hi,
                        java.lang.String low,
                        boolean includeHi,
                        boolean includeLow)
A filter specifying the field possessing this domainId, the range bounded by high value and low value, and two specifiers about boundaries. Filters values of this field by the range specified without going to this field.

Specified by:
filterRange in interface com.ragic.s3.sdb.query.SDBQuery
Parameters:
domainId -
hi -
low -
includeHi -
includeLow -
See Also:
filterRange(String, String, boolean, boolean)

filter

public void filter(int domainId,
                   java.util.List<java.lang.Integer> list)
A filter specifying the field possessing this domainId and the pattern. Filters values of this field by the list of node IDs without going to this field.

Specified by:
filter in interface com.ragic.s3.sdb.query.SDBQuery
Parameters:
domainId -
list -
See Also:
filter(java.util.List)

sort

public void sort(int domainId,
                 int dir)
Specified by:
sort in interface com.ragic.s3.sdb.query.SDBQuery

setReverse

public void setReverse(boolean reverse)
Puts the order of values of current field upside down.

Specified by:
setReverse in interface com.ragic.s3.sdb.query.SDBQuery
Parameters:
reverse - true reverse the order. false otherwise.

go

public void go(int domainId)
Selects the field of interest to manipulate. If going root field, root node IDs can be accessed by dip.

Specified by:
go in interface com.ragic.s3.sdb.query.SDBQuery
Parameters:
domainId - the field of interest. Usually root field.
See Also:
dip(int), SDBQueryScript

next

public com.ragic.s3.sdb.query.SDBNode next()
Shifts to the next SDBNode object of the field this query went and returns last SDBNode it pointed.

Specified by:
next in interface com.ragic.s3.sdb.query.SDBQuery
Returns:
last node the query pointed.
See Also:
go(int)

goback

public void goback()
Goes back to last queried field. For example, these two paragraphs of code function the same.

code example 1:

q = db.getQuery(); q.go(FIELD_1); q.go(FIELD_2); q.goback();

code example 2:

q = db.getQuery(); q.go(FIELD_1);

Specified by:
goback in interface com.ragic.s3.sdb.query.SDBQuery

getResultSize

public int getResultSize()
Specified by:
getResultSize in interface com.ragic.s3.sdb.query.SDBQuery
Returns:

dip

public java.lang.String dip(int domainId)
Returns the value corresponding to this field ID. Can access a sequence of values by calling next and dip in a while loop. For example, q = db. getQuery(); q.go(FIELD_1); while(q.next()!=null) { q.dip(FIELD_2); } Will remain at the same node if no next or go happens, which is the major difference between dip and dive

Specified by:
dip in interface com.ragic.s3.sdb.query.SDBQuery
Parameters:
domainId - field ID of interest.
Returns:
value of the given field.
See Also:
dive(int)

dipNode

public com.ragic.s3.sdb.query.SDBNode dipNode(int domainId)
Returns the SDBNode object corresponding to this field ID. Can access a sequence of node by calling next and dipNode in a while loop.

Specified by:
dipNode in interface com.ragic.s3.sdb.query.SDBQuery
Parameters:
domainId - field ID of interest.
Returns:
SDBNode object of the given field.
See Also:
dip(int)

dipAll

public java.lang.String dipAll(int domainId)
Returns all the values corresponding to this field ID in a single string. Every two values are separated by a comma and a space, that is, ", ".

Specified by:
dipAll in interface com.ragic.s3.sdb.query.SDBQuery
Parameters:
domainId - field ID of interest.
Returns:
a joined string of a sequence of values.

dipAllNodes

public java.util.List<com.ragic.s3.sdb.query.SDBNode> dipAllNodes(int domainId)
Returns all the SDBNode objects corresponding to this field ID in a list.

Specified by:
dipAllNodes in interface com.ragic.s3.sdb.query.SDBQuery
Parameters:
domainId - field ID of interest.
Returns:
a list of all the SDBNode objects.

dive

public java.lang.String dive(int domainId)
Returns the value corresponding to this field ID. Query cursor will shift to next node after dive being called, which is the major difference between dip and dive

Specified by:
dive in interface com.ragic.s3.sdb.query.SDBQuery
Parameters:
domainId -
Returns:
See Also:
dip(int)

getList

public java.util.List<com.ragic.s3.sdb.query.SDBNode> getList()
Returns a list of all nodes corresponding to the current field that the query cursor goes.

Specified by:
getList in interface com.ragic.s3.sdb.query.SDBQuery
Returns:
a list of nodes corresponding to the current field.

getDomainId

public int getDomainId()
Returns field ID of the current field which this query cursor goes

Specified by:
getDomainId in interface com.ragic.s3.sdb.query.SDBQuery
Returns:
field ID

getParentDomainId

public int getParentDomainId()
Returns the field ID of last querying field.

Specified by:
getParentDomainId in interface com.ragic.s3.sdb.query.SDBQuery
Returns:
field ID of last querying field

getParentNodeId

public int getParentNodeId()
Returns the node ID of last querying field.

Specified by:
getParentNodeId in interface com.ragic.s3.sdb.query.SDBQuery
Returns:
node ID of last querying field.

skip

public boolean skip(int i)
Skips given number of nodes.

Specified by:
skip in interface com.ragic.s3.sdb.query.SDBQuery
Parameters:
i - number of nodes that should be skipped.
Returns:
false if i is a non-positive number or if there is no node to go after the current one. true otherwise.

setFetchSize

public void setFetchSize(int i)
Deprecated. 

Specified by:
setFetchSize in interface com.ragic.s3.sdb.query.SDBQuery

resetCursor

public void resetCursor()
Specified by:
resetCursor in interface com.ragic.s3.sdb.query.SDBQuery

close

public void close()
Deprecated. 



Copyright © 2009,2010,2011,2012 Ragic Corp. All Rights Reserved.