net.sf.jsqlparser.statement.select.KSQLWindow 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) 2004 - 2019 JSQLParser
* %%
* Dual licensed under GNU LGPL 2.1 or Apache License 2.0
* #L%
*/
package net.sf.jsqlparser.statement.select;
import net.sf.jsqlparser.parser.ASTNodeAccessImpl;
public class KSQLWindow extends ASTNodeAccessImpl {
public enum TimeUnit {
DAY ("DAY"),
HOUR ("HOUR"),
MINUTE ("MINUTE"),
SECOND ("SECOND"),
MILLISECOND ("MILLISECOND"),
DAYS ("DAYS"),
HOURS ("HOURS"),
MINUTES ("MINUTES"),
SECONDS ("SECONDS"),
MILLISECONDS ("MILLISECONDS");
private String timeUnit;
TimeUnit(String timeUnit) {
this.timeUnit = timeUnit;
}
public String getTimeUnit() {
return timeUnit;
}
}
public enum WindowType {
HOPPING ("HOPPING"),
SESSION ("SESSION"),
TUMBLING ("TUMBLING");
private String windowType;
WindowType(String windowType) {
this.windowType = windowType;
}
public String getWindowType() {
return windowType;
}
}
private boolean hopping;
private boolean tumbling;
private boolean session;
private long sizeDuration;
private TimeUnit sizeTimeUnit;
private long advanceDuration;
private TimeUnit advanceTimeUnit;
public boolean isHoppingWindow() {
return hopping;
}
public void setHoppingWindow(boolean hopping) {
this.hopping = hopping;
}
public boolean isTumblingWindow() {
return tumbling;
}
public void setTumblingWindow(boolean tumbling) {
this.tumbling = tumbling;
}
public boolean isSessionWindow() {
return session;
}
public void setSessionWindow(boolean session) {
this.session = session;
}
public long getSizeDuration() {
return sizeDuration;
}
public void setSizeDuration(long sizeDuration) {
this.sizeDuration = sizeDuration;
}
public TimeUnit getSizeTimeUnit() {
return sizeTimeUnit;
}
public void setSizeTimeUnit(TimeUnit sizeTimeUnit) {
this.sizeTimeUnit = sizeTimeUnit;
}
public long getAdvanceDuration() {
return advanceDuration;
}
public void setAdvanceDuration(long advanceDuration) {
this.advanceDuration = advanceDuration;
}
public TimeUnit getAdvanceTimeUnit() {
return advanceTimeUnit;
}
public void setAdvanceTimeUnit(TimeUnit advanceTimeUnit) {
this.advanceTimeUnit = advanceTimeUnit;
}
public KSQLWindow() {
}
@Override
public String toString() {
if (isHoppingWindow()) {
return "HOPPING (" + "SIZE " + sizeDuration + " " + sizeTimeUnit + ", " +
"ADVANCE BY " + advanceDuration + " " + advanceTimeUnit + ")";
} else if (isSessionWindow()) {
return "SESSION (" + sizeDuration + " " + sizeTimeUnit + ")";
} else {
return "TUMBLING (" + "SIZE " + sizeDuration + " " + sizeTimeUnit + ")";
}
}
}