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">&lt;embed&gt;</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 * <h2 class='section'>Examples:</h2>
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 *
068 * <h2 class='section'>See Also:</h2><ul>
069 *    <li class='link'><a class="doclink" href="https://juneau.apache.org/docs/topics/JuneauBeanHtml5">juneau-bean-html5</a>
070 * </ul>
071 */
072@Marshalled(typeName = "embed")
073public class Embed extends HtmlElementVoid<Embed> {
074
075   /**
076    * Creates an empty {@link Embed} element.
077    */
078   public Embed() {}
079
080   /**
081    * Creates an {@link Embed} element with the specified {@link Embed#src(Object)} attribute.
082    *
083    * @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).
084    */
085   public Embed(Object src) {
086      src(src);
087   }
088
089   /**
090    * <a class="doclink" href="https://www.w3.org/TR/html5/embedded-content-0.html#attr-dim-height">height</a>
091    * attribute.
092    *
093    * <p>
094    * Vertical dimension.
095    *
096    * @param value
097    *    The new value for this attribute.
098    *    Typically a {@link Number} or {@link String}.
099    *    Can be <jk>null</jk> to unset the attribute.
100    * @return This object.
101    */
102   public Embed height(Object value) {
103      attr("height", value);
104      return this;
105   }
106
107   /**
108    * <a class="doclink" href="https://www.w3.org/TR/html5/embedded-content-0.html#attr-embed-src">src</a> attribute.
109    *
110    * <p>
111    * Address of the resource.
112    *
113    * <p>
114    * The value can be of any of the following types: {@link URI}, {@link URL}, {@link String}.
115    * Strings must be valid URIs.
116    *
117    * <p>
118    * URIs defined by {@link UriResolver} can be used for values.
119    *
120    * @param value
121    *    The new value for this attribute.
122    *    Typically a {@link URL} or {@link String}.
123    *    Can be <jk>null</jk>, in which case the attribute is stored with a <jk>null</jk> value (not removed).
124    * @return This object.
125    */
126   public Embed src(Object value) {
127      attrUri("src", value);
128      return this;
129   }
130
131   /**
132    * <a class="doclink" href="https://www.w3.org/TR/html5/embedded-content-0.html#attr-embed-type">type</a> attribute.
133    *
134    * <p>
135    * Specifies the MIME type of the embedded resource. Helps browsers determine how to handle the resource.
136    *
137    * <p>
138    * Common values:
139    * <ul>
140    *    <li><js>"application/pdf"</js> - PDF document</li>
141    *    <li><js>"application/x-shockwave-flash"</js> - Flash content</li>
142    *    <li><js>"image/svg+xml"</js> - SVG image</li>
143    *    <li><js>"video/mp4"</js> - MP4 video</li>
144    *    <li><js>"audio/mp3"</js> - MP3 audio</li>
145    * </ul>
146    *
147    * @param value The MIME type of the embedded resource. Can be <jk>null</jk> to unset the attribute.
148    * @return This object.
149    */
150   public Embed type(String value) {
151      attr("type", value);
152      return this;
153   }
154
155   /**
156    * <a class="doclink" href="https://www.w3.org/TR/html5/embedded-content-0.html#attr-dim-width">width</a> attribute.
157    *
158    * <p>
159    * Horizontal dimension.
160    *
161    * @param value
162    *    The new value for this attribute.
163    *    Typically a {@link Number} or {@link String}.
164    *    Can be <jk>null</jk> to unset the attribute.
165    * @return This object.
166    */
167   public Embed width(Object value) {
168      attr("width", value);
169      return this;
170   }
171}