use of org.ballerinalang.siddhi.query.api.expression.constant.TimeConstant in project ballerina by ballerina-lang.
the class SiddhiQLBaseVisitorImpl method visitTime_value.
/**
* {@inheritDoc}
* <p>The default implementation returns the result of calling
* {@link #visitChildren} on {@code ctx}.</p>
*
* @param ctx
*/
@Override
public TimeConstant visitTime_value(@NotNull SiddhiQLParser.Time_valueContext ctx) {
TimeConstant timeValueInMillis = Expression.Time.milliSec(0);
if (ctx.millisecond_value() != null) {
timeValueInMillis.milliSec(((TimeConstant) visit(ctx.millisecond_value())).value());
}
if (ctx.second_value() != null) {
timeValueInMillis.milliSec(((TimeConstant) visit(ctx.second_value())).value());
}
if (ctx.minute_value() != null) {
timeValueInMillis.milliSec(((TimeConstant) visit(ctx.minute_value())).value());
}
if (ctx.hour_value() != null) {
timeValueInMillis.milliSec(((TimeConstant) visit(ctx.hour_value())).value());
}
if (ctx.day_value() != null) {
timeValueInMillis.milliSec(((TimeConstant) visit(ctx.day_value())).value());
}
if (ctx.week_value() != null) {
timeValueInMillis.milliSec(((TimeConstant) visit(ctx.week_value())).value());
}
if (ctx.month_value() != null) {
timeValueInMillis.milliSec(((TimeConstant) visit(ctx.month_value())).value());
}
if (ctx.year_value() != null) {
timeValueInMillis.milliSec(((TimeConstant) visit(ctx.year_value())).value());
}
populateQueryContext(timeValueInMillis, ctx);
return timeValueInMillis;
}
use of org.ballerinalang.siddhi.query.api.expression.constant.TimeConstant in project ballerina by ballerina-lang.
the class SiddhiQLBaseVisitorImpl method visitSecond_value.
/**
* {@inheritDoc}
* <p>The default implementation returns the result of calling
* {@link #visitChildren} on {@code ctx}.</p>
*
* @param ctx
*/
@Override
public TimeConstant visitSecond_value(@NotNull SiddhiQLParser.Second_valueContext ctx) {
TimeConstant timeConstant = Expression.Time.sec(Long.parseLong(ctx.INT_LITERAL().getText().replaceFirst("[lL]", "")));
populateQueryContext(timeConstant, ctx);
return timeConstant;
}
use of org.ballerinalang.siddhi.query.api.expression.constant.TimeConstant in project ballerina by ballerina-lang.
the class SiddhiQLBaseVisitorImpl method visitHour_value.
/**
* {@inheritDoc}
* <p>The default implementation returns the result of calling
* {@link #visitChildren} on {@code ctx}.</p>
*
* @param ctx
*/
@Override
public TimeConstant visitHour_value(@NotNull SiddhiQLParser.Hour_valueContext ctx) {
TimeConstant timeConstant = Expression.Time.hour(Long.parseLong(ctx.INT_LITERAL().getText().replaceFirst("[lL]", "")));
populateQueryContext(timeConstant, ctx);
return timeConstant;
}
use of org.ballerinalang.siddhi.query.api.expression.constant.TimeConstant in project ballerina by ballerina-lang.
the class SiddhiQLBaseVisitorImpl method visitConstant_value.
/**
* {@inheritDoc}
* <p>The default implementation returns the result of calling
* {@link #visitChildren} on {@code ctx}.</p>
*
* @param ctx
*/
@Override
public Constant visitConstant_value(@NotNull SiddhiQLParser.Constant_valueContext ctx) {
// constant_value
// :bool_value
// |signed_double_value
// |signed_float_value
// |signed_long_value
// |signed_int_value
// |time_value
// |string_value
// ;
Constant constant;
if (ctx.bool_value() != null) {
constant = Expression.value(((BoolConstant) visit(ctx.bool_value())).getValue());
} else if (ctx.signed_double_value() != null) {
constant = Expression.value(((DoubleConstant) visit(ctx.signed_double_value())).getValue());
} else if (ctx.signed_float_value() != null) {
constant = Expression.value(((FloatConstant) visit(ctx.signed_float_value())).getValue());
} else if (ctx.signed_long_value() != null) {
constant = Expression.value(((LongConstant) visit(ctx.signed_long_value())).getValue());
} else if (ctx.signed_int_value() != null) {
constant = Expression.value(((IntConstant) visit(ctx.signed_int_value())).getValue());
} else if (ctx.time_value() != null) {
constant = (TimeConstant) visit(ctx.time_value());
} else if (ctx.string_value() != null) {
constant = Expression.value(((StringConstant) visit(ctx.string_value())).getValue());
} else {
throw newSiddhiParserException(ctx);
}
populateQueryContext(constant, ctx);
return constant;
}
use of org.ballerinalang.siddhi.query.api.expression.constant.TimeConstant in project ballerina by ballerina-lang.
the class SiddhiQLBaseVisitorImpl method visitMonth_value.
/**
* {@inheritDoc}
* <p>The default implementation returns the result of calling
* {@link #visitChildren} on {@code ctx}.</p>
*
* @param ctx
*/
@Override
public TimeConstant visitMonth_value(@NotNull SiddhiQLParser.Month_valueContext ctx) {
TimeConstant timeConstant = Expression.Time.month(Long.parseLong(ctx.INT_LITERAL().getText().replaceFirst("[lL]", "")));
populateQueryContext(timeConstant, ctx);
return timeConstant;
}
Aggregations