Small last-in-first-out collection for templates and scripts, created via Formatter's newStack helper and exported to GraalJS. Items are pushed and popped only at the head, so the head is always the most recently added item, which makes it useful for simple bookkeeping such as tracking the current section while rendering nested content.


Properties

PropertyReturnsDescription
headObjectThe current head, ie the most recently pushed object still on the stack.
listListThe full contents of the stack, ordered from the bottom to the head.

Methods

push(Object o)

Returns: String

Pushes the given object onto the stack so it becomes the new head. A null value is still pushed, but a warning is logged.

ParameterDescription
othe object to push, may be null

pop()

Returns: String

Removes the current head, if the stack is not empty. Does nothing if the stack is already empty.

getHead()

Returns: Object

The current head, ie the most recently pushed object still on the stack.

size()

Returns: int

The number of objects currently on the stack.

getList()

Returns: List

The full contents of the stack, ordered from the bottom to the head.

To get full access to the Kademi Hub existing customers can login here, or new customers can register here.