Package org.pentaho.di.core.database
Class SqlCommentScrubber
java.lang.Object
org.pentaho.di.core.database.SqlCommentScrubber
Deprecated.
Use SqlScriptParser instead.
This class represents a parser that will remove SQL comments (both multi-line and single-line) from a string
representing a SQL query. It respects the notion of a string literal, such that if a comment appears in a string
literal, it is treated as part of the string instead of a comment. Both single-quoted and double-quoted string
literals are supported, including nested quotes (whether the SQL dialect supports them or not).
- Author:
- Matt Burgess
-
Field Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic String
removeComments
(String text) Deprecated.This method will remove SQL comments (both multi-line and single-line) from a string representing a SQL query.
-
Field Details
-
EOF
public static final int EOFDeprecated.End-of-File (EOF) indicator- See Also:
-
EOL
public static final int EOLDeprecated.End-of-Line (EOL) indicator- See Also:
-
-
Method Details
-
removeComments
Deprecated.This method will remove SQL comments (both multi-line and single-line) from a string representing a SQL query. It respects the notion of a string literal, such that if a comment appears in a string literal, it is treated as part of the string instead of a comment. A simple state machine is implemented, keeping track of whether the current character is starting, ending, or inside a comment construct. The state machine also checks to see if the current character is starting, ending, or inside a single-quoted string literal, as this takes precedence over comment constructs. In other words, comments inside strings are not actually comments, they are part of the string literal.- Parameters:
text
- a string representing the SQL query to parse and from which to remove comments- Returns:
- the input string with SQL comments removed, or null if the input string is null
-