001/*
002 * Licensed to the Apache Software Foundation (ASF) under one or more
003 * contributor license agreements.  See the NOTICE file distributed with
004 * this work for additional information regarding copyright ownership.
005 * The ASF licenses this file to You under the Apache License, Version 2.0
006 * (the "License"); you may not use this file except in compliance with
007 * the License.  You may obtain a copy of the License at
008 *
009 *      http://www.apache.org/licenses/LICENSE-2.0
010 *
011 * Unless required by applicable law or agreed to in writing, software
012 * distributed under the License is distributed on an "AS IS" BASIS,
013 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014 * See the License for the specific language governing permissions and
015 * limitations under the License.
016 */
017package org.apache.juneau.http.header;
018
019import java.util.function.*;
020
021import org.apache.juneau.http.annotation.*;
022
023/**
024 * Represents a parsed <l>Content-Language</l> HTTP response header.
025 *
026 * <p>
027 * The natural language or languages of the intended audience for the enclosed content.
028 *
029 * <h5 class='figure'>Example</h5>
030 * <p class='bcode'>
031 *    Content-Language: da
032 * </p>
033 *
034 * <h5 class='topic'>RFC2616 Specification</h5>
035 *
036 * The Content-Language entity-header field describes the natural language(s) of the intended audience for the
037 * enclosed entity.
038 * Note that this might not be equivalent to all the languages used within the entity-body.
039 * <p class='bcode'>
040 *    Content-Language  = "Content-Language" ":" 1#language-tag
041 * </p>
042 *
043 * <p>
044 * Language tags are defined in section 3.10.
045 * The primary purpose of Content-Language is to allow a user to identify and differentiate entities according to the
046 * user's own preferred language.
047 * Thus, if the body content is intended only for a Danish-literate audience, the appropriate field is...
048 * <p class='bcode'>
049 *    Content-Language: da
050 * </p>
051 *
052 * <p>
053 * If no Content-Language is specified, the default is that the content is intended for all language audiences.
054 * This might mean that the sender does not consider it to be specific to any natural language, or that the sender
055 * does not know for which language it is intended.
056 *
057 * <p>
058 * Multiple languages MAY be listed for content that is intended for multiple audiences.
059 * For example, a rendition of the "Treaty of Waitangi," presented simultaneously in the original Maori and English
060 * versions, would call for...
061 * <p class='bcode'>
062 *    Content-Language: mi, en
063 * </p>
064 *
065 * <p>
066 * However, just because multiple languages are present within an entity does not mean that it is intended for
067 * multiple linguistic audiences.
068 * An example would be a beginner's language primer, such as "A First Lesson in Latin," which is clearly intended to
069 * be used by an English-literate audience.
070 * In this case, the Content-Language would properly only include "en".
071 *
072 * <p>
073 * Content-Language MAY be applied to any media type -- it is not limited to textual documents.
074 *
075 * <h5 class='section'>See Also:</h5><ul>
076 *    <li class='link'><a class="doclink" href="https://juneau.apache.org/docs/topics/JuneauRestCommonBasics">juneau-rest-common Basics</a>
077 *    <li class='extlink'><a class="doclink" href="https://www.w3.org/Protocols/rfc2616/rfc2616.html">Hypertext Transfer Protocol -- HTTP/1.1</a>
078 * </ul>
079 *
080 * @serial exclude
081 */
082@Header("Content-Language")
083public class ContentLanguage extends BasicCsvHeader {
084
085   //-----------------------------------------------------------------------------------------------------------------
086   // Static
087   //-----------------------------------------------------------------------------------------------------------------
088
089   private static final long serialVersionUID = 1L;
090   private static final String NAME = "Content-Language";
091
092   /**
093    * Static creator.
094    *
095    * @param value
096    *    The header value.
097    *    <br>Can be <jk>null</jk>.
098    * @return A new header bean, or <jk>null</jk> if the value is <jk>null</jk>.
099    */
100   public static ContentLanguage of(String value) {
101      return value == null ? null : new ContentLanguage(value);
102   }
103
104   /**
105    * Static creator.
106    *
107    * @param value
108    *    The header value.
109    *    <br>Can be <jk>null</jk>.
110    * @return A new header bean, or <jk>null</jk> if the value is <jk>null</jk>.
111    */
112   public static ContentLanguage of(String...value) {
113      return value == null ? null : new ContentLanguage(value);
114   }
115
116   /**
117    * Static creator with delayed value.
118    *
119    * <p>
120    * Header value is re-evaluated on each call to {@link #getValue()}.
121    *
122    * @param value
123    *    The supplier of the header value.
124    *    <br>Can be <jk>null</jk>.
125    * @return A new header bean, or <jk>null</jk> if the value is <jk>null</jk>.
126    */
127   public static ContentLanguage of(Supplier<String[]> value) {
128      return value == null ? null : new ContentLanguage(value);
129   }
130
131   //-----------------------------------------------------------------------------------------------------------------
132   // Instance
133   //-----------------------------------------------------------------------------------------------------------------
134
135   /**
136    * Constructor.
137    *
138    * @param value
139    *    The header value.
140    *    <br>Can be <jk>null</jk>.
141    */
142   public ContentLanguage(String value) {
143      super(NAME, value);
144   }
145
146   /**
147    * Constructor.
148    *
149    * @param value
150    *    The header value.
151    *    <br>Can be <jk>null</jk>.
152    */
153   public ContentLanguage(String...value) {
154      super(NAME, value);
155   }
156
157   /**
158    * Constructor with delayed value.
159    *
160    * <p>
161    * Header value is re-evaluated on each call to {@link #getValue()}.
162    *
163    * @param value
164    *    The supplier of the header value.
165    *    <br>Can be <jk>null</jk>.
166    */
167   public ContentLanguage(Supplier<String[]> value) {
168      super(NAME, value);
169   }
170}