Package com.yahoo.prelude.query
Class NotItem
- java.lang.Object
-
- com.yahoo.prelude.query.Item
-
- com.yahoo.prelude.query.CompositeItem
-
- com.yahoo.prelude.query.NotItem
-
- All Implemented Interfaces:
java.lang.Cloneable
public class NotItem extends CompositeItem
A composite item where the first item is positive and the following items are negative items which should be excluded from the result.- 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
Constructors Constructor Description NotItem()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addItem(Item item)
Adds an item.void
addNegativeItem(Item negative)
Adds a negative item.void
addPositiveItem(Item item)
Convenience method for adding a positive item.protected void
appendBodyString(java.lang.StringBuilder buffer)
Overridden to tolerate nulls and to append "+" to the first item and "-" to the restprotected void
appendHeadingString(java.lang.StringBuilder buffer)
Not items uses a empty heading instead of "NOT "Item.ItemType
getItemType()
Return the enumerated type of this item.java.lang.String
getName()
Returns the name of this itemItem
getPositiveItem()
Returns the positive item (the first subitem), or null if no positive items has been addedint
getTermCount()
Returns the number of actual *positive* terms in thisjava.util.List<Item>
negativeItems()
Returns the negative items of this: All child items except the firstItem
removeItem(int index)
Removes the item at the given indexboolean
removeItem(Item item)
Removes the given item.Item
setPositiveItem(Item item)
Sets the positive item (the first item)-
Methods inherited from class com.yahoo.prelude.query.CompositeItem
adding, addItem, clone, disclose, encode, encodeThis, encodingArity, ensureNotInSubtree, equals, extractSingleChild, getItem, getItemCount, getItemIndex, getItemIterator, hashCode, isLocked, items, lock, setIndexName, setItem, shouldParenthize
-
Methods inherited from class com.yahoo.prelude.query.Item
addAnnotation, getAnnotation, getBytes, getCode, getCreator, getLabel, getLanguage, getParent, getWeight, hasAnnotation, hasConnectivityBackLink, hasUniqueID, isFilter, isFromSpecialToken, isProtected, isRanked, isRoot, putBytes, putString, setCreator, setFilter, setFromSpecialToken, setHasUniqueID, setLabel, setLanguage, setParent, setPositionData, setProtected, setRanked, setWeight, toString, usePositionData
-
-
-
-
Method Detail
-
getItemType
public Item.ItemType getItemType()
Description copied from class:Item
Return the enumerated type of this item.- Specified by:
getItemType
in classItem
-
getName
public java.lang.String getName()
Description copied from class:Item
Returns the name of this item
-
addItem
public void addItem(Item item)
Adds an item. The first item is the positive the rest is negative- Overrides:
addItem
in classCompositeItem
-
addNegativeItem
public void addNegativeItem(Item negative)
Adds a negative item. Like addItem but skips the first position (position 0) if it is not already set.
-
negativeItems
public java.util.List<Item> negativeItems()
Returns the negative items of this: All child items except the first
-
getPositiveItem
public Item getPositiveItem()
Returns the positive item (the first subitem), or null if no positive items has been added
-
setPositiveItem
public Item setPositiveItem(Item item)
Sets the positive item (the first item)- Returns:
- the old positive item, or null if there was no items
-
addPositiveItem
public void addPositiveItem(Item item)
Convenience method for adding a positive item. If a positive item is already present the positive item becomes an AndItem with the items added
-
removeItem
public boolean removeItem(Item item)
Description copied from class:CompositeItem
Removes the given item. Does nothing if the item is not present.- Overrides:
removeItem
in classCompositeItem
- Parameters:
item
- the item to remove- Returns:
- whether the item was removed
-
removeItem
public Item removeItem(int index)
Description copied from class:CompositeItem
Removes the item at the given index- Overrides:
removeItem
in classCompositeItem
- Parameters:
index
- the index of the item to remove- Returns:
- the removed item
-
appendHeadingString
protected void appendHeadingString(java.lang.StringBuilder buffer)
Not items uses a empty heading instead of "NOT "- Overrides:
appendHeadingString
in classItem
-
appendBodyString
protected void appendBodyString(java.lang.StringBuilder buffer)
Overridden to tolerate nulls and to append "+" to the first item and "-" to the rest- Overrides:
appendBodyString
in classCompositeItem
-
getTermCount
public int getTermCount()
Returns the number of actual *positive* terms in this- Overrides:
getTermCount
in classCompositeItem
-
-