Class StaticContext.Builder

java.lang.Object
dev.metaschema.core.metapath.StaticContext.Builder
Enclosing class:
StaticContext

public static final class StaticContext.Builder extends Object
A builder used to generate the static context.
  • Method Details

    • baseUri

      @NonNull public StaticContext.Builder baseUri(@NonNull URI uri)
      Sets the static base URI to use in resolving URIs handled by the Metapath processor, when a document base URI is not available. There is only a single base URI. Subsequent calls to this method will change the base URI.
      Parameters:
      uri - the base URI to use
      Returns:
      this builder
    • namespace

      @NonNull public StaticContext.Builder namespace(@NonNull String prefix, @NonNull URI uri)
      Adds a new prefix to namespace URI binding to the mapping of statically known namespaces.

      A namespace set by this method can be resolved using the StaticContext.lookupNamespaceForPrefix(String) method.

      Well-known namespace bindings are used by default, which are provided by WellKnown.

      Parameters:
      prefix - the prefix to associate with the namespace, which may be
      uri - the namespace URI
      Returns:
      this builder
      See Also:
    • namespace

      @NonNull public StaticContext.Builder namespace(@NonNull String prefix, @NonNull String uri)
      A convenience method for namespace(String, URI).
      Parameters:
      prefix - the prefix to associate with the namespace, which may be
      uri - the namespace URI
      Returns:
      this builder
      Throws:
      IllegalArgumentException - if the provided prefix or URI is invalid
      See Also:
    • defaultModelNamespace

      @NonNull public StaticContext.Builder defaultModelNamespace(@NonNull URI namespace)
      Defines the default namespace to use for assembly, field, or flag references that have no namespace prefix.
      Parameters:
      namespace - the namespace URI
      Returns:
      this builder
    • defaultModelNamespace

      @NonNull public StaticContext.Builder defaultModelNamespace(@NonNull String uri)
      A convenience method for defaultModelNamespace(URI).
      Parameters:
      uri - the namespace URI
      Returns:
      this builder
      Throws:
      IllegalArgumentException - if the provided URI is invalid
    • defaultFunctionNamespace

      @NonNull public StaticContext.Builder defaultFunctionNamespace(@NonNull URI namespace)
      Defines the default namespace to use for assembly, field, or flag references that have no namespace prefix.
      Parameters:
      namespace - the namespace URI
      Returns:
      this builder
    • defaultFunctionNamespace

      @NonNull public StaticContext.Builder defaultFunctionNamespace(@NonNull String uri)
      A convenience method for defaultFunctionNamespace(URI).
      Parameters:
      uri - the namespace URI
      Returns:
      this builder
      Throws:
      IllegalArgumentException - if the provided URI is invalid
    • defaultLanguage

      @NonNull public StaticContext.Builder defaultLanguage(@NonNull String language)
      Defines the default language to be used by functions like fn:lang() when processing language-sensitive operations.

      If not set, the JVM's default locale language code will be used (e.g., "en" for English systems, "fr" for French systems).

      Parameters:
      language - the language code (e.g., "en", "fr", "de")
      Returns:
      this builder
      See Also:
    • useWildcardWhenNamespaceNotDefaulted

      public StaticContext.Builder useWildcardWhenNamespaceNotDefaulted(boolean value)
      Set the name matching behavior for when a model node has no namespace.
      Parameters:
      value - true if on or false otherwise
      Returns:
      this builder
    • functionResolver

      public StaticContext.Builder functionResolver(@NonNull IFunctionResolver resolver)
      Set the function resolver used to lookup function implementations.

      By default, the FunctionService is used to load function implementations using the service provider interface.

      Parameters:
      resolver - the resolver to use instead of the default resolver
      Returns:
      this builder
    • build

      @NonNull public StaticContext build()
      Construct a new static context using the information provided to the builder.
      Returns:
      the new static context