public static void initializeForm(DispatchForm form, Item item, ItemIdMapper itemIdMapper) { if (item.getWeight() != Item.DEFAULT_WEIGHT) { form.setProperty(weightProperty, item.getWeight()); } if (item instanceof IndexedItem) { initializeIndexedForm(form, (IndexedItem) item); } if (item instanceof TaggableItem) { initializeTaggableForm(form, (TaggableItem) item, itemIdMapper); } initializeFormWithIdIfConnected(form, item, itemIdMapper); }
boolean isRanked = leaf.isRanked(); String label = leaf.getLabel(); int weight = leaf.getWeight();
/** * Splits the given item into n-grams and adds them as a CompositeItem containing WordItems searching the * index of the input term. If the result is a single gram, that single WordItem is returned rather than the AndItem * * @param term the term to split, must be an item which implement the IndexedItem and BlockItem "mixins" * @param text the text of the item, just stringValue() if the item is a TermItem * @param gramSize the gram size to split to * @param query the query in which this rewriting is done * @return the root of the query subtree produced by this, containing the split items */ protected Item splitToGrams(Item term, String text, int gramSize, Query query) { String index = ((HasIndexItem)term).getIndexName(); CompositeItem gramsItem = createGramRoot(query); gramsItem.setIndexName(index); Substring origin = ((BlockItem)term).getOrigin(); for (Iterator<GramSplitter.Gram> i = getGramSplitter().split(text,gramSize); i.hasNext(); ) { GramSplitter.Gram gram = i.next(); WordItem gramWord = new WordItem(gram.extractFrom(text), index, false, origin); gramWord.setWeight(term.getWeight()); gramWord.setProtected(true); gramsItem.addItem(gramWord); } return gramsItem.getItemCount()==1 ? gramsItem.getItem(0) : gramsItem; // return the AndItem, or just the single gram if not multiple }
/** * create an EQUIV with the given item as child. * The new EQUIV will take connectivity, * significance and weight from the given item. * * @param item Will be modified and added as a child. **/ public EquivItem(Item item) { addItem(item); // steal other item's connectivity: if (item.connectedItem != null) { setConnectivity(item.connectedItem, item.connectivity); item.connectedItem = null; item.connectivity = 0.0; } TaggableItem back = (TaggableItem)item.connectedBacklink; if (back != null) { back.setConnectivity(this, back.getConnectivity()); item.connectedBacklink = null; } // steal other item's significance: if (item.explicitSignificance) { setSignificance(item.significance); } // steal other item's weight: setWeight(item.getWeight()); // we have now stolen all of the other item's unique id needs: item.setHasUniqueID(false); }