@@ -26,8 +26,8 @@ public class DDLCommandEnlist {
2626 private Boolean [] notNulls ;
2727 private Map <String , String > columnMap = new HashMap <>();
2828
29- private void enlistCreateTable (String _sql , DDLType _ddlType ) throws SQLException {
30- String tn = _ddlType .getDBObjectName ();
29+ private void enlistCreateTable (String sql , DDLType ddlType ) throws SQLException {
30+ String tn = ddlType .getDBObjectName ();
3131 UcanaccessConnection ac = UcanaccessConnection .getCtxConnection ();
3232 String execId = UcanaccessConnection .getCtxExcId ();
3333 Connection hsqlConn = ac .getHSQLDBConnection ();
@@ -40,12 +40,12 @@ private void enlistCreateTable(String _sql, DDLType _ddlType) throws SQLExceptio
4040
4141 lfa .synchronisationTriggers (ntn , true , true );
4242 CreateTableCommand c4io ;
43- if (_ddlType .equals (DDLType .CREATE_TABLE )) {
44- parseTypesFromCreateStatement (_sql );
43+ if (ddlType .equals (DDLType .CREATE_TABLE )) {
44+ parseTypesFromCreateStatement (sql );
4545 c4io = new CreateTableCommand (tn , execId , columnMap , types , defaults , notNulls );
4646 } else {
4747 try (UcanaccessStatement st = ac .createStatement ()) {
48- ResultSet rs = st .executeQuery (_ddlType .getSelect (_sql ));
48+ ResultSet rs = st .executeQuery (ddlType .getSelect (sql ));
4949 ResultSetMetaData rsmd = rs .getMetaData ();
5050 Metadata mt = new Metadata (ac .getHSQLDBConnection ());
5151 for (int i = 1 ; i <= rsmd .getColumnCount (); i ++) {
@@ -58,7 +58,7 @@ private void enlistCreateTable(String _sql, DDLType _ddlType) throws SQLExceptio
5858 }
5959 }
6060 c4io = new CreateTableCommand (tn , execId , columnMap );
61- } catch (Exception _ignored ) {
61+ } catch (Exception ignored ) {
6262 c4io = new CreateTableCommand (tn , execId );
6363 }
6464
@@ -102,10 +102,10 @@ public void enlistDDLCommand(String sql, DDLType ddlType) throws SQLException {
102102 }
103103 }
104104
105- private void enlistCreateForeignKey (DDLType _ddlType ) throws SQLException {
106- String tableName = _ddlType .getDBObjectName ();
107- String relationshipName = _ddlType .getSecondDBObjectName ();
108- String referencedTable = _ddlType .getThirdDBObjectName ();
105+ private void enlistCreateForeignKey (DDLType ddlType ) throws SQLException {
106+ String tableName = ddlType .getDBObjectName ();
107+ String relationshipName = ddlType .getSecondDBObjectName ();
108+ String referencedTable = ddlType .getThirdDBObjectName ();
109109 String execId = UcanaccessConnection .getCtxExcId ();
110110 CreateForeignKeyCommand c4io =
111111 new CreateForeignKeyCommand (tableName , referencedTable , execId , relationshipName );
@@ -202,34 +202,34 @@ private void enlistAlterRename(DDLType ddlType) throws SQLException {
202202 }
203203 }
204204
205- private String [] checkEscaped (String _ll , String _rl , String [] _colDecls , String _tknt ) {
206- if (_colDecls [0 ].startsWith (_ll ) && _tknt .indexOf (_rl , 1 ) > 0 ) {
207- for (int k = 0 ; k < _colDecls .length ; k ++) {
208- if (_colDecls [k ].endsWith (_rl )) {
209- String [] colDecls0 = new String [_colDecls .length - k ];
210- colDecls0 [0 ] = _tknt .substring (1 , _tknt .substring (1 ).indexOf (_rl ) + 1 );
211- System .arraycopy (_colDecls , 1 + k , colDecls0 , 1 , colDecls0 .length - 1 );
212- _colDecls = colDecls0 ;
205+ private String [] checkEscaped (String ll , String rl , String [] colDecls , String tknt ) {
206+ if (colDecls [0 ].startsWith (ll ) && tknt .indexOf (rl , 1 ) > 0 ) {
207+ for (int k = 0 ; k < colDecls .length ; k ++) {
208+ if (colDecls [k ].endsWith (rl )) {
209+ String [] colDecls0 = new String [colDecls .length - k ];
210+ colDecls0 [0 ] = tknt .substring (1 , tknt .substring (1 ).indexOf (rl ) + 1 );
211+ System .arraycopy (colDecls , 1 + k , colDecls0 , 1 , colDecls0 .length - 1 );
212+ colDecls = colDecls0 ;
213213 break ;
214214 }
215215 }
216216 }
217- return _colDecls ;
217+ return colDecls ;
218218 }
219219
220- private void parseColumnTypes (List <String > _typeList , List <String > _defaultList , List <Boolean > _notNullList , String _tknt ) {
221- String [] colDecls = _tknt .split ("\\ s+" );
222- colDecls = checkEscaped ("[" , "]" , colDecls , _tknt );
223- colDecls = checkEscaped ("`" , "`" , colDecls , _tknt );
220+ private void parseColumnTypes (List <String > typeList , List <String > defaultList , List <Boolean > notNullList , String tknt ) {
221+ String [] colDecls = tknt .split ("\\ s+" );
222+ colDecls = checkEscaped ("[" , "]" , colDecls , tknt );
223+ colDecls = checkEscaped ("`" , "`" , colDecls , tknt );
224224 String escaped = SQLConverter .isListedAsKeyword (colDecls [0 ]) ? colDecls [0 ].toUpperCase ()
225225 : SQLConverter .basicEscapingIdentifier (colDecls [0 ]);
226226 columnMap .put (escaped , colDecls [0 ]);
227227
228228 boolean reset = false ;
229- if (_tknt .matches ("\\ s*\\ d+\\ s*\\ ).*" )) {
229+ if (tknt .matches ("\\ s*\\ d+\\ s*\\ ).*" )) {
230230 reset = true ;
231- _tknt = _tknt .substring (_tknt .indexOf (')' ) + 1 ).trim ();
232- colDecls = _tknt .split ("\\ s+" );
231+ tknt = tknt .substring (tknt .indexOf (')' ) + 1 ).trim ();
232+ colDecls = tknt .split ("\\ s+" );
233233 }
234234
235235 if (!reset && colDecls .length < 2 ) {
@@ -241,31 +241,31 @@ private void parseColumnTypes(List<String> _typeList, List<String> _defaultList,
241241 colDecls [1 ] = "NUMERIC" ;
242242 decDef = true ;
243243 }
244- _typeList .add (colDecls [1 ]);
244+ typeList .add (colDecls [1 ]);
245245
246246 }
247247
248248 if ((colDecls .length > 2 || reset && colDecls .length == 2 )
249249 && "not" .equalsIgnoreCase (colDecls [colDecls .length - 2 ])
250250 && "null" .equalsIgnoreCase (colDecls [colDecls .length - 1 ])) {
251- _notNullList .add (true );
251+ notNullList .add (true );
252252 } else if (!decDef ) {
253- _notNullList .add (false );
253+ notNullList .add (false );
254254 }
255255
256256 if (!decDef ) {
257- _defaultList .add (value (SQLConverter .getDDLDefault (_tknt )));
257+ defaultList .add (value (SQLConverter .getDDLDefault (tknt )));
258258 }
259259
260- types = _typeList .toArray (new String [0 ]);
261- defaults = _defaultList .toArray (new String [0 ]);
262- notNulls = _notNullList .toArray (new Boolean [0 ]);
260+ types = typeList .toArray (new String [0 ]);
261+ defaults = defaultList .toArray (new String [0 ]);
262+ notNulls = notNullList .toArray (new Boolean [0 ]);
263263 }
264264
265265 // getting AUTOINCREMENT and GUID
266- private void parseTypesFromCreateStatement (String _sql ) throws SQLException {
266+ private void parseTypesFromCreateStatement (String inputSql ) throws SQLException {
267267 Pattern pat = Pattern .compile ("(\\ s+)(?:DECIMAL|NUMERIC)\\ s*\\ (" , Pattern .CASE_INSENSITIVE );
268- String sql = pat .matcher (_sql ).replaceAll ("$1NUMERIC(" );
268+ String sql = pat .matcher (inputSql ).replaceAll ("$1NUMERIC(" );
269269 int startDecl = sql .indexOf ('(' );
270270 int endDecl = sql .lastIndexOf (')' );
271271
@@ -286,17 +286,17 @@ private void parseTypesFromCreateStatement(String _sql) throws SQLException {
286286 }
287287 }
288288
289- private String value (String _value ) {
290- if (_value == null ) {
289+ private String value (String value ) {
290+ if (value == null ) {
291291 return null ;
292292 }
293- if (_value .startsWith ("\" " ) && _value .endsWith ("\" " )) {
294- return _value .substring (1 , _value .length () - 1 ).replace ("\" \" " , "\" " );
293+ if (value .startsWith ("\" " ) && value .endsWith ("\" " )) {
294+ return value .substring (1 , value .length () - 1 ).replace ("\" \" " , "\" " );
295295 }
296- if (_value .startsWith ("'" ) && _value .endsWith ("'" )) {
297- return _value .substring (1 , _value .length () - 1 ).replace ("''" , "'" );
296+ if (value .startsWith ("'" ) && value .endsWith ("'" )) {
297+ return value .substring (1 , value .length () - 1 ).replace ("''" , "'" );
298298 }
299- return _value ;
299+ return value ;
300300 }
301301
302302}
0 commit comments