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