Class Identifier

    • Constructor Detail

      • Identifier

        public Identifier​(String text,
                          boolean quoted)
        Constructs an identifier instance.
        Parameters:
        text - The identifier text.
        quoted - Is this a quoted identifier?
      • Identifier

        protected Identifier​(String text)
        Constructs an unquoted identifier instance.
        Parameters:
        text - The identifier text.
    • Method Detail

      • toIdentifier

        public static Identifier toIdentifier​(String text)
        Means to generate an Identifier instance from its simple text form.

        If passed text is null, null is returned.

        If passed text is surrounded in quote markers, the generated Identifier is considered quoted. Quote markers include back-ticks (`), double-quotes (") and brackets ([ and ]). If the text, after trimming, contains a character that is not a valid identifier character, the identifier is treated as quoted.

        Parameters:
        text - The text form
        Returns:
        The identifier form, or null if text was null
      • toIdentifier

        public static Identifier toIdentifier​(String text,
                                              boolean quote)
        Means to generate an Identifier instance from its simple text form.

        If passed text is null, null is returned.

        If passed text is surrounded in quote markers, the generated Identifier is considered quoted. Quote markers include back-ticks (`), double-quotes (") and brackets ([ and ]). If the text, after trimming, contains a character that is not a valid identifier character, the identifier is treated as quoted.

        Parameters:
        text - The text form
        quote - Whether to quote unquoted text forms
        Returns:
        The identifier form, or null if text was null
      • toIdentifier

        public static Identifier toIdentifier​(String text,
                                              boolean quote,
                                              boolean quoteOnNonIdentifierChar)
        Means to generate an Identifier instance from its simple text form.

        If passed text is null, null is returned.

        If passed text is surrounded in quote markers, the generated Identifier is considered quoted. Quote markers include back-ticks (`), double-quotes (") and brackets ([ and ]).

        Parameters:
        text - The text form
        quote - Whether to quote unquoted text forms
        quoteOnNonIdentifierChar - Controls whether to treat the result as quoted if text contains characters that are invalid for identifiers
        Returns:
        The identifier form, or null if text was null
      • isQuoted

        public static boolean isQuoted​(String name)
        Is the given identifier text considered quoted. The following patterns are recognized as quoted:
        • `name`
        • [name]
        • "name"

        That final form using double-quote (") is the JPA-defined quoting pattern. Although it is the standard, it makes for ugly declarations.

        Returns:
        true if the given identifier text is considered quoted; false otherwise.
      • isQuoted

        public static boolean isQuoted​(String name,
                                       int start,
                                       int end)
      • getText

        public String getText()
        Get the identifiers name (text)
        Returns:
        The name
      • isQuoted

        public boolean isQuoted()
        Is this a quoted identifier?
        Returns:
        True if this is a quote identifier; false otherwise.
      • render

        public String render​(Dialect dialect)
        If this is a quoted identifier, then return the identifier name enclosed in dialect-specific open- and end-quotes; otherwise, simply return the unquoted identifier.
        Parameters:
        dialect - The dialect whose dialect-specific quoting should be used.
        Returns:
        if quoted, identifier name enclosed in dialect-specific open- and end-quotes; otherwise, the unquoted identifier.
      • render

        public String render()
      • getCanonicalName

        public String getCanonicalName()
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class Object