Class Embed<T extends Embed<T>>


public class Embed<T extends Embed<T>> extends StyledElement<T>
Represents an HTML <embed> element.

The <embed> element is used to embed external content such as multimedia, plugins, or applications into an HTML document. This is a self-closing element that acts as a container for external resources like Flash, PDF documents, audio/video files, or other plugin-based content.

Features:

  • Embeds external multimedia and plugin content
  • Supports configurable width and height dimensions
  • Allows specification of content type and source URL
  • Self-closing element with no child content

Usage:


 // Create an embed element
 Embed embed = new Embed();
 embed.setSrc("video.mp4");
 embed.setType("video/mp4");
 embed.setIntrinsicWidth(640);
 embed.setIntrinsicHeight(480);

 // Embed a PDF document
 Embed pdfEmbed = new Embed();
 pdfEmbed.setSrc("document.pdf");
 pdfEmbed.setType("application/pdf");
 
Since:
2007
Version:
1.0
Author:
Marvin P. Warble Jr.
See Also:
  • Constructor Details

    • Embed

      public Embed()
      Constructs an empty <embed> element.

      Creates an embed element without initial attributes. The source URL, dimensions, and content type should be set using the appropriate setter methods.

  • Method Details

    • setSrc

      public T setSrc(String url)
      Sets the URL of the embedded content.

      Specifies the address of the external resource to be embedded. This is typically a required attribute for the embed element.

      If the URL starts with "/" (absolute path within the application), the servlet context path will be automatically prepended.

      Parameters:
      url - the URL of the resource to embed; may be absolute or relative
    • setType

      public T setType(String mediaType)
      Sets the MIME type of the embedded content.

      Specifies the media type of the embedded resource, helping browsers determine how to handle the content. Common types include "video/mp4", "application/pdf", "audio/mpeg", etc.

      Parameters:
      mediaType - the MIME type of the embedded resource (e.g., "video/mp4")
    • setIntrinsicWidth

      public T setIntrinsicWidth(int pixels)
      Sets the HTML width attribute to specify intrinsic width in pixels.

      This sets the HTML attribute (e.g., <img width="300">), not the CSS width property. To set CSS width, use the inherited StyledElement.setWidth(int) method.

      Parameters:
      pixels - The width in pixels.
      Returns:
      This element for method chaining.
    • setIntrinsicWidth

      public T setIntrinsicWidth(String width)
      Sets the HTML width attribute to specify intrinsic width.

      This sets the HTML attribute, not the CSS width property. To set CSS width, use the inherited StyledElement.setWidth(String) method.

      Parameters:
      width - The width value.
      Returns:
      This element for method chaining.
    • setIntrinsicHeight

      public T setIntrinsicHeight(int pixels)
      Sets the HTML height attribute to specify intrinsic height in pixels.

      This sets the HTML attribute (e.g., <img height="200">), not the CSS height property. To set CSS height, use the inherited StyledElement.setHeight(int) method.

      Parameters:
      pixels - The height in pixels.
      Returns:
      This element for method chaining.
    • setIntrinsicHeight

      public T setIntrinsicHeight(String height)
      Sets the HTML height attribute to specify intrinsic height.

      This sets the HTML attribute, not the CSS height property. To set CSS height, use the inherited StyledElement.setHeight(String) method.

      Parameters:
      height - The height value.
      Returns:
      This element for method chaining.
    • getIntrinsicWidth

      public String getIntrinsicWidth()
      Returns the HTML width attribute value.

      Returns the intrinsic width set via the HTML attribute, not the CSS width.

      Returns:
      The width value, or null if not set.
    • getIntrinsicHeight

      public String getIntrinsicHeight()
      Returns the HTML height attribute value.

      Returns the intrinsic height set via the HTML attribute, not the CSS height.

      Returns:
      The height value, or null if not set.