org.teiid.language.Function类的使用及代码示例

x33g5p2x  于2022-01-19 转载在 其他  
字(7.9k)|赞(0)|评价(0)|浏览(168)

本文整理了Java中org.teiid.language.Function类的一些代码示例,展示了Function类的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Function类的具体详情如下:
包路径:org.teiid.language.Function
类名称:Function

Function介绍

[英]Represents a function. A function has a name and 0..n Expressions that are parameters.
[中]表示一个函数。函数具有名称和0。。n是参数的表达式。

代码示例

代码示例来源:origin: org.teiid.connectors/translator-jdbc

private boolean isConvertFunctionWithSimpleExpression(Expression expr) {
  if (expr instanceof Function && ((Function) expr).getName().equals("convert")) {
    Function f = (Function) expr;
    Expression param = f.getParameters().get(0);
    if (param instanceof ColumnReference) {
      return true;
    } else if (param instanceof Literal) {
      return true;
    }
  }
  return false;
}

代码示例来源:origin: org.teiid.connectors/translator-odata

@Override
  public List<?> translate(Function function) {
    function.setName(SourceSystemFunctions.ADD_OP);
    
    Expression param1 = function.getParameters().get(0);
    Expression param2 = function.getParameters().get(1);
    
    Function indexOf = new Function("indexof", Arrays.asList(param2, param1), TypeFacility.RUNTIME_TYPES.INTEGER); //$NON-NLS-1$
    indexOf.setMetadataObject(function.getMetadataObject());
    function.getParameters().set(0, indexOf);
    function.getParameters().set(1, new Literal(1, TypeFacility.RUNTIME_TYPES.INTEGER));
    return null;
  }
});

代码示例来源:origin: org.teiid.connectors/translator-jdbc

@Override
  public List<?> translate(Function function) {
    if (this.name != null) {
      function.setName(this.name);
    }
    return Arrays.asList(function.getName());
  }
}

代码示例来源:origin: org.teiid.connectors/translator-jdbc

@Override
protected boolean isNonAsciiFunction(Function f) {
  return f.getName().equalsIgnoreCase(TO_NCHAR)
         || (f.getType() == TypeFacility.RUNTIME_TYPES.CHAR && f.getName().equalsIgnoreCase(SourceSystemFunctions.CONVERT));
}

代码示例来源:origin: org.teiid.connectors/translator-jdbc

@Override
  public List<?> translate(Function function) {
    return Arrays.asList("cast(", function.getParameters().get(0), " as int64)", "%", //$NON-NLS-1$ //$NON-NLS-2$
        "cast(",function.getParameters().get(1), " as int64)");
  }
}); //$NON-NLS-1$

代码示例来源:origin: org.teiid.connectors/translator-jdbc

@Override
  public List<?> translate(Function function) {
    Expression ex = function.getParameters().get(0);
    if (ex instanceof Parameter || ex instanceof Literal) {
      function.getParameters().set(0, new Function("TO_BLOB", Arrays.asList(ex), TypeFacility.RUNTIME_TYPES.BLOB)); //$NON-NLS-1$
    }
    return super.translate(function);
  }
});

代码示例来源:origin: org.teiid.connectors/translator-odata

