Class NamespaceCache

java.lang.Object
dev.metaschema.core.qname.NamespaceCache

public final class NamespaceCache extends Object
An integer-based cache of namespaces to reduce the memory footprint of namespaces used by reusing instances with the same namespace.
  • Method Details

    • instance

      @NonNull public static NamespaceCache instance()
      Get the singleton instance.
      Returns:
      the singleton instance
    • indexOf

      public int indexOf(@NonNull String namespace)
      Get the index value of the provided namespace.
      Parameters:
      namespace - the namespace
      Returns:
      the index value
    • get

      @NonNull public Optional<Integer> get(@NonNull String namespace)
      Lookup the index value for an existing namespace.
      Parameters:
      namespace - the namespace to lookup
      Returns:
      an optional containing the index value, if it exists
    • get

      @NonNull public Optional<String> get(int index)
      Lookup the namespace using the index value for an existing namespace.
      Parameters:
      index - the index value to lookup
      Returns:
      an optional containing the namespace, if the index value exists
    • getAsURI

      @NonNull public Optional<URI> getAsURI(int index)
      Lookup the namespace using the index value for an existing namespace.
      Parameters:
      index - the index value to lookup
      Returns:
      an optional containing the namespace as a URI, if the index value exists