001// *************************************************************************************************************************** 002// * Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements. See the NOTICE file * 003// * distributed with this work for additional information regarding copyright ownership. The ASF licenses this file * 004// * to you under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance * 005// * with the License. You may obtain a copy of the License at * 006// * * 007// * http://www.apache.org/licenses/LICENSE-2.0 * 008// * * 009// * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an * 010// * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the * 011// * specific language governing permissions and limitations under the License. * 012// *************************************************************************************************************************** 013package org.apache.juneau.http.header; 014 015import java.time.*; 016import java.util.*; 017import java.util.function.*; 018 019import org.apache.juneau.http.annotation.*; 020 021/** 022 * Represents a parsed <l>Last-Modified</l> HTTP response header. 023 * 024 * <p> 025 * The last modified date for the requested object (in "HTTP-date" format as defined by RFC 7231). 026 * 027 * <h5 class='figure'>Example</h5> 028 * <p class='bcode w800'> 029 * Last-Modified: Tue, 15 Nov 1994 12:45:26 GMT 030 * </p> 031 * 032 * <h5 class='topic'>RFC2616 Specification</h5> 033 * 034 * The Last-Modified entity-header field indicates the date and time at which the origin server believes the variant was 035 * last modified. 036 * 037 * <p class='bcode w800'> 038 * Last-Modified = "Last-Modified" ":" HTTP-date 039 * </p> 040 * 041 * <p> 042 * An example of its use is... 043 * <p class='bcode w800'> 044 * Last-Modified: Tue, 15 Nov 1994 12:45:26 GMT 045 * </p> 046 * 047 * <p> 048 * The exact meaning of this header field depends on the implementation of the origin server and the nature of the 049 * original resource. 050 * For files, it may be just the file system last-modified time. 051 * For entities with dynamically included parts, it may be the most recent of the set of last-modify times for its 052 * component parts. 053 * For database gateways, it may be the last-update time stamp of the record. 054 * For virtual objects, it may be the last time the internal state changed. 055 * 056 * <p> 057 * An origin server MUST NOT send a Last-Modified date which is later than the server's time of message origination. 058 * In such cases, where the resource's last modification would indicate some time in the future, the server MUST replace 059 * that date with the message origination date. 060 * 061 * <p> 062 * An origin server SHOULD obtain the Last-Modified value of the entity as close as possible to the time that it 063 * generates the Date value of its response. 064 * This allows a recipient to make an accurate assessment of the entity's modification time, especially if the entity 065 * changes near the time that the response is generated. 066 * 067 * <p> 068 * HTTP/1.1 servers SHOULD send Last-Modified whenever feasible. 069 * 070 * <ul class='seealso'> 071 * <li class='extlink'>{@doc ExtRFC2616} 072 * </ul> 073 */ 074@Header("Last-Modified") 075public class LastModified extends BasicDateHeader { 076 077 private static final long serialVersionUID = 1L; 078 079 /** 080 * Convenience creator. 081 * 082 * @param value 083 * The header value. 084 * <br>Can be any of the following: 085 * <ul> 086 * <li><c>String</c> - An RFC-1123 formated string (e.g. <js>"Sat, 29 Oct 1994 19:43:31 GMT"</js>). 087 * <li>{@link ZonedDateTime} 088 * <li>{@link Calendar} 089 * <li>Anything else - Converted to <c>String</c>. 090 * </ul> 091 * @return A new {@link LastModified} object, or <jk>null</jk> if the value was null. 092 */ 093 public static LastModified of(Object value) { 094 if (value == null) 095 return null; 096 return new LastModified(value); 097 } 098 099 /** 100 * Convenience creator using supplier. 101 * 102 * <p> 103 * Header value is re-evaluated on each call to {@link #getValue()}. 104 * 105 * @param value 106 * The header value supplier. 107 * <br>Can be any of the following: 108 * <ul> 109 * <li><c>String</c> - An RFC-1123 formated string (e.g. <js>"Sat, 29 Oct 1994 19:43:31 GMT"</js>). 110 * <li>{@link ZonedDateTime} 111 * <li>{@link Calendar} 112 * <li>Anything else - Converted to <c>String</c>. 113 * </ul> 114 * @return A new {@link LastModified} object, or <jk>null</jk> if the value was null. 115 */ 116 public static LastModified of(Supplier<?> value) { 117 if (value == null) 118 return null; 119 return new LastModified(value); 120 } 121 122 /** 123 * Constructor. 124 * 125 * @param value 126 * The header value. 127 * <br>Can be any of the following: 128 * <ul> 129 * <li><c>String</c> - An RFC-1123 formated string (e.g. <js>"Sat, 29 Oct 1994 19:43:31 GMT"</js>). 130 * <li>{@link ZonedDateTime} 131 * <li>{@link Calendar} 132 * <li>Anything else - Converted to <c>String</c>. 133 * <li>A {@link Supplier} of anything on this list. 134 * </ul> 135 */ 136 public LastModified(Object value) { 137 super("Last-Modified", value); 138 } 139 140 /** 141 * Constructor 142 * 143 * @param value 144 * The header value. 145 */ 146 public LastModified(String value) { 147 this((Object)value); 148 } 149}