/** * Returns the name of the archived file * * @param time the archive date */ protected String getFormatName(String format, long time) { if (time <= 0) time = CurrentTime.getCurrentTime(); if (format != null) return QDate.formatLocal(time, format); else if (_rolloverCron != null) return _rolloverPrefix + "." + QDate.formatLocal(time, "%Y%m%d.%H"); else if (getRolloverPeriod() % (24 * 3600 * 1000L) == 0) return _rolloverPrefix + "." + QDate.formatLocal(time, "%Y%m%d"); else return _rolloverPrefix + "." + QDate.formatLocal(time, "%Y%m%d.%H"); }
/** * Logs a message to the error log. * * @param log the error log to write the message. * @param message the message to write * @param e the exception to write */ public void log( String message, Throwable e, HttpServletRequest request, HttpServletResponse response, ServletContext application) throws IOException { WriteStream logStream = getLogStream(); if (logStream == null) return; Throwable t = e; while (t != null) { e = t; if (e instanceof ServletException) t = ((ServletException) e).getRootCause(); else if (e instanceof ExceptionWrapper) t = ((ExceptionWrapper) e).getRootCause(); else t = null; } CharBuffer cb = CharBuffer.allocate(); QDate.formatLocal(cb, CurrentTime.getCurrentTime(), "[%Y/%m/%d %H:%M:%S] "); cb.append(message); logStream.log(cb.close()); if (e != null && !(e instanceof CompileException)) logStream.log(e); logStream.flush(); }
/** * Logs an error. * * @param message the error message * @param request the servlet request * @param response the servlet response * @param application the servlet context */ public void log( String message, HttpServletRequest request, HttpServletResponse response, ServletContext application) throws IOException { WriteStream logStream = getLogStream(); if (logStream == null) return; CharBuffer cb = CharBuffer.allocate(); QDate.formatLocal(cb, CurrentTime.getCurrentTime(), "[%Y/%m/%d %H:%M:%S] "); cb.append(message); logStream.log(cb.close()); logStream.flush(); }
/** * Fills the time buffer with the formatted time. * * @param date current time in milliseconds */ private void fillTime(long date) throws IOException { synchronized (_timeBuffer) { if (date / 1000 == _lastTime / 1000) return; if (_timeFormatSecondOffset >= 0 && date / 3600000 == _lastTime / 3600000) { byte[] bBuf = _timeBuffer.getBuffer(); int min = (int) (date / 60000 % 60); int sec = (int) (date / 1000 % 60); bBuf[_timeFormatMinuteOffset + 0] = (byte) ('0' + min / 10); bBuf[_timeFormatMinuteOffset + 1] = (byte) ('0' + min % 10); bBuf[_timeFormatSecondOffset + 0] = (byte) ('0' + sec / 10); bBuf[_timeFormatSecondOffset + 1] = (byte) ('0' + sec % 10); _lastTime = date; return; } _timeCharBuffer.clear(); QDate.formatLocal(_timeCharBuffer, date, _timeFormat); if (_timeFormatSecondOffset >= 0) { _timeFormatSecondOffset = _timeCharBuffer.lastIndexOf(':') + 1; _timeFormatMinuteOffset = _timeFormatSecondOffset - 3; } char[] cBuf = _timeCharBuffer.getBuffer(); int length = _timeCharBuffer.getLength(); _timeBuffer.setLength(length); byte[] bBuf = _timeBuffer.getBuffer(); for (int i = length - 1; i >= 0; i--) bBuf[i] = (byte) cBuf[i]; } _lastTime = date; }
/** * Evaluates the expression as a string. * * @param rows the current tuple being evaluated * @return the string value */ public String evalString(QueryContext context) throws SQLException { return QDate.formatLocal(evalLong(context)); }