org.teiid.language.Function.getParameters()方法的使用及代码示例

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

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

Function.getParameters介绍

[英]Get the parameters used in this function.
[中]获取此函数中使用的参数。

代码示例

代码示例来源: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) {
    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) {
    return Arrays.asList("trunc(cast(",function.getParameters().get(0)," AS date))"); //$NON-NLS-1$ //$NON-NLS-2$
  }
});

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

@Override
  public List<?> translate(Function function) {
    Expression stringValue = function.getParameters().get(0);
    return Arrays.asList("CASE WHEN ", stringValue, " = 0 THEN 0 WHEN ", stringValue, " IS NOT NULL THEN 1 END"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
  }
}, FunctionModifier.BOOLEAN);

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

@Override
  public List<?> translate(Function function) {
    if (function.getParameters().size() == 1) {
      function.getParameters().add(new Literal(1, TypeFacility.RUNTIME_TYPES.INTEGER));
    }
    return null;
  }
});

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

@Override
  public List<?> translate(Function function) {
    if (Number.class.isAssignableFrom(function.getParameters().get(0).getType())) {
      return Arrays.asList("trunc(", function.getParameters().get(0), ")"); //$NON-NLS-1$ //$NON-NLS-2$
    }
    return Arrays.asList("trunc(to_number(", function.getParameters().get(0), "))"); //$NON-NLS-1$ //$NON-NLS-2$
  }
},

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

@Override
  public List<?> translate(Function function) {
    ArrayList<Object> target = new ArrayList<Object>();
    target.add("TRIM(TRAILING FROM ");//$NON-NLS-1$
    target.add(function.getParameters().get(0));
    target.add(")"); //$NON-NLS-1$
    return target; 
  }
});

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

@Override
  public List<?> translate(Function function) {
    if (isNonAscii(function.getParameters().get(0))) {
      ((Literal)function.getParameters().get(1)).setValue("nchar(1)"); //$NON-NLS-1$
    } else {
      ((Literal)function.getParameters().get(1)).setValue("char(1)"); //$NON-NLS-1$
    }
    return null;
  }
});

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

@Override
  public List<?> translate(Function function) {
    if (isNonAscii(function.getParameters().get(0))) {
      ((Literal)function.getParameters().get(1)).setValue("nchar(1)"); //$NON-NLS-1$
    } else {
      ((Literal)function.getParameters().get(1)).setValue("char(1)"); //$NON-NLS-1$
    }
    return null;
  }
}, FunctionModifier.CHAR);

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

@Override
  public List<?> translate(Function function) {
    ((Literal)function.getParameters().get(1)).setValue(INTEGER_TYPE); 
    return null;
  }
}, FunctionModifier.BOOLEAN);

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

@Override
  public List<?> translate(Function function) {
    if (function.getParameters().size() != 3) {
      return null;
    }
    Expression param2 = function.getParameters().get(1);
    
    param2 = new Function(SourceSystemFunctions.ADD_OP, Arrays.asList(param2, new Literal(1, TypeFacility.RUNTIME_TYPES.INTEGER)), TypeFacility.RUNTIME_TYPES.INTEGER); 
    function.getParameters().set(1, param2);
    return null;
  }
});

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

@Override
public List<?> translate(Function function) {
  modify(function);
  if (format == null) {
    function.getParameters().remove(1);
  } else {
    ((Literal)function.getParameters().get(1)).setValue(format);
  }
  return null;
}

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

@Override
  public List<?> translate(Function function) {
    Literal intervalType = (Literal)function.getParameters().get(0);
    String interval = ((String)intervalType.getValue()).toUpperCase();
    if (interval.equals(NonReserved.SQL_TSI_FRAC_SECOND)) {
      intervalType.setValue("MICROSECOND"); //$NON-NLS-1$
      return Arrays.asList(function, " * 1000"); //$NON-NLS-1$
    }
    return null;
  }
});

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

@Override
  public List<?> translate(Function function) {
    if (isNonAscii(function.getParameters().get(0))) {
      return toNChar.translate(function);
    }
    return toChar.translate(function);
  }
}, FunctionModifier.STRING);

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

@Override
  public List<?> translate(Function function) {
    Expression ex = function.getParameters().get(0);
    if (ex.getType() == TypeFacility.RUNTIME_TYPES.DATE || ex.getType() == TypeFacility.RUNTIME_TYPES.TIME 
        || (ex instanceof ColumnReference && "date".equalsIgnoreCase(((ColumnReference)ex).getMetadataObject().getNativeType())) //$NON-NLS-1$ 
        || (!(ex instanceof ColumnReference) && !(ex instanceof Literal) && !(ex instanceof Function))) {
      ex = ConvertModifier.createConvertFunction(getLanguageFactory(), function.getParameters().get(0), TypeFacility.RUNTIME_NAMES.TIMESTAMP);
      function.getParameters().set(0, ex);
    }
    return super.translate(function);
  }
}

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

@Override
public void visit(Comparison obj) {
  if (allowImplictConversion(obj)) {
    Function left = (Function) obj.getLeftExpression();
    obj.setLeftExpression(left.getParameters().get(0));
    Function right = (Function) obj.getRightExpression();
    obj.setRightExpression(right.getParameters().get(0));
  }
  super.visit(obj);
}

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

@Override
  public List<?> translate(Function function) {
    Expression trueValue = function.getParameters().get(0);
    Expression falseValue = trueValue;
    falseValue = new IsNull(falseValue, true);
    if (!(trueValue instanceof Predicate)) {
      trueValue = new Comparison(trueValue, new Literal(Boolean.TRUE, TypeFacility.RUNTIME_TYPES.BOOLEAN), Comparison.Operator.EQ);
    }
    return Arrays.asList("CASE WHEN ", trueValue, " THEN 'true' WHEN ", falseValue, " THEN 'false' END"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
  }
});

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

@Test public void testGetParameters() throws Exception {
  List<Expression> params = example("testFunction").getParameters(); //$NON-NLS-1$
  assertNotNull(params);
  assertEquals(2, params.size());
  for (int i = 0; i < params.size(); i++) {
    assertNotNull(params.get(i));
  }
}

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

@Test public void testLongTimestampAddLongExpression() throws Exception {
  org.teiid.query.sql.symbol.Function ex = (org.teiid.query.sql.symbol.Function)TestFunctionResolving.getExpression("timestampadd(sql_tsi_second, cast(1 as long), now())");
  Function f = (Function) TstLanguageBridgeFactory.factory.translate(ex);
  assertEquals(DataTypeManager.DefaultDataClasses.INTEGER, f.getParameters().get(1).getType());
}

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

@Test public void testLongTimestampAddLiteral1() throws Exception {
  org.teiid.query.sql.symbol.Function ex = (org.teiid.query.sql.symbol.Function)TestFunctionResolving.getExpression("timestampadd(sql_tsi_second, 1, now())");
  ex.getArgs()[1] = new Constant(1l);
  Function f = (Function) TstLanguageBridgeFactory.factory.translate(ex);
  assertEquals(DataTypeManager.DefaultDataClasses.INTEGER, f.getParameters().get(1).getType());
}

相关文章