/** * 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; }
public RequestDispatcher getRequestDispatcher(String path) { if (path == null || path.length() == 0) return null; else if (path.charAt(0) == '/') return getWebApp().getRequestDispatcher(path); else { CharBuffer cb = new CharBuffer(); WebApp webApp = getWebApp(); String servletPath = getPageServletPath(); if (servletPath != null) cb.append(servletPath); String pathInfo = getPagePathInfo(); if (pathInfo != null) cb.append(pathInfo); int p = cb.lastIndexOf('/'); if (p >= 0) cb.setLength(p); cb.append('/'); cb.append(path); if (webApp != null) return webApp.getRequestDispatcher(cb.toString()); return null; } }