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.bean.html5;
018
019import org.apache.juneau.marshall.*;
020
021/**
022 * DTO for an HTML <a class="doclink" href="https://www.w3.org/TR/html5/document-metadata.html#the-meta-element">&lt;meta&gt;</a>
023 * element.
024 *
025 * <p>
026 * The meta element represents metadata about the document. It provides information about the document
027 * that is not displayed to users but is used by browsers, search engines, and other web services.
028 * Common uses include character encoding, viewport settings, SEO information, and social media tags.
029 *
030 * <h5 class='section'>Examples:</h5>
031 * <p class='bcode w800'>
032 *    // Character encoding
033 *    Meta meta1 = meta().charset("utf-8");
034 *
035 *    // Viewport for responsive design
036 *    Meta meta2 = meta()
037 *       .name("viewport")
038 *       .content("width=device-width, initial-scale=1.0");
039 *
040 *    // SEO description
041 *    Meta meta3 = meta()
042 *       .name("description")
043 *       .content("This is a sample web page with meta information");
044 *
045 *    // Open Graph tags for social media
046 *    Meta meta4 = meta()
047 *       .property("og:title")
048 *       .content("My Web Page");
049 *
050 *    // HTTP-equiv for cache control
051 *    Meta meta5 = meta()
052 *       .httpequiv("Cache-Control")
053 *       .content("no-cache, no-store, must-revalidate");
054 * </p>
055 *
056 * <p>
057 * The following convenience methods are provided for constructing instances of this bean:
058 * <ul class='javatree'>
059 *    <li class='jc'>{@link HtmlBuilder}
060 *    <ul class='javatree'>
061 *       <li class='jm'>{@link HtmlBuilder#meta() meta()}
062 *    </ul>
063 * </ul>
064 * </p>
065 *
066 * <h5 class='section'>See Also:</h5><ul>
067 *    <li class='link'><a class="doclink" href="https://juneau.apache.org/docs/topics/JuneauBeanHtml5">juneau-bean-html5</a>
068 * </ul>
069 */
070@Marshalled(typeName = "meta")
071public class Meta extends HtmlElementVoid<Meta> {
072
073   /**
074    * Creates an empty {@link Meta} element.
075    */
076   public Meta() { /* Empty constructor. */ }
077
078   /**
079    * <a class="doclink" href="https://www.w3.org/TR/html5/document-metadata.html#attr-meta-charset">charset</a>
080    * attribute.
081    *
082    * <p>
083    * Specifies the character encoding for the HTML document. Should be placed early in the document head.
084    *
085    * <p>
086    * Common values:
087    * <ul>
088    *    <li><js>"UTF-8"</js> - Unicode UTF-8 encoding (recommended)</li>
089    *    <li><js>"ISO-8859-1"</js> - Latin-1 encoding</li>
090    *    <li><js>"windows-1252"</js> - Windows-1252 encoding</li>
091    * </ul>
092    *
093    * @param value The character encoding for the document. Can be <jk>null</jk> to unset the attribute.
094    * @return This object.
095    */
096   public Meta charset(String value) {
097      attr("charset", value);
098      return this;
099   }
100
101   /**
102    * <a class="doclink" href="https://www.w3.org/TR/html5/document-metadata.html#attr-meta-content">content</a>
103    * attribute.
104    *
105    * <p>
106    * Specifies the value associated with the name or http-equiv attribute.
107    * The content varies depending on the type of metadata being defined.
108    *
109    * @param value The metadata value (e.g., description text, viewport settings, etc.). Can be <jk>null</jk> to unset the attribute.
110    * @return This object.
111    */
112   public Meta content(String value) {
113      attr("content", value);
114      return this;
115   }
116
117   /**
118    * <a class="doclink" href="https://www.w3.org/TR/html5/document-metadata.html#attr-meta-http-equiv">http-equiv</a>
119    * attribute.
120    *
121    * <p>
122    * Specifies a pragma directive that simulates an HTTP header. Used with the content attribute.
123    *
124    * <p>
125    * Common values:
126    * <ul>
127    *    <li><js>"content-type"</js> - Document content type and character encoding</li>
128    *    <li><js>"refresh"</js> - Page refresh or redirect timing</li>
129    *    <li><js>"expires"</js> - Document expiration date</li>
130    *    <li><js>"cache-control"</js> - Caching directives</li>
131    *    <li><js>"pragma"</js> - Cache control (legacy)</li>
132    *    <li><js>"set-cookie"</js> - Cookie settings</li>
133    *    <li><js>"x-ua-compatible"</js> - Browser compatibility mode</li>
134    * </ul>
135    *
136    * @param value The HTTP header name to simulate. Can be <jk>null</jk> to unset the attribute.
137    * @return This object.
138    */
139   public Meta httpequiv(String value) {
140      attr("http-equiv", value);
141      return this;
142   }
143
144   /**
145    * <a class="doclink" href="https://www.w3.org/TR/html5/document-metadata.html#attr-meta-name">name</a> attribute.
146    *
147    * <p>
148    * Specifies the name of the metadata property. Used with the content attribute to define document metadata.
149    *
150    * <p>
151    * Common values:
152    * <ul>
153    *    <li><js>"description"</js> - Page description for search engines</li>
154    *    <li><js>"keywords"</js> - Keywords for search engines</li>
155    *    <li><js>"author"</js> - Page author</li>
156    *    <li><js>"viewport"</js> - Viewport settings for mobile devices</li>
157    *    <li><js>"robots"</js> - Instructions for search engine crawlers</li>
158    * </ul>
159    *
160    * @param value The name of the metadata property. Can be <jk>null</jk> to unset the attribute.
161    * @return This object.
162    */
163   public Meta name(String value) {
164      attr("name", value);
165      return this;
166   }
167
168}