Class Ol<T extends Ol<T>>

All Implemented Interfaces:
com.oorian.css.ListIntf<T>
Direct Known Subclasses:
OrderedList

public class Ol<T extends Ol<T>> extends StyledElement<T>
Represents an HTML <ol> (ordered list) element that displays a numbered list of items.

The <ol> element creates a list where each item is automatically numbered. The numbering can be customized with different marker types (numbers, letters, Roman numerals), starting values, and direction (normal or reversed).

Features:

  • Automatically numbered list items
  • Customizable marker types (1, A, a, I, i)
  • Configurable starting number
  • Supports reversed numbering
  • Semantic structure for ordered content
  • Nesting support for hierarchical lists

Usage:


 // Basic ordered list
 Ol steps = new Ol();
 steps.addItem("Preheat oven to 350°F");
 steps.addItem("Mix ingredients");
 steps.addItem("Bake for 30 minutes");

 // Ordered list with Roman numerals starting at 5
 Ol chapters = new Ol();
 chapters.setType(OlMarkerType.UPPER_ROMAN);
 chapters.setStart(5);
 chapters.addItem("Introduction to Java");
 chapters.addItem("Object-Oriented Programming");
 chapters.addItem("Collections Framework");

 // Reversed countdown list
 Ol countdown = new Ol();
 countdown.setStart(10);
 countdown.setReversed(true);
 countdown.addItem("Final preparations");
 countdown.addItem("Launch sequence initiated");
 countdown.addItem("Liftoff!");
 
Since:
2007
Version:
1.0
Author:
Marvin P. Warble Jr.
See Also:
  • Constructor Details

    • Ol

      public Ol()
      Constructs a new Ol (ordered list) element.

      Creates an HTML <ol> element with automatic numbering enabled. By default, the list will use decimal numbers (1, 2, 3, ...) starting from 1.

  • Method Details

    • setReversed

      public final T setReversed(boolean reversed)
      Sets whether the list numbering should be reversed (descending).
      Parameters:
      reversed - True for descending numbering, false for ascending.
      Returns:
      This element for method chaining.
    • setStart

      public final T setStart(int number)
      Sets the starting number for the list.
      Parameters:
      number - The starting number.
      Returns:
      This element for method chaining.
    • setType

      public final T setType(OlMarkerType type)
      Sets the marker type for list items.

      Specifies the kind of marker to use for list items. Options include: decimal numbers (1, 2, 3), lowercase letters (a, b, c), uppercase letters (A, B, C), lowercase Roman numerals (i, ii, iii), or uppercase Roman numerals (I, II, III).

      Parameters:
      type - the marker type from the OlMarkerType enumeration
      Returns:
      this element for method chaining
    • setType

      public final T setType(String type)
      Sets the marker type for list items.

      Specifies the kind of marker to use for list items using a raw string value.

      Parameters:
      type - the marker type as a string (e.g., "1", "A", "a", "I", "i")
      Returns:
      this element for method chaining
    • setListStyle

      public T setListStyle(String attrValue)
      Sets the overall list-style CSS property.
      Specified by:
      setListStyle in interface com.oorian.css.ListIntf<T extends com.oorian.html.elements.List<T>>
      Parameters:
      attrValue - the list-style value
      Returns:
      this for method chaining
    • setListStyleImage

      public T setListStyleImage(String attrValue)
      Sets the list-style-image CSS property.
      Specified by:
      setListStyleImage in interface com.oorian.css.ListIntf<T extends com.oorian.html.elements.List<T>>
      Parameters:
      attrValue - the URL of the image to use as a list marker
      Returns:
      this for method chaining
    • setListStyleType

      public T setListStyleType(String attrValue)
      Sets the list-style-type CSS property.
      Specified by:
      setListStyleType in interface com.oorian.css.ListIntf<T extends com.oorian.html.elements.List<T>>
      Parameters:
      attrValue - the list-style-type value (e.g., "disc", "circle", "decimal")
      Returns:
      this for method chaining
    • setListStyleType

      public T setListStyleType(ListStyleType attrValue)
      Sets the list-style-type CSS property using a type-safe constant.
      Specified by:
      setListStyleType in interface com.oorian.css.ListIntf<T extends com.oorian.html.elements.List<T>>
      Parameters:
      attrValue - the ListStyleType constant
      Returns:
      this for method chaining
    • setListStylePosition

      public T setListStylePosition(String listStylePosition)
      Sets the list-style-position CSS property.
      Specified by:
      setListStylePosition in interface com.oorian.css.ListIntf<T extends com.oorian.html.elements.List<T>>
      Parameters:
      listStylePosition - the position value ("inside" or "outside")
      Returns:
      this for method chaining
    • setListStylePosition

      public T setListStylePosition(ListStylePosition attrValue)
      Sets the list-style-position CSS property using a type-safe constant.
      Specified by:
      setListStylePosition in interface com.oorian.css.ListIntf<T extends com.oorian.html.elements.List<T>>
      Parameters:
      attrValue - the ListStylePosition constant
      Returns:
      this for method chaining
    • addListItem

      public Li addListItem(Element element)
      Adds a list item containing the specified HTML element.
      Parameters:
      element - the HTML element to wrap in a list item
      Returns:
      the created Li element
    • addListItem

      public Li addListItem(String text)
      Adds a list item with the specified text content.
      Parameters:
      text - the text content for the list item
      Returns:
      the created Li element
    • addListItem

      public Li addListItem(Li item)
      Adds an existing list item to this list.
      Parameters:
      item - the Li element to add
      Returns:
      the added Li element
    • insertListItem

      public Li insertListItem(int index, Li item)
      Inserts a list item at the specified index.
      Parameters:
      index - the position to insert at (0-based)
      item - the Li element to insert
      Returns:
      the inserted Li element
    • insertListItem

      public Li insertListItem(int index, Element element)
      Inserts a list item containing an HTML element at the specified index.
      Parameters:
      index - the position to insert at (0-based)
      element - the HTML element to wrap in a list item
      Returns:
      the created Li element
    • insertListItem

      public Li insertListItem(int index, String text)
      Inserts a list item with text content at the specified index.
      Parameters:
      index - the position to insert at (0-based)
      text - the text content for the list item
      Returns:
      the created Li element
    • removeListItems

      public void removeListItems()
      Removes all list items from this list.
    • removeListItem

      public void removeListItem(Element element)
      Removes a specific list item from this list.
      Parameters:
      element - the list item element to remove