@Test public void testCreateLabelDropTable() { assertEquals("CQL DROP TABLE (FUBAR)", CassandraOperationFinalizer.createLabel("drop table fubar")); assertEquals("CQL DROP TABLE IF EXISTS (FUBAR)", CassandraOperationFinalizer.createLabel("drop table if exists fubar")); assertEquals("CQL DROP TABLE", CassandraOperationFinalizer.createLabel("drop table")); }
public static String createLabel(String cql) { if (StringUtil.isEmpty(cql)) { return "CQL"; } String upperSql = cql.toUpperCase().trim(); for (Keywords keywords : stmtsList) { String kwd = keywords.getKeyword(); if (!upperSql.startsWith(kwd)) { continue; } String argPos = keywords.getArgPos(); return appendArgumentValue("CQL " + kwd, captureWordAfter(upperSql, argPos)); } if (upperSql.startsWith("CREATE") || upperSql.startsWith("DROP") || upperSql.startsWith("ALTER") ) { return "CQL DML"; } else { return "CQL STATEMENT"; } }
CassandraOperationFinalizer { public static String createLabel(String cql) { if (StringUtil.isEmpty(cql)) { return "CQL"; } String upperSql = cql.toUpperCase().trim(); for (Keywords keywords : stmtsList) { String kwd = keywords.getKeyword(); if (!upperSql.startsWith(kwd)) { continue; } String argPos = keywords.getArgPos(); return appendArgumentValue("CQL " + kwd, captureWordAfter(upperSql, argPos)); } if (upperSql.startsWith("CREATE") || upperSql.startsWith("DROP") || upperSql.startsWith("ALTER") ) { return "CQL DML"; } else { return "CQL STATEMENT"; } } }
CassandraOperationFinalizer { public static String createLabel(String cql) { if (StringUtil.isEmpty(cql)) { return "CQL"; } String upperSql = cql.toUpperCase().trim(); for (Keywords keywords : stmtsList) { String kwd = keywords.getKeyword(); if (!upperSql.startsWith(kwd)) { continue; } String argPos = keywords.getArgPos(); return appendArgumentValue("CQL " + kwd, captureWordAfter(upperSql, argPos)); } if (upperSql.startsWith("CREATE") || upperSql.startsWith("DROP") || upperSql.startsWith("ALTER") ) { return "CQL DML"; } else { return "CQL STATEMENT"; } } private  CassandraOperationFinalizer(); }
CassandraOperationFinalizer { public static String createLabel(String cql) { if (StringUtil.isEmpty(cql)) { return "CQL"; } String upperSql = cql.toUpperCase().trim(); for (Keywords keywords : stmtsList) { String kwd = keywords.getKeyword(); if (!upperSql.startsWith(kwd)) { continue; } String argPos = keywords.getArgPos(); return appendArgumentValue("CQL " + kwd, captureWordAfter(upperSql, argPos)); } if (upperSql.startsWith("CREATE") || upperSql.startsWith("DROP") || upperSql.startsWith("ALTER") ) { return "CQL DML"; } else { return "CQL STATEMENT"; } } private  CassandraOperationFinalizer(); static Operation get(Statement statement); static Operation put(Statement statement, Operation operation); static Operation remove(Statement statement); static void addParam(Operation operation, String key, Object param); static void addParam(Operation operation, int index, Object param); static String createLabel(String cql); }
CassandraOperationFinalizer { public static String createLabel(String cql) { if (StringUtil.isEmpty(cql)) { return "CQL"; } String upperSql = cql.toUpperCase().trim(); for (Keywords keywords : stmtsList) { String kwd = keywords.getKeyword(); if (!upperSql.startsWith(kwd)) { continue; } String argPos = keywords.getArgPos(); return appendArgumentValue("CQL " + kwd, captureWordAfter(upperSql, argPos)); } if (upperSql.startsWith("CREATE") || upperSql.startsWith("DROP") || upperSql.startsWith("ALTER") ) { return "CQL DML"; } else { return "CQL STATEMENT"; } } private  CassandraOperationFinalizer(); static Operation get(Statement statement); static Operation put(Statement statement, Operation operation); static Operation remove(Statement statement); static void addParam(Operation operation, String key, Object param); static void addParam(Operation operation, int index, Object param); static String createLabel(String cql); static final String KEYSPACE; static final String CLUSTER_NAME; static final String PORT; static final String HOSTS; static final String PARAMS_VALUES; static final String UNKNOWN_CQL; }