Class QueryFormatter


  • public class QueryFormatter
    extends java.lang.Object
    Formatter for JCR queries in order to make them easier to read. Formatting is done on a best-effort basis. Warning: Care was taken to not add newlines inside string literals and so on, but there is still no guarantee that the formatted query is semantically equal to the original one. It is NOT recommended to run queries that are returned by these methods.
    • Constructor Summary

      Constructors 
      Constructor Description
      QueryFormatter()  
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static java.lang.String format​(@NotNull java.lang.String query, java.lang.String language)
      Format the query into a more human-readable way, by adding newlines before keywords such as "where", "and", and "or".
      static boolean isXPath​(java.lang.String query, java.lang.String language)
      Detect whether the query is an XPath query.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • QueryFormatter

        public QueryFormatter()
    • Method Detail

      • isXPath

        public static boolean isXPath​(java.lang.String query,
                                      java.lang.String language)
        Detect whether the query is an XPath query.
        Parameters:
        query - the query
        language - the language, if known, or null
        Returns:
        true if xpath
      • format

        public static java.lang.String format​(@NotNull
                                              @NotNull java.lang.String query,
                                              java.lang.String language)
        Format the query into a more human-readable way, by adding newlines before keywords such as "where", "and", and "or".
        Parameters:
        query - the query (may not be null)
        language - the query language, or null if unknown
        Returns:
        the formatted query