diff --git a/checkFile.awk b/checkFile.awk index b2eac0c..e6a9d50 100644 --- a/checkFile.awk +++ b/checkFile.awk @@ -33,6 +33,8 @@ function _matchFile(fname) { || fname ~ "/fennel/" \ || fname ~ "/extensions/" \ || fname ~ "/com/sqlstream/" \ + || fname ~ "/linq4j/" \ + || fname ~ "/optiq/" \ || strict > 0; } function _isCpp(fname) { @@ -44,6 +46,9 @@ function _isJava(fname) { function _isMondrian(fname) { return fname ~ /mondrian/; } +function _isOlap4j(fname) { + return fname ~ "/org/olap4j/"; +} function push(val) { switchStack[switchStackLen++] = val; } @@ -70,7 +75,6 @@ function afterFile() { function unmatchedOpenParens(s) { i = index(s, "("); if (i == 0) { - if (0) print FNR, "unmatchedOpenParens=0"; return 0; } openCount = 1; @@ -81,12 +85,10 @@ function unmatchedOpenParens(s) { } if (c == ")") { if (--openCount == 0) { - if (0) print FNR, "unmatchedOpenParens=0 (b)"; return 0; } } } - if (0) print FNR, "unmatchedOpenParens=1"; return 1; } @@ -122,6 +124,45 @@ FNR == 1 { mondrian = _isMondrian(fname); prevImport = ""; prevImportGroup = ""; + + delete headers; + headerCount = 0; + if ($0 ~ /Generated By:JavaCC/ \ + || $0 ~ /This class is generated/) { + # generated; skip whole file + nextfile + } else if (fname ~ /XmlaOlap4jDriverVersion.java/ \ + || fname ~ /package-info.java/) { + # generated; does not contain standard header + } else if (1) { + headers[headerCount++] = "/\\*$"; + if (_isOlap4j(fname)) { + headers[headerCount++] = /^\/\/ \$Id: /; + headers[headerCount++] = "//"; + } + headers[headerCount++] = "// Licensed to Julian Hyde under one or more contributor license$"; + headers[headerCount++] = "// agreements. See the NOTICE file distributed with this work for$"; + headers[headerCount++] = "// additional information regarding copyright ownership.$"; + headers[headerCount++] = "//$"; + headers[headerCount++] = "// Julian Hyde licenses this file to you under the Apache License,$"; + headers[headerCount++] = "// Version 2.0 \\(the \"License\"\\); you may not use this file except in$"; + headers[headerCount++] = "// compliance with the License. You may obtain a copy of the License at:$"; + headers[headerCount++] = "//$"; + headers[headerCount++] = "// http://www.apache.org/licenses/LICENSE-2.0$"; + headers[headerCount++] = "//$"; + headers[headerCount++] = "// Unless required by applicable law or agreed to in writing, software$"; + headers[headerCount++] = "// distributed under the License is distributed on an \"AS IS\" BASIS,$"; + headers[headerCount++] = "// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.$"; + headers[headerCount++] = "// See the License for the specific language governing permissions and$"; + headers[headerCount++] = "// limitations under the License.$"; + headers[headerCount++] = "*/$"; + } +} +FNR < headerCount { + if ($0 !~ headers[FNR - 1]) { + error(fname, FNR, "Does not match expected header line: " headers[FNR - 1] "\n"); + headerCount = 0; # prevent further errors from this file + } } { if (previousLineEndedInCloseBrace > 0) { @@ -230,19 +271,28 @@ FNR == 1 { gsub(/;/, "", thisImport); gsub(/\*/, "", thisImport); if (thisPackage ~ /^mondrian.*/ && thisImport ~ /^mondrian.*/ \ + || thisPackage ~ /^net.hydromatic.*/ && thisImport ~ /^net.hydromatic.*/ \ || thisPackage ~ /^org.olap4j.*/ && thisImport ~ /^org.olap4j.*/) { importGroup = "a"; } else if (thisImport ~ /^static/) { importGroup = "z"; } else if (thisImport ~ /^java.*/) { - importGroup = "y"; + if (thisPackage ~ /^org.eigenbase.*/) { + importGroup = "aa"; + } else { + importGroup = "y"; + } } else if (thisImport ~ /^junit.*/) { importGroup = "b"; } else if (thisImport ~ /^mondrian.*/) { importGroup = "bb"; + } else if (thisImport ~ /^openjava.*/) { + importGroup = "cc"; } else if (thisImport ~ /^org.apache.*/) { importGroup = "c"; + } else if (thisImport ~ /^org.codehaus.*/) { + importGroup = "ccc"; } else if (thisImport ~ /^org.eigenbase.*/) { importGroup = "d"; } else if (thisImport ~ /^org.olap4j.*/) { @@ -268,7 +318,9 @@ FNR == 1 { prevImport = thisImport; prevImportGroup = importGroup; } -/^\/\/ Copyright .* Julian/ && strict { +/^\/\/ Copyright .* Julian/ && strict > 1 { + # We assume that '--strict' is only invoked on files currently being + # edited. Therefore we would expect the copyright to be current. if ($0 !~ /-2012/) { error(fname, FNR, "copyright is not current"); } @@ -277,22 +329,22 @@ FNR == 1 { # Order of qualifiers: "public/private/protected static final abstract class ..." s2 = s; gsub(/\(.*$/, "", s2); - if (s2 ~ /abstract .*final/) { + if (s2 ~ /abstract .*final /) { error(fname, FNR, "'final' must come before 'abstract'"); } - if (s2 ~ /final .*static/) { + if (s2 ~ /final .*static /) { error(fname, FNR, "'static' must come before 'final'"); } - if (s2 ~ /abstract .*static/) { + if (s2 ~ /abstract .*static /) { error(fname, FNR, "'static' must come before 'abstract'"); } - if (s2 ~ /static .*(public|protected|private)/) { + if (s2 ~ /static .*(public|protected|private) /) { error(fname, FNR, "'public/private/protected' must come before 'static'"); } - if (s2 ~ /final .*(public|protected|private)/) { + if (s2 ~ /final .*(public|protected|private) /) { error(fname, FNR, "'public/private/protected' must come before 'final'"); } - if (s2 ~ /abstract .*(public|protected|private)/) { + if (s2 ~ /abstract .*(public|protected|private) /) { error(fname, FNR, "'public/private/protected' must come before 'abstract'"); } } @@ -692,8 +744,9 @@ length($0) > maxLineLength \ && $0 !~ /\$Id: / \ && $0 !~ /^import / \ && $0 !~ /http:/ \ +&& $0 !~ /https:/ \ && $0 !~ /\/\/ Expect "/ \ -&& s !~ /^ *(\+ |<< )?string\)?[;,]?$/ { +&& s !~ /^ *(\+ |<< |: |\?)?string\)?[;,]?$/ { error( \ fname, \ FNR, \ diff --git a/checkFile.sh b/checkFile.sh index 0741b70..7b12e26 100755 --- a/checkFile.sh +++ b/checkFile.sh @@ -136,7 +136,7 @@ doCheck() { ;; # Only validate .java and .jj files at present. - *.java|*.jj|*.h|*.cpp) + *.java|*.h|*.cpp) ;; *) @@ -283,6 +283,8 @@ if [ -s /tmp/checkFile_output_$$.txt ]; then status=1 fi +rm -f /tmp/checkFile_output_$$.txt + exit $status # End checkFile.sh diff --git a/src/org/olap4j/driver/xmla/XmlaOlap4jConnection.java b/src/org/olap4j/driver/xmla/XmlaOlap4jConnection.java index caee134..f8d036f 100644 --- a/src/org/olap4j/driver/xmla/XmlaOlap4jConnection.java +++ b/src/org/olap4j/driver/xmla/XmlaOlap4jConnection.java @@ -1052,14 +1052,14 @@ public String generateRequest( if (metadataRequest.requiresDatasourceName()) { final String dataSourceInfo; switch (BackendFlavor.getFlavor(context.olap4jConnection)) { - case ESSBASE: - dataSourceInfo = - context.olap4jConnection.getOlapDatabase() - .getDataSourceInfo(); - break; - default: - dataSourceInfo = - context.olap4jConnection.getDatabase(); + case ESSBASE: + dataSourceInfo = + context.olap4jConnection.getOlapDatabase() + .getDataSourceInfo(); + break; + default: + dataSourceInfo = + context.olap4jConnection.getDatabase(); } buf.append(" "); xmlEncode(buf, dataSourceInfo); diff --git a/src/org/olap4j/driver/xmla/XmlaOlap4jStatement.java b/src/org/olap4j/driver/xmla/XmlaOlap4jStatement.java index e14371a..60eabef 100644 --- a/src/org/olap4j/driver/xmla/XmlaOlap4jStatement.java +++ b/src/org/olap4j/driver/xmla/XmlaOlap4jStatement.java @@ -297,14 +297,13 @@ public CellSet executeOlapQuery(String mdx) throws OlapException { final String dataSourceInfo; switch (BackendFlavor.getFlavor(olap4jConnection)) { - case ESSBASE: - dataSourceInfo = - olap4jConnection.getOlapDatabase() - .getDataSourceInfo(); - break; - default: - dataSourceInfo = - olap4jConnection.getDatabase(); + case ESSBASE: + dataSourceInfo = + olap4jConnection.getOlapDatabase().getDataSourceInfo(); + break; + default: + dataSourceInfo = + olap4jConnection.getDatabase(); } StringBuilder buf = new StringBuilder(