All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.mvel2.ast.InvokationContextFactory Maven / Gradle / Ivy

Go to download

A fork of MVEL by Axibase. Original version is hosted here: https://github.com/mvel/mvel. MVEL is a powerful expression language for Java-based applications. It provides a plethora of features and is suited for everything from the smallest property binding and extraction, to full blown scripts.

There is a newer version: 2.4.5.11
Show newest version
package org.mvel2.ast;

import org.mvel2.integration.VariableResolver;
import org.mvel2.integration.VariableResolverFactory;
import org.mvel2.integration.impl.MapVariableResolverFactory;

/**
* @author Mike Brock
*/
public class InvokationContextFactory extends MapVariableResolverFactory {
  private VariableResolverFactory protoContext;

  public InvokationContextFactory(VariableResolverFactory next, VariableResolverFactory protoContext) {
    this.nextFactory = next;
    this.protoContext = protoContext;
  }

  @Override
  public VariableResolver createVariable(String name, Object value) {
    if (isResolveable(name) && !protoContext.isResolveable(name)) {
      return nextFactory.createVariable(name, value);
    }
    else {
      return protoContext.createVariable(name, value);
    }
  }

  @Override
  public VariableResolver createVariable(String name, Object value, Class type) {
    if (isResolveable(name) && !protoContext.isResolveable(name)) {
      return nextFactory.createVariable(name, value, type);
    }
    else {
      return protoContext.createVariable(name, value, type);
    }
  }

  @Override
  public VariableResolver getVariableResolver(String name) {
    if (isResolveable(name) && !protoContext.isResolveable(name)) {
      return nextFactory.getVariableResolver(name);
    }
    else {
      return protoContext.getVariableResolver(name);
    }
  }

  @Override
  public boolean isTarget(String name) {
    return protoContext.isTarget(name);
  }

  @Override
  public boolean isResolveable(String name) {
    return protoContext.isResolveable(name) || nextFactory.isResolveable(name);
  }

  @Override
  public boolean isIndexedFactory() {
    return true;
  }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy