Package org.mvel2.util

Examples of org.mvel2.util.FastList


    protected static String JAVA_RULE_MVEL             = "javaRule.mvel";
    protected static String JAVA_INVOKERS_MVEL         = "javaInvokers.mvel";

    public static void setConsequenceTemplate( String name ) {
        JAVA_RULE_MVEL = name;
        RULE_REGISTRY = new SimpleTemplateRegistry();
    }
View Full Code Here


        RULE_REGISTRY = new SimpleTemplateRegistry();
    }

    public static void setInvokerTemplate( String name ) {
        JAVA_INVOKERS_MVEL = name;
        INVOKER_REGISTRY = new SimpleTemplateRegistry();
    }
View Full Code Here

                                 final ProcessBuildContext context,
                                 final String className,
                                 final Map vars,
                                 final Object invokerLookup,
                                 final BaseDescr descrLookup) {
        TemplateRegistry registry = getRuleTemplateRegistry();

        context.getMethods().add(
                TemplateRuntime.execute(registry.getNamedTemplate(ruleTemplate), null, new MapVariableResolverFactory(vars), registry)
        );

        registry = getInvokerTemplateRegistry();
        final String invokerClassName = context.getPkg().getName() + "." + context.getProcessDescr().getClassName() + StringUtils.ucFirst(className) + "Invoker";

        context.getInvokers().put(invokerClassName,
                TemplateRuntime.execute(registry.getNamedTemplate(invokerTemplate), null, new MapVariableResolverFactory(vars), registry)
        );

        context.getInvokerLookups().put(invokerClassName,
                invokerLookup);
        context.getDescrLookups().put(invokerClassName,
View Full Code Here

        generateMethodTemplate(ruleTemplate, context, vars);
        generateInvokerTemplate(invokerTemplate, context, className, vars, invokerLookup, descrLookup);
    }

    public static void generateMethodTemplate(final String ruleTemplate, final RuleBuildContext context, final Map vars) {
        TemplateRegistry registry = getRuleTemplateRegistry(context.getPackageBuilder().getRootClassLoader());

        context.addMethod((String) TemplateRuntime.execute( registry.getNamedTemplate(ruleTemplate),
                                                            null,
                                                            new MapVariableResolverFactory(vars),
                                                            registry) );
    }
View Full Code Here

                                               final RuleBuildContext context,
                                               final String className,
                                               final Map vars,
                                               final Object invokerLookup,
                                               final BaseDescr descrLookup) {
        TemplateRegistry registry = getInvokerTemplateRegistry(context.getPackageBuilder().getRootClassLoader());
        final String invokerClassName = context.getPkg().getName() + "." + context.getRuleDescr().getClassName() + StringUtils.ucFirst( className ) + "Invoker";

        context.getInvokers().put( invokerClassName,
                                   (String) TemplateRuntime.execute( registry.getNamedTemplate( invokerTemplate ),
                                                                     null,
                                                                     new MapVariableResolverFactory( vars ),
                                                                     registry ) );

        context.getInvokerLookups().put( invokerClassName,
View Full Code Here

        new StringAppender(10).append("C:/projects/webcat/exploded/")
            .append("resources/productimages/").toString());
  }

  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!");
View Full Code Here

      if (!zz2[i++].equals(o)) throw new AssertionError("problem with list!");
    }
  }

  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());
  }
View Full Code Here

    fl.add("value");
    assertEquals(1, fl.size());
  }

  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());
View Full Code Here

//            assert "Foo244".equals(list.get(0)) && "Foo244".equals(list.get(2)) && list.size() == 10;
//        }
  }

  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;
    }

  }
View Full Code Here

        String[] allVars = new String[varNames.length + locals.length];

        System.arraycopy(varNames, 0, allVars, 0, varNames.length);
        System.arraycopy(locals, 0, allVars, varNames.length, locals.length);       
       
        this.varModel = new SimpleVariableSpaceModel(allVars);
        this.allVarsLength = allVars.length;
       
        return stmt;
    }
View Full Code Here

TOP

Related Classes of org.mvel2.util.FastList

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.