Class Name

java.lang.Object
org.rumbledb.context.Name
All Implemented Interfaces:
com.esotericsoftware.kryo.KryoSerializable, Serializable, Comparable<Name>

public class Name extends Object implements Comparable<Name>, Serializable, com.esotericsoftware.kryo.KryoSerializable
This class represents expanded names, corresponding to QNames in the W3C XQuery standard. An expanded name consists logically of a namespace (possibly absent) and a local name. A namespace may also have a proxy called a namespace prefix, used in lexical representation (e.g., name of the function or variable in JSONiq code). Expanded names serve as (global or local) variable names, function names, and error codes.
Author:
Ghislain Fourny
See Also:
  • Field Details

  • Constructor Details

    • Name

      public Name()
    • Name

      public Name(String namespace, String prefix, String localName)
  • Method Details

    • createVariableInNoNamespace

      public static Name createVariableInNoNamespace(String localName)
      Creates an expanded name that has no namespace. In JSONiq, unprefixed variables are never in a namespace.
      Parameters:
      localName - the name of the variable
      Returns:
      the expanded name
    • createVariableInDefaultTypeNamespace

      public static Name createVariableInDefaultTypeNamespace(String localName)
      Creates an expanded name that has the default JSONiq function namespace. By default, in Rumble, unprefixed function names live in this namespace. This namespace is for convenience and includes all functions in XQuery's fn namespace, JSONiq's jn (JSONiq core) and jnlib (JSONiq library) namespaces, as well as any user-defined functions with unprefixed names.
      Parameters:
      localName - the name of the variable
      Returns:
      the expanded name
    • createVariableInDefaultFunctionNamespace

      public static Name createVariableInDefaultFunctionNamespace(String localName)
      Creates an expanded name that has the default JSONiq type namespace. By default, in Rumble, unprefixed type names live in this namespace. This namespace is for convenience and includes all builtin XQuery and JSONiq functions.
      Parameters:
      localName - the name of the variable
      Returns:
      the expanded name
    • createVariableInDefaultAnnotationsNamespace

      public static Name createVariableInDefaultAnnotationsNamespace(String localName)
      Creates an expanded name that has the default annotations namespace. By default, in Rumble, unprefixed annotations live in this namespace. This namespace includes all builtin annotations.
      Parameters:
      localName - the name of the variable
      Returns:
      the expanded name
    • createVariableInDefaultXQueryTypeNamespace

      public static Name createVariableInDefaultXQueryTypeNamespace(String localName)
    • createVariableInDefaultXQueryFunctionNamespace

      public static Name createVariableInDefaultXQueryFunctionNamespace(String localName)
    • createVariableResolvingPrefix

      public static Name createVariableResolvingPrefix(String prefix, String localName, StaticContext moduleContext)
      Creates an expanded name resolving the prefix from namespace bindings.
      Parameters:
      prefix - the prefix
      localName - the local name
      moduleContext - the module context containing the bindings.
      Returns:
      the expanded name.
    • createTypeNameFromLiteral

      public static Name createTypeNameFromLiteral(String prefixedName, StaticContext moduleContext)
      Creates an expanded name resolving the prefix from namespace bindings.
      Parameters:
      prefixedName - the QName literal.
      moduleContext - the module context containing the bindings.
      Returns:
      the expanded name.
    • addArityToFunctionName

      public Name addArityToFunctionName(int arity)
      Converts the expanded name to an expanded name whose local name has a #n suffix, where n is the arity of the function, in order to encode the whole function identifier as an expanded name. This is only used to keep track of dependencies between functions and variables in the dependency resolution mechanism, and it should not be used for other purposes.
      Parameters:
      arity - the arity of the function.
      Returns:
      the expanded name
    • getNamespace

      public String getNamespace()
    • getPrefix

      public String getPrefix()
    • getLocalName

      public String getLocalName()
    • toString

      public String toString()
      Converts to a string. If there is a prefix, it is used. Otherwise, if there is a namespace, the Clark notation of the expanded name is returned. Otherwise, the local name is returned.
      Overrides:
      toString in class Object
      Returns:
      The converted string.
    • compareTo

      public int compareTo(Name o)
      Specified by:
      compareTo in interface Comparable<Name>
    • equals

      public boolean equals(Object o)
      Overrides:
      equals in class Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • write

      public void write(com.esotericsoftware.kryo.Kryo kryo, com.esotericsoftware.kryo.io.Output output)
      Specified by:
      write in interface com.esotericsoftware.kryo.KryoSerializable
    • read

      public void read(com.esotericsoftware.kryo.Kryo kryo, com.esotericsoftware.kryo.io.Input input)
      Specified by:
      read in interface com.esotericsoftware.kryo.KryoSerializable
    • precomputeHashCode

      public void precomputeHashCode()