Class QueryStringManipulator

  • Direct Known Subclasses:
    RwQueryDetailHandler

    public class QueryStringManipulator
    extends java.lang.Object
    THIS CLASS IS NOT SUPPORTED FOR USE IN CUSTOM APPLICATION DEVELOPMENT. THE CLASS IS SUBJECT TO CHANGE IN FUTURE RELEASES AND SOME METHODS AND PROPERTIES MAY NOT BE SUITABLE FOR CUSTOM DEVELOPMENT. Query string manipulation methods from Integrity Manager It provides the functionality for extract info, split SQL, find CSI, align two query (for comparison) from query strings.
    • Field Detail

      • KEYWORD_SQL_START

        public static final java.lang.String KEYWORD_SQL_START
        See Also:
        Constant Field Values
      • PATTERN_TO_STATEMENT

        public static final java.util.regex.Pattern PATTERN_TO_STATEMENT
      • MDX_STATEMENTS_PASS_PATTERN

        protected static final java.util.regex.Pattern MDX_STATEMENTS_PASS_PATTERN
      • queryString

        protected java.lang.String queryString
    • Constructor Detail

      • QueryStringManipulator

        public QueryStringManipulator​(java.lang.String queryString)
        Constructor
    • Method Detail

      • splitQueryStrings

        public static java.util.List<org.apache.commons.lang3.tuple.Pair<java.lang.String,​java.lang.Integer>> splitQueryStrings​(java.lang.String queryStrings)
        Split a multi-pass query strings into an array.
        Parameters:
        queryStrings - The query string to split.
        Returns:
        A list of pairs, each of which represents (the string, the offsets in the original string).
      • splitQueryStrings

        public static java.util.List<org.apache.commons.lang3.tuple.Pair<java.lang.String,​java.lang.Integer>> splitQueryStrings​(java.lang.String queryStrings,
                                                                                                                                      boolean shouldStartAtNewLine)
        Split a multi-pass query strings into an array.
        Parameters:
        queryStrings - The query string to split.
        Returns:
        A list of pairs, each of which represents (the string, the offsets in the original string).
      • findSinglePassQueryStartIndexesByPatterns

        public java.util.List<java.lang.Integer> findSinglePassQueryStartIndexesByPatterns()
        Find start indexes of a single pass query.
        Returns:
        The indexes.
      • findSinglePassQueryStartIndexesByPatterns

        public java.util.List<java.lang.Integer> findSinglePassQueryStartIndexesByPatterns​(java.lang.String queryString)
        Find start indexes of a single pass query.
        Returns:
        The indexes.
      • findSinglePassQueryStartIndexesByPatterns

        public java.util.List<java.lang.Integer> findSinglePassQueryStartIndexesByPatterns​(java.lang.String queryString,
                                                                                           boolean shouldStarAtNewLine)
        Find start indexes of a single pass query.
        Parameters:
        shouldStarAtNewLine - The query should start at a new line after at least one empty line.
        Returns:
        The indexes.
      • findSqlStatementsStartIndexesByPatterns

        public java.util.List<QueryStringManipulator.StatementIndex> findSqlStatementsStartIndexesByPatterns()
        Find statement start indexes.
        Returns:
        The indexes.
      • findSqlPassStartIndexesByPatterns

        public java.util.List<java.lang.Integer> findSqlPassStartIndexesByPatterns​(java.lang.String sqlString)
        Find sql passes start indexes.
        Returns:
        The indexes.
      • findSqlPassEndIndexesByPatterns

        public java.util.List<java.lang.Integer> findSqlPassEndIndexesByPatterns​(java.lang.String queryString)
        Find sql passes end indexes.
        Returns:
        The indexes.
      • findMdxStatementsStartIndexesByPatterns

        public java.util.List<QueryStringManipulator.StatementIndex> findMdxStatementsStartIndexesByPatterns()
        Find mdx start indexes.
        Returns:
        The indexes.
      • findMdxPassStartIndexesByPatterns

        public java.util.List<java.lang.Integer> findMdxPassStartIndexesByPatterns​(java.lang.String mdxString)
        Find mdx start indexes.
        Returns:
        The indexes.
      • findMdxPassEndIndexesByPatterns

        public java.util.List<java.lang.Integer> findMdxPassEndIndexesByPatterns​(java.lang.String queryString)
        Find mdx end indexes.
        Returns:
        The indexes.
      • wrangleStatementsSnippetFoundAmongQueryDetail

        protected java.lang.String wrangleStatementsSnippetFoundAmongQueryDetail​(java.lang.String statement,
                                                                                 java.util.function.Function<java.lang.String,​java.util.List<java.lang.Integer>> sqlPassStartIndexesFinder,
                                                                                 java.util.function.Function<java.lang.String,​java.util.List<java.lang.Integer>> sqlPassEndIndexesFinder)
      • wrangleSqlSnippetFoundAmongQueryDetail

        protected java.lang.String wrangleSqlSnippetFoundAmongQueryDetail​(java.lang.String statement)
      • wrangleMdxSnippetFoundAmongQueryDetail

        protected java.lang.String wrangleMdxSnippetFoundAmongQueryDetail​(java.lang.String statement)
      • removeNoisesFromStatement

        protected java.lang.String removeNoisesFromStatement​(java.lang.String statement)
      • findCsiEndIndexesByKeywordPatterns

        public java.util.List<java.lang.Integer> findCsiEndIndexesByKeywordPatterns()
        Find CSI end indexes from a query detail.
        Returns:
        The indexes.
      • findIndexesByKeywordPattern

        protected java.util.List<java.lang.Integer> findIndexesByKeywordPattern​(java.util.regex.Pattern pattern)
      • findIndexesByKeywordPattern

        protected java.util.List<java.lang.Integer> findIndexesByKeywordPattern​(java.util.regex.Pattern pattern,
                                                                                java.lang.String queryString)
      • findIndexesByKeywordPattern

        protected java.util.List<java.lang.Integer> findIndexesByKeywordPattern​(java.util.regex.Pattern pattern,
                                                                                java.lang.String queryString,
                                                                                boolean shouldAtNewLine)
        Find the indexes of the matched pattern.
        Parameters:
        pattern - The pattern.
        queryString - The string to query.
        shouldAtNewLine - The pattern should be at the start of a new line right after an empty line.
        Returns:
        The indexes found.
      • alignBaseAndTargetQueries

        public static java.lang.String[] alignBaseAndTargetQueries​(java.lang.String base,
                                                                   java.lang.String target)
        Align the base and target query string.
        Parameters:
        base - The base query string.
        target - The target query string.
        Returns:
        A 2-dimension array which stores the aligned base and target query respectively.
      • setServerLocale

        public void setServerLocale​(java.util.Set<java.util.Locale> serverLocale)