Class QName

    • Method Detail

      • createQName

        public static QName createQName​(String namespaceURI,
                                        String localName)
                                 throws InvalidQNameException
        Create a QName (With no prefix)
        Parameters:
        namespaceURI - the qualifying namespace (maybe null or empty string)
        localName - the local name
        Returns:
        the QName
        Throws:
        InvalidQNameException
      • createQNameWithValidLocalName

        public static QName createQNameWithValidLocalName​(String namespaceURI,
                                                          String localName)
        Create a QName, optionally truncating the localname to MAX_LENGTH.
        Parameters:
        namespaceURI - the qualifying namespace (maybe null or empty string)
        localName - the local name, which will be truncated, if necessary
        Returns:
        the QName with potentially-truncated localname
      • createValidLocalName

        public static String createValidLocalName​(String name)
        Create a valid local name from the specified name
        Parameters:
        name - name to create valid local name from
        Returns:
        valid local name
      • getLocalName

        public String getLocalName()
        Gets the name
        Returns:
        the name
      • getNamespaceURI

        public String getNamespaceURI()
        Gets the namespace
        Returns:
        the namespace (empty string when not specified, but never null)
      • getPrefixedQName

        public QName getPrefixedQName​(NamespacePrefixResolver resolver)
        Gets a prefix resolved version of this QName
        Parameters:
        resolver - namespace prefix resolver
        Returns:
        QName with prefix resolved
      • equals

        public boolean equals​(Object object)
        Two QNames are equal only when both their name and namespace match. Note: The prefix is ignored during the comparison.
        Overrides:
        equals in class Object
      • isMatch

        public boolean isMatch​(QName qname)
        Performs a direct comparison between qnames.
        Specified by:
        isMatch in interface QNamePattern
        Parameters:
        qname - the instance to check
        Returns:
        Returns true if the qname matches this pattern
        See Also:
        equals(Object)
      • hashCode

        public int hashCode()
        Calculate hashCode. Follows pattern used by String where hashCode is cached (QName is immutable).
        Overrides:
        hashCode in class Object
      • toString

        public String toString()
        Render string representation of QName using format: {namespace}name
        Overrides:
        toString in class Object
        Returns:
        the string representation
      • toPrefixString

        public String toPrefixString()
        Render string representation of QName using format: prefix:name
        Returns:
        the string representation
      • getPrefixString

        public String getPrefixString()
        Getter version of toPrefixString()
        Returns:
        the string representation of QName
      • toPrefixString

        public String toPrefixString​(NamespacePrefixResolver prefixResolver)
        Render string representation of QName using format: prefix:name according to namespace prefix mappings of specified namespace resolver.
        Parameters:
        prefixResolver - namespace prefix resolver
        Returns:
        the string representation
      • resolveToQName

        public static QName resolveToQName​(NamespacePrefixResolver prefixResolver,
                                           String str)
        Creates a QName representation for the given String. If the String has no namespace the Alfresco namespace is added. If the String has a prefix an attempt to resolve the prefix to the full URI will be made.
        Parameters:
        str - The string to convert
        Returns:
        A QName representation of the given string
      • resolveToQNameString

        public static String resolveToQNameString​(NamespacePrefixResolver prefixResolver,
                                                  String str)
        Creates a string representation of a QName for the given string. If the given string already has a namespace, either a URL or a prefix, nothing the given string is returned. If it does not have a namespace the Alfresco namespace is added.
        Parameters:
        str - The string to convert
        Returns:
        A QName String representation of the given string