/** Returns the word for encoding. By default simply the word */ protected String getEncodedWord() { return getIndexedString(); }
@Override public boolean visit(Item item) { if (item instanceof NullItem) { throw new IllegalArgumentException("Got NullItem inside nonEmpty()."); } else if (item instanceof WordItem) { if (((WordItem) item).getIndexedString().isEmpty()) { throw new IllegalArgumentException("Searching for empty string inside nonEmpty()"); } } else if (item instanceof CompositeItem) { if (((CompositeItem) item).getItemCount() == 0) { throw new IllegalArgumentException("Empty composite operator (" + item.getName() + ") inside nonEmpty()"); } } return true; }
private static void serializeWords(StringBuilder destination, AndSegmentItem segment) { for (int i = 0; i < segment.getItemCount(); ++i) { if (i > 0) { destination.append(", "); } Item current = segment.getItem(i); if (current instanceof WordItem) { destination.append('"'); escape(((WordItem) current).getIndexedString(), destination).append('"'); } else { throw new IllegalArgumentException("Serializing of " + current.getClass().getSimpleName() + " in segment AND expressions not implemented, please report this as a bug."); } } }
private static void serializeWords(StringBuilder destination, PhraseSegmentItem segment) { for (int i = 0; i < segment.getItemCount(); ++i) { if (i > 0) { destination.append(", "); } Item current = segment.getItem(i); if (current instanceof WordItem) { destination.append('"'); escape(((WordItem) current).getIndexedString(), destination).append('"'); } else { throw new IllegalArgumentException("Serializing of " + current.getClass().getSimpleName() + " in phrases not implemented, please report this as a bug."); } } }
@Override boolean serialize(StringBuilder destination, Item item) { NearItem n = (NearItem) item; String annotations = nearAnnotations(n); destination.append(getIndexName(n.getItem(0))).append(" contains "); if (annotations.length() > 0) { destination.append('(').append(annotations); } destination.append(NEAR).append('('); int initLen = destination.length(); for (ListIterator<Item> i = n.getItemIterator(); i.hasNext();) { WordItem close = (WordItem) i.next(); if (destination.length() > initLen) { destination.append(", "); } destination.append('"'); escape(close.getIndexedString(), destination).append('"'); } destination.append(')'); if (annotations.length() > 0) { destination.append(')'); } return false; }
@Override boolean serialize(StringBuilder destination, Item item) { NearItem n = (NearItem) item; String annotations = NearSerializer.nearAnnotations(n); destination.append(getIndexName(n.getItem(0))).append(" contains "); if (annotations.length() > 0) { destination.append('(').append(annotations); } destination.append(ONEAR).append('('); int initLen = destination.length(); for (ListIterator<Item> i = n.getItemIterator(); i.hasNext();) { WordItem close = (WordItem) i.next(); if (destination.length() > initLen) { destination.append(", "); } destination.append('"'); escape(close.getIndexedString(), destination).append('"'); } destination.append(')'); if (annotations.length() > 0) { destination.append(')'); } return false; }
if (!image.substring(offset, offset + length).equals(item.getIndexedString())) { VespaSerializer.serializeOrigin(annotation, image, offset, length);