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

org.mentabean.sql.functions.Substring Maven / Gradle / Ivy

There is a newer version: 2.2.4
Show newest version
package org.mentabean.sql.functions;

import org.mentabean.sql.Function;
import org.mentabean.sql.Parametrizable;
import org.mentabean.sql.param.Param;
import org.mentabean.sql.param.ParamFunction;
import org.mentabean.sql.param.ParamValue;

public class Substring extends Parametrizable implements Function {

	private Param str, beginIndex, endIndex;
	
	public Substring(Param str) {
		this.str = str;
	}
	
	public Substring endIndex(Param param) {
		endIndex = param;
		return this;
	}
	
	public Substring beginIndex(Param param) {
		beginIndex = param;
		return this;
	}
	
	@Override
	public Param[] getParams() {
		
		if (beginIndex == null)
			beginIndex = new ParamValue(0);
		if (endIndex == null)
			endIndex = new ParamFunction(new Length(str));
		
		return new Param[] {str, beginIndex, endIndex};
	}
	
	@Override
	public String name() {
		return "SUBSTRING";
	}

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy