com.ds.fw.dv.search
Class FwDVBuildSearchQuery

java.lang.Object
  |
  +--com.ds.fw.types.FwSimpleObject
        |
        +--com.ds.fw.dv.search.FwDVBuildSearchQuery
All Implemented Interfaces:
java.lang.Cloneable, FwCopyableIF, FwDisplayableIF, FwSimpleObjectIF, java.io.Serializable

public class FwDVBuildSearchQuery
extends FwSimpleObject

This class is used for building a FwDVSearchQuery(a vector presentation of the query elements) from a string. The string format is:
data elements separated with predeterminate separator, operators or brackets.

See Also:
Serialized Form

Field Summary
 java.util.Vector breakets
          Collection with admissible brackets.
 int defaultOperator
          Index of the default operator from the operators collection.
 java.lang.String defaultSeparator
          Default separator.
 java.util.Vector operators
          Collection with admissible operators.
 
Constructor Summary
FwDVBuildSearchQuery()
          Initializes class members.
 
Method Summary
 void addBreacket(com.ds.fw.dv.search.FwDVSearchBreacket s)
          Adds a bracket pair to the end of the brackets collection.
 void addBreacket(java.lang.String open, java.lang.String close)
          Adds a bracket pair to the end of the brackets collection.
 java.lang.String addBreacketSeparator(java.lang.String s)
          Finds all brackets in a string and inserts before and after them a default separator.
 void addOperator(java.lang.String s)
          Adds an operator to the end of the operators' collection.
 com.ds.fw.dv.search.FwDVSearchQuery bulid(java.lang.String s1)
          This methods build a framework query object from a string.
 int checkIsBreacket(java.lang.String s)
          Checks if the given bracket is in the current brackets collection.
 int checkIsOperator(java.lang.String s)
          Checks if the given operator is in the current operators' collection.
 void clearBreackets()
          Clears the collection with brackets.
 void clearOperators()
          Clears the collection with operators.
 java.lang.String fixQuery(java.lang.String s)
          Fixes the string which will be parsed to produse a query.
 com.ds.fw.dv.search.FwDVSearchBreacket getBreacket(int i)
          Gets a bracket pair with index i.
 java.lang.String getOperator(int i)
          Gets an operator with index i.
 java.lang.String removeDoubleSeparator(java.lang.String s)
          Replaces all double separators with single ones.
 void setBreacket(int i, com.ds.fw.dv.search.FwDVSearchBreacket s)
          Sets a bracket pair at possition i.
 void setDefaultOperator(int s)
          Sets the default operator index.
 void setDefaultSeparator(java.lang.String s)
          Sets the default separator index.
 void setOperator(int i, java.lang.String s)
          Sets an operator at possition i.
 int sizeBreackets()
          Returns the size of the collection with brackets.
 int sizeOperators()
          Returns the size of the collection with operators.
 java.lang.String stringCorrect(java.lang.String s)
          Replaces default separator in a quoted substring of a string with other special simbol(s) (i.e "^^").
 java.lang.String strReplace(java.lang.String sOld, java.lang.String sNew, java.lang.String s)
          This method replaces all substrings of a string, metching a given string.
 
Methods inherited from class com.ds.fw.types.FwSimpleObject
getClassName, getClone, getCopy, getCopy, getDeepCopy, getDisplayString, getDisplayStringFor, postCopy, printStackTrace, toString, toStringValue
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

operators

public java.util.Vector operators
Collection with admissible operators.


defaultOperator

public int defaultOperator
Index of the default operator from the operators collection.


defaultSeparator

public java.lang.String defaultSeparator
Default separator.


breakets

public java.util.Vector breakets
Collection with admissible brackets.

Constructor Detail

FwDVBuildSearchQuery

public FwDVBuildSearchQuery()
Initializes class members. Here the collections with operators and brackets are filled.

Method Detail

bulid

public com.ds.fw.dv.search.FwDVSearchQuery bulid(java.lang.String s1)
This methods build a framework query object from a string.

Parameters:
s1 - the string to be parsed
Returns:
the query

strReplace

public java.lang.String strReplace(java.lang.String sOld,
                                   java.lang.String sNew,
                                   java.lang.String s)
This method replaces all substrings of a string, metching a given string.

Parameters:
sOld - substring to be replaced
sNew - the new substring to be placed
s - the main string
Returns:
a new edited string

fixQuery

public java.lang.String fixQuery(java.lang.String s)
Fixes the string which will be parsed to produse a query. (i.e. replaces all double separators with single ones)

Parameters:
s - the string to be fixed
Returns:
a new fixed string

removeDoubleSeparator

public java.lang.String removeDoubleSeparator(java.lang.String s)
Replaces all double separators with single ones.

Parameters:
s - the string to be fixed
Returns:
a new fixed string

addBreacketSeparator

public java.lang.String addBreacketSeparator(java.lang.String s)
Finds all brackets in a string and inserts before and after them a default separator.

Parameters:
s - the string to be fixed
Returns:
a new fixed string

stringCorrect

public java.lang.String stringCorrect(java.lang.String s)
Replaces default separator in a quoted substring of a string with other special simbol(s) (i.e "^^").

Parameters:
s - the string to be edited
Returns:
a new edited string

setDefaultOperator

public void setDefaultOperator(int s)
Sets the default operator index.

Parameters:
s - the index to be set

setDefaultSeparator

public void setDefaultSeparator(java.lang.String s)
Sets the default separator index.

Parameters:
s - the index to be set

clearOperators

public void clearOperators()
Clears the collection with operators.


sizeOperators

public int sizeOperators()
Returns the size of the collection with operators.


getOperator

public java.lang.String getOperator(int i)
Gets an operator with index i. If the index is lower than the array boundary the first operator will be returned, if it is greater than the array boundary an empty string will be returned.


setOperator

public void setOperator(int i,
                        java.lang.String s)
Sets an operator at possition i.

Parameters:
i - possition
s - operator to be set

addOperator

public void addOperator(java.lang.String s)
Adds an operator to the end of the operators' collection.

Parameters:
s - operator to be added

checkIsOperator

public int checkIsOperator(java.lang.String s)
Checks if the given operator is in the current operators' collection.

Parameters:
s - the operator to be checked
Returns:
-1 if not found or the possition in the collection

clearBreackets

public void clearBreackets()
Clears the collection with brackets.


sizeBreackets

public int sizeBreackets()
Returns the size of the collection with brackets.


getBreacket

public com.ds.fw.dv.search.FwDVSearchBreacket getBreacket(int i)
Gets a bracket pair with index i. If the index is lower than the array boundary the first bracket pair will be returned, if it is greater than the array boundary null will be returned.


setBreacket

public void setBreacket(int i,
                        com.ds.fw.dv.search.FwDVSearchBreacket s)
Sets a bracket pair at possition i.

Parameters:
i - possition
s - bracket pair object to be set

addBreacket

public void addBreacket(com.ds.fw.dv.search.FwDVSearchBreacket s)
Adds a bracket pair to the end of the brackets collection.

Parameters:
s - the bracket pair to be added

addBreacket

public void addBreacket(java.lang.String open,
                        java.lang.String close)
Adds a bracket pair to the end of the brackets collection.

Parameters:
open - the open bracket
close - the close bracket

checkIsBreacket

public int checkIsBreacket(java.lang.String s)
Checks if the given bracket is in the current brackets collection.

Parameters:
s - the bracket to be checked
Returns:
-1 if not found or the possition in the collection (if it is a close bracket the result will be increased with 1000)