/** * Marks all filter terms in the given query tree as unranked. * * @param root The root of the tree to update. */ private static void updateFilterTerms(Item root) { Stack<Item> stack = new Stack<>(); stack.push(root); while (!stack.isEmpty()) { Item item = stack.pop(); if (item.getCreator() == Item.ItemCreator.FILTER) { item.setRanked(false); } if (item instanceof CompositeItem) { CompositeItem lst = (CompositeItem)item; for (Iterator<Item> it = lst.getItemIterator(); it.hasNext();) { stack.push(it.next()); } } } } }
/** * Returns the first word item contained in the given item tree that is an instance of {@link WordItem} with the * given word value. * * @param root The root of the tree to check. * @param value The word to look for. * @return The first node found. */ private static WordItem findOrigWordItem(Item root, String value) { Stack<Item> stack = new Stack<>(); stack.push(root); while (!stack.isEmpty()) { Item item = stack.pop(); if (item.getCreator() == Item.ItemCreator.ORIG && item instanceof WordItem) { WordItem word = (WordItem)item; if (word.getWord().equals(value)) { return word; } } if (item instanceof CompositeItem) { CompositeItem lst = (CompositeItem)item; for (Iterator<Item> it = lst.getItemIterator(); it.hasNext();) { stack.push(it.next()); } } } return null; }
private void copyAttributes(Item blockAsItem, Item replacement) { copyWeight(blockAsItem, replacement); replacement.setCreator(blockAsItem.getCreator()); replacement.setRanked(blockAsItem.isRanked()); replacement.setPositionData(blockAsItem.usePositionData()); }