java.lang.Object
org.hansken.plugin.extraction.hql_lite.lang.human.HqlHumanUtil

public final class HqlHumanUtil extends Object
HQL-human string utilities.
Author:
Netherlands Forensic Institute
  • Method Details

    • escapeText

      public static String escapeText(String text)
      Escapes full, untokenized text so it can be used within a single quoted string literal. Escapes: - backslashes - single quotes - whitespace
      Parameters:
      text - the text to escape
      Returns:
      text
    • escapeTerm

      public static String escapeTerm(String text)
      Escapes text so it can be used as a term. Escapes: - backslashes - single quotes - whitespace - any non-alphanumertic characters that are not glue characters.
      Parameters:
      text - the text to escape
      Returns:
      text
    • unescape

      public static String unescape(String text)
      Unescapes escaped characters, including wildcards, so it can be used within a query or for suggestions.
      Parameters:
      text - the text to unescape
      Returns:
      text
    • unescapeKeepWildcards

      public static String unescapeKeepWildcards(String text)
      Unescapes escaped characters, except wildcards, so it can be used within a term query.
      Parameters:
      text - the text to unescape
      Returns:
      text
    • isPlain

      public static boolean isPlain(String text)
      Returns whether text contains only plain characters that need no escaping.
      Parameters:
      text - the text to test
      Returns:
      whether text contains only plain characters that need no escaping.
    • swapEscapedWildcards

      public static String swapEscapedWildcards(String query)
      Swap the escaped wildcards with placeholders.
      Parameters:
      query - the hql-lite query
      Returns:
      the hql-lite query with placeholders instead of wildcards.
    • unswapEscapedWildcards

      public static String unswapEscapedWildcards(String query)
      Restore placeholders with their respective escaped wildcards.
      Parameters:
      query - the hql-lite query with placeholders
      Returns:
      the hql-lite query with wildcards instead of placeholders.