public static HSQLDDLInfo preprocessHSQLDDL ( String ddl ) { ddl = SQLLexer . stripComments ( ddl ) ; Matcher matcher = HSQL_DDL_PREPROCESSOR . matcher ( ddl ) ; if ( matcher . find ( ) ) { String verbString = matcher . group ( "verb" ) ; HSQLDDLInfo . Verb verb = HSQLDDLInfo . Verb . get ( verbString ) ; if ( verb == null ) { return null ; } String nounString = matcher . group ( "object" ) ; HSQLDDLInfo . Noun noun = HSQLDDLInfo . Noun . get ( nounString ) ; if ( noun == null ) { return null ; } boolean createStream = verb . equals ( HSQLDDLInfo . Verb . CREATE ) && noun . equals ( HSQLDDLInfo . Noun . STREAM ) ; String name = matcher . group ( "name" ) ; if ( name == null ) { return null ; } String secondName = matcher . group ( "subject" ) ; if ( secondName != null ) { secondName = secondName . toLowerCase ( ) ; } // cascade/if exists are interesting on alters and drops boolean cascade = false ; boolean ifexists = false ; if ( verb != HSQLDDLInfo . Verb . CREATE ) { matcher = DDL_IFEXISTS_OR_CASCADE_CHECK . matcher ( ddl ) ; if ( matcher . matches ( ) ) { // Don't be too sensitive to regex specifics by assuming null always // indicates a missing clause. Look for empty too. String existsClause = matcher . group ( "exists" ) ; String cascadeClause = matcher . group ( "cascade" ) ; ifexists = existsClause != null && ! existsClause . isEmpty ( ) ; cascade = cascadeClause != null && ! cascadeClause . isEmpty ( ) ; } } return new HSQLDDLInfo ( verb , noun , name . toLowerCase ( ) , secondName , cascade , ifexists , createStream ) ; } return null ; }
Glean some basic info about DDL statements sent to HSQLDB