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

org.mvel2.integration.impl.SimpleVariableResolverFactory Maven / Gradle / Ivy

There is a newer version: 2.12.15
Show newest version
package org.mvel2.integration.impl;

import org.mvel2.integration.VariableResolver;

import java.util.HashMap;
import java.util.Map;
import java.util.Set;


public class SimpleVariableResolverFactory extends BaseVariableResolverFactory {
  public SimpleVariableResolverFactory(Map variables) {
    for (Map.Entry entry : variables.entrySet()) {
      createVariable(entry.getKey(), entry.getValue());
    }
  }

  public VariableResolver createVariable(String name, Object value) {
    if (variableResolvers == null) variableResolvers = new HashMap(5, 0.6f);
    SimpleValueResolver svr = new SimpleValueResolver(value);
    variableResolvers.put(name, svr);
    return svr;
  }

  public VariableResolver createIndexedVariable(int index, String name, Object value) {
    return null;
  }

  public VariableResolver createVariable(String name, Object value, Class type) {
    if (variableResolvers == null) variableResolvers = new HashMap(5, 0.6f);
    SimpleSTValueResolver svr = new SimpleSTValueResolver(value, type);
    variableResolvers.put(name, svr);
    return svr;
  }

  public VariableResolver createIndexedVariable(int index, String name, Object value, Class typee) {
    return null;
  }

  public VariableResolver setIndexedVariableResolver(int index, VariableResolver variableResolver) {
    return null;
  }

  public boolean isTarget(String name) {
    return variableResolvers.containsKey(name);
  }

  public boolean isResolveable(String name) {
    return variableResolvers.containsKey(name) || (nextFactory != null && nextFactory.isResolveable(name));
  }

  @Override
  public VariableResolver getVariableResolver(String name) {
    VariableResolver vr = variableResolvers.get(name);
    return vr != null ? vr : (nextFactory == null ? null : nextFactory.getVariableResolver(name));
  }

  public Set getKnownVariables() {
    return variableResolvers.keySet();
  }

  public int variableIndexOf(String name) {
    return 0;  //To change body of implemented methods use File | Settings | File Templates.
  }

  public boolean isIndexedFactory() {
    return false;  //To change body of implemented methods use File | Settings | File Templates.
  }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy