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

org.mvel2.util.SimpleVariableSpaceModel 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.util;

import org.mvel2.integration.VariableResolver;
import org.mvel2.integration.VariableResolverFactory;
import org.mvel2.integration.impl.IndexVariableResolver;
import org.mvel2.integration.impl.IndexedVariableResolverFactory;
import org.mvel2.integration.impl.SimpleValueResolver;

/**
 * @author Mike Brock .
 */
public class SimpleVariableSpaceModel extends VariableSpaceModel {
  public SimpleVariableSpaceModel(String[] varNames) {
    this.allVars = varNames;
  }

  public VariableResolverFactory createFactory(Object[] vals) {
    VariableResolver[] resolvers = new VariableResolver[allVars.length];
    for (int i = 0; i < resolvers.length; i++) {
      if (i >= vals.length) {
        resolvers[i] = new SimpleValueResolver(null);
      }
      else {
        resolvers[i] = new IndexVariableResolver(i, vals);
      }
    }

    return new IndexedVariableResolverFactory(allVars, resolvers);
  }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy