net.sf.jsqlparser.statement.select.First Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of jsqlparser Show documentation
Show all versions of jsqlparser Show documentation
JSqlParser parses an SQL statement and translate it into a hierarchy of Java classes.
The generated hierarchy can be navigated using the Visitor Pattern.
/*
* #%L
* JSQLParser library
* %%
* Copyright (C) 2015 JSQLParser
* %%
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as
* published by the Free Software Foundation, either version 2.1 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Lesser Public License for more details.
*
* You should have received a copy of the GNU General Lesser Public
* License along with this program. If not, see
* .
* #L%
*/
package net.sf.jsqlparser.statement.select;
import net.sf.jsqlparser.expression.JdbcParameter;
/**
* A FIRST clause in the form [FIRST row_count] the alternative form
* [LIMIT row_count] is also supported.
*
* Initial implementation was done for informix special syntax:
* http://www-01.ibm.com/support/knowledgecenter/SSGU8G_12.1.0/com.ibm.sqls.doc/ids_sqs_0156.htm
*/
public class First {
public enum Keyword {
FIRST,
LIMIT
}
private Keyword keyword;
private Long rowCount;
private JdbcParameter jdbcParameter;
private String variable;
public Long getRowCount() {
return rowCount;
}
public void setRowCount(Long rowCount) {
this.rowCount = rowCount;
}
public JdbcParameter getJdbcParameter() {
return jdbcParameter;
}
public void setJdbcParameter(JdbcParameter jdbcParameter) {
this.jdbcParameter = jdbcParameter;
}
public Keyword getKeyword() {
return keyword;
}
public void setKeyword(Keyword keyword) {
this.keyword = keyword;
}
public String getVariable() {
return variable;
}
public void setVariable(String variable) {
this.variable = variable;
}
@Override
public String toString() {
String result = keyword.name() + " ";
if(rowCount != null) {
result += rowCount;
} else if (jdbcParameter != null) {
result += jdbcParameter.toString();
} else if (variable != null){
result += variable;
}
return result;
}
}