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-Language</l> HTTP response header.
021 *
022 * <p>
023 * The natural language or languages of the intended audience for the enclosed content.
024 *
025 * <h5 class='figure'>Example</h5>
026 * <p class='bcode'>
027 *    Content-Language: da
028 * </p>
029 *
030 * <h5 class='topic'>RFC2616 Specification</h5>
031 *
032 * The Content-Language entity-header field describes the natural language(s) of the intended audience for the
033 * enclosed entity.
034 * Note that this might not be equivalent to all the languages used within the entity-body.
035 * <p class='bcode'>
036 *    Content-Language  = "Content-Language" ":" 1#language-tag
037 * </p>
038 *
039 * <p>
040 * Language tags are defined in section 3.10.
041 * The primary purpose of Content-Language is to allow a user to identify and differentiate entities according to the
042 * user's own preferred language.
043 * Thus, if the body content is intended only for a Danish-literate audience, the appropriate field is...
044 * <p class='bcode'>
045 *    Content-Language: da
046 * </p>
047 *
048 * <p>
049 * If no Content-Language is specified, the default is that the content is intended for all language audiences.
050 * This might mean that the sender does not consider it to be specific to any natural language, or that the sender
051 * does not know for which language it is intended.
052 *
053 * <p>
054 * Multiple languages MAY be listed for content that is intended for multiple audiences.
055 * For example, a rendition of the "Treaty of Waitangi," presented simultaneously in the original Maori and English
056 * versions, would call for...
057 * <p class='bcode'>
058 *    Content-Language: mi, en
059 * </p>
060 *
061 * <p>
062 * However, just because multiple languages are present within an entity does not mean that it is intended for
063 * multiple linguistic audiences.
064 * An example would be a beginner's language primer, such as "A First Lesson in Latin," which is clearly intended to
065 * be used by an English-literate audience.
066 * In this case, the Content-Language would properly only include "en".
067 *
068 * <p>
069 * Content-Language MAY be applied to any media type -- it is not limited to textual documents.
070 *
071 * <h5 class='section'>See Also:</h5><ul>
072 *    <li class='link'><a class="doclink" href="../../../../../index.html#juneau-rest-common">juneau-rest-common</a>
073 *    <li class='extlink'><a class="doclink" href="https://www.w3.org/Protocols/rfc2616/rfc2616.html">Hypertext Transfer Protocol -- HTTP/1.1</a>
074 * </ul>
075 *
076 * @serial exclude
077 */
078@Header("Content-Language")
079public class ContentLanguage extends BasicCsvHeader {
080
081   //-----------------------------------------------------------------------------------------------------------------
082   // Static
083   //-----------------------------------------------------------------------------------------------------------------
084
085   private static final long serialVersionUID = 1L;
086   private static final String NAME = "Content-Language";
087
088   /**
089    * Static creator.
090    *
091    * @param value
092    *    The header value.
093    *    <br>Can be <jk>null</jk>.
094    * @return A new header bean, or <jk>null</jk> if the value is <jk>null</jk>.
095    */
096   public static ContentLanguage of(String value) {
097      return value == null ? null : new ContentLanguage(value);
098   }
099
100   /**
101    * Static creator.
102    *
103    * @param value
104    *    The header value.
105    *    <br>Can be <jk>null</jk>.
106    * @return A new header bean, or <jk>null</jk> if the value is <jk>null</jk>.
107    */
108   public static ContentLanguage of(String...value) {
109      return value == null ? null : new ContentLanguage(value);
110   }
111
112   /**
113    * Static creator with delayed value.
114    *
115    * <p>
116    * Header value is re-evaluated on each call to {@link #getValue()}.
117    *
118    * @param value
119    *    The supplier of the header value.
120    *    <br>Can be <jk>null</jk>.
121    * @return A new header bean, or <jk>null</jk> if the value is <jk>null</jk>.
122    */
123   public static ContentLanguage of(Supplier<String[]> value) {
124      return value == null ? null : new ContentLanguage(value);
125   }
126
127   //-----------------------------------------------------------------------------------------------------------------
128   // Instance
129   //-----------------------------------------------------------------------------------------------------------------
130
131   /**
132    * Constructor.
133    *
134    * @param value
135    *    The header value.
136    *    <br>Can be <jk>null</jk>.
137    */
138   public ContentLanguage(String value) {
139      super(NAME, value);
140   }
141
142   /**
143    * Constructor.
144    *
145    * @param value
146    *    The header value.
147    *    <br>Can be <jk>null</jk>.
148    */
149   public ContentLanguage(String...value) {
150      super(NAME, value);
151   }
152
153   /**
154    * Constructor with delayed value.
155    *
156    * <p>
157    * Header value is re-evaluated on each call to {@link #getValue()}.
158    *
159    * @param value
160    *    The supplier of the header value.
161    *    <br>Can be <jk>null</jk>.
162    */
163   public ContentLanguage(Supplier<String[]> value) {
164      super(NAME, value);
165   }
166}