Package org.teiid.query.function

Examples of org.teiid.query.function.FunctionDescriptor


 
  private Object evaluate(Function function, List<?> tuple)
    throws ExpressionEvaluationException, BlockedException, TeiidComponentException {
 
      // Get function based on resolved function info
      FunctionDescriptor fd = function.getFunctionDescriptor();
     
    // Evaluate args
    Expression[] args = function.getArgs();
      Object[] values = null;
      int start = 0;
     
      if (fd.requiresContext()) {
      values = new Object[args.length+1];
          values[0] = context;
          start = 1;
      }
      else {
          values = new Object[args.length];
      }
     
      for(int i=0; i < args.length; i++) {
          values[i+start] = internalEvaluate(args[i], tuple);
      }           
     
      // Check for function we can't evaluate
      if(fd.getPushdown() == PushDown.MUST_PUSHDOWN) {
          throw new TeiidComponentException(QueryPlugin.Util.getString("ExpressionEvaluator.Must_push", fd.getName())); //$NON-NLS-1$
      }
 
      // Check for special lookup function
      if(fd.getName().equalsIgnoreCase(FunctionLibrary.LOOKUP)) {
          if(dataMgr == null) {
              throw new ComponentNotFoundException("ERR.015.006.0055", QueryPlugin.Util.getString("ERR.015.006.0055")); //$NON-NLS-1$ //$NON-NLS-2$
          }
 
          String codeTableName = (String) values[0];
          String returnElementName = (String) values[1];
          String keyElementName = (String) values[2];
         
          try {
        return dataMgr.lookupCodeValue(context, codeTableName, returnElementName, keyElementName, values[3]);
      } catch (TeiidProcessingException e) {
        throw new ExpressionEvaluationException(e, e.getMessage());
      }
      }
     
    // Execute function
    Object result = fd.invokeFunction(values);
    return result;       
  }
View Full Code Here

TOP

Related Classes of org.teiid.query.function.FunctionDescriptor

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.