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;
014
015import org.apache.juneau.http.annotation.*;
016
017/**
018 * Represents a parsed <l>Age</l> HTTP response header.
019 *
020 * <p>
021 * The age the object has been in a proxy cache in seconds.
022 *
023 * <h5 class='figure'>Example</h5>
024 * <p class='bcode w800'>
025 *    Age: 12
026 * </p>
027 *
028 * <h5 class='topic'>RFC2616 Specification</h5>
029 *
030 * The Age response-header field conveys the sender's estimate of the amount of time since the response (or its
031 * revalidation) was generated at the origin server.
032 * A cached response is "fresh" if its age does not exceed its freshness lifetime.
033 * Age values are calculated as specified in section 13.2.3.
034 *
035 * <p class='bcode w800'>
036 *    Age = "Age" ":" age-value
037 *    age-value = delta-seconds
038 * </p>
039 *
040 * <p>
041 * Age values are non-negative decimal integers, representing time in seconds.
042 *
043 * <p>
044 * If a cache receives a value larger than the largest positive integer it can represent, or if any of its age
045 * calculations overflows, it MUST transmit an Age header with a value of 2147483648 (2^31).
046 *
047 * <p>
048 * An HTTP/1.1 server that includes a cache MUST include an Age header field in every response generated from its own
049 * cache.
050 *
051 * <p>
052 * Caches SHOULD use an arithmetic type of at least 31 bits of range.
053 *
054 * <ul class='seealso'>
055 *    <li class='extlink'>{@doc RFC2616}
056 * </ul>
057 */
058@Header("Age")
059public final class Age extends HeaderInteger {
060
061   /**
062    * Constructor.
063    *
064    * @param value The value for this header.
065    */
066   public Age(Integer value) {
067      super(value);
068   }
069
070   /**
071    * Returns a parsed <c>Age</c> header.
072    *
073    * @param value The <c>Age</c> header string.
074    * @return The parsed <c>Age</c> header, or <jk>null</jk> if the string was null.
075    */
076   public static Age forString(String value) {
077      if (value == null)
078         return null;
079      return new Age(value);
080   }
081
082   private Age(String value) {
083      super(value);
084   }
085}