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.util.function.*;
016
017import org.apache.juneau.http.annotation.*;
018
019/**
020 * Represents a parsed <l>Content-Location</l> HTTP response header.
021 *
022 * <p>
023 * An alternate location for the returned data.
024 *
025 * <h5 class='figure'>Example</h5>
026 * <p class='bcode w800'>
027 *    Content-Location: /index.htm
028 * </p>
029 *
030 * <h5 class='topic'>RFC2616 Specification</h5>
031 *
032 * The Content-Location entity-header field MAY be used to supply the resource location for the entity enclosed in the
033 * message when that entity is accessible from a location separate from the requested resource's URI.
034 * A server SHOULD provide a Content-Location for the variant corresponding to the response entity; especially in the
035 * case where a resource has multiple entities associated with it, and those entities actually have separate locations
036 * by which they might be individually accessed, the server SHOULD provide a Content-Location for the particular variant
037 * which is returned.
038 * <p class='bcode w800'>
039 *    Content-Location = "Content-Location" ":"
040 *                       ( absoluteURI | relativeURI )
041 * </p>
042 *
043 * <p>
044 * The value of Content-Location also defines the base URI for the entity.
045 *
046 * <p>
047 * The Content-Location value is not a replacement for the original requested URI; it is only a statement of the
048 * location of the resource corresponding to this particular entity at the time of the request.
049 * Future requests MAY specify the Content-Location URI as the request- URI if the desire is to identify the source of
050 * that particular entity.
051 *
052 * <p>
053 * A cache cannot assume that an entity with a Content-Location different from the URI used to retrieve it can be used
054 * to respond to later requests on that Content-Location URI.
055 * However, the Content- Location can be used to differentiate between multiple entities retrieved from a single
056 * requested resource, as described in section 13.6.
057 *
058 * <p>
059 * If the Content-Location is a relative URI, the relative URI is interpreted relative to the Request-URI.
060 *
061 * <p>
062 * The meaning of the Content-Location header in PUT or POST requests is undefined; servers are free to ignore it in
063 * those cases.
064 *
065 * <ul class='seealso'>
066 *    <li class='extlink'>{@doc ExtRFC2616}
067 * </ul>
068 */
069@Header("Content-Location")
070public class ContentLocation extends BasicUriHeader {
071
072   private static final long serialVersionUID = 1L;
073
074   /**
075    * Convenience creator.
076    *
077    * @param value
078    *    The header value.
079    *    <br>Can be any of the following:
080    *    <ul>
081    *       <li>{@link String}
082    *       <li>Anything else - Converted to <c>String</c> then parsed.
083    *    </ul>
084    * @return A new {@link ContentLocation} object.
085    */
086   public static ContentLocation of(Object value) {
087      if (value == null)
088         return null;
089      return new ContentLocation(value);
090   }
091
092   /**
093    * Convenience creator using supplier.
094    *
095    * <p>
096    * Header value is re-evaluated on each call to {@link #getValue()}.
097    *
098    * @param value
099    *    The header value supplier.
100    *    <br>Can be any of the following:
101    *    <ul>
102    *       <li>{@link String}
103    *       <li>Anything else - Converted to <c>String</c> then parsed.
104    *    </ul>
105    * @return A new {@link ContentLocation} object.
106    */
107   public static ContentLocation of(Supplier<?> value) {
108      if (value == null)
109         return null;
110      return new ContentLocation(value);
111   }
112
113   /**
114    * Constructor
115    *
116    * @param value
117    *    The header value.
118    *    <br>Can be any of the following:
119    *    <ul>
120    *       <li>{@link String}
121    *       <li>Anything else - Converted to <c>String</c> then parsed.
122    *       <li>A {@link Supplier} of anything on this list.
123    *    </ul>
124    */
125   public ContentLocation(Object value) {
126      super("Content-Location", value);
127   }
128
129   /**
130    * Constructor
131    *
132    * @param value
133    *    The header value.
134    */
135   public ContentLocation(String value) {
136      this((Object)value);
137   }
138}