incubator-blur-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From amccu...@apache.org
Subject [8/17] Changing license header to Apache for blur-jdbc.
Date Mon, 03 Sep 2012 02:25:02 GMT
http://git-wip-us.apache.org/repos/asf/incubator-blur/blob/4437d316/src/blur-jdbc/src/main/java/com/nearinfinity/blur/jdbc/util/SimpleStringResultSet.java
----------------------------------------------------------------------
diff --git a/src/blur-jdbc/src/main/java/com/nearinfinity/blur/jdbc/util/SimpleStringResultSet.java
b/src/blur-jdbc/src/main/java/com/nearinfinity/blur/jdbc/util/SimpleStringResultSet.java
index 9688cbe..3e939bf 100644
--- a/src/blur-jdbc/src/main/java/com/nearinfinity/blur/jdbc/util/SimpleStringResultSet.java
+++ b/src/blur-jdbc/src/main/java/com/nearinfinity/blur/jdbc/util/SimpleStringResultSet.java
@@ -1,5 +1,21 @@
 package com.nearinfinity.blur.jdbc.util;
 
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
 import java.sql.ResultSetMetaData;
 import java.sql.SQLException;
 import java.sql.Types;
@@ -10,75 +26,75 @@ import com.nearinfinity.blur.jdbc.abstractimpl.AbstractBlurResultSet;
 import com.nearinfinity.blur.jdbc.abstractimpl.AbstractBlurResultSetMetaData;
 
 public class SimpleStringResultSet extends AbstractBlurResultSet {
-    
-    private List<String> columnNames;
-    private List<Map<String, String>> data;
-    private int position = -1;
-    private String lastValue;
 
-    public SimpleStringResultSet(List<String> columnNames, List<Map<String,String>>
data) {
-        this.columnNames = columnNames;
-        this.data = data;
+  private List<String> columnNames;
+  private List<Map<String, String>> data;
+  private int position = -1;
+  private String lastValue;
+
+  public SimpleStringResultSet(List<String> columnNames, List<Map<String, String>>
data) {
+    this.columnNames = columnNames;
+    this.data = data;
+  }
+
+  @Override
+  public ResultSetMetaData getMetaData() throws SQLException {
+    return new SimpleStringResultSetMetaData(columnNames);
+  }
+
+  @Override
+  public boolean next() throws SQLException {
+    if (position + 1 >= data.size()) {
+      return false;
     }
+    position++;
+    return true;
+  }
 
-    @Override
-    public ResultSetMetaData getMetaData() throws SQLException {
-        return new SimpleStringResultSetMetaData(columnNames);
+  @Override
+  public String getString(int columnIndex) throws SQLException {
+    String name = columnNames.get(columnIndex - 1);
+    Map<String, String> row = data.get(position);
+    return lastValue = row.get(name);
+  }
+
+  @Override
+  public boolean wasNull() throws SQLException {
+    return lastValue == null ? true : false;
+  }
+
+  @Override
+  public void close() throws SQLException {
+
+  }
+
+  public static class SimpleStringResultSetMetaData extends AbstractBlurResultSetMetaData
{
+
+    private List<String> columnNames;
+
+    public SimpleStringResultSetMetaData(List<String> columnNames) {
+      this.columnNames = columnNames;
     }
 
     @Override
-    public boolean next() throws SQLException {
-        if (position + 1 >= data.size()) {
-            return false;
-        }
-        position++;
-        return true;
+    public int getColumnCount() throws SQLException {
+      return columnNames.size();
     }
 
     @Override
-    public String getString(int columnIndex) throws SQLException {
-        String name = columnNames.get(columnIndex-1);
-        Map<String, String> row = data.get(position);
-        return lastValue = row.get(name);
+    public String getColumnName(int column) throws SQLException {
+      return columnNames.get(column - 1);
     }
-    
+
     @Override
-    public boolean wasNull() throws SQLException {
-        return lastValue == null ? true : false;
+    public int getColumnType(int column) throws SQLException {
+      return Types.VARCHAR;
     }
-    
+
     @Override
-    public void close() throws SQLException {
-        
-    }
-    
-    public static class SimpleStringResultSetMetaData extends AbstractBlurResultSetMetaData
{
-
-        private List<String> columnNames;
-
-        public SimpleStringResultSetMetaData(List<String> columnNames) {
-            this.columnNames = columnNames;
-        }
-
-        @Override
-        public int getColumnCount() throws SQLException {
-            return columnNames.size();
-        }
-
-        @Override
-        public String getColumnName(int column) throws SQLException {
-            return columnNames.get(column - 1);
-        }
-
-        @Override
-        public int getColumnType(int column) throws SQLException {
-            return Types.VARCHAR;
-        }
-
-        @Override
-        public String getColumnTypeName(int column) throws SQLException {
-            return "string";
-        }
-        
+    public String getColumnTypeName(int column) throws SQLException {
+      return "string";
     }
+
+  }
 }

http://git-wip-us.apache.org/repos/asf/incubator-blur/blob/4437d316/src/blur-jdbc/test/com/nearinfinity/blur/jdbc/grammar/BlurParserTest.java
----------------------------------------------------------------------
diff --git a/src/blur-jdbc/test/com/nearinfinity/blur/jdbc/grammar/BlurParserTest.java b/src/blur-jdbc/test/com/nearinfinity/blur/jdbc/grammar/BlurParserTest.java
deleted file mode 100644
index c151b43..0000000
--- a/src/blur-jdbc/test/com/nearinfinity/blur/jdbc/grammar/BlurParserTest.java
+++ /dev/null
@@ -1,148 +0,0 @@
-package com.nearinfinity.blur.jdbc.grammar;
-
-import static org.hamcrest.CoreMatchers.is;
-import static org.junit.Assert.assertThat;
-
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Map;
-
-import org.antlr.runtime.ANTLRStringStream;
-import org.antlr.runtime.CharStream;
-import org.antlr.runtime.CommonTokenStream;
-import org.antlr.runtime.TokenStream;
-import org.junit.Test;
-
-import com.nearinfinity.blur.jdbc.QueryData;
-
-@SuppressWarnings("serial")
-public class BlurParserTest {
-	
-	private BlurLexer blurLexer;
-	private BlurParser blurParser;
-	private CharStream charStream;
-	private TokenStream tokenStream;
-	
-	@Test
-	public void testGetColumnsNoAlias() throws Exception {
-		String query = "select person.pn, person.ln, cert.br, cert.ba from person,certification
where person.pn = 'smith';";
-		setUpParsing(query);
-		List<QueryData> expectedColumns = new ArrayList<QueryData>(){{
-			add(new QueryData("person.pn",null));
-			add(new QueryData("person.ln",null));
-			add(new QueryData("cert.br",null));
-			add(new QueryData("cert.ba",null));
-		}};
-		Map<String,List<QueryData>>columnsTables = blurParser.parse();
-		assertThat(columnsTables.get("columns"),is(expectedColumns));
-	}
-	
-	@Test
-	public void testGetColumnsAlias() throws Exception {
-		String query = "select person.pn as firstName, person.ln as lastName, cert.br as certNumber,
cert.ba as certBar from person,certification where lastName = 'smith';";
-		setUpParsing(query);
-		List<QueryData> expectedColumns = new ArrayList<QueryData>(){{
-			add(new QueryData("person.pn","firstName"));
-			add(new QueryData("person.ln","lastName"));
-			add(new QueryData("cert.br","certNumber"));
-			add(new QueryData("cert.ba","certBar"));
-		}};
-		Map<String,List<QueryData>>columnsTables = blurParser.parse();
-		assertThat(columnsTables.get("columns"),is(expectedColumns));
-	}
-	
-	@Test
-	public void testGetColumnsWithAndWithoutAlias() throws Exception {
-		String query = "select person.pn as firstName, person.ln as lastName, cert.br, cert.ba
from person,certification where lastName = 'smith';";
-		setUpParsing(query);
-		List<QueryData> expectedColumns = new ArrayList<QueryData>(){{
-			add(new QueryData("person.pn","firstName"));
-			add(new QueryData("person.ln","lastName"));
-			add(new QueryData("cert.br",null));
-			add(new QueryData("cert.ba",null));
-		}};
-		Map<String,List<QueryData>>columnsTables = blurParser.parse();
-		assertThat(columnsTables.get("columns"),is(expectedColumns));
-	}
-	
-	@Test
-	public void testGetTableNamesNoAlias() throws Exception {
-		String query = "select person.pn as firstName, person.ln as lastName, cert.br, cert.ba
from person,certification where lastName = 'smith';";
-		setUpParsing(query);
-		List<QueryData> expectedTables = new ArrayList<QueryData>(){{
-			add(new QueryData("person",null));
-			add(new QueryData("certification",null));
-		}};
-		Map<String,List<QueryData>>columnsTables = blurParser.parse();
-		assertThat(columnsTables.get("tables"),is(expectedTables));
-	}
-	
-	@Test
-	public void testGetColumnsTablesWithAlias() throws Exception {
-		String query = "select person.pn as firstName, person.ln as lastName, cert.br as certNumber,
cert.ba as certBar from person as per,certification as cert where lastName = 'smith';";
-		setUpParsing(query);
-		List<QueryData> expectedColumns = new ArrayList<QueryData>(){{
-			add(new QueryData("person.pn","firstName"));
-			add(new QueryData("person.ln","lastName"));
-			add(new QueryData("cert.br","certNumber"));
-			add(new QueryData("cert.ba","certBar"));
-		}};
-		
-		List<QueryData> expectedTables = new ArrayList<QueryData>(){{
-			add(new QueryData("person","per"));
-			add(new QueryData("certification","cert"));
-		}};
-		Map<String,List<QueryData>>columnsTables = blurParser.parse();
-		assertThat(columnsTables.get("tables"),is(expectedTables));
-		assertThat(columnsTables.get("columns"),is(expectedColumns));
-	}
-	
-	@Test
-	public void testGetColumnsTablesWithIdentAlias() throws Exception {
-		String query = "select person.pn as col1, person.ln as col2, cert.br as certNumber, cert.ba
as certBar from person as per,certification as cert where col1 = 'smith';";
-		setUpParsing(query);
-		List<QueryData> expectedColumns = new ArrayList<QueryData>(){{
-			add(new QueryData("person.pn","col1"));
-			add(new QueryData("person.ln","col2"));
-			add(new QueryData("cert.br","certNumber"));
-			add(new QueryData("cert.ba","certBar"));
-		}};
-		
-		List<QueryData> expectedTables = new ArrayList<QueryData>(){{
-			add(new QueryData("person","per"));
-			add(new QueryData("certification","cert"));
-		}};
-		Map<String,List<QueryData>>columnsTables = blurParser.parse();
-		assertThat(columnsTables.get("tables"),is(expectedTables));
-		assertThat(columnsTables.get("columns"),is(expectedColumns));
-	}
-	
-	@Test
-	public void testGetColumnsTablesWithAndWithoutAlias() throws Exception {
-		String query = "select person.pn as firstName, person.ln as lastName, cert.br, cert.ba
from person,certification as cert where lastName = 'smith';";
-		setUpParsing(query);
-		List<QueryData> expectedColumns = new ArrayList<QueryData>(){{
-			add(new QueryData("person.pn","firstName"));
-			add(new QueryData("person.ln","lastName"));
-			add(new QueryData("cert.br",null));
-			add(new QueryData("cert.ba",null));
-		}};
-		
-		List<QueryData> expectedTables = new ArrayList<QueryData>(){{
-			add(new QueryData("person",null));
-			add(new QueryData("certification","cert"));
-		}};
-		Map<String,List<QueryData>>columnsTables = blurParser.parse();
-		assertThat(columnsTables.get("columns"),is(expectedColumns));
-		assertThat(columnsTables.get("tables"),is(expectedTables));
-	}
-	
-	private void setUpParsing(String query){
-		charStream = new ANTLRStringStream(query);
-		blurLexer = new BlurLexer(charStream);
-		tokenStream = new CommonTokenStream(blurLexer);
-		blurParser = new BlurParser(tokenStream);
-	}
-
-
-}


Mime
View raw message