Check if a SQL string is a comment.
@param sql  SQL string
@return     true if it's a comment
485851
public static boolean isComment(String sql)
    {
        Matcher commentMatcher = PAT_SINGLE_LINE_COMMENT.matcher(sql);
        return commentMatcher.matches();
    }
605251
protected void parseComment() {
        int commentEndPos = sql.indexOf("*/", position);
        int commentEndPos2 = sql.indexOf("*#", position);
        if (0 < commentEndPos2 && commentEndPos2 < commentEndPos) {
            commentEndPos = commentEndPos2;
        }
        if (commentEndPos < 0) {
            throw new TwoWaySQLException(String.format(
                    "%s is not closed with %s.", sql.substring(position), "*/"));
        }
        token = sql.substring(position, commentEndPos);
        nextTokenType = TokenType.SQL;
        position = commentEndPos + 2;
        tokenType = TokenType.COMMENT;
    }
379202
public static boolean isStatement(JCTree tree) {
        return (tree instanceof JCStatement) &&
                !tree.hasTag(CLASSDEF) &&
                !tree.hasTag(Tag.BLOCK) &&
                !tree.hasTag(METHODDEF);
    }
622896
function isCommentLine (line) {
  var isCmnt = commentRE.test(line);
  if (isCmnt) {
    debug('removing comment: %s', line);
  }
  return !isCmnt;
}
75268
public static SQLiteStatement compile(SQLContext context, String sql) {
		SQLiteStatement ps = context.database().compileStatement(sql);
		
		return ps;
	}
754068
public final void mSTATEMENT_COMMENT() throws RecognitionException {
        try {
            int _type = STATEMENT_COMMENT;
            int _channel = DEFAULT_TOKEN_CHANNEL;
            // BELScript.g:257:18: ( '//' ( ( '\\\\\\n' ) | ( '\\\\\\r\\n' ) | ~ ( '\\n' | '\\r' ) )* )
            // BELScript.g:258:5: '//' ( ( '\\\\\\n' ) | ( '\\\\\\r\\n' ) | ~ ( '\\n' | '\\r' ) )*
            {
            match("//"); 

            // BELScript.g:258:10: ( ( '\\\\\\n' ) | ( '\\\\\\r\\n' ) | ~ ( '\\n' | '\\r' ) )*
            loop2:
            do {
                int alt2=4;
                int LA2_0 = input.LA(1);

                if ( (LA2_0=='\\') ) {
                    switch ( input.LA(2) ) {
                    case '\n':
                        {
                        alt2=1;
                        }
                        break;
                    case '\r':
                        {
                        alt2=2;
                        }
                        break;

                    default:
                        alt2=3;
                        break;
                    }

                }
                else if ( ((LA2_0>='\u0000' && LA2_0<='\t')||(LA2_0>='\u000B' && LA2_0<='\f')||(LA2_0>='\u000E' && LA2_0<='[')||(LA2_0>=']' && LA2_0<='\uFFFF')) ) {
                    alt2=3;
                }


                switch (alt2) {
            	case 1 :
            	    // BELScript.g:258:11: ( '\\\\\\n' )
            	    {
            	    // BELScript.g:258:11: ( '\\\\\\n' )
            	    // BELScript.g:258:12: '\\\\\\n'
            	    {
            	    match("\\\n"); 


            	    }


            	    }
            	    break;
            	case 2 :
            	    // BELScript.g:258:22: ( '\\\\\\r\\n' )
            	    {
            	    // BELScript.g:258:22: ( '\\\\\\r\\n' )
            	    // BELScript.g:258:23: '\\\\\\r\\n'
            	    {
            	    match("\\\r\n"); 


            	    }


            	    }
            	    break;
            	case 3 :
            	    // BELScript.g:258:35: ~ ( '\\n' | '\\r' )
            	    {
            	    if ( (input.LA(1)>='\u0000' && input.LA(1)<='\t')||(input.LA(1)>='\u000B' && input.LA(1)<='\f')||(input.LA(1)>='\u000E' && input.LA(1)<='\uFFFF') ) {
            	        input.consume();

            	    }
            	    else {
            	        MismatchedSetException mse = new MismatchedSetException(null,input);
            	        recover(mse);
            	        throw mse;}


            	    }
            	    break;

            	default :
            	    break loop2;
                }
            } while (true);


            }

            state.type = _type;
            state.channel = _channel;
        }
        finally {
        }
    }
305675
static public SFStatementType checkStageManageCommand(String sql)
  {
    if (sql == null)
    {
      return null;
    }

    String trimmedSql = sql.trim();

    // skip commenting prefixed with //
    while (trimmedSql.startsWith("//"))
    {
      logger.debug("skipping // comments in: \n{}", trimmedSql);

      if (trimmedSql.indexOf('\n') > 0)
      {
        trimmedSql = trimmedSql.substring(trimmedSql.indexOf('\n'));
        trimmedSql = trimmedSql.trim();
      }
      else
      {
        break;
      }

      logger.debug("New sql after skipping // comments: \n{}",
                   trimmedSql);

    }

    // skip commenting enclosed with /* */
    while (trimmedSql.startsWith("/*"))
    {
      logger.debug("skipping /* */ comments in: \n{}", trimmedSql);

      if (trimmedSql.indexOf("*/") > 0)
      {
        trimmedSql = trimmedSql.substring(trimmedSql.indexOf("*/") + 2);
        trimmedSql = trimmedSql.trim();
      }
      else
      {
        break;

      }
      logger.debug("New sql after skipping /* */ comments: \n{}", trimmedSql);

    }

    trimmedSql = trimmedSql.toLowerCase();

    if (trimmedSql.startsWith("put "))
    {
      return SFStatementType.PUT;
    }
    else if (trimmedSql.startsWith("get "))
    {
      return SFStatementType.GET;
    }
    else if (trimmedSql.startsWith("ls ") ||
             trimmedSql.startsWith("list "))
    {
      return SFStatementType.LIST;
    }
    else if (trimmedSql.startsWith("rm ") ||
             trimmedSql.startsWith("remove "))
    {
      return SFStatementType.REMOVE;
    }
    else
    {
      return null;
    }
  }
