Class NsBinder

java.lang.Object
com.fasterxml.aalto.out.NsBinder

final class NsBinder extends Object
Simple helper class to allow resolving of namespace bindings either from prefix to URI, or vice versa.

Note: unlike with input side resolvers, here we can not assume that prefixes or URIs given are canonicalized (interned), and identity comparison can not be used exclusively.

  • Field Details

    • DEFAULT_ARRAY_SIZE

      static final int DEFAULT_ARRAY_SIZE
      Let's plan for having up to 14 explicit namespace declarations (in addition to 2 defaults, 'xml' and 'xmlns')
      See Also:
    • _scopeStart

      final int _scopeStart
    • _nsStrings

      String[] _nsStrings
      Array that contains { prefix, ns-uri } pairs, up to (but not including) index _scopeEnd.
    • _scopeEnd

      int _scopeEnd
  • Constructor Details

    • NsBinder

      private NsBinder(int scopeStart, String[] strs)
  • Method Details

    • createEmpty

      public static NsBinder createEmpty()
    • createChild

      public NsBinder createChild()
    • findUriByPrefix

      public String findUriByPrefix(String prefix)
    • findPrefixByUri

      public String findPrefixByUri(String uri)
    • getPrefixesBoundToUri

      public List<String> getPrefixesBoundToUri(String uri, List<String> l)
    • size

      public int size()
    • localSize

      public int localSize()
    • addMapping

      String addMapping(String prefix, String uri)
      Method to add a new prefix-to-URI mapping for the current scope. Note that it should NOT be used for the default namespace declaration
      Parameters:
      prefix - Prefix to bind
      uri - URI to bind to the prefix
      Returns:
      If the prefix was already bound, the URI it was bound to: null if it's a new binding for the current scope.
    • generatePrefix

      String generatePrefix(String prefixBase, NamespaceContext ctxt, int[] seqArr)
      Method used to generate a new prefix that does not conflict with an existing bound prefix.
    • toString

      public String toString()
      Overrides:
      toString in class Object