Class Ul<T extends Ul<T>>

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

public class Ul<T extends Ul<T>> extends StyledElement<T>
Represents an HTML <ul> element for creating unordered (bulleted) lists.

This class provides functionality to create unordered lists, where list items are typically marked with bullets rather than numbers. Unordered lists are used when the order of items is not significant, such as in feature lists, navigation menus, or collections of related items. Each item in the list should be wrapped in an <li> element.

Features:

  • Creates bulleted lists where order is not significant
  • Automatically applies bullet markers to list items
  • Supports nested lists for hierarchical structures
  • Bullet style can be customized with CSS
  • Extends List for common list functionality
  • Accepts <li> elements as children

Usage:


 // Create a simple unordered list
 Ul list = new Ul();
 list.addElement(new Li("First item"));
 list.addElement(new Li("Second item"));
 list.addElement(new Li("Third item"));

 // Create nested lists
 Ul mainList = new Ul();
 Li item1 = new Li("Main item 1");
 mainList.addElement(item1);

 Li item2 = new Li("Main item 2");
 Ul subList = new Ul();
 subList.addElement(new Li("Sub item 2.1"));
 subList.addElement(new Li("Sub item 2.2"));
 item2.addElement(subList);
 mainList.addElement(item2);

 // Navigation menu
 Ul nav = new Ul();
 nav.addElement(new Li(new A("Home", "/")));
 nav.addElement(new Li(new A("About", "/about")));
 nav.addElement(new Li(new A("Contact", "/contact")));
 
Since:
2007
Version:
1.0
Author:
Marvin P. Warble Jr.
See Also:
  • Constructor Details

    • Ul

      public Ul()
      Constructs a Ul element.

      Creates a new <ul> element configured to accept list item children. The element is initialized with default unordered list behavior, displaying bullet markers for each list item.

  • Method Details

    • 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