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-embed-element"><embed></a> 025 * element. 026 * 027 * <p> 028 * The embed element represents an integration point for an external application or interactive content. 029 * It is used to embed content such as Flash applications, PDF documents, or other multimedia content 030 * that requires a plugin or external application to display. 031 * 032 * <h5 class='section'>Examples:</h5> 033 * <p class='bcode w800'> 034 * <jk>import static</jk> org.apache.juneau.bean.html5.HtmlBuilder.*; 035 * 036 * <jc>// Embed a PDF document</jc> 037 * Embed <jv>embed1</jv> = <jsm>embed</jsm>() 038 * .src(<js>"document.pdf"</js>) 039 * .type(<js>"application/pdf"</js>) 040 * .width(<js>"800"</js>) 041 * .height(<js>"600"</js>); 042 * 043 * <jc>// Embed a Flash application</jc> 044 * Embed <jv>embed2</jv> = <jsm>embed</jsm>() 045 * .src(<js>"game.swf"</js>) 046 * .type(<js>"application/x-shockwave-flash"</js>) 047 * .width(<js>"640"</js>) 048 * .height(<js>"480"</js>); 049 * 050 * <jc>// Embed with fallback content</jc> 051 * Embed <jv>embed3</jv> = <jsm>embed</jsm>() 052 * .src(<js>"interactive-content.swf"</js>) 053 * .type(<js>"application/x-shockwave-flash"</js>) 054 * .children( 055 * <jsm>p</jsm>(<js>"Your browser does not support embedded content."</js>) 056 * ); 057 * </p> 058 * 059 * <p> 060 * The following convenience methods are provided for constructing instances of this bean: 061 * <ul class='javatree'> 062 * <li class='jc'>{@link HtmlBuilder} 063 * <ul class='javatree'> 064 * <li class='jm'>{@link HtmlBuilder#embed() embed()} 065 * </ul> 066 * </ul> 067 * </p> 068 * 069 * <h5 class='section'>See Also:</h5><ul> 070 * <li class='link'><a class="doclink" href="https://juneau.apache.org/docs/topics/JuneauBeanHtml5">juneau-bean-html5</a> 071 * </ul> 072 */ 073@Marshalled(typeName = "embed") 074public class Embed extends HtmlElementVoid<Embed> { 075 076 /** 077 * Creates an empty {@link Embed} element. 078 */ 079 public Embed() {} 080 081 /** 082 * Creates an {@link Embed} element with the specified {@link Embed#src(Object)} attribute. 083 * 084 * @param src The {@link Embed#src(Object)} attribute. Can be <jk>null</jk>, in which case the attribute is stored with a <jk>null</jk> value (not removed). 085 */ 086 public Embed(Object src) { 087 src(src); 088 } 089 090 /** 091 * <a class="doclink" href="https://www.w3.org/TR/html5/embedded-content-0.html#attr-dim-height">height</a> 092 * attribute. 093 * 094 * <p> 095 * Vertical dimension. 096 * 097 * @param value 098 * The new value for this attribute. 099 * Typically a {@link Number} or {@link String}. 100 * Can be <jk>null</jk> to unset the attribute. 101 * @return This object. 102 */ 103 public Embed height(Object value) { 104 attr("height", value); 105 return this; 106 } 107 108 /** 109 * <a class="doclink" href="https://www.w3.org/TR/html5/embedded-content-0.html#attr-embed-src">src</a> attribute. 110 * 111 * <p> 112 * Address of the resource. 113 * 114 * <p> 115 * The value can be of any of the following types: {@link URI}, {@link URL}, {@link String}. 116 * Strings must be valid URIs. 117 * 118 * <p> 119 * URIs defined by {@link UriResolver} can be used for values. 120 * 121 * @param value 122 * The new value for this attribute. 123 * Typically a {@link URL} or {@link String}. 124 * Can be <jk>null</jk>, in which case the attribute is stored with a <jk>null</jk> value (not removed). 125 * @return This object. 126 */ 127 public Embed src(Object value) { 128 attrUri("src", value); 129 return this; 130 } 131 132 /** 133 * <a class="doclink" href="https://www.w3.org/TR/html5/embedded-content-0.html#attr-embed-type">type</a> attribute. 134 * 135 * <p> 136 * Specifies the MIME type of the embedded resource. Helps browsers determine how to handle the resource. 137 * 138 * <p> 139 * Common values: 140 * <ul> 141 * <li><js>"application/pdf"</js> - PDF document</li> 142 * <li><js>"application/x-shockwave-flash"</js> - Flash content</li> 143 * <li><js>"image/svg+xml"</js> - SVG image</li> 144 * <li><js>"video/mp4"</js> - MP4 video</li> 145 * <li><js>"audio/mp3"</js> - MP3 audio</li> 146 * </ul> 147 * 148 * @param value The MIME type of the embedded resource. Can be <jk>null</jk> to unset the attribute. 149 * @return This object. 150 */ 151 public Embed type(String value) { 152 attr("type", value); 153 return this; 154 } 155 156 /** 157 * <a class="doclink" href="https://www.w3.org/TR/html5/embedded-content-0.html#attr-dim-width">width</a> attribute. 158 * 159 * <p> 160 * Horizontal 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 Embed width(Object value) { 169 attr("width", value); 170 return this; 171 } 172}