APIdia Launch Partner
Top Description Inners Fields Constructors Methods
jdk.javadoc.internal.html

public Class ListBuilder

extends Content
Class Inheritance
Imports
java.io.IOException, .Writer, java.util.ArrayDeque, .Deque, .NoSuchElementException, .Objects

A utility class for building nested HTML lists. The class maintains a stack of nested list trees which it adapts to obtain the desired nesting level of added items.

Nested and Inner Type Summary

Modifier and TypeClass and Description
private static record

Field Summary

Modifier and TypeField and Description
private HtmlTree
private HtmlTree
private final HtmlStyle
private final HtmlTag
pack-priv static final int
private final HtmlTree
private final Deque<ListBuilder.Pair>

Constructor Summary

AccessConstructor and Description
public
ListBuilder(HtmlTag
the tag to use for the list elements
listTag
,
HtmlStyle
the style to use for list elements
listStyle
)

Creates a new list builder.

Method Summary

Modifier and TypeMethod and Description
public void
addItem(Content
content for the new list item.
listItemContent
,
int
nesting level for the added item
level
)

Adds a new list item with the given content to the current list at the given nesting level, which must be greater than or equal to 0 and less than or equal to MAX_LEVEL.

private HtmlTree
public boolean
isEmpty()

Implements abstract jdk.javadoc.internal.html.Content.isEmpty.

Returns true if the content is empty.

private void
popNestedList()

Closes the current nested list and makes its parent the current list.

private void
pushNestedList()

Adds a new nested nested list to which new items will be added.

public boolean
write(Writer writer, String newline, boolean atNewline)

Implements abstract jdk.javadoc.internal.html.Content.write.

Writes content to a writer, using a given newline sequence, which should be either \n or the platform line separator.

Inherited from jdk.javadoc.internal.html.Content:
addaddaddAllcharCountisDiscardableisPhrasingContentstripTagstoString

Field Detail

currentItemback to summary
private HtmlTree currentItem
currentListback to summary
private HtmlTree currentList
listStyleback to summary
private final HtmlStyle listStyle
listTagback to summary
private final HtmlTag listTag
MAX_LEVELback to summary
pack-priv static final int MAX_LEVEL
rootback to summary
private final HtmlTree root
stackback to summary
private final Deque<ListBuilder.Pair> stack

Constructor Detail

ListBuilderback to summary
public ListBuilder(HtmlTag listTag, HtmlStyle listStyle)

Creates a new list builder.

Parameters
listTag:HtmlTag

the tag to use for the list elements

listStyle:HtmlStyle

the style to use for list elements

Method Detail

addItemback to summary
public void addItem(Content listItemContent, int level)

Adds a new list item with the given content to the current list at the given nesting level, which must be greater than or equal to 0 and less than or equal to MAX_LEVEL. If level is greater than the current nesting level new sublists are added until the level is reached. If level is less than the current level, sublists are closed to reach the level.

Parameters
listItemContent:Content

content for the new list item.

level:int

nesting level for the added item

createListback to summary
private HtmlTree createList()
isEmptyback to summary
public boolean isEmpty()

Implements abstract jdk.javadoc.internal.html.Content.isEmpty.

Doc from jdk.javadoc.internal.html.Content.isEmpty.

Returns true if the content is empty.

Annotations
@Override
popNestedListback to summary
private void popNestedList()

Closes the current nested list and makes its parent the current list.

Exceptions
NoSuchElementException:
if the stack is empty
pushNestedListback to summary
private void pushNestedList()

Adds a new nested nested list to which new items will be added.

writeback to summary
public boolean write(Writer writer, String newline, boolean atNewline) throws IOException

Implements abstract jdk.javadoc.internal.html.Content.write.

Doc from jdk.javadoc.internal.html.Content.write.

Writes content to a writer, using a given newline sequence, which should be either \n or the platform line separator.

Annotations
@Override
Exceptions
IOException:
if an error occurs while writing the output
jdk.javadoc.internal.html back to summary

private final Record ListBuilder.Pair

extends Record
Class Inheritance
Record Components
list:HtmlTree 
item:HtmlTree 

Field Summary

Modifier and TypeField and Description
private final HtmlTree
item

Record Component accessed by item().

private final HtmlTree
list

Record Component accessed by list().

Constructor Summary

AccessConstructor and Description
private
Pair(HtmlTree list, HtmlTree item)

Method Summary

Modifier and TypeMethod and Description
public final boolean
equals(Object o)

Implements abstract java.lang.Record.equals.

Indicates whether some other object is "equal to" this one.

public final int
hashCode()

Implements abstract java.lang.Record.hashCode.

Returns a hash code value for the record.

public HtmlTree
item()

Record Component getter of item.

public HtmlTree
list()

Record Component getter of list.

public final String
toString()

Implements abstract java.lang.Record.toString.

Returns a string representation of the record.

Field Detail

itemback to summary
private final HtmlTree item

Record Component accessed by item().

listback to summary
private final HtmlTree list

Record Component accessed by list().

Constructor Detail

Pairback to summary
private Pair(HtmlTree list, HtmlTree item)

Method Detail

equalsback to summary
public final boolean equals(Object o)

Implements abstract java.lang.Record.equals.

Doc from java.lang.Record.equals.

Indicates whether some other object is "equal to" this one. In addition to the general contract of Object.equals, record classes must further obey the invariant that when a record instance is "copied" by passing the result of the record component accessor methods to the canonical constructor, as follows:

    R copy = new R(r.c1(), r.c2(), ..., r.cn());
then it must be the case that r.equals(copy).
hashCodeback to summary
public final int hashCode()

Implements abstract java.lang.Record.hashCode.

Doc from java.lang.Record.hashCode.

Returns a hash code value for the record. Obeys the general contract of Object.hashCode. For records, hashing behavior is constrained by the refined contract of Record.equals, so that any two records created from the same components must have the same hash code.

itemback to summary
public HtmlTree item()

Record Component getter of item.

listback to summary
public HtmlTree list()

Record Component getter of list.

toStringback to summary
public final String toString()

Implements abstract java.lang.Record.toString.

Doc from java.lang.Record.toString.

Returns a string representation of the record. In accordance with the general contract of Object#toString(), the toString method returns a string that "textually represents" this record. The result should be a concise but informative representation that is easy for a person to read.

In addition to this general contract, record classes must further participate in the invariant that any two records which are equal must produce equal strings. This invariant is necessarily relaxed in the rare case where corresponding equal component values might fail to produce equal strings for themselves.