@PublicAPI public class FormulaSearch extends java.lang.Object
Features:
Search types:
Example code:
FormulaSearch formulaSearch = new FormulaSearch(); String queryFormula; ... // obtain chemical formula of the query String targetFormula; ... // obtain chemical formula of the target formulaSearch.setSearchType(FormulaSearch.EXACT); // see search types formulaSearch.setQuery(queryFormula); // set query formula formulaSearch.setTarget(targetFormula); // set target formula return formulaSearch.isMatching();
Modifier and Type | Field and Description |
---|---|
static int |
EXACT
Constant value specifying the exact search type.
|
static int |
EXACT_SUBFORMULA
Constant value specifying the exact sub formula
search type.
|
static int |
NONE
Constant value specifying the none search type.
|
static int |
SUBFORMULA
Constant value specifying the sub formula search type.
|
Constructor and Description |
---|
FormulaSearch() |
Modifier and Type | Method and Description |
---|---|
java.lang.String |
getQuery()
Gets the chemical formula query string used for searching
|
int |
getSearchType()
Gets the formula search type.
|
java.lang.String |
getTarget()
Gets the chemical formula of the target used to search in
|
boolean |
isMatching()
Checks if the query formula matches the target formula
according to the formula search type.
|
static boolean |
isValidQuery(java.lang.String formula)
Checks the given formula whether it is a valid query formula
|
static boolean |
isValidTarget(java.lang.String formula)
Checks the given formula whether it is a valid target formula
|
void |
setQuery(java.lang.String query)
Sets the chemical formula query string used for searching
|
void |
setSearchType(int value)
Sets the type of the formula search.
|
void |
setTarget(java.lang.String target)
Sets the chemical formula target string used to search in
|
public static final int NONE
public static final int EXACT
public static final int EXACT_SUBFORMULA
public static final int SUBFORMULA
public void setSearchType(int value)
value
- the search typeEXACT
,
EXACT_SUBFORMULA
,
SUBFORMULA
public int getSearchType()
EXACT
,
EXACT_SUBFORMULA
,
SUBFORMULA
public void setQuery(java.lang.String query) throws java.lang.IllegalArgumentException
query
- chemical formula of the queryjava.lang.IllegalArgumentException
- if encounters some parsing errorspublic java.lang.String getQuery()
public void setTarget(java.lang.String target) throws java.lang.IllegalArgumentException
target
- chemical formula of the targetjava.lang.IllegalArgumentException
- if encounters some parsing errorspublic java.lang.String getTarget()
public boolean isMatching()
false
if query or target was not supplied correctly, or no
match is possiblesetQuery(String)
,
setTarget(String)
,
setSearchType(int)
public static boolean isValidQuery(java.lang.String formula)
formula
- the formula to be checkedpublic static boolean isValidTarget(java.lang.String formula)
formula
- the formula to be checked