Class EQNameFactory

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

public final class EQNameFactory extends Object
A factory that produces qualified names.

This implementation uses an underlying integer-based cache to reduce the memory footprint of qualified names and namespaces by reusing instances with the same namespace and local name.

  • Method Details

    • instance

      @NonNull public static EQNameFactory instance()
      Get the singleton instance.
      Returns:
      the singleton instance
    • get

      @NonNull public Optional<IEnhancedQName> get(int index)
      Get an existing qualified name by looking up the cached entry using the provided index value.
      Parameters:
      index - the index value to lookup
      Returns:
      an optional containing the qualified name, if it exists
    • newQName

      @NonNull public IEnhancedQName newQName(@NonNull String namespace, @NonNull String localName)
      Get a new qualified name based on the provided namespace and local name.
      Parameters:
      namespace - the namespace part of the qualified name
      localName - the local part of the qualified name
      Returns:
      the qualified name
    • parseName

      @NonNull public IEnhancedQName parseName(@NonNull String name, @NonNull EQNameFactory.PrefixToNamespaceResolver resolver)
      Parse a name as a qualified name.

      The name can be:

      • A URI qualified name of the form Q{URI}name, where the URI represents the namespace
      • A lexical name of the forms prefix:name or name, where the prefix represents the namespace
      Parameters:
      name - the name to parse
      resolver - the prefix resolver to use to determine the namespace for a given prefix
      Returns:
      the parsed qualified name
    • parseUriQualifiedName

      @NonNull public IEnhancedQName parseUriQualifiedName(@NonNull String name)
      Parse a URI qualified name.

      The name is expected to be a URI qualified name of the form {URI}name, where the URI represents the namespace.

      Parameters:
      name - the name to parse
      Returns:
      the parsed qualified name
    • parseLexicalQName

      @NonNull public IEnhancedQName parseLexicalQName(@NonNull String name, @NonNull EQNameFactory.PrefixToNamespaceResolver resolver)
      Parse a lexical name as a qualified name.

      The name is expected to be a lexical name of the forms prefix:name or name, where the prefix represents the namespace.

      Parameters:
      name - the name to parse
      resolver - the prefix resolver to use to determine the namespace for a given prefix
      Returns:
      the parsed qualified name