java.lang.Object
dev.metaschema.core.qname.EQNameFactory
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.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic interfaceProvides a callback for resolving namespace prefixes. -
Method Summary
Modifier and TypeMethodDescriptionget(int index) Get an existing qualified name by looking up the cached entry using the provided index value.static EQNameFactoryinstance()Get the singleton instance.Get a new qualified name based on the provided namespace and local name.parseLexicalQName(String name, EQNameFactory.PrefixToNamespaceResolver resolver) Parse a lexical name as a qualified name.parseName(String name, EQNameFactory.PrefixToNamespaceResolver resolver) Parse a name as a qualified name.parseUriQualifiedName(String name) Parse a URI qualified name.
-
Method Details
-
instance
Get the singleton instance.- Returns:
- the singleton instance
-
get
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
Get a new qualified name based on the provided namespace and local name.- Parameters:
namespace- the namespace part of the qualified namelocalName- 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:nameorname, where the prefix represents the namespace
- Parameters:
name- the name to parseresolver- the prefix resolver to use to determine the namespace for a given prefix- Returns:
- the parsed qualified name
- A URI qualified name of the form
-
parseUriQualifiedName
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:nameorname, where the prefix represents the namespace.- Parameters:
name- the name to parseresolver- the prefix resolver to use to determine the namespace for a given prefix- Returns:
- the parsed qualified name
-