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 * <h5 class='section'>See Also:</h5>
055 * <ul class='doctree'>
056 *    <li class='extlink'>{@doc RFC2616}
057 * </ul>
058 */
059@Header("Age")
060public final class Age extends HeaderInteger {
061
062   /**
063    * Constructor.
064    *
065    * @param value
066    */
067   public Age(Integer value) {
068      super(value);
069   }
070
071   /**
072    * Returns a parsed <code>Age</code> header.
073    *
074    * @param value The <code>Age</code> header string.
075    * @return The parsed <code>Age</code> header, or <jk>null</jk> if the string was null.
076    */
077   public static Age forString(String value) {
078      if (value == null)
079         return null;
080      return new Age(value);
081   }
082
083   private Age(String value) {
084      super(value);
085   }
086}