/** * Get a String representation of this lock token. */ public String toString() { StringBuilder result = new StringBuilder("Type:"); result.append(type).append("\n"); result.append("Scope:").append(scope).append("\n"); result.append("Depth:").append(depth).append("\n"); result.append("Owner:").append(owner).append("\n"); result.append("Expiration:").append( FastHttpDateFormat.formatDate(expiresAt, null)).append("\n"); Enumeration<String> tokensList = tokens.elements(); while (tokensList.hasMoreElements()) { result.append("Token:").append(tokensList.nextElement()).append("\n"); } return result.toString(); }
/** * Return the value of the specified date header, if any; otherwise * return -1. * * @param name Name of the requested date header * * @exception IllegalArgumentException if the specified header value * cannot be converted to a date */ @Override public long getDateHeader(String name) { String value = getHeader(name); if (value == null) { return -1L; } // Attempt to convert the date header in a variety of formats long result = FastHttpDateFormat.parseDate(value, formats); if (result != -1L) { return result; } throw new IllegalArgumentException(value); }
/** * Get the current date in HTTP format. */ public static String getCurrentDate() { final byte[] currentDateBytesNow = getCurrentDateBytes(); if (currentDateBytesNow != dateBytesForCachedStringDate) { try { cachedStringDate = new String(currentDateBytesNow, ASCII_CHARSET_NAME); dateBytesForCachedStringDate = currentDateBytesNow; } catch (UnsupportedEncodingException ignored) { // should never reach this line } } return cachedStringDate; }
/** * Try to parse the given date as a HTTP date. */ public static long parseDate(final String value, DateFormat[] threadLocalformats) { Long cachedDate = parseCache.get(value); if (cachedDate != null){ return cachedDate; } long date ; if (threadLocalformats != null) { date = internalParseDate(value, threadLocalformats); } else { date = internalParseDate(value, (SimpleDateFormat[])FORMATS.get()); } if (date != -1) { updateParseCache(value, date); } return date; }
newDate = FORMAT.get().format(value); updateFormatCache(longValue, newDate); return newDate;
/** * Try to parse the given date as a HTTP date. */ public static long parseDate(final String value, DateFormat[] threadLocalformats) { Long cachedDate = parseCache.get(value); if (cachedDate != null){ return cachedDate; } long date ; if (threadLocalformats != null) { date = internalParseDate(value, threadLocalformats); } else { date = internalParseDate(value, (SimpleDateFormat[])FORMATS.get()); } if (date != -1) { updateParseCache(value, date); } return date; }
newDate = FORMAT.get().format(value); updateFormatCache(longValue, newDate); return newDate;
protected static long convertToLong(final String dateHeader) { if (dateHeader == null) return (-1L); final SimpleDateFormats formats = SimpleDateFormats.create(); try { // Attempt to convert the date header in a variety of formats long result = FastHttpDateFormat.parseDate(dateHeader, formats.getFormats()); if (result != (-1L)) { return result; } throw new IllegalArgumentException(dateHeader); } finally { formats.recycle(); } }
/** * Add the specified date header to the specified value. * * @param name Name of the header to set * @param value Date value to be set */ public void addDateHeader(final String name, final long value) { if (isCommitted()) return; if (format == null) { format = new SimpleDateFormat(HTTP_RESPONSE_DATE_HEADER, Locale.US); format.setTimeZone(TimeZone.getTimeZone("GMT")); } addHeader(name, FastHttpDateFormat.formatDate(value, format)); }
/** * Try to parse the given date as a HTTP date. */ public static long parseDate(final String value, DateFormat[] threadLocalformats) { Long cachedDate = parseCache.get(value); if (cachedDate != null){ return cachedDate; } long date ; if (threadLocalformats != null) { date = internalParseDate(value, threadLocalformats); } else { date = internalParseDate(value, (SimpleDateFormat[])FORMATS.get()); } if (date != -1) { updateParseCache(value, date); } return date; }
/** * Get the current date in HTTP format. */ public static String getCurrentDate() { final byte[] currentDateBytesNow = getCurrentDateBytes(); if (currentDateBytesNow != dateBytesForCachedStringDate) { try { cachedStringDate = new String(currentDateBytesNow, ASCII_CHARSET_NAME); dateBytesForCachedStringDate = currentDateBytesNow; } catch (UnsupportedEncodingException ignored) { // should never reach this line } } return cachedStringDate; }
newDate = FORMAT.get().format(value); updateFormatCache(longValue, newDate); return newDate;
protected static long convertToLong(final String dateHeader) { if (dateHeader == null) return (-1L); final SimpleDateFormats formats = SimpleDateFormats.create(); try { // Attempt to convert the date header in a variety of formats long result = FastHttpDateFormat.parseDate(dateHeader, formats.getFormats()); if (result != (-1L)) { return result; } throw new IllegalArgumentException(dateHeader); } finally { formats.recycle(); } }
/** * Set the specified date header to the specified value. * * @param name Name of the header to set * @param value Date value to be set */ public void setDateHeader(String name, long value) { if (isCommitted()) return; if (format == null) { format = new SimpleDateFormat(HTTP_RESPONSE_DATE_HEADER, Locale.US); format.setTimeZone(TimeZone.getTimeZone("GMT")); } setHeader(name, FastHttpDateFormat.formatDate(value, format)); }
/** * Try to parse the given date as a HTTP date. */ public static long parseDate(final String value, DateFormat[] threadLocalformats) { Long cachedDate = parseCache.get(value); if (cachedDate != null){ return cachedDate; } long date ; if (threadLocalformats != null) { date = internalParseDate(value, threadLocalformats); } else { date = internalParseDate(value, (SimpleDateFormat[])FORMATS.get()); } if (date != -1) { updateParseCache(value, date); } return date; }
/** * Get the current date in HTTP format. */ public static String getCurrentDate() { final byte[] currentDateBytesNow = getCurrentDateBytes(); if (currentDateBytesNow != dateBytesForCachedStringDate) { try { cachedStringDate = new String(currentDateBytesNow, ASCII_CHARSET_NAME); dateBytesForCachedStringDate = currentDateBytesNow; } catch (UnsupportedEncodingException ignored) { // should never reach this line } } return cachedStringDate; }
newDate = FORMAT.get().format(value); updateFormatCache(longValue, newDate); return newDate;
protected static long convertToLong(final String dateHeader) { if (dateHeader == null) return (-1L); final SimpleDateFormats formats = SimpleDateFormats.create(); try { // Attempt to convert the date header in a variety of formats long result = FastHttpDateFormat.parseDate(dateHeader, formats.getFormats()); if (result != (-1L)) { return result; } throw new IllegalArgumentException(dateHeader); } finally { formats.recycle(); } }
/** * Add the specified date header to the specified value. * * @param name Name of the header to set * @param value Date value to be set */ public void addDateHeader(final String name, final long value) { if (isCommitted()) return; if (format == null) { format = new SimpleDateFormat(HTTP_RESPONSE_DATE_HEADER, Locale.US); format.setTimeZone(TimeZone.getTimeZone("GMT")); } addHeader(name, FastHttpDateFormat.formatDate(value, format)); }
/** * Try to parse the given date as a HTTP date. */ public static long parseDate(final String value, DateFormat[] threadLocalformats) { Long cachedDate = parseCache.get(value); if (cachedDate != null){ return cachedDate; } long date ; if (threadLocalformats != null) { date = internalParseDate(value, threadLocalformats); } else { date = internalParseDate(value, (SimpleDateFormat[])FORMATS.get()); } if (date != -1) { updateParseCache(value, date); } return date; }