Class Data<T extends Data<T>>


public class Data<T extends Data<T>> extends PhrasingContentElement<T>
Represents an HTML <data> element that associates machine-readable data with its content.

The <data> element links a piece of content with a machine-readable translation via the value attribute. This is useful when content needs to be displayed in a human-readable format while also providing a machine-readable equivalent for scripts or data processing. Common use cases include product IDs, encoded values, and numerical data that is displayed as text.

Features:

  • Associates machine-readable values with human-readable content
  • Provides semantic meaning for data processing
  • Useful for product IDs, codes, and structured data
  • Extends
    invalid reference
    TextElement
    for text content management

Usage:


 // Product with machine-readable ID
 Data product = new Data("Fancy Widget");
 product.setValue("widget-001");

 // Numeric value with formatted display
 Data price = new Data("$1,234.56");
 price.setValue("1234.56");

 // Create with both value and text
 Data item = new Data("Large", "L");
 
Since:
2026
Version:
1.0
Author:
Marvin P. Warble Jr.
See Also:
  • Constructor Details

    • Data

      public Data()
      Constructs an empty <data> element.

      Creates a data element without initial content. Text and value can be added later using inherited methods and setValue(String).

    • Data

      public Data(String text)
      Constructs a <data> element with the specified display text.
      Parameters:
      text - the human-readable text to display; may be null or empty
    • Data

      public Data(String text, String value)
      Constructs a <data> element with the specified display text and machine-readable value.
      Parameters:
      text - the human-readable text to display; may be null or empty
      value - the machine-readable value
  • Method Details

    • setValue

      public final T setValue(String value)
      Sets the machine-readable value for this data element.
      Parameters:
      value - the machine-readable translation of the content