Class Content


public class Content extends Text
Represents the content of an Atom entry.

The content element contains or links to the complete content of an entry. It supports multiple content types and delivery methods:

  • Inline text content - Plain text or HTML content embedded in the feed
  • Inline XHTML content - Well-formed XHTML embedded in the feed
  • Inline other content - Other media types (XML, base64-encoded binary, etc.)
  • Out-of-line content - Link to external content via the src attribute

The type attribute indicates the media type of the content. Common values:

  • "text" - Plain text (default)
  • "html" - HTML, entity-escaped
  • "xhtml" - XHTML wrapped in a div element
  • Other MIME types - For multimedia content or base64-encoded data
Schema

atomContent = atomInlineTextContent | atomInlineXHTMLContent | atomInlineOtherContent | atomOutOfLineContent atomInlineTextContent = element atom:content { atomCommonAttributes, attribute type { "text" | "html" }?, (text)* } atomInlineXHTMLContent = element atom:content { atomCommonAttributes, attribute type { "xhtml" }, xhtmlDiv } atomInlineOtherContent = element atom:content { atomCommonAttributes, attribute type { atomMediaType }?, (text|anyElement)* } atomOutOfLineContent = element atom:content { atomCommonAttributes, attribute type { atomMediaType }?, attribute src { atomUri }, empty }

Examples:

// Plain text content Content c1 = new Content("text") .setText("This is plain text content"); // HTML content Content c2 = new Content("html") .setText("<p>This is <strong>HTML</strong> content</p>"); // XHTML content Content c3 = new Content("xhtml") .setText("<div xmlns='http://www.w3.org/1999/xhtml'><p>XHTML content</p></div>"); // External content (out-of-line) Content c4 = new Content() .setType("video/mp4") .setSrc("http://example.org/movie.mp4");

Specification:

Represents an atomContent construct in the RFC 4287 - Section 4.1.3 specification.

See Also:
  • Constructor Details

    • Content

      public Content(String type)
      Normal content.
      Parameters:
      type - The content type of this content.
    • Content

      public Content()
      Normal content.
  • Method Details

    • getSrc

      @Xml(format=ATTR) public URI getSrc()
      Bean property getter: src.

      Returns the URI of externally-hosted content (out-of-line content).

      When src is present, the content is not embedded in the feed but is instead referenced by URI. This is useful for large media files or content hosted elsewhere.

      Returns:
      The property value, or null if it is not set.
    • setSrc

      public Content setSrc(Object value)
      Bean property setter: src.

      Sets the URI of externally-hosted content (out-of-line content).

      The value can be of any of the following types: URI, URL, String. Strings must be valid URIs.

      Example:

      // Link to external video Content content = new Content() .setType("video/mp4") .setSrc("http://example.org/videos/intro.mp4");

      Parameters:
      value - The new value for this property.
      Can be null to unset the property.
      Returns:
      This object.
    • setText

      public Content setText(String text)
      Description copied from class: Text
      Bean property setter: text.

      The content of this content.

      Overrides:
      setText in class Text
      Parameters:
      text - The new value for this property.
      Can be null to unset the property.
      Returns:
      This object
    • setType

      public Content setType(String type)
      Description copied from class: Text
      Bean property setter: type.

      The content type of this content.

      Must be one of the following:

      • "text"
      • "html"
      • "xhtml"
      • null (defaults to "text")
      Overrides:
      setType in class Text
      Parameters:
      type - The new value for this property.
      Can be null to unset the property.
      Returns:
      This object
    • setBase

      public Content setBase(Object value)
      Description copied from class: Common
      Bean property setter: base.

      Sets the base URI for resolving relative URI references (xml:base attribute).

      The value can be of any of the following types: URI, URL, String. Strings must be valid URIs.

      Example:

      Feed feed = new Feed(...) .setBase("http://example.org/");

      Overrides:
      setBase in class Text
      Parameters:
      value - The new value for this property.
      Can be null to unset the property.
      Returns:
      This object.
    • setLang

      public Content setLang(String value)
      Description copied from class: Common
      Bean property setter: lang.

      Sets the natural language of the element's content (xml:lang attribute).

      Example:

      Text title = new Text("text") .setText("Mon Blog") .setLang("fr");

      Overrides:
      setLang in class Text
      Parameters:
      value - The new value for this property (e.g., "en", "fr", "de", "en-US").
      Can be null to unset the property.
      Returns:
      This object.