Search in sources :

Example 6 with StringFieldPart

use of com.yahoo.prelude.hitfield.StringFieldPart in project vespa by vespa-engine.

the class TokenFieldIteratorTestCase method testTokenIteratorSet.

@Test
public void testTokenIteratorSet() {
    HitField hf = new HitField("boo", "hei paa deg");
    assertEquals(3, hf.getTokenizedContent().size());
    ListIterator<FieldPart> l = hf.tokenIterator();
    l.next();
    l.next();
    l.set(new StringFieldPart("aap", true));
    l.next();
    assertEquals(false, l.hasNext());
    l.previous();
    l.set(new StringFieldPart("ged", true));
    assertEquals("hei aap ged", hf.getContent());
}
Also used : FieldPart(com.yahoo.prelude.hitfield.FieldPart) StringFieldPart(com.yahoo.prelude.hitfield.StringFieldPart) HitField(com.yahoo.prelude.hitfield.HitField) StringFieldPart(com.yahoo.prelude.hitfield.StringFieldPart) Test(org.junit.Test)

Example 7 with StringFieldPart

use of com.yahoo.prelude.hitfield.StringFieldPart in project vespa by vespa-engine.

the class HitFieldTestCase method testHitField.

@Test
public void testHitField() {
    HitField hf = new HitField("boo", "hei paa deg");
    assertEquals(3, hf.getTokenizedContent().size());
    List l = new ArrayList();
    l.add(new StringFieldPart("foo", true));
    l.add(new StringFieldPart(" ", false));
    l.add(new StringFieldPart("bar", true));
    hf.setTokenizedContent(l);
    assertEquals("foo bar", hf.getContent());
    assertEquals("hei paa deg", hf.getRawContent());
}
Also used : HitField(com.yahoo.prelude.hitfield.HitField) ArrayList(java.util.ArrayList) List(java.util.List) ArrayList(java.util.ArrayList) StringFieldPart(com.yahoo.prelude.hitfield.StringFieldPart) Test(org.junit.Test)

Example 8 with StringFieldPart

use of com.yahoo.prelude.hitfield.StringFieldPart in project vespa by vespa-engine.

the class HitFieldTestCase method testCjk.

@Test
public void testCjk() {
    HitField hf = new HitField("boo", "hmm\u001fgr");
    assertEquals(2, hf.getTokenizedContent().size());
    assertEquals("hmmgr", hf.getContent());
    List l = new ArrayList();
    l.add(new StringFieldPart("foo", true));
    l.add(new StringFieldPart("bar", true));
    hf.setTokenizedContent(l);
    assertEquals("foobar", hf.getContent());
}
Also used : HitField(com.yahoo.prelude.hitfield.HitField) ArrayList(java.util.ArrayList) List(java.util.List) ArrayList(java.util.ArrayList) StringFieldPart(com.yahoo.prelude.hitfield.StringFieldPart) Test(org.junit.Test)

Aggregations

StringFieldPart (com.yahoo.prelude.hitfield.StringFieldPart)8 FieldPart (com.yahoo.prelude.hitfield.FieldPart)6 HitField (com.yahoo.prelude.hitfield.HitField)5 Test (org.junit.Test)5 BoldCloseFieldPart (com.yahoo.prelude.hitfield.BoldCloseFieldPart)2 BoldOpenFieldPart (com.yahoo.prelude.hitfield.BoldOpenFieldPart)2 SeparatorFieldPart (com.yahoo.prelude.hitfield.SeparatorFieldPart)2 ArrayList (java.util.ArrayList)2 List (java.util.List)2 ImmutableFieldPart (com.yahoo.prelude.hitfield.ImmutableFieldPart)1