Package com.yahoo.prelude.query
Class CompositeItem
java.lang.Object
com.yahoo.prelude.query.Item
com.yahoo.prelude.query.CompositeItem
- All Implemented Interfaces:
Cloneable
- Direct Known Subclasses:
AndItem
,CompositeTaggableItem
,NearItem
,NonReducibleCompositeItem
,NotItem
,OrItem
,QueryTree
,RankItem
,SegmentItem
Superclass of expressions which contains a collection of sub-expressions
- Author:
- bratseth
-
Nested Class Summary
Nested classes/interfaces inherited from class com.yahoo.prelude.query.Item
Item.ItemCreator, Item.ItemType
-
Field Summary
Fields inherited from class com.yahoo.prelude.query.Item
connectedBacklink, connectedItem, connectivity, DEFAULT_WEIGHT, explicitSignificance, significance, uniqueID
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionboolean
acceptsItemsOfType
(Item.ItemType itemType) protected void
void
Inserts the item at a position and increases the index of existing items starting on this position by onevoid
protected void
appendBodyString
(StringBuilder buffer) Override to append the item body in the canonical query language of this item.clone()
Returns a deep copy of this itemvoid
int
encode
(ByteBuffer buffer) protected void
encodeThis
(ByteBuffer buffer) Encodes just this item, not its regular subitems, to the given buffer.protected int
void
boolean
Returns whether this item is of the same class and contains the same state as the given item.Returns the single child of this, if this can be omitted without changes to recall semantics.getItem
(int index) Returns a subitemint
Returns the number of direct children of this itemint
getItemIndex
(Item item) Returns the index of a subitemReturns a modifiable list iterator of the immediate children of thisint
int
hashCode()
boolean
isLocked()
Whether this composite is in a mutable state.items()
Returns a read only list of the immediate children of thisvoid
lock()
Make composite immutable if this is supported.removeItem
(int index) Removes the item at the given indexboolean
removeItem
(Item item) Removes the given item.void
setIndexName
(String index) Sets the index name of all subitems of thisReplaces the item at the given index.protected boolean
Composite items should be parenthized when not on the top levelMethods inherited from class com.yahoo.prelude.query.Item
addAnnotation, appendHeadingString, getAnnotation, getBytes, getCode, getCreator, getItemType, getLabel, getLanguage, getName, getParent, getWeight, hasAnnotation, hasConnectivityBackLink, hasPrefixMatchSemantics, hasUniqueID, isFilter, isFromSpecialToken, isProtected, isRanked, isRoot, putBytes, putString, setCreator, setFilter, setFromSpecialToken, setHasUniqueID, setLabel, setLanguage, setParent, setPositionData, setProtected, setRanked, setWeight, toString, usePositionData
-
Constructor Details
-
CompositeItem
public CompositeItem()
-
-
Method Details
-
setIndexName
Sets the index name of all subitems of this- Specified by:
setIndexName
in classItem
-
disclose
-
ensureNotInSubtree
-
addItem
-
adding
-
addItem
Inserts the item at a position and increases the index of existing items starting on this position by one- Throws:
IndexOutOfBoundsException
- if the index is out of range
-
getItem
Returns a subitem- Parameters:
index
- the (0-base) index of the item to return- Throws:
IndexOutOfBoundsException
- if there is no subitem at index
-
setItem
Replaces the item at the given index.- Parameters:
index
- the (0-base) index of the item to replaceitem
- the new item- Returns:
- the old item at this position. The parent of the old item is not cleared
- Throws:
IndexOutOfBoundsException
- if there is no item at this index
-
getItemIndex
Returns the index of a subitem- Parameters:
item
- the child item to find the index of- Returns:
- the 0-base index of the child or -1 if there is no such child
-
removeItem
Removes the item at the given index- Parameters:
index
- the index of the item to remove- Returns:
- the removed item
- Throws:
IndexOutOfBoundsException
- if there is no item at the given index
-
removeItem
Removes the given item. Does nothing if the item is not present.- Parameters:
item
- the item to remove- Returns:
- whether the item was removed
-
getItemCount
public int getItemCount()Returns the number of direct children of this item -
getItemIterator
Returns a modifiable list iterator of the immediate children of this -
items
Returns a read only list of the immediate children of this -
encode
-
encodeThis
Encodes just this item, not its regular subitems, to the given buffer.- Overrides:
encodeThis
in classItem
-
encodingArity
protected int encodingArity() -
appendBodyString
Description copied from class:Item
Override to append the item body in the canonical query language of this item. An item is usually represented by the string([itemName] [body])
The body must be appended appended by this method.- Specified by:
appendBodyString
in classItem
-
shouldParenthesize
protected boolean shouldParenthesize()Composite items should be parenthized when not on the top level- Overrides:
shouldParenthesize
in classItem
-
clone
Returns a deep copy of this item -
hashCode
public int hashCode() -
equals
Returns whether this item is of the same class and contains the same state as the given item. -
lock
public void lock()Make composite immutable if this is supported. -
isLocked
public boolean isLocked()Whether this composite is in a mutable state. -
getTermCount
public int getTermCount()- Specified by:
getTermCount
in classItem
-
extractSingleChild
Returns the single child of this, if this can be omitted without changes to recall semantics. -
acceptsItemsOfType
-