Class LiteralFactory

java.lang.Object
eu.bandm.tools.format.LiteralFactory

public class LiteralFactory extends Object
A store for format literals.

Objects of this class can be used to avoid duplication of format literals in a controlled context. Each literal created through a factory is stored in a map, and reused if a literal with the same content is requested again. Map entries last as long as the lifetime of the factory object. Hence, to avoid space leaks, it is recommended to limit either the scope where the factory is known to a trusted context, or its lifetime.

See Also:
  • Constructor Details

    • LiteralFactory

      public LiteralFactory()
  • Method Details

    • literal

      public Format literal(String text)
      Returns a format literal with the given text content.

      If there is already an equivalent literal in the internal map, it is reused.