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

org.mule.mvel2.ast.Instance Maven / Gradle / Ivy

Go to download

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. This is a fork of MVEL customized for use in Mule.

There is a newer version: 2.1.9-MULE-019
Show newest version
package org.mule.mvel2.ast;

import org.mule.mvel2.ParserContext;
import org.mule.mvel2.integration.VariableResolverFactory;
import org.mule.mvel2.util.CompilerTools;


public class Instance extends ASTNode {
  private ASTNode stmt;
  private ASTNode clsStmt;

  public Instance(ASTNode stmt, ASTNode clsStmt, ParserContext pCtx) {
    super(pCtx);
    this.stmt = stmt;
    this.clsStmt = clsStmt;
    CompilerTools.expectType(clsStmt, Class.class, true);
  }

  public Object getReducedValueAccelerated(Object ctx, Object thisValue, VariableResolverFactory factory) {
    return ((Class) clsStmt.getReducedValueAccelerated(ctx, thisValue, factory)).isInstance(stmt.getReducedValueAccelerated(ctx, thisValue, factory));
  }

  public Object getReducedValue(Object ctx, Object thisValue, VariableResolverFactory factory) {
    try {
      Class i = (Class) clsStmt.getReducedValue(ctx, thisValue, factory);
      if (i == null) throw new ClassCastException();

      return i.isInstance(stmt.getReducedValue(ctx, thisValue, factory));
    }
    catch (ClassCastException e) {
      throw new RuntimeException("not a class reference: " + clsStmt.getName());
    }

  }

  public Class getEgressType() {
    return Boolean.class;
  }

  public ASTNode getStatement() {
    return stmt;
  }

  public ASTNode getClassStatement() {
    return clsStmt;
  }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy