/** * Returns whether this item is of the same class and * contains the same state as the given item */ public boolean equals(Object object) { if (!super.equals(object)) { return false; } CompositeItem other = (CompositeItem) object; // Ensured by superclass if (!this.subitems.equals(other.subitems)) { return false; } return true; }
/** Removes an item, prefers the one at/close to the given position if there are multiple ones */ public void removeItem(int position,Item item) { Item removeCandidate=item.getParent().getItem(position); if (removeCandidate.equals(item)) // Remove based on position item.getParent().removeItem(position); else item.getParent().removeItem(item); // Otherwise, just removeField any such item }
@Override public Result search(Query query, Execution execution) { QueryTree tree = query.getModel().getQueryTree(); Item root = tree.getRoot(); if (root != null) { Item newRoot = root.clone(); newRoot = simplifyPhrases(newRoot); // Sets new root instead of transforming the query tree // to make code nicer if the root is a single term phrase if (!root.equals(newRoot)) { tree.setRoot(newRoot); query.trace("Collapsing single term phrases to single terms", true, 2); } } return execution.search(query); }
oldRoot.equals(origQueryItem)) { PhraseItem phrase = convertAndToPhrase((AndItem)oldRoot);