Package org.mvel2.integration.impl

Examples of org.mvel2.integration.impl.ItemResolverFactory$ItemResolver


    return list;
  }

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


    }
  }

  public Object getReducedValueAccelerated(Object ctx, Object thisValue, VariableResolverFactory factory) {
    ItemResolverFactory.ItemResolver itemR = new ItemResolverFactory.ItemResolver(item);
    ItemResolverFactory itemFactory = new ItemResolverFactory(itemR, new DefaultLocalVariableResolverFactory(factory));

    Object iterCond = condition.getValue(ctx, thisValue, factory);

    if (type == -1) {
      determineIterType(iterCond.getClass());
    }

    Object v;
    switch (type) {
      case ARRAY:
        int len = Array.getLength(iterCond);
        for (int i = 0; i < len; i++) {
          itemR.setValue(Array.get(iterCond, i));
          v = compiledBlock.getValue(ctx, thisValue, itemFactory);
          if (itemFactory.tiltFlag()) return v;
        }
        break;
      case CHARSEQUENCE:
        for (Object o : iterCond.toString().toCharArray()) {
          itemR.setValue(o);
          v = compiledBlock.getValue(ctx, thisValue, itemFactory);
          if (itemFactory.tiltFlag()) return v;
        }
        break;
      case INTEGER:
        int max = (Integer) iterCond + 1;
        for (int i = 1; i != max; i++) {
          itemR.setValue(i);
          v = compiledBlock.getValue(ctx, thisValue, itemFactory);
          if (itemFactory.tiltFlag()) return v;
        }
        break;

      case ITERABLE:
        for (Object o : (Iterable) iterCond) {
          itemR.setValue(o);
          v = compiledBlock.getValue(ctx, thisValue, itemFactory);
          if (itemFactory.tiltFlag()) return v;
        }

        break;
    }
View Full Code Here

    return null;
  }

  public Object getReducedValue(Object ctx, Object thisValue, VariableResolverFactory factory) {
    ItemResolverFactory.ItemResolver itemR = new ItemResolverFactory.ItemResolver(item);
    ItemResolverFactory itemFactory = new ItemResolverFactory(itemR, new DefaultLocalVariableResolverFactory(factory));

    Object iterCond = MVEL.eval(expr, start, offset, thisValue, factory);

    if (itemType != null && itemType.isArray())
      enforceTypeSafety(itemType, getBaseComponentType(iterCond.getClass()));

    this.compiledBlock = (ExecutableStatement) subCompileExpression(expr, blockStart, blockOffset);

    Object v;
    if (iterCond instanceof Iterable) {
      for (Object o : (Iterable) iterCond) {
        itemR.setValue(o);
        v = compiledBlock.getValue(ctx, thisValue, itemFactory);
        if (itemFactory.tiltFlag()) return v;
      }
    }
    else if (iterCond != null && iterCond.getClass().isArray()) {
      int len = Array.getLength(iterCond);
      for (int i = 0; i < len; i++) {
        itemR.setValue(Array.get(iterCond, i));
        v = compiledBlock.getValue(ctx, thisValue, itemFactory);
        if (itemFactory.tiltFlag()) return v;
      }
    }
    else if (iterCond instanceof CharSequence) {
      for (Object o : iterCond.toString().toCharArray()) {
        itemR.setValue(o);
        v = compiledBlock.getValue(ctx, thisValue, itemFactory);
        if (itemFactory.tiltFlag()) return v;
      }
    }
    else if (iterCond instanceof Integer) {
      int max = (Integer) iterCond + 1;
      for (int i = 1; i != max; i++) {
        itemR.setValue(i);
        v = compiledBlock.getValue(ctx, thisValue, itemFactory);
        if (itemFactory.tiltFlag()) return v;
      }
    }
    else {
      throw new CompileException("non-iterable type: "
          + (iterCond != null ? iterCond.getClass().getName() : "null"), expr, start);
View Full Code Here

    }
  }

  public Object getReducedValueAccelerated(Object ctx, Object thisValue, VariableResolverFactory factory) {
    ItemResolverFactory.ItemResolver itemR = new ItemResolverFactory.ItemResolver(item);
    ItemResolverFactory itemFactory = new ItemResolverFactory(itemR, new DefaultLocalVariableResolverFactory(factory));

    Object iterCond = condition.getValue(ctx, thisValue, factory);

    if (type == -1) {
      determineIterType(iterCond.getClass());
    }

    Object v;
    switch (type) {
      case ARRAY:
        int len = Array.getLength(iterCond);
        for (int i = 0; i < len; i++) {
          itemR.setValue(Array.get(iterCond, i));
          v = compiledBlock.getValue(ctx, thisValue, itemFactory);
          if (itemFactory.tiltFlag()) return v;
        }
        break;
      case CHARSEQUENCE:
        for (Object o : iterCond.toString().toCharArray()) {
          itemR.setValue(o);
          v = compiledBlock.getValue(ctx, thisValue, itemFactory);
          if (itemFactory.tiltFlag()) return v;
        }
        break;
      case INTEGER:
        int max = (Integer) iterCond + 1;
        for (int i = 1; i != max; i++) {
          itemR.setValue(i);
          v = compiledBlock.getValue(ctx, thisValue, itemFactory);
          if (itemFactory.tiltFlag()) return v;
        }
        break;

      case ITERABLE:
        for (Object o : (Iterable) iterCond) {
          itemR.setValue(o);
          v = compiledBlock.getValue(ctx, thisValue, itemFactory);
          if (itemFactory.tiltFlag()) return v;
        }

        break;
    }
View Full Code Here

    return null;
  }

  public Object getReducedValue(Object ctx, Object thisValue, VariableResolverFactory factory) {
    ItemResolverFactory.ItemResolver itemR = new ItemResolverFactory.ItemResolver(item);
    ItemResolverFactory itemFactory = new ItemResolverFactory(itemR, new DefaultLocalVariableResolverFactory(factory));

    Object iterCond = MVEL.eval(expr, start, offset, thisValue, factory);

    if (itemType != null && itemType.isArray())
      enforceTypeSafety(itemType, getBaseComponentType(iterCond.getClass()));

    this.compiledBlock = (ExecutableStatement) subCompileExpression(expr, blockStart, blockOffset);

    Object v;
    if (iterCond instanceof Iterable) {
      for (Object o : (Iterable) iterCond) {
        itemR.setValue(o);
        v = compiledBlock.getValue(ctx, thisValue, itemFactory);
        if (itemFactory.tiltFlag()) return v;
      }
    }
    else if (iterCond != null && iterCond.getClass().isArray()) {
      int len = Array.getLength(iterCond);
      for (int i = 0; i < len; i++) {
        itemR.setValue(Array.get(iterCond, i));
        v = compiledBlock.getValue(ctx, thisValue, itemFactory);
        if (itemFactory.tiltFlag()) return v;
      }
    }
    else if (iterCond instanceof CharSequence) {
      for (Object o : iterCond.toString().toCharArray()) {
        itemR.setValue(o);
        v = compiledBlock.getValue(ctx, thisValue, itemFactory);
        if (itemFactory.tiltFlag()) return v;
      }
    }
    else if (iterCond instanceof Integer) {
      int max = (Integer) iterCond + 1;
      for (int i = 1; i != max; i++) {
        itemR.setValue(i);
        v = compiledBlock.getValue(ctx, thisValue, itemFactory);
        if (itemFactory.tiltFlag()) return v;
      }
    }
    else {
      throw new CompileException("non-iterable type: "
          + (iterCond != null ? iterCond.getClass().getName() : "null"), expr, start);
View Full Code Here

        Collection.class, ((fields & COMPILE_IMMEDIATE) != 0));
  }

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

    return list;
  }

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

                                 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

    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 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,
                                             invokerLookup );
        context.getDescrLookups().put( invokerClassName,
View Full Code Here

TOP

Related Classes of org.mvel2.integration.impl.ItemResolverFactory$ItemResolver

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.