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,RankItem,RootItem,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, documentFrequency, explicitSignificance, significance, uniqueID -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbooleanacceptsItemsOfType(Item.ItemType itemType) protected voidvoidInserts the item at a position and increases the index of existing items starting on this position by onevoidprotected voidappendBodyString(StringBuilder buffer) Override to append the item body in the canonical query language of this item.clone()Returns a deep copy of this itemvoidintencode(ByteBuffer buffer) protected voidencodeThis(ByteBuffer buffer) Encodes just this item, not its regular subitems, to the given buffer.protected intvoidbooleanReturns 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 subitemintReturns the number of direct children of this itemintgetItemIndex(Item item) Returns the index of a subitemReturns a modifiable list iterator of the immediate children of thisintinthashCode()booleanisLocked()Whether this composite is in a mutable state.items()Returns a read only list of the immediate children of thisvoidlock()Make composite immutable if this is supported.removeItem(int index) Removes the item at the given indexbooleanremoveItem(Item item) Removes the given item.voidsetIndexName(String index) Sets the index name of all subitems of thisReplaces the item at the given index.protected booleanComposite 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:
setIndexNamein 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:
encodeThisin classItem
-
encodingArity
protected int encodingArity() -
appendBodyString
Description copied from class:ItemOverride 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 by this method.- Specified by:
appendBodyStringin classItem
-
shouldParenthesize
protected boolean shouldParenthesize()Composite items should be parenthized when not on the top level- Overrides:
shouldParenthesizein 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:
getTermCountin classItem
-
extractSingleChild
Returns the single child of this, if this can be omitted without changes to recall semantics. -
acceptsItemsOfType
-