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 * <h5 class='section'>Examples:</h5> 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 * </p> 094 * 095 * <h5 class='section'>See Also:</h5><ul> 096 * <li class='link'><a class="doclink" href="https://juneau.apache.org/docs/topics/JuneauBeanHtml5">juneau-bean-html5</a> 097 * </ul> 098 */ 099@Marshalled(typeName = "object") 100@SuppressWarnings({ 101 "java:S100", // Class name uses underscore suffix to avoid conflict with Object 102 "java:S101" // Class name uses underscore suffix to avoid conflict with Object 103}) 104public class Object_ extends HtmlElementMixed<Object_> { 105 106 /** 107 * Creates an empty {@link Object_} element. 108 */ 109 public Object_() {} 110 111 /** 112 * Creates an {@link Object_} element with the specified child nodes. 113 * 114 * @param children The child nodes. Must not be <jk>null</jk>. 115 */ 116 public Object_(Object...children) { 117 children(children); 118 } 119 120 /** 121 * <a class="doclink" href="https://www.w3.org/TR/html5/embedded-content-0.html#attr-object-data">data</a> attribute. 122 * 123 * <p> 124 * Specifies the URL of the resource to be embedded. This is the primary source of content 125 * for the object element. 126 * 127 * <p> 128 * The value can be of any of the following types: {@link URI}, {@link URL}, {@link String}. 129 * Strings must be valid URIs. 130 * 131 * <p> 132 * URIs defined by {@link UriResolver} can be used for values. 133 * 134 * @param value The URL of the resource to be embedded. Can be <jk>null</jk> to unset the attribute. 135 * @return This object. 136 */ 137 public Object_ data(String value) { 138 attr("data", value); 139 return this; 140 } 141 142 /** 143 * <a class="doclink" href="https://www.w3.org/TR/html5/forms.html#attr-fae-form">form</a> attribute. 144 * 145 * <p> 146 * Associates the control with a form element. 147 * 148 * @param value The new value for this attribute. Can be <jk>null</jk> to unset the attribute. 149 * @return This object. 150 */ 151 public Object_ form(String value) { 152 attr("form", value); 153 return this; 154 } 155 156 /** 157 * <a class="doclink" href="https://www.w3.org/TR/html5/embedded-content-0.html#attr-dim-height">height</a> 158 * attribute. 159 * 160 * <p> 161 * Vertical dimension. 162 * 163 * @param value 164 * The new value for this attribute. 165 * Typically a {@link Number} or {@link String}. 166 * Can be <jk>null</jk> to unset the attribute. 167 * @return This object. 168 */ 169 public Object_ height(Object value) { 170 attr("height", value); 171 return this; 172 } 173 174 /** 175 * <a class="doclink" href="https://www.w3.org/TR/html5/embedded-content-0.html#attr-object-name">name</a> attribute. 176 * 177 * <p> 178 * Name of nested browsing context. 179 * 180 * @param value The new value for this attribute. Can be <jk>null</jk> to unset the attribute. 181 * @return This object. 182 */ 183 public Object_ name(String value) { 184 attr("name", value); 185 return this; 186 } 187 188 /** 189 * <a class="doclink" href="https://www.w3.org/TR/html5/embedded-content-0.html#attr-object-type">type</a> attribute. 190 * 191 * <p> 192 * Type of embedded resource. 193 * 194 * @param value The new value for this attribute. Can be <jk>null</jk> to unset the attribute. 195 * @return This object. 196 */ 197 public Object_ type(String value) { 198 attr("type", value); 199 return this; 200 } 201 202 /** 203 * <a class="doclink" href="https://www.w3.org/TR/html5/embedded-content-0.html#attr-object-typemustmatch">typemustmatch</a> 204 * attribute. 205 * 206 * <p> 207 * Whether the type attribute and the Content-Type value need to match for the resource to be used. 208 * 209 * @param value 210 * The new value for this attribute. 211 * Typically a {@link Boolean} or {@link String}. 212 * Can be <jk>null</jk> to unset the attribute. 213 * @return This object. 214 */ 215 public Object_ typemustmatch(Object value) { 216 attr("typemustmatch", value); 217 return this; 218 } 219 220 /** 221 * <a class="doclink" href="https://www.w3.org/TR/html5/embedded-content-0.html#attr-hyperlink-usemap">usemap</a> 222 * attribute. 223 * 224 * <p> 225 * Name of image map to use. 226 * 227 * @param value The new value for this attribute. Can be <jk>null</jk> to unset the attribute. 228 * @return This object. 229 */ 230 public Object_ usemap(String value) { 231 attr("usemap", value); 232 return this; 233 } 234 235 /** 236 * <a class="doclink" href="https://www.w3.org/TR/html5/embedded-content-0.html#attr-dim-width">width</a> attribute. 237 * 238 * <p> 239 * Horizontal dimension. 240 * 241 * @param value 242 * The new value for this attribute. 243 * Typically a {@link Number} or {@link String}. 244 * Can be <jk>null</jk> to unset the attribute. 245 * @return This object. 246 */ 247 public Object_ width(Object value) { 248 attr("width", value); 249 return this; 250 } 251}