Options
All
  • Public
  • Public/Protected
  • All
Menu

Class LabelManager

Maintains a mapping from HTML element id to labels meaningful to humans. Also keeps a counter that can be used for assigning new ids to elements that don't already have one.

Hierarchy

Index

Constructors

constructor

  • Parameters

    • name: string

      The name of this label manager. This is a convenience that can be used to produce distinctive error messages, for instance.

    Returns LabelManager

Properties

Protected _idToLabel

_idToLabel: Record<string, string> = Object.create(null)

A mapping of element id to allocated label.

Protected labelIndex

labelIndex: number = 0

A counter that must be incremented with each new label allocation. This allows the allocation algorithm to know what the next label should be.

name

name: string

The name of this label manager. This is a convenience that can be used to produce distinctive error messages, for instance.

Methods

Protected Abstract _deallocateAllLabels

  • _deallocateAllLabels(): void
  • Clear out the labels that were allocated. This method is called by deallocateAll to perform class-specific cleanup.

    Returns void

Abstract allocateLabel

  • allocateLabel(id: string): string
  • Allocate a label for an id. The relation between id and label remains constant until deallocateAll is called.

    Parameters

    • id: string

      The id of the element.

    Returns string

    The allocated label. If the method is called multiple times with the same id, the return value must be the same. It may change only if deallocateAll has been called between the calls to this method.

deallocateAll

  • deallocateAll(): void

idToLabel

  • idToLabel(id: string): string | undefined
  • Gets the label associated with an id.

    Parameters

    • id: string

      The id.

    Returns string | undefined

    The label. The value returned by this method obeys the same rules as that of allocateLabel with the exception that if a call returned undefined it may return another value on a subsequent call. (That is, an id that did not have a label allocated to it may acquire such label.)

nextNumber

  • nextNumber(): number

Generated using TypeDoc