Class Li<T extends Li<T>>

Direct Known Subclasses:
ListItem, TreeItem

public class Li<T extends Li<T>> extends StyledContainerElement<T>
Represents an HTML <li> (list item) element.

The <li> element defines an item in an ordered (<ol>) or unordered (<ul>) list. List items are the building blocks of HTML lists and can contain text, other inline elements, or even block-level elements and nested lists. In ordered lists, the value attribute can be used to override the default numbering.

Features:

  • Represents individual items in lists
  • Works with both ordered and unordered lists
  • Supports custom numbering in ordered lists
  • Can contain text, elements, or nested lists

Usage:


 // Create list items with text
 Li item1 = new Li("First item");
 Li item2 = new Li("Second item");

 // Create list item with an element
 Li linkItem = new Li(new Hyperlink("/page", "Go to page"));

 // Create list item with custom numbering
 Li customItem = new Li("Custom numbered item");
 customItem.setValue(10);

 // Add to a list
 Ul list = new Ul();
 list.addListItem(item1);
 list.addListItem(item2);
 
Since:
2007
Version:
1.0
Author:
Marvin P. Warble Jr.
See Also:
  • Constructor Details

    • Li

      public Li()
      Constructs an empty <li> element.

      Creates a list item without initial content. Content can be added later using inherited methods.

    • Li

      public Li(Element element)
      Constructs a <li> element containing the specified HTML element.
      Parameters:
      element - the HTML element to place inside the list item
    • Li

      public Li(String text)
      Constructs a <li> element with the specified text content.
      Parameters:
      text - the text content for the list item; may be null or empty
  • Method Details

    • setValue

      public void setValue(int number)
      Sets the ordinal value of this list item in an ordered list.

      This attribute is only relevant for list items within an <ol> element. It overrides the default sequential numbering and sets a specific number for this item. Subsequent items will continue numbering from this value.

      Parameters:
      number - the ordinal value to assign to this list item