public abstract class QueryModel
extends java.lang.Object
The model can store different types of query, for example QueryConst
.ASXML
,
TEXT
, ASTEXT
, NUMERICAL
, ASMATHCOMPARE
, ASMATHEVAL
or
even the special cases, such as EXISTS
. The default is ASXML
, which is a
query over XML documents. TEXT
, ASTEXT
or NUMERICAL
are over lines
of text, or word tokens in lines of text. The others are special types of case that
might include a mathematical evaluator.
Modifier and Type | Field and Description |
---|---|
protected java.util.ArrayList<java.lang.String> |
fileList
List of files or addresses to retrieve information from
|
protected java.lang.String |
fileType
Type of file to read.
|
protected org.licas_xml.abs.Element |
otherMeta
A slot for any other metadata that might be passed.
|
protected java.util.ArrayList<PatternElement> |
pattern
The pattern to match.
|
protected java.lang.String |
queryID
Unique ID to define the query
|
protected java.lang.String |
queryType
Defines a search over text or XML elements, or a mathematical operation.
|
protected PatternElement |
selectedPattern
A pattern selected as part of some process
|
Modifier | Constructor and Description |
---|---|
protected |
QueryModel()
Create a new instance of QueryModel
|
Modifier and Type | Method and Description |
---|---|
java.lang.String |
constraintValues()
Get a full list of constraint values, concatenated with AND.
|
static QueryModelText |
createAsTextModel()
Create a as text query model instance.
|
static QueryModel |
createModel(java.lang.String queryType)
Create a query model instance.
|
static QueryModelNumerical |
createNumericalModel()
Create a numerical query model instance.
|
static QueryModelText |
createTextModel()
Create a text query model instance.
|
static QueryModelXml |
createXmlModel()
Create an xml query model instance.
|
PatternConstraint |
firstConstraint()
Get the first listed constraint in the first listed pattern.
|
java.lang.String |
firstConstraintType()
Get the first listed constraint type, in case a special query type.
|
PatternElement |
firstPattern()
Get the first pattern in a possible list of patterns.
|
static QueryModel |
fromXml(org.licas_xml.abs.Element queryXml)
Utility method to parse the query description into a query model.
|
java.util.ArrayList<java.lang.String> |
getFileList()
Get the list of file addresses that the query would be executed over.
|
java.lang.String |
getFileType()
Get the value indicating the type of file the file list references.
|
org.licas_xml.abs.Element |
getOtherMeta()
Get the other metadata value.
|
PatternElement |
getPatternNestedAt(int index)
Get the pattern at the specified index.
|
java.lang.String |
getQueryID()
Get the unique query value.
|
java.util.ArrayList<PatternElement> |
getQueryPattern()
Get the query pattern that must be matched.
|
java.lang.String |
getQueryType()
Get the value indicating to search over text, xml, or a mathematical operation,
specified by
QueryConst .ASTEXT , etc. |
int |
getTotalNestedPatternCount(PatternElement pattern)
Get a count of the total number of nested patterns, not including the parameter.
|
int |
getTotalPatternCount()
Get a count of the total number of patterns, including nested ones.
|
boolean |
isNumericalQuery()
Return true if the query type is a numerical type (numerical evaluation).
|
boolean |
isOtherQuery()
Return true if the query type is a special type (specific evaluation).
|
boolean |
isTextQuery()
Return true if the query type is a text-based type (lines of text).
|
boolean |
isXmlQuery()
Return true if the query type is a pattern-based XML type.
|
boolean |
patternToNested(int index)
Move the pattern at the specified overall index to a child of its
immediate sibling pattern.
|
boolean |
printPatternType()
Return true if this model should print out the pattern section.
|
boolean |
removePatternNestedAt(int index)
Remove the pattern at the specified index.
|
void |
setFileList(java.util.ArrayList<java.lang.String> theFileList)
Set the list of file addresses that the query would be executed over.
|
void |
setFileType(java.lang.String theFileType)
Set the value indicating the type of file the file list references.
|
void |
setOtherMeta(org.licas_xml.abs.Element theOtherMeta)
Set the other metadata value.
|
void |
setQueryID(java.lang.String theQueryID)
Set the unique query ID value.
|
void |
setQueryPattern(java.util.ArrayList<PatternElement> thePattern)
Set the query pattern to try to match.
|
void |
setQueryType(java.lang.String theQueryType)
Set the value indicating to search over text, xml, or a mathematical operation.
|
void |
setSingleCondition(PatternConstraint newConstraint)
Set the pattern element that is the single query condition.
|
void |
setSingleCondition(java.lang.String operator,
java.lang.String value)
This method can be used to set a single query condition in an empty (this) query model.
|
void |
setSingleCondition(java.lang.String type,
java.lang.String operator,
java.lang.String value)
This method can be used to set a single query condition in an empty (this) query model.
|
static org.licas_xml.abs.Element |
toXml(QueryModel queryModel)
Utility method to convert the query model into the XML-based description.
|
static java.lang.String |
typeFromOpOther(java.lang.String operator)
Get the likely 'other' query type for the query operator or condition.
|
static java.lang.String |
typeFromOpText(java.lang.String operator)
Get the likely 'text' query type for the query operator or condition.
|
protected java.lang.String queryType
QueryConst
.ASXML
, TEXT
, ASTEXT
,
NUMERICAL
, ASMATHCOMPARE
, ASMATHEVAL
or even the special cases,
such as EXISTS
.protected java.lang.String queryID
protected java.lang.String fileType
protected java.util.ArrayList<java.lang.String> fileList
protected java.util.ArrayList<PatternElement> pattern
PatternElement
.protected PatternElement selectedPattern
protected org.licas_xml.abs.Element otherMeta
public boolean isXmlQuery()
QueryConst
.ASXML
.public boolean isTextQuery()
QueryConst
.ASTEXT
or TEXT
.public boolean isNumericalQuery()
QueryConst
.NUMERICAL
, ASMATHCOMPARE
,
ASMATHEVAL
.public boolean isOtherQuery()
QueryConst
.EXISTS
.public void setQueryType(java.lang.String theQueryType)
theQueryType
- can be QueryConst
.ASTEXT
, etc.
Default value is as ASXML
.public java.lang.String getQueryType()
QueryConst
.ASTEXT
, etc.public void setQueryID(java.lang.String theQueryID)
theQueryID
- a unique value to define the query.public java.lang.String getQueryID()
public void setFileType(java.lang.String theFileType)
theFileType
- the file type.public java.lang.String getFileType()
public void setFileList(java.util.ArrayList<java.lang.String> theFileList)
theFileList
- list of file or URI addresses, for example.public java.util.ArrayList<java.lang.String> getFileList()
public void setSingleCondition(java.lang.String operator, java.lang.String value)
operator
- the comparison operator or evaluation condition.value
- the value to compare with.public void setSingleCondition(java.lang.String type, java.lang.String operator, java.lang.String value)
type
- this can be different to the model type, for a server file search, for example.operator
- the comparison operator or evaluation condition.value
- the value to compare with.public void setSingleCondition(PatternConstraint newConstraint)
newConstraint
- the new constraint to use.public PatternElement firstPattern()
public PatternConstraint firstConstraint()
public java.lang.String firstConstraintType()
public boolean patternToNested(int index)
index
- the pattern index - including all nested patterns of all
previous pattern sets.public int getTotalPatternCount()
public int getTotalNestedPatternCount(PatternElement pattern)
pattern
- the pattern to count from.public PatternElement getPatternNestedAt(int index)
index
- the index of the pattern as it would be shown over all
patterns.public boolean removePatternNestedAt(int index)
index
- the index of the pattern as it would be drawn.public void setQueryPattern(java.util.ArrayList<PatternElement> thePattern)
thePattern
- the ordered list of element names to match to.public java.util.ArrayList<PatternElement> getQueryPattern()
public void setOtherMeta(org.licas_xml.abs.Element theOtherMeta)
MetaConst.META
(Meta) tag name.theOtherMeta
- and other metadata.public org.licas_xml.abs.Element getOtherMeta()
MetaConst.META
(Meta).public java.lang.String constraintValues()
public boolean printPatternType()
public static java.lang.String typeFromOpText(java.lang.String operator)
operator
- the comparison operator or evaluation condition.public static java.lang.String typeFromOpOther(java.lang.String operator)
operator
- the comparison operator or evaluation condition.public static QueryModel createModel(java.lang.String queryType)
queryType
- the type of model to create, xml, text, numerical, other.public static QueryModelXml createXmlModel()
public static QueryModelText createTextModel()
public static QueryModelText createAsTextModel()
public static QueryModelNumerical createNumericalModel()
public static QueryModel fromXml(org.licas_xml.abs.Element queryXml) throws java.lang.Exception
QueryParser
for this.queryXml
- the query description to parse.java.lang.Exception
- any error.public static org.licas_xml.abs.Element toXml(QueryModel queryModel) throws java.lang.Exception
QueryParser
for this.queryModel
- the query model to serialize.java.lang.Exception
- any error.