本文整理了Java中org.teiid.language.Function.getName()
方法的一些代码示例,展示了Function.getName()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Function.getName()
方法的具体详情如下:
包路径:org.teiid.language.Function
类名称:Function
方法名:getName
[英]Get name of the function
[中]获取函数的名称
代码示例来源: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) {
if (this.name != null) {
function.setName(this.name);
}
return Arrays.asList(function.getName());
}
}
代码示例来源: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-google
@Override
public void visit(Function function) {
if (function.getName().equalsIgnoreCase(SourceSystemFunctions.DAYOFMONTH)) {
function.setName("day"); //$NON-NLS-1$
} else if (function.getName().equalsIgnoreCase(SourceSystemFunctions.UCASE)) {
function.setName("upper"); //$NON-NLS-1$
} else if (function.getName().equalsIgnoreCase(SourceSystemFunctions.LCASE)) {
function.setName("lower"); //$NON-NLS-1$
} else if (function.getName().equalsIgnoreCase(SourceSystemFunctions.DAYOFWEEK)) {
function.setName("weekday"); //$NON-NLS-1$
}
super.visit(function);
}
代码示例来源:origin: org.teiid.connectors/translator-jdbc
public static boolean isNotNull(Expression expr) {
if (expr instanceof Literal) {
Literal literal = (Literal)expr;
return literal.getValue() != null;
}
if (expr instanceof Function) {
Function function = (Function)expr;
if (function.getName().equalsIgnoreCase("NVL") || function.getName().equalsIgnoreCase(SourceSystemFunctions.IFNULL)) { //$NON-NLS-1$
return isNotNull(function.getParameters().get(1));
}
}
return false;
}
代码示例来源: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
/**
* Most geospatial functions in HANA are called from the geometry object or an equivalent expression.
* For example, <geometry-expression>.ST_SRID() or <geometry-expression>.ST_Relate(<geo2>). This method
* will take the argument(s) to the Teiid spatial function and move the first argument to precede
* the function name.
*/
public List<?> translate(Function function) {
List<Expression> params = function.getParameters();
List<Object> objs = new ArrayList<Object>();
Expression exp1 = params.get(0);
objs.add(exp1+"."+function.getName());
objs.add("("); //$NON-NLS-1$
if (params.size()>1){
objs.add(params.get(1));
}
objs.add(")"); //$NON-NLS-1$
return objs;
}
代码示例来源:origin: org.teiid.connectors/translator-jdbc
public List<?> translate(Function function) {
List<Expression> args = function.getParameters();
List<Object> objs = new ArrayList<Object>();
objs.add("EXTRACT("); //$NON-NLS-1$
objs.add(FUNCTION_PART_MAP.get(function.getName().toLowerCase()));
objs.add(Tokens.SPACE);
objs.add(Reserved.FROM);
objs.add(Tokens.SPACE);
objs.add(args.get(0));
objs.add(Tokens.RPAREN);
//for pg - may not be needed for other dbs
if (function.getName().toLowerCase().equals(SourceSystemFunctions.DAYOFWEEK)) {
objs.add(0, Tokens.LPAREN);
objs.add(" + 1)"); //$NON-NLS-1$
}
if (castTarget != null) {
if (castTarget != null) {
objs.add(0, "CAST("); //$NON-NLS-1$
}
objs.add(" AS "); //$NON-NLS-1$
objs.add(castTarget);
objs.add(")"); //$NON-NLS-1$
}
return objs;
}
}
代码示例来源:origin: org.teiid.connectors/translator-jdbc
@Override
public List<?> translate(Function function) {
Expression booleanValue = function.getParameters().get(0);
if (booleanValue instanceof Function) {
Function nested = (Function)booleanValue;
if (nested.getName().equalsIgnoreCase("convert") && Number.class.isAssignableFrom(nested.getParameters().get(0).getType())) { //$NON-NLS-1$
booleanValue = nested.getParameters().get(0);
}
}
return Arrays.asList("CASE WHEN ", booleanValue, " = '0' THEN 'false' WHEN ", booleanValue, " IS NOT NULL THEN 'true' END"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
}
代码示例来源: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) {
List<Expression> args = function.getParameters();
ArrayList<Object> target = new ArrayList<Object>();
if (function.getName().equalsIgnoreCase("left")) { //$NON-NLS-1$
//substr(string, 1, length)
target.add("substr("); //$NON-NLS-1$
target.add(args.get(0));
target.add(","); //$NON-NLS-1$
target.add(langFactory.createLiteral(Integer.valueOf(1), TypeFacility.RUNTIME_TYPES.INTEGER));
target.add(","); //$NON-NLS-1$
target.add(args.get(1));
target.add(")"); //$NON-NLS-1$
} else if (function.getName().equalsIgnoreCase("right")) { //$NON-NLS-1$
//substr(case_size, character_length(case_size) -4)
target.add("substr("); //$NON-NLS-1$
target.add(args.get(0));
target.add(",(character_length("); //$NON-NLS-1$
target.add(args.get(0));
target.add(")-"); //$NON-NLS-1$
target.add(args.get(1));
target.add("+1))"); //$NON-NLS-1$ // offset for 1 based index
}
return target;
}
}
代码示例来源:origin: org.teiid.connectors/translator-jdbc
/**
* If either of the first two parameters are a Literal String, then we need to put the literal itself in the SQL
* to be passed to Oracle, without the tick marks
*/
public List<?> translate(Function function) {
List<Expression> params = function.getParameters();
List<Object> objs = new ArrayList<Object>();
objs.add(function.getName());
objs.add("("); //$NON-NLS-1$
addParamWithConversion(objs, params.get(0));
objs.add(", "); //$NON-NLS-1$
addParamWithConversion(objs, params.get(1));
for (int i = 2; i < params.size(); i++) {
objs.add(", "); //$NON-NLS-1$
objs.add(params.get(i));
}
objs.add(")"); //$NON-NLS-1$
return objs;
}
代码示例来源:origin: org.teiid.connectors/translator-jdbc
@Override
public List<?> translate(Function function) {
Expression booleanValue = function.getParameters().get(0);
if (booleanValue instanceof Function) {
Function nested = (Function)booleanValue;
if (nested.getName().equalsIgnoreCase("convert") && Number.class.isAssignableFrom(nested.getParameters().get(0).getType())) { //$NON-NLS-1$
booleanValue = nested.getParameters().get(0);
}
}
return Arrays.asList("(CASE WHEN ", booleanValue, " IN ( '0', 'FALSE') THEN 0 WHEN ", booleanValue, " IS NOT NULL THEN 1 END)"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
}
代码示例来源:origin: org.teiid.connectors/translator-simpledb
@Override
public void visit(Function obj) {
String name = obj.getName();
List<Expression> args = obj.getParameters();
if(name.equalsIgnoreCase(SimpleDBExecutionFactory.INTERSECTION) || name.equalsIgnoreCase(SimpleDBExecutionFactory.SIMPLEDB+"."+SimpleDBExecutionFactory.INTERSECTION)) { //$NON-NLS-1$
append(args.get(0));
buffer.append(Tokens.SPACE).append(Tokens.EQ).append(Tokens.SPACE);
for (int i = 1; i < args.size(); i++) {
append(args.get(i));
if (i < args.size()-1) {
buffer.append(Tokens.SPACE).append(SimpleDBExecutionFactory.INTERSECTION).append(Tokens.SPACE);
buffer.append(SimpleDBMetadataProcessor.getQuotedName(this.previousColumn));
buffer.append(Tokens.SPACE).append(Tokens.EQ).append(Tokens.SPACE);
}
}
this.skipCompare = true;
}
else {
super.visit(obj);
}
}
代码示例来源:origin: org.teiid.connectors/translator-jdbc
@Override
public List<?> translate(Function function) {
List<Expression> args = function.getParameters();
Function func = null;
if (function.getName().equalsIgnoreCase("left")) { //$NON-NLS-1$
func = langFactory.createFunction(SourceSystemFunctions.SUBSTRING,
Arrays.asList(
args.get(0),
langFactory.createLiteral(Integer.valueOf(1), TypeFacility.RUNTIME_TYPES.INTEGER),
args.get(1)),
String.class);
} else if (function.getName().equalsIgnoreCase("right")) { //$NON-NLS-1$
Function negIndex = langFactory.createFunction("*", //$NON-NLS-1$
Arrays.asList(langFactory.createLiteral(Integer.valueOf(-1), TypeFacility.RUNTIME_TYPES.INTEGER), args.get(1)),
Integer.class);
func = langFactory.createFunction(SourceSystemFunctions.SUBSTRING,
Arrays.asList(
args.get(0),
negIndex),
String.class);
}
return Arrays.asList(func);
}
}
代码示例来源:origin: org.teiid.connectors/translator-mongodb
private BasicDBObject handleStringFunction(String functionName, Function function) {
List<Expression> args = function.getParameters();
BasicDBObject func = null;
append(args.get(0));
Object column = this.onGoingExpression.pop();
if (args.size() == 1) {
func = new BasicDBObject(function.getName(), column);
}
else {
BasicDBList params = new BasicDBList();
params.add(column);
for (int i = 1; i < args.size(); i++) {
append(args.get(i));
Object param = this.onGoingExpression.pop();
params.add(param);
}
func = new BasicDBObject(function.getName(), params);
}
BasicDBObject ne = buildNE(column.toString(), null);
return buildCondition(ne, func, null);
}
代码示例来源:origin: org.teiid.connectors/translator-odata
public void visitComparisonWithBooleanFunction(Comparison obj) {
boolean truthiness = SQLConstants.Reserved.TRUE.equals(obj.getRightExpression().toString());
boolean isNot = !truthiness;
switch(obj.getOperator()) {
case EQ:
break;
case NE:
isNot = !isNot;
break;
default:
this.exceptions.add(new TranslatorException(
ODataPlugin.Util.gs(ODataPlugin.Event.TEIID17018, ((Function)obj.getLeftExpression()).getName())));
}
if(isNot) {
// can't use a Not object, because it requires a Condition inside,
// and we don't have support for generic unary conditions
this.filter.append(NOT)
.append(Tokens.SPACE)
.append(Tokens.LPAREN);
append(obj.getLeftExpression());
this.filter.append(Tokens.RPAREN);
} else {
append(obj.getLeftExpression());
}
}
代码示例来源:origin: teiid/teiid
@Test public void testGetName() throws Exception {
assertEquals("testName", example("testName").getName()); //$NON-NLS-1$ //$NON-NLS-2$
}
代码示例来源:origin: org.teiid.connectors/translator-mongodb
private DBObject buildGeoFunction(Function function) throws TranslatorException{
List<Expression> args = function.getParameters();
// Column Name
int paramIndex = 0;
ColumnDetail column = getExpressionAlias(args.get(paramIndex++));
BasicDBObjectBuilder builder = BasicDBObjectBuilder.start();
builder.push(column.documentFieldName);
builder.push(function.getName());
append(args.get(paramIndex++));
Object object = this.onGoingExpression.pop();
if (object instanceof GeometryType) {
convertGeometryToJson(builder, (GeometryType)object);
} else {
// Type: Point, LineString, Polygon..
SpatialType type = SpatialType.valueOf((String)object);
append(args.get(paramIndex++));
builder.push("$geometry");//$NON-NLS-1$
builder.add("type", type.name());//$NON-NLS-1$
// walk the co-ordinates
BasicDBList coordinates = new BasicDBList();
coordinates.add(this.onGoingExpression.pop());
builder.add("coordinates", coordinates); //$NON-NLS-1$
}
return builder.get();
}
代码示例来源:origin: org.teiid.connectors/translator-jdbc
@Override
public void visit(Comparison obj) {
if (isFixedChar(obj.getLeftExpression())) {
if (obj.getRightExpression() instanceof Literal) {
Literal l = (Literal)obj.getRightExpression();
l.setType(FixedCharType.class);
} else if (obj.getRightExpression() instanceof Parameter) {
Parameter p = (Parameter)obj.getRightExpression();
p.setType(FixedCharType.class);
}
}
if (obj.getLeftExpression().getType() == TypeFacility.RUNTIME_TYPES.BOOLEAN
&& (obj.getLeftExpression() instanceof Function)
&& obj.getRightExpression() instanceof Literal) {
Function f = (Function)obj.getLeftExpression();
if (STRING_BOOLEAN_FUNCTIONS.contains(f.getName())) {
Boolean b = (Boolean)((Literal)obj.getRightExpression()).getValue();
obj.setRightExpression(new Literal(b!=null?(b?"TRUE":"FALSE"):null, TypeFacility.RUNTIME_TYPES.STRING)); //$NON-NLS-1$ //$NON-NLS-2$
}
}
super.visit(obj);
}
内容来源于网络,如有侵权,请联系作者删除!