use of lucee.runtime.type.dt.TimeSpanImpl in project Lucee by lucee.
the class HttpGetWithBody method setTimeout.
/**
* set the value timeout
*
* @param timeout
* value to set
* @throws ExpressionException
*/
public void setTimeout(Object timeout) throws PageException {
if (timeout instanceof TimeSpan)
this.timeout = (TimeSpan) timeout;
else // seconds
{
int i = Caster.toIntValue(timeout);
if (i < 0)
throw new ApplicationException("invalid value [" + i + "] for attribute timeout, value must be a positive integer greater or equal than 0");
this.timeout = new TimeSpanImpl(0, 0, 0, i);
}
}
use of lucee.runtime.type.dt.TimeSpanImpl in project Lucee by lucee.
the class ASMUtil method cachedWithinValue.
public static Literal cachedWithinValue(Expression val) throws EvaluatorException {
if (val instanceof Literal) {
Literal l = (Literal) val;
// double == days
Double d = l.getDouble(null);
if (d != null) {
return val.getFactory().createLitLong(TimeSpanImpl.fromDays(d.doubleValue()).getMillis(), null, null);
}
return l;
} else // createTimespan
if (val instanceof Variable) {
Variable var = (Variable) val;
if (var.getMembers().size() == 1) {
Member first = var.getFirstMember();
if (first instanceof BIF) {
BIF bif = (BIF) first;
if ("createTimeSpan".equalsIgnoreCase(bif.getFlf().getName())) {
Argument[] args = bif.getArguments();
int len = ArrayUtil.size(args);
if (len >= 4 && len <= 5) {
double days = toDouble(args[0].getValue());
double hours = toDouble(args[1].getValue());
double minutes = toDouble(args[2].getValue());
double seconds = toDouble(args[3].getValue());
double millis = len == 5 ? toDouble(args[4].getValue()) : 0;
return val.getFactory().createLitLong(new TimeSpanImpl((int) days, (int) hours, (int) minutes, (int) seconds, (int) millis).getMillis(), null, null);
}
}
}
}
}
throw cacheWithinException();
}
use of lucee.runtime.type.dt.TimeSpanImpl in project Lucee by lucee.
the class Query method setTimeout.
/**
* set the value timeout The maximum number of milliseconds for the query to execute before returning an error indicating that the query has timed-out. This
* attribute is not supported by most ODBC drivers. timeout is supported by the SQL Server 6.x or above driver. The minimum and maximum allowable values
* vary, depending on the driver.
*
* @param timeout
* value to set
* @throws PageException
*/
public void setTimeout(Object timeout) throws PageException {
if (timeout instanceof TimeSpan)
this.timeout = (TimeSpan) timeout;
else // seconds
{
int i = Caster.toIntValue(timeout);
if (i < 0)
throw new ApplicationException("invalid value [" + i + "] for attribute timeout, value must be a positive integer greater or equal than 0");
this.timeout = new TimeSpanImpl(0, 0, 0, i);
}
}
Aggregations