/** * Constructor used to make a comparator which will compare * Associations using the context provided. */ public AssociationComparator(Collection<TopicIF> context) { this.scopes = context; if (scopes == null) scopes = Collections.emptyList(); StringifierIF<TopicIF> bts = new GrabberStringifier<TopicIF, TopicNameIF>(new TopicNameGrabber(scopes), new NameStringifier()); tc = new StringifierComparator<TopicIF>(new GrabberStringifier<TopicIF, String>(new GrabberGrabber<TopicIF, String>(new StringifierGrabber<TopicIF>(bts), new UpperCaseGrabber()))); }
public void testUpperCaseGrabber() { String str = "Don't you eat that YELLOW snow!"; testGrabber(new UpperCaseGrabber().grab(str), str.toUpperCase(), str); }
public void testGrabberComparator() { UpperCaseGrabber upg = new UpperCaseGrabber(); LowerCaseGrabber log = new LowerCaseGrabber(); Comparator sc = LexicalComparator.CASE_SENSITIVE; Comparator isc = new GrabberComparator(new UpperCaseGrabber(), sc); testComparator(new GrabberComparator(upg, sc).compare("foobar", "FOOBAR"), 0, 1); testComparator(new GrabberComparator(upg, isc).compare("foobar", "FoOBAR"), 0, 1); testComparator(new GrabberComparator(upg, log, sc).compare("foobar", "FoOBAR"), new GrabberComparator(log, upg, sc).compare("foobar", "FoOBAR") * -1, new GrabberComparator(upg, isc).compare("foobar", "FoOBAR ")); }
public void testStringifierComparator() { UpperCaseGrabber upg = new UpperCaseGrabber(); GrabberStringifier grb = new GrabberStringifier(upg); testComparator(new StringifierComparator(grb).compare(upg.grab("foobar"), "FOOBAR"), 0, 1); }
public void testGrabberCollection() { UpperCaseGrabber grbU = new UpperCaseGrabber(); testCollection(new GrabberCollection(getCollectionLow(intended_size), grbU), getCollection(intended_size), getCollection(intended_size - 5)); testCollection(new GrabberCollection(getCollectionLow(intended_size), grbU, getDeciders(intended_size)), getCollection(intended_size), getCollection(intended_size - 5)); intended_size = 10; }
public void testCachedGrabber() { CachedGrabber grb = new CachedGrabber(new SubstringGrabber(5, 15)); String str = "Jazz is not dead, it just smells funny!"; testGrabber(grb.grab(str), grb.getGrabber().grab(str), grb.getGrabber().grab(str.substring(2))); str.replace(' ', '-'); testGrabber(grb.grab(str), grb.getGrabber().grab(str), grb.getGrabber().grab(str.substring(2))); testGrabber(grb.grab(str), grb.getGrabber().grab(str), grb.getGrabber().grab(str.substring(2))); grb.refresh(); testGrabber(grb.grab(str), grb.getGrabber().grab(str), grb.getGrabber().grab(str.substring(2))); str.replace('-', '_'); testGrabber(grb.grab(str), grb.getGrabber().grab(str), grb.getGrabber().grab(str.substring(2))); testGrabber(grb.grab(str), grb.getGrabber().grab(str), grb.getGrabber().grab(str.substring(2))); grb.setGrabber(new UpperCaseGrabber()); testGrabber(grb.grab(str), grb.grab(str), grb.getGrabber().grab(str)); grb.refresh(); testGrabber(grb.grab(str), grb.getGrabber().grab(str), grb.getGrabber().grab(str.substring(2))); }
public void testGrabberGrabber() { LowerCaseGrabber grbLow = new LowerCaseGrabber(); UpperCaseGrabber grbUp = new UpperCaseGrabber(); SubstringGrabber grbSub1 = new SubstringGrabber(4, 15); SubstringGrabber grbSub2 = new SubstringGrabber(2,7); GrabberGrabber grbGrb1 = new GrabberGrabber(grbLow, grbUp); GrabberGrabber grbGrb2 = new GrabberGrabber(grbLow, grbUp); GrabberGrabber grbGrb3 = new GrabberGrabber(grbUp, grbLow); testGrabber(grbGrb1.getGrabbers(), grbGrb2.getGrabbers(), grbGrb3.getGrabbers()); GrabberGrabber grbGrb4 = new GrabberGrabber(grbSub1, grbSub2, grbUp); GrabberGrabber grbGrb5 = new GrabberGrabber(grbSub1, grbSub2, grbUp); GrabberGrabber grbGrb6 = new GrabberGrabber(grbSub1, grbSub2, grbLow); testGrabber(grbGrb4.getGrabbers(), grbGrb5.getGrabbers(), grbGrb6.getGrabbers()); GrabberGrabber grbGrb7 = new GrabberGrabber(grbSub1, grbSub2, grbUp, grbLow); GrabberGrabber grbGrb8 = new GrabberGrabber(grbSub1, grbSub2, grbUp, grbLow); GrabberGrabber grbGrb9 = new GrabberGrabber(grbSub1, grbSub2, grbLow, grbUp); testGrabber(grbGrb7.getGrabbers(), grbGrb8.getGrabbers(), grbGrb9.getGrabbers()); grbGrb1.addGrabber(grbSub1); grbGrb2.addGrabber(grbSub1); grbGrb3.addGrabber(grbSub1); grbGrb4.setGrabbers(grbGrb7.getGrabbers()); grbGrb6.setGrabbers(grbGrb9.getGrabbers()); testGrabber(grbGrb4.getGrabbers(), grbGrb7.getGrabbers(), grbGrb6.getGrabbers()); String str = "JaZz Is NoT dEaD, iT jUsT sMeLlS fUnNy!"; testGrabber(grbGrb4.grab(str), grbGrb7.grab(str), grbGrb6.grab(str)); }