@Override
public void visit(Function obj) {
  if (this.executionFactory.getFunctionModifiers().containsKey(obj.getName())) {
    List<?> parts = this.executionFactory.getFunctionModifiers().get(obj.getName()).translate(obj);
    if (parts != null) {
      throw new AssertionError("not supported"); //$NON-NLS-1$
  String name = obj.getName();
  List<Expression> args = obj.getParameters();
  if(isInfixFunction(name)) {
    this.filter.append(Tokens.LPAREN);
    FunctionMethod method = obj.getMetadataObject();
    if (name.startsWith(method.getCategory())) {
      name = name.substring(method.getCategory().length()+1);

代码示例来源:origin: org.teiid.connectors/translator-salesforce

public void parseFunction( Function func ) {
  String functionName = func.getName();
  try {
    if (functionName.equalsIgnoreCase("includes")) { //$NON-NLS-1$
      generateMultiSelect(func, INCLUDES);
    } else if (functionName.equalsIgnoreCase("excludes")) { //$NON-NLS-1$
      generateMultiSelect(func, EXCLUDES);
    }
  } catch (TranslatorException e) {
    exceptions.add(e);
  }
}

代码示例来源:origin: org.teiid.connectors/translator-jdbc

@Override
public List<?> translate(Function function) {
  function.setName("log"); //$NON-NLS-1$
  
  List<Expression> args = function.getParameters();
  args.add(args.get(0));
  args.set(0, languageFactory.createLiteral(new Integer(10), TypeFacility.RUNTIME_TYPES.INTEGER));
  return null;
}

代码示例来源:origin: teiid/teiid

public Function createFunction(String functionName, List<? extends Expression> args, Class<?> type) {
  return new Function(functionName, args, type);
}

代码示例来源:origin: org.teiid.connectors/translator-jdbc

@Override
public List<?> translate(Function function) {
  function.setName("cast"); //$NON-NLS-1$
  int targetCode = getCode(function.getType());
  List<Expression> args = function.getParameters();
  Class<?> srcType = args.get(0).getType();
  int sourceCode = getCode(srcType);
      ((Literal)function.getParameters().get(1)).setValue(type);
      return null;
  return Arrays.asList(function.getParameters().get(0));

代码示例来源:origin: org.teiid/teiid-engine

params.set(1, new org.teiid.language.Function(SourceSystemFunctions.CONVERT, 
          Arrays.asList(params.get(1), new Literal(DataTypeManager.DefaultDataTypes.INTEGER, DataTypeManager.DefaultDataClasses.STRING)), DataTypeManager.DefaultDataClasses.INTEGER));
org.teiid.language.Function result = new org.teiid.language.Function(name, params, function.getType());
if (function.getFunctionDescriptor() != null) {
  result.setMetadataObject(function.getFunctionDescriptor().getMethod());

代码示例来源:origin: org.teiid.connectors/translator-jdbc

public void visit(Function obj) {
  FunctionMethod f = obj.getMetadataObject();
  if (f != null) {
    String nativeQuery = f.getProperty(TEIID_NATIVE_QUERY, false);
    if (nativeQuery != null) {
      List<Argument> args = new ArrayList<Argument>(obj.getParameters().size());
      for (Expression p : obj.getParameters()) {
        args.add(new Argument(Direction.IN, p, p.getType(), null));
      }
      parseNativeQueryParts(nativeQuery, args, buffer, this);
      return;
    }
  }
  super.visit(obj);
}

代码示例来源:origin: org.teiid.connectors/translator-jdbc

protected void modify(Function function) {
  function.setName(alias);
}

代码示例来源:origin: org.teiid.connectors/translator-odata4

private BaseColumn setCurrentExpression(Expression leftExpression) {
  BaseColumn old = currentExpression;
  if (leftExpression instanceof ColumnReference) {
    ColumnReference cr = (ColumnReference)leftExpression;
    currentExpression = cr.getMetadataObject();
  } else if (leftExpression instanceof Function) {
    Function function = (Function)leftExpression;
    currentExpression = function.getMetadataObject().getOutputParameter();
  } else {
    currentExpression = null;
  }
  //we are really looking for the native type, if it's not set then don't bother
  if (currentExpression != null && currentExpression.getNativeType() == null) {
    currentExpression = null;
  }
  return old;
}

代码示例来源:origin: org.teiid.connectors/translator-jdbc

@Override
  public List<?> translate(Function function) {
    return Arrays.asList(function.getParameters().get(0), " MOD ", function.getParameters().get(1)); //$NON-NLS-1$
  }
});

代码示例来源:origin: org.teiid.connectors/translator-jdbc

@Override
  public List<?> translate(Function function) {
    Expression ex = function.getParameters().get(0);
    if (ex instanceof Parameter || ex instanceof Literal) {
      function.getParameters().set(0, new Function("TO_CLOB", Arrays.asList(ex), TypeFacility.RUNTIME_TYPES.CLOB)); //$NON-NLS-1$
    }
    return super.translate(function);
  }
});

代码示例来源:origin: org.teiid.connectors/translator-odata4

@Override
public void visit(Function obj) {
  if (this.ef.getFunctionModifiers().containsKey(obj.getName())) {
    List<?> parts = this.ef.getFunctionModifiers().get(obj.getName()).translate(obj);
    if (parts != null) {
      throw new AssertionError("not supported"); //$NON-NLS-1$
  String name = obj.getName();
  List<Expression> args = obj.getParameters();
  if(isInfixFunction(name)) {
    this.filter.append(Tokens.LPAREN);
    FunctionMethod method = obj.getMetadataObject();
    if (name.startsWith(method.getCategory())) {
      name = name.substring(method.getCategory().length()+1);

代码示例来源:origin: org.teiid.connectors/translator-jpa

@Override
public void visit(Function func) {
  if (visitor.executionFactory.getFunctionModifiers().containsKey(func.getName())) {
    visitor.executionFactory.getFunctionModifiers().get(func.getName()).translate(func);
  }
  super.visit(func);
}

代码示例来源:origin: org.teiid.connectors/translator-jdbc

@Override
public List<?> translate(Function function) {
  function.setName("log"); //$NON-NLS-1$
  
  List<Expression> args = function.getParameters();
  args.add(args.get(0));
  args.set(0, languageFactory.createLiteral(new Integer(10), TypeFacility.RUNTIME_TYPES.INTEGER));
  return null;
}

相关文章