494250
private boolean isComment(String line) {
        String trimmed = line.trim();
        if (trimmed.length() == 0) {
            return false;
        }
        return trimmed.charAt(0) == '#';
    }
134943
protected boolean isInCondition(String sql){
		Connection conn = null;
		Statement stmt = null;
		ResultSet rs = null;
		try{
			conn = dataSource.getConnection();
			stmt = conn.createStatement();
			rs = stmt.executeQuery(sql);
			rs.next();
			long result = rs.getInt(1);
			log.debug("Result from the condition checking SQL is " + result + " : " + sql);
			return result > 0;
		} catch (SQLException sqle) {
			throw new RuntimeException("Unable to check condition (" + sqle.getMessage() + ") for: " + sql, sqle);
		}finally{
			ConnectionUtility.closeConnection(conn, stmt, rs);
		}
	}
253947
public static String getWhereClause (String sql) {
        if (null == sql ) return null;

        String s = sql.trim();
        int len = s.length();
        int last = s.lastIndexOf("AND");
        if (len > 0 && (last == len -3)) {
            if (s.indexOf("WHERE") == -1) {
                s = "WHERE " + s.substring(0,len-3);
            } else {
                s = s.substring(0,len-3);
            }
        }
        return s;
    }
609968
public static final String sqlEscape(final String sql) {
        if (sql == null) {
            return "";
        }

        int primePos = sql.indexOf("'");

        if (primePos == -1) {
            return sql;
        }

        final StringBuffer sb = new StringBuffer(sql.length() + 4);
        int startPos = 0;

        do {
            sb.append(sql.substring(startPos, primePos + 1));
            sb.append("'");
            startPos = primePos + 1;
            primePos = sql.indexOf("'", startPos);
        } while (primePos != -1);

        sb.append(sql.substring(startPos));
        return sb.toString();
    }
185065
private Map<String, String> parseComment(String sql) {
		Map<String, String> commentMap = new HashMap<String, String>();
		try {
		while (StringUtils.contains(sql, "/*") && StringUtils.contains(sql, "*/")) {
			String comment = StringUtils.substringBetween(sql, "/*", "*/");
			comment = comment.toUpperCase().trim();

			if (StringUtils.isNotEmpty(comment)) {
				if (comment.contains("NO_CACHE")) {
					commentMap.put("CACHE", "FALSE");
				}
				String commentItems[] = comment.split(",");
				for (String commentItem : commentItems) {
					if (commentItem != null && commentItem.contains("=")) {
						String value[] = commentItem.trim().split("=");
						if (value != null && value.length == 2) {
							commentMap.put(value[0].trim(), value[1].trim());
						}
					}
				}
			}

			sql = StringUtils.substringBefore(sql, "/*") + StringUtils.substringAfter(sql, "*/");
		}
		} catch (Exception e) {
			logger.error("Parse sql comment fail:" + sql);
		}
		return commentMap;
	}
118208
public boolean isPanelsComment(QueryQuestionComment comment, Panel panel) {
    Panel queryPanel = resourceController.getResourcePanel(comment.getQueryPage().getQuerySection().getQuery());
    if (queryPanel == null || panel == null) {
      return false;
    }
    
    return queryPanel.getId().equals(panel.getId());
  }
1057540
private boolean verify() throws SQLException {
    //check total num pageview
    String countAccessQuery = "SELECT COUNT(*) FROM Access";
    String sumPageviewQuery = "SELECT SUM(pageview) FROM Pageview";
    Statement st = null;
    ResultSet rs = null;
    try {
      st = connection.createStatement();
      rs = st.executeQuery(countAccessQuery);
      rs.next();
      long totalPageview = rs.getLong(1);

      rs = st.executeQuery(sumPageviewQuery);
      rs.next();
      long sumPageview = rs.getLong(1);

      LOG.info("totalPageview=" + totalPageview);
      LOG.info("sumPageview=" + sumPageview);

      return totalPageview == sumPageview && totalPageview != 0;
    }finally {
      if(st != null)
        st.close();
      if(rs != null)
        rs.close();
    }
  }
783868
function isConsecutiveComment(comment) {
            const previousTokenOrComment = sourceCode.getTokenBefore(comment, { includeComments: true });

            return Boolean(
                previousTokenOrComment &&
                ["Block", "Line"].indexOf(previousTokenOrComment.type) !== -1
            );
        }
1252103
private static String sqlFilter(String sql) {
        sql = sql.replace(", WHERE", " WHERE").replace("AND  OR", "OR");
        if (sql.endsWith(Const.SPACE + Const.SQL_AND + Const.SPACE)) {
            sql = sql.substring(0, sql.length() - 5);
        }
        if (sql.endsWith(", ")) {
            sql = sql.substring(0, sql.length() - 2);
        }
        return sql;
    }
1094228
private void get(final StringBuilder sql) {
        sql.append("SELECT * FROM ").append(getName()).append(" WHERE ").append(JdbcRepositories.getDefaultKeyName()).append(" = ?");
    }