public Object getValue(Object ctx, Object elCtx, VariableResolverFactory variableFactory) { Object[] template = new Object[values.length]; for (int i = 0; i < values.length; i++) { template[i] = values[i].getValue(ctx, elCtx, variableFactory); } return new FastList(template); }
public Object getReducedValue(Object ctx, Object thisValue, VariableResolverFactory factory) { ItemResolverFactory.ItemResolver itemR = new ItemResolverFactory.ItemResolver("$"); ItemResolverFactory itemFactory = new ItemResolverFactory(itemR, new DefaultLocalVariableResolverFactory(factory)); List list; if (constraintEx != null) { Object x = dataEx.getValue(ctx, thisValue, factory); if (!(x instanceof Collection)) throw new CompileException("was expecting type: Collection; but found type: " + (x == null ? "null" : x.getClass().getName())); list = new FastList(((Collection) x).size()); for (Object o : (Collection) x) { itemR.value = o; if ((Boolean) constraintEx.getValue(ctx, thisValue, itemFactory)) { list.add(subEx.getValue(o, thisValue, itemFactory)); } } } else { Object x = dataEx.getValue(ctx, thisValue, factory); if (!(x instanceof Collection)) throw new CompileException("was expecting type: Collection; but found type: " + (x == null ? "null" : x.getClass().getName())); list = new FastList(((Collection) x).size()); for (Object o : (Collection) x) { list.add(subEx.getValue(itemR.value = o, thisValue, itemFactory)); } } return list; }
public Object getReducedValueAccelerated(Object ctx, Object thisValue, VariableResolverFactory factory) { ItemResolverFactory.ItemResolver itemR = new ItemResolverFactory.ItemResolver("$"); ItemResolverFactory itemFactory = new ItemResolverFactory(itemR, new DefaultLocalVariableResolverFactory(factory)); List list; if (constraintEx != null) { Collection col = ((Collection) dataEx.getValue(ctx, thisValue, factory)); list = new FastList(col.size()); for (Object o : col) { itemR.value = o; if ((Boolean) constraintEx.getValue(ctx, thisValue, itemFactory)) { list.add(subEx.getValue(o, thisValue, itemFactory)); } } } else { Collection col = ((Collection) dataEx.getValue(ctx, thisValue, factory)); list = new FastList(col.size()); for (Object o : col) { list.add(subEx.getValue(itemR.value = o, thisValue, itemFactory)); } } return list; }
public void testFastList1() { FastList list = new FastList(3); list.add("One"); list.add("Two"); list.add("Three"); list.add("Five"); list.add(1, "Four"); String[] zz1 = {"One", "Four", "Two", "Three", "Five"}; int i = 0; for (Object o : list) { if (!zz1[i++].equals(o)) throw new AssertionError("problem with list!"); } list.remove(2); String[] zz2 = {"One", "Four", "Three", "Five"}; i = 0; for (Object o : list) { if (!zz2[i++].equals(o)) throw new AssertionError("problem with list!"); } }
public void testAddAllFastList() throws Exception { FastList fl1 = new FastList(1); fl1.add("value1"); fl1.add("value2"); assertEquals(2, fl1.size()); FastList fl2 = new FastList(1); fl2.add("value3"); fl2.add("value4"); // the addAll results in a list of 2 instead of 4 that was expected fl1.addAll(fl2); assertEquals(4, fl1.size()); }
public void testAddToFastList() throws Exception { FastList fl = new FastList(0); assertEquals(0, fl.size()); // this throws an ArrayIndexOutOfBoundsException:0 fl.add("value"); assertEquals(1, fl.size()); }
public void testAddAllFastList2() throws Exception { FastList<String> fl1 = new FastList<String>(); fl1.add("value1"); fl1.add("value2"); FastList<String> fl2 = new FastList<String>(); fl2.add("value3"); fl2.add("value4"); fl1.addAll(fl2); assertEquals("value1", fl1.get(0)); assertEquals("value2", fl1.get(1)); assertEquals("value3", fl1.get(2)); // this results in null assertEquals("value4", fl1.get(3)); // this results in null }
public static void testJavaList() { FastList list; for (int i = 0; i < COUNT; i++) { list = new FastList(10); list.add("Foo244"); list.add("Bar"); list.add("Foo244"); list.add("Bar"); list.add("Foo244"); list.add("Bar"); list.add("Foo244"); list.add("Bar"); list.add("Foo244"); list.add("Bar"); assert "Foo244".equals(list.get(0)) && "Bar".equals(list.get(1)) && list.size() == 10; } } }