All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.hibernate.sql.ast.tree.spi.expression.SubstrFunction Maven / Gradle / Ivy

There is a newer version: 7.0.0.Alpha3
Show newest version
/*
 * 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()
		);
	}
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy