org.hibernate.sql.ast.tree.spi.expression.SubstrFunction Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of hibernate-core Show documentation
Show all versions of hibernate-core Show documentation
Hibernate's core ORM functionality
/*
* Hibernate, Relational Persistence for Idiomatic Java
*
* License: GNU Lesser General Public License (LGPL), version 2.1 or later.
* See the lgpl.txt file in the root directory or .
*/
package org.hibernate.sql.ast.tree.spi.expression;
import java.util.List;
import org.hibernate.sql.SqlExpressableType;
import org.hibernate.sql.ast.consume.spi.SqlAstWalker;
import org.hibernate.sql.ast.produce.spi.SqlExpressable;
import org.hibernate.sql.results.internal.SqlSelectionImpl;
import org.hibernate.sql.results.spi.SqlSelection;
import org.hibernate.type.descriptor.java.spi.BasicJavaDescriptor;
import org.hibernate.type.spi.TypeConfiguration;
/**
* @author Chris Cranford
*/
public class SubstrFunction implements StandardFunction {
private final String functionName;
private final List expressions;
private final SqlExpressableType type;
public SubstrFunction(String name, List expressions, SqlExpressableType type) {
this.functionName = name;
this.expressions = expressions;
this.type = type;
}
public String getFunctionName() {
return functionName;
}
public List getExpressions() {
return expressions;
}
@Override
public SqlExpressableType getExpressableType() {
return type;
}
@Override
public SqlExpressableType getType() {
return getExpressableType();
}
@Override
public SqlExpressable getExpressable() {
return this;
}
@Override
public void accept(SqlAstWalker walker) {
walker.visitSubstrFunction( this );
}
@Override
public SqlSelection createSqlSelection(
int jdbcPosition,
int valuesArrayPosition,
BasicJavaDescriptor javaTypeDescriptor,
TypeConfiguration typeConfiguration) {
return new SqlSelectionImpl(
jdbcPosition,
valuesArrayPosition,
this,
getType().getJdbcValueExtractor()
);
}
}