Improved unit tests for AveragingProgressTracker class
[controller.git] / opendaylight / md-sal / sal-dom-xsql / src / main / java / org / opendaylight / controller / md / sal / dom / xsql / jdbc / JDBCServer.java
index b348d8fda8b64da5509c39346e976e59b453ed99..2b50a4d87e0e4cd9158a54d99b5637f287d0b4ff 100644 (file)
@@ -1,3 +1,11 @@
+/*
+ * Copyright (c) 2014, 2015 Cisco Systems, Inc. and others.  All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+
 package org.opendaylight.controller.md.sal.dom.xsql.jdbc;
 
 import java.net.ServerSocket;
@@ -15,6 +23,10 @@ import org.opendaylight.controller.md.sal.dom.xsql.XSQLBluePrintNode;
 import org.opendaylight.controller.md.sal.dom.xsql.XSQLColumn;
 import org.opendaylight.controller.md.sal.dom.xsql.XSQLCriteria;
 
+/**
+ * To be removed in Nitrogen
+ */
+@Deprecated
 public class JDBCServer extends Thread {
     private ServerSocket socket = null;
     private XSQLAdapter adapter = null;
@@ -46,8 +58,7 @@ public class JDBCServer extends Thread {
         }
     }
 
-    public static void execute(JDBCResultSet rs, XSQLAdapter adapter)
-            throws SQLException {
+    public static void execute(JDBCResultSet rs, XSQLAdapter adapter)throws SQLException {
         if(rs.getSQL().toLowerCase().trim().equals("select 1")){
             rs.setFinished(true);
             return;
@@ -99,8 +110,8 @@ public class JDBCServer extends Thread {
             return;
         }
 
-        Map<String, XSQLBluePrintNode> logicalNameToNode = new HashMap<String, XSQLBluePrintNode>();
-        Map<String, String> origNameToName = new HashMap<String, String>();
+        Map<String, XSQLBluePrintNode> logicalNameToNode = new HashMap<>();
+        Map<String, String> origNameToName = new HashMap<>();
         List<XSQLColumn> columnOrder = new ArrayList<>();
         int nextLogField = addNextLogicalField(sql, 0,
                 logicalNameToNode, origNameToName,columnOrder);
@@ -193,10 +204,12 @@ public class JDBCServer extends Thread {
             int braketCount = 0;
             int endSubQuery = startSubQuery;
             do {
-                if (sql.charAt(endSubQuery) == '(')
+                if (sql.charAt(endSubQuery) == '(') {
                     braketCount++;
-                else if (sql.charAt(endSubQuery) == ')')
+                }
+                else if (sql.charAt(endSubQuery) == ')') {
                     braketCount--;
+                }
                 endSubQuery++;
             } while (braketCount > 0 || endSubQuery == sql.length());
             String subQuerySQL = sql.substring(startSubQuery + 1,endSubQuery - 1);
@@ -260,12 +273,12 @@ public class JDBCServer extends Thread {
         Map<XSQLColumn, List<XSQLCriteria>> tblCriteria = rs.getCriteria().get(
                 col.getTableName());
         if (tblCriteria == null) {
-            tblCriteria = new ConcurrentHashMap<XSQLColumn, List<XSQLCriteria>>();
+            tblCriteria = new ConcurrentHashMap<>();
             rs.getCriteria().put(col.getTableName(), tblCriteria);
         }
         List<XSQLCriteria> lstCriteria = tblCriteria.get(col);
         if (lstCriteria == null) {
-            lstCriteria = new ArrayList<XSQLCriteria>();
+            lstCriteria = new ArrayList<>();
             tblCriteria.put(col, lstCriteria);
         }
         lstCriteria.add(c);
@@ -338,8 +351,9 @@ public class JDBCServer extends Thread {
             whereTo = order;
         }
 
-        if(whereTo==-1)
+        if(whereTo==-1) {
             whereTo=lowSQL.length();
+        }
 
         String whereStatement = rs.getSQL().substring(where + 5, whereTo)
                 .trim();