public static TableLocation parse ( String concatenatedTableLocation , Boolean isH2Database ) { List < String > parts = new LinkedList < String > ( ) ; String catalog , schema , table ; catalog = table = schema = "" ; StringTokenizer st = new StringTokenizer ( concatenatedTableLocation , ".`\"" , true ) ; boolean openQuote = false ; StringBuilder sb = new StringBuilder ( ) ; while ( st . hasMoreTokens ( ) ) { String token = st . nextToken ( ) ; if ( token . equals ( "`" ) || token . equals ( "\"" ) ) { openQuote = ! openQuote ; } else if ( token . equals ( "." ) ) { if ( openQuote ) { // Still in part sb . append ( token ) ; } else { // end of part parts . add ( sb . toString ( ) ) ; sb = new StringBuilder ( ) ; } } else { if ( ! openQuote && isH2Database != null ) { token = capsIdentifier ( token , isH2Database ) ; } sb . append ( token ) ; } } if ( sb . length ( ) != 0 ) { parts . add ( sb . toString ( ) ) ; } String [ ] values = parts . toArray ( new String [ 0 ] ) ; switch ( values . length ) { case 1 : table = values [ 0 ] . trim ( ) ; break ; case 2 : schema = values [ 0 ] . trim ( ) ; table = values [ 1 ] . trim ( ) ; break ; case 3 : catalog = values [ 0 ] . trim ( ) ; schema = values [ 1 ] . trim ( ) ; table = values [ 2 ] . trim ( ) ; } return new TableLocation ( catalog , schema , table ) ; }
Convert catalog . schema . table schema . table or table into a TableLocation instance . Non - specified schema or catalogs are converted to the empty string .