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 java.net.*; 020 021import org.apache.juneau.marshall.*; 022 023/** 024 * DTO for an HTML <a class="doclink" href="https://www.w3.org/TR/html5/embedded-content-0.html#the-object-element"><object></a> 025 * element. 026 * 027 * <p> 028 * The object element represents an external resource, which can be treated as an image, a nested browsing context, 029 * or a resource to be handled by a plugin. It is commonly used to embed multimedia content such as Flash applications, 030 * PDFs, images, videos, or other HTML documents. While historically used for plugins, modern web development often 031 * prefers more specific elements like img, video, audio, or iframe when appropriate. 032 * 033 * <h2 class='section'>Examples:</h2> 034 * <p class='bcode w800'> 035 * <jc>// PDF document</jc> 036 * Object_ <jv>pdf</jv> = <jsm>object</jsm>() 037 * .data(<js>"/documents/manual.pdf"</js>) 038 * .type(<js>"application/pdf"</js>) 039 * .width(<js>"600"</js>) 040 * .height(<js>"800"</js>) 041 * .children(<jsm>p</jsm>(<js>"Your browser doesn't support PDF viewing."</js>)); 042 * 043 * <jc>// SVG image</jc> 044 * Object_ <jv>svg</jv> = <jsm>object</jsm>() 045 * .data(<js>"/images/diagram.svg"</js>) 046 * .type(<js>"image/svg+xml"</js>) 047 * .width(<js>"400"</js>) 048 * .height(<js>"300"</js>); 049 * 050 * <jc>// Embedded HTML page</jc> 051 * Object_ <jv>html</jv> = <jsm>object</jsm>() 052 * .data(<js>"/external/page.html"</js>) 053 * .type(<js>"text/html"</js>) 054 * .width(<js>"100%"</js>) 055 * .height(<js>"500"</js>); 056 * 057 * <jc>// Flash content (legacy)</jc> 058 * Object_ <jv>flash</jv> = <jsm>object</jsm>() 059 * .data(<js>"/media/animation.swf"</js>) 060 * .type(<js>"application/x-shockwave-flash"</js>) 061 * .width(<js>"800"</js>) 062 * .height(<js>"600"</js>) 063 * .children( 064 * <jsm>param</jsm>().name(<js>"quality"</js>).value(<js>"high"</js>), 065 * <jsm>param</jsm>().name(<js>"bgcolor"</js>).value(<js>"#ffffff"</js>), 066 * <jsm>p</jsm>(<js>"Flash is not supported by your browser."</js>) 067 * ); 068 * 069 * <jc>// Image with fallback</jc> 070 * Object_ <jv>image</jv> = <jsm>object</jsm>() 071 * .data(<js>"/images/photo.jpg"</js>) 072 * .type(<js>"image/jpeg"</js>) 073 * .width(<js>"640"</js>) 074 * .height(<js>"480"</js>) 075 * .children(<jsm>img</jsm>().src(<js>"/images/fallback.jpg"</js>).alt(<js>"Photo"</js>)); 076 * 077 * <jc>// With usemap for image map</jc> 078 * Object_ <jv>mapped</jv> = <jsm>object</jsm>() 079 * .data(<js>"/images/map.jpg"</js>) 080 * .type(<js>"image/jpeg"</js>) 081 * .usemap(<js>"#imagemap"</js>); 082 * </p> 083 * 084 * <p> 085 * The following convenience methods are provided for constructing instances of this bean: 086 * <ul class='javatree'> 087 * <li class='jc'>{@link HtmlBuilder} 088 * <ul class='javatree'> 089 * <li class='jm'>{@link HtmlBuilder#object() object()} 090 * <li class='jm'>{@link HtmlBuilder#object(Object...) object(Object...)} 091 * </ul> 092 * </ul> 093 * 094 * <h2 class='section'>See Also:</h2><ul> 095 * <li class='link'><a class="doclink" href="https://juneau.apache.org/docs/topics/JuneauBeanHtml5">juneau-bean-html5</a> 096 * </ul> 097 */ 098@Marshalled(typeName = "object") 099@SuppressWarnings({ 100 "java:S100", // Class name uses underscore suffix to avoid conflict with Object 101 "java:S101" // Class name uses underscore suffix to avoid conflict with Object 102}) 103public class Object_ extends HtmlElementMixed<Object_> { 104 105 /** 106 * Creates an empty {@link Object_} element. 107 */ 108 public Object_() {} 109 110 /** 111 * Creates an {@link Object_} element with the specified child nodes. 112 * 113 * @param children The child nodes. Must not be <jk>null</jk>. 114 */ 115 public Object_(Object...children) { 116 children(children); 117 } 118 119 /** 120 * <a class="doclink" href="https://www.w3.org/TR/html5/embedded-content-0.html#attr-object-data">data</a> attribute. 121 * 122 * <p> 123 * Specifies the URL of the resource to be embedded. This is the primary source of content 124 * for the object element. 125 * 126 * <p> 127 * The value can be of any of the following types: {@link URI}, {@link URL}, {@link String}. 128 * Strings must be valid URIs. 129 * 130 * <p> 131 * URIs defined by {@link UriResolver} can be used for values. 132 * 133 * @param value The URL of the resource to be embedded. Can be <jk>null</jk> to unset the attribute. 134 * @return This object. 135 */ 136 public Object_ data(String value) { 137 attr("data", value); 138 return this; 139 } 140 141 /** 142 * <a class="doclink" href="https://www.w3.org/TR/html5/forms.html#attr-fae-form">form</a> attribute. 143 * 144 * <p> 145 * Associates the control with a form element. 146 * 147 * @param value The new value for this attribute. Can be <jk>null</jk> to unset the attribute. 148 * @return This object. 149 */ 150 public Object_ form(String value) { 151 attr("form", value); 152 return this; 153 } 154 155 /** 156 * <a class="doclink" href="https://www.w3.org/TR/html5/embedded-content-0.html#attr-dim-height">height</a> 157 * attribute. 158 * 159 * <p> 160 * Vertical dimension. 161 * 162 * @param value 163 * The new value for this attribute. 164 * Typically a {@link Number} or {@link String}. 165 * Can be <jk>null</jk> to unset the attribute. 166 * @return This object. 167 */ 168 public Object_ height(Object value) { 169 attr("height", value); 170 return this; 171 } 172 173 /** 174 * <a class="doclink" href="https://www.w3.org/TR/html5/embedded-content-0.html#attr-object-name">name</a> attribute. 175 * 176 * <p> 177 * Name of nested browsing context. 178 * 179 * @param value The new value for this attribute. Can be <jk>null</jk> to unset the attribute. 180 * @return This object. 181 */ 182 public Object_ name(String value) { 183 attr("name", value); 184 return this; 185 } 186 187 /** 188 * <a class="doclink" href="https://www.w3.org/TR/html5/embedded-content-0.html#attr-object-type">type</a> attribute. 189 * 190 * <p> 191 * Type of embedded resource. 192 * 193 * @param value The new value for this attribute. Can be <jk>null</jk> to unset the attribute. 194 * @return This object. 195 */ 196 public Object_ type(String value) { 197 attr("type", value); 198 return this; 199 } 200 201 /** 202 * <a class="doclink" href="https://www.w3.org/TR/html5/embedded-content-0.html#attr-object-typemustmatch">typemustmatch</a> 203 * attribute. 204 * 205 * <p> 206 * Whether the type attribute and the Content-Type value need to match for the resource to be used. 207 * 208 * @param value 209 * The new value for this attribute. 210 * Typically a {@link Boolean} or {@link String}. 211 * Can be <jk>null</jk> to unset the attribute. 212 * @return This object. 213 */ 214 public Object_ typemustmatch(Object value) { 215 attr("typemustmatch", value); 216 return this; 217 } 218 219 /** 220 * <a class="doclink" href="https://www.w3.org/TR/html5/embedded-content-0.html#attr-hyperlink-usemap">usemap</a> 221 * attribute. 222 * 223 * <p> 224 * Name of image map to use. 225 * 226 * @param value The new value for this attribute. Can be <jk>null</jk> to unset the attribute. 227 * @return This object. 228 */ 229 public Object_ usemap(String value) { 230 attr("usemap", value); 231 return this; 232 } 233 234 /** 235 * <a class="doclink" href="https://www.w3.org/TR/html5/embedded-content-0.html#attr-dim-width">width</a> attribute. 236 * 237 * <p> 238 * Horizontal dimension. 239 * 240 * @param value 241 * The new value for this attribute. 242 * Typically a {@link Number} or {@link String}. 243 * Can be <jk>null</jk> to unset the attribute. 244 * @return This object. 245 */ 246 public Object_ width(Object value) { 247 attr("width", value); 248 return this; 249 } 250}