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"><meta></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 * <h2 class='section'>Examples:</h2> 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 * 065 * <h2 class='section'>See Also:</h2><ul> 066 * <li class='link'><a class="doclink" href="https://juneau.apache.org/docs/topics/JuneauBeanHtml5">juneau-bean-html5</a> 067 * </ul> 068 */ 069@Marshalled(typeName = "meta") 070public class Meta extends HtmlElementVoid<Meta> { 071 072 /** 073 * Creates an empty {@link Meta} element. 074 */ 075 public Meta() { /* Empty constructor. */ } 076 077 /** 078 * <a class="doclink" href="https://www.w3.org/TR/html5/document-metadata.html#attr-meta-charset">charset</a> 079 * attribute. 080 * 081 * <p> 082 * Specifies the character encoding for the HTML document. Should be placed early in the document head. 083 * 084 * <p> 085 * Common values: 086 * <ul> 087 * <li><js>"UTF-8"</js> - Unicode UTF-8 encoding (recommended)</li> 088 * <li><js>"ISO-8859-1"</js> - Latin-1 encoding</li> 089 * <li><js>"windows-1252"</js> - Windows-1252 encoding</li> 090 * </ul> 091 * 092 * @param value The character encoding for the document. Can be <jk>null</jk> to unset the attribute. 093 * @return This object. 094 */ 095 public Meta charset(String value) { 096 attr("charset", value); 097 return this; 098 } 099 100 /** 101 * <a class="doclink" href="https://www.w3.org/TR/html5/document-metadata.html#attr-meta-content">content</a> 102 * attribute. 103 * 104 * <p> 105 * Specifies the value associated with the name or http-equiv attribute. 106 * The content varies depending on the type of metadata being defined. 107 * 108 * @param value The metadata value (e.g., description text, viewport settings, etc.). Can be <jk>null</jk> to unset the attribute. 109 * @return This object. 110 */ 111 public Meta content(String value) { 112 attr("content", value); 113 return this; 114 } 115 116 /** 117 * <a class="doclink" href="https://www.w3.org/TR/html5/document-metadata.html#attr-meta-http-equiv">http-equiv</a> 118 * attribute. 119 * 120 * <p> 121 * Specifies a pragma directive that simulates an HTTP header. Used with the content attribute. 122 * 123 * <p> 124 * Common values: 125 * <ul> 126 * <li><js>"content-type"</js> - Document content type and character encoding</li> 127 * <li><js>"refresh"</js> - Page refresh or redirect timing</li> 128 * <li><js>"expires"</js> - Document expiration date</li> 129 * <li><js>"cache-control"</js> - Caching directives</li> 130 * <li><js>"pragma"</js> - Cache control (legacy)</li> 131 * <li><js>"set-cookie"</js> - Cookie settings</li> 132 * <li><js>"x-ua-compatible"</js> - Browser compatibility mode</li> 133 * </ul> 134 * 135 * @param value The HTTP header name to simulate. Can be <jk>null</jk> to unset the attribute. 136 * @return This object. 137 */ 138 public Meta httpequiv(String value) { 139 attr("http-equiv", value); 140 return this; 141 } 142 143 /** 144 * <a class="doclink" href="https://www.w3.org/TR/html5/document-metadata.html#attr-meta-name">name</a> attribute. 145 * 146 * <p> 147 * Specifies the name of the metadata property. Used with the content attribute to define document metadata. 148 * 149 * <p> 150 * Common values: 151 * <ul> 152 * <li><js>"description"</js> - Page description for search engines</li> 153 * <li><js>"keywords"</js> - Keywords for search engines</li> 154 * <li><js>"author"</js> - Page author</li> 155 * <li><js>"viewport"</js> - Viewport settings for mobile devices</li> 156 * <li><js>"robots"</js> - Instructions for search engine crawlers</li> 157 * </ul> 158 * 159 * @param value The name of the metadata property. Can be <jk>null</jk> to unset the attribute. 160 * @return This object. 161 */ 162 public Meta name(String value) { 163 attr("name", value); 164 return this; 165 } 166 167}