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   private static final long serialVersionUID = 1L;
085   private static final String NAME = "Content-Language";
086
087   /**
088    * Static creator.
089    *
090    * @param value
091    *    The header value.
092    *    <br>Can be <jk>null</jk>.
093    * @return A new header bean, or <jk>null</jk> if the value is <jk>null</jk>.
094    */
095   public static ContentLanguage of(String value) {
096      return value == null ? null : new ContentLanguage(value);
097   }
098
099   /**
100    * Static creator.
101    *
102    * @param value
103    *    The header value.
104    *    <br>Can be <jk>null</jk>.
105    * @return A new header bean, or <jk>null</jk> if the value is <jk>null</jk>.
106    */
107   public static ContentLanguage of(String...value) {
108      return value == null ? null : new ContentLanguage(value);
109   }
110
111   /**
112    * Static creator with delayed value.
113    *
114    * <p>
115    * Header value is re-evaluated on each call to {@link #getValue()}.
116    *
117    * @param value
118    *    The supplier of the header value.
119    *    <br>Can be <jk>null</jk>.
120    * @return A new header bean, or <jk>null</jk> if the value is <jk>null</jk>.
121    */
122   public static ContentLanguage of(Supplier<String[]> value) {
123      return value == null ? null : new ContentLanguage(value);
124   }
125
126   /**
127    * Constructor.
128    *
129    * @param value
130    *    The header value.
131    *    <br>Can be <jk>null</jk>.
132    */
133   public ContentLanguage(String value) {
134      super(NAME, value);
135   }
136
137   /**
138    * Constructor.
139    *
140    * @param value
141    *    The header value.
142    *    <br>Can be <jk>null</jk>.
143    */
144   public ContentLanguage(String...value) {
145      super(NAME, value);
146   }
147
148   /**
149    * Constructor with delayed value.
150    *
151    * <p>
152    * Header value is re-evaluated on each call to {@link #getValue()}.
153    *
154    * @param value
155    *    The supplier of the header value.
156    *    <br>Can be <jk>null</jk>.
157    */
158   public ContentLanguage(Supplier<String[]> value) {
159      super(NAME, value);
160   }
161}