Class QueryNodeImpl
- java.lang.Object
-
- org.apache.lucene.queryparser.flexible.core.nodes.QueryNodeImpl
-
- All Implemented Interfaces:
java.lang.Cloneable,QueryNode
- Direct Known Subclasses:
AbstractRangeQueryNode,BooleanQueryNode,BoostQueryNode,DeletedQueryNode,FieldQueryNode,GroupQueryNode,MatchAllDocsQueryNode,ModifierQueryNode,MultiPhraseQueryNode,OpaqueQueryNode,PathQueryNode,PhraseSlopQueryNode,PointQueryNode,RegexpQueryNode,SlopQueryNode,TokenizedPhraseQueryNode
public abstract class QueryNodeImpl extends java.lang.Object implements QueryNode, java.lang.Cloneable
AQueryNodeImplis the default implementation of the interfaceQueryNode
-
-
Field Summary
Fields Modifier and Type Field Description private java.util.List<QueryNode>clausesprivate booleanisLeafprivate QueryNodeparentstatic java.lang.StringPLAINTEXT_FIELD_NAMEprivate java.util.Hashtable<java.lang.String,java.lang.Object>tagsprotected booleantoQueryStringIgnoreFieldsIf set to true the the method toQueryString will not write field names
-
Constructor Summary
Constructors Constructor Description QueryNodeImpl()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidadd(java.util.List<QueryNode> children)voidadd(QueryNode child)protected voidallocate()QueryNodeclone()QueryNodecloneTree()Recursive clone the QueryNode tree The tags are not copied to the new tree when you call the cloneTree() methodbooleancontainsTag(java.lang.String tagName)verify if a node contains a tagjava.util.List<QueryNode>getChildren()get Children nodesQueryNodegetParent()java.lang.ObjectgetTag(java.lang.String tagName)Returns object stored under that tag namejava.util.Map<java.lang.String,java.lang.Object>getTagMap()Returns a map containing all tags attached to this query node.protected booleanisDefaultField(java.lang.CharSequence fld)This method is use toQueryString to detect if fld is the default fieldbooleanisLeaf()verify if a node is a Leaf nodeprotected booleanisRoot()voidremoveChildren(QueryNode childNode)Remove a child nodevoidremoveFromParent()Removes this query node from its parent.voidset(java.util.List<QueryNode> children)protected voidsetLeaf(boolean isLeaf)private voidsetParent(QueryNode parent)voidsetTag(java.lang.String tagName, java.lang.Object value)Associate the specified value with the specified tagName.java.lang.StringtoString()Every implementation of this class should return pseudo xml like this: For FieldQueryNode: <field start='1' end='2' field='subject' text='foo'/>voidunsetTag(java.lang.String tagName)Unset a tag.-
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface org.apache.lucene.queryparser.flexible.core.nodes.QueryNode
toQueryString
-
-
-
-
Field Detail
-
PLAINTEXT_FIELD_NAME
public static final java.lang.String PLAINTEXT_FIELD_NAME
- See Also:
- Constant Field Values
-
isLeaf
private boolean isLeaf
-
tags
private java.util.Hashtable<java.lang.String,java.lang.Object> tags
-
clauses
private java.util.List<QueryNode> clauses
-
parent
private QueryNode parent
-
toQueryStringIgnoreFields
protected boolean toQueryStringIgnoreFields
If set to true the the method toQueryString will not write field names
-
-
Method Detail
-
allocate
protected void allocate()
-
add
public final void add(java.util.List<QueryNode> children)
-
isLeaf
public boolean isLeaf()
Description copied from interface:QueryNodeverify if a node is a Leaf node
-
set
public final void set(java.util.List<QueryNode> children)
-
cloneTree
public QueryNode cloneTree() throws java.lang.CloneNotSupportedException
Description copied from interface:QueryNodeRecursive clone the QueryNode tree The tags are not copied to the new tree when you call the cloneTree() method
-
clone
public QueryNode clone() throws java.lang.CloneNotSupportedException
- Overrides:
clonein classjava.lang.Object- Throws:
java.lang.CloneNotSupportedException
-
setLeaf
protected void setLeaf(boolean isLeaf)
-
getChildren
public final java.util.List<QueryNode> getChildren()
Description copied from interface:QueryNodeget Children nodes- Specified by:
getChildrenin interfaceQueryNode- Returns:
- a List for QueryNode object. Returns null, for nodes that do not contain children. All leaf Nodes return null.
-
setTag
public void setTag(java.lang.String tagName, java.lang.Object value)Description copied from interface:QueryNodeAssociate the specified value with the specified tagName. If the tagName already exists, the old value is replaced. The tagName and value cannot be null. tagName will be converted to lowercase.
-
unsetTag
public void unsetTag(java.lang.String tagName)
Description copied from interface:QueryNodeUnset a tag. tagName will be converted to lowercase.
-
containsTag
public boolean containsTag(java.lang.String tagName)
verify if a node contains a tag- Specified by:
containsTagin interfaceQueryNode
-
getTag
public java.lang.Object getTag(java.lang.String tagName)
Description copied from interface:QueryNodeReturns object stored under that tag name
-
setParent
private void setParent(QueryNode parent)
-
isRoot
protected boolean isRoot()
-
isDefaultField
protected boolean isDefaultField(java.lang.CharSequence fld)
This method is use toQueryString to detect if fld is the default field- Parameters:
fld- - field name- Returns:
- true if fld is the default field
-
toString
public java.lang.String toString()
Every implementation of this class should return pseudo xml like this: For FieldQueryNode: <field start='1' end='2' field='subject' text='foo'/>- Specified by:
toStringin interfaceQueryNode- Overrides:
toStringin classjava.lang.Object- See Also:
QueryNode.toString()
-
getTagMap
public java.util.Map<java.lang.String,java.lang.Object> getTagMap()
Returns a map containing all tags attached to this query node.
-
removeChildren
public void removeChildren(QueryNode childNode)
Description copied from interface:QueryNodeRemove a child node- Specified by:
removeChildrenin interfaceQueryNode- Parameters:
childNode- Which child to remove
-
removeFromParent
public void removeFromParent()
Description copied from interface:QueryNodeRemoves this query node from its parent.- Specified by:
removeFromParentin interfaceQueryNode
-
-