From 2def7bc64faa1dfb9f3393f2c2ef0bca0c6265e1 Mon Sep 17 00:00:00 2001 From: Jakub Skoczen Date: Wed, 17 Feb 2010 10:02:59 +0100 Subject: [PATCH] Use Java naming conventions --- src/main/java/org/yaz4j/Bib1Diagnostic.java | 2 +- src/main/java/org/yaz4j/Connection.java | 38 ++++++++++---------- src/main/java/org/yaz4j/ConnectionExtended.java | 4 +-- .../org/yaz4j/ConnectionOptionsCollection.java | 6 ++-- src/main/java/org/yaz4j/Package.java | 6 ++-- .../java/org/yaz4j/PackageOptionsCollection.java | 2 +- src/main/java/org/yaz4j/Record.java | 6 ++-- src/main/java/org/yaz4j/ResultSet.java | 7 ++-- src/main/java/org/yaz4j/ScanSet.java | 4 +-- src/main/java/org/yaz4j/Yaz4jMain.java | 4 +-- src/test/java/yaz4jtest/ConnectionTest.java | 2 +- src/test/java/yaz4jtest/DinosaurTest.java | 2 +- 12 files changed, 40 insertions(+), 43 deletions(-) diff --git a/src/main/java/org/yaz4j/Bib1Diagnostic.java b/src/main/java/org/yaz4j/Bib1Diagnostic.java index f567112..ad08aef 100644 --- a/src/main/java/org/yaz4j/Bib1Diagnostic.java +++ b/src/main/java/org/yaz4j/Bib1Diagnostic.java @@ -121,7 +121,7 @@ class Bib1Diagnostic { errorCodes.put(247, "Type1QueryAttributesetAsPartOfAttributeelementNotSupported"); } - public static String GetError(int errorCode) { + public static String getError(int errorCode) { String errorText = "Unknown Error"; if (errorCodes.containsKey(errorCode)) { diff --git a/src/main/java/org/yaz4j/Connection.java b/src/main/java/org/yaz4j/Connection.java index 680dabc..613e3ce 100644 --- a/src/main/java/org/yaz4j/Connection.java +++ b/src/main/java/org/yaz4j/Connection.java @@ -40,14 +40,14 @@ public class Connection { SWIGTYPE_p_p_char cp = null; SWIGTYPE_p_p_char addinfo = null; int errorCode = yaz4jlib.ZOOM_connection_error(zoomConnection, cp, addinfo); - CheckErrorCodeAndThrow(errorCode); + checkErrorCodeAndThrow(errorCode); } public void finalize() { - Dispose(); + dispose(); } - private void CheckErrorCodeAndThrow(int errorCode) { + private void checkErrorCodeAndThrow(int errorCode) { String message; if (errorCode == yaz4jlibConstants.ZOOM_ERROR_NONE) { @@ -68,7 +68,7 @@ public class Connection { message = yaz4jlib.ZOOM_connection_errmsg(zoomConnection); throw new ZoomImplementationException("A fatal error occurred in Yaz: " + errorCode + " - " + message); } else { - String errMsgBib1 = "Bib1Exception: Error Code = " + errorCode + " (" + Bib1Diagnostic.GetError(errorCode) + ")"; + String errMsgBib1 = "Bib1Exception: Error Code = " + errorCode + " (" + Bib1Diagnostic.getError(errorCode) + ")"; throw new Bib1Exception(errMsgBib1); } } @@ -78,16 +78,16 @@ public class Connection { CQLQuery, PrefixQuery }; - public ResultSet Search(PrefixQuery query) { - return Search(query.getQueryString(), QueryType.PrefixQuery); + public ResultSet search(PrefixQuery query) { + return search(query.getQueryString(), QueryType.PrefixQuery); } - public ResultSet Search(CQLQuery query) { - return Search(query.getQueryString(), QueryType.CQLQuery); + public ResultSet search(CQLQuery query) { + return search(query.getQueryString(), QueryType.CQLQuery); } - private ResultSet Search(String query, QueryType queryType) { - EnsureConnected(); + private ResultSet search(String query, QueryType queryType) { + ensureConnected(); SWIGTYPE_p_ZOOM_query_p yazQuery = yaz4jlib.ZOOM_query_create(); ResultSet resultSet = null; @@ -107,7 +107,7 @@ public class Connection { if (errorCode != yaz4jlib.ZOOM_ERROR_NONE) { yaz4jlib.ZOOM_resultset_destroy(yazResultSet); } - CheckErrorCodeAndThrow(errorCode); + checkErrorCodeAndThrow(errorCode); resultSet = new ResultSet(yazResultSet, zoomConnection); } finally { @@ -117,15 +117,15 @@ public class Connection { return resultSet; } - public ScanSet Scan(String query) { - EnsureConnected(); + public ScanSet scan(String query) { + ensureConnected(); SWIGTYPE_p_ZOOM_scanset_p yazScanSet = yaz4jlib.ZOOM_connection_scan(zoomConnection, query); int errorCode = yaz4jlib.ZOOM_connection_errcode(zoomConnection); if (errorCode != yaz4jlib.ZOOM_ERROR_NONE) { yaz4jlib.ZOOM_scanset_destroy(yazScanSet); } - CheckErrorCodeAndThrow(errorCode); + checkErrorCodeAndThrow(errorCode); ScanSet scanSet = new ScanSet(yazScanSet, this); return scanSet; @@ -135,20 +135,20 @@ public class Connection { return options; } - protected void EnsureConnected() { + protected void ensureConnected() { if (!connected) { - Connect(); + connect(); } } - public void Connect() { + public void connect() { yaz4jlib.ZOOM_connection_connect(zoomConnection, host, port); int errorCode = yaz4jlib.ZOOM_connection_errcode(zoomConnection); - CheckErrorCodeAndThrow(errorCode); + checkErrorCodeAndThrow(errorCode); connected = true; } - public void Dispose() { + public void dispose() { if (!disposed) { yaz4jlib.ZOOM_connection_destroy(zoomConnection); zoomConnection = null; diff --git a/src/main/java/org/yaz4j/ConnectionExtended.java b/src/main/java/org/yaz4j/ConnectionExtended.java index 629e51e..a617f0d 100644 --- a/src/main/java/org/yaz4j/ConnectionExtended.java +++ b/src/main/java/org/yaz4j/ConnectionExtended.java @@ -10,8 +10,8 @@ public class ConnectionExtended extends Connection { super(host, port); } - public Package Package(String type) { - EnsureConnected(); + public Package getPackage(String type) { + ensureConnected(); Package pack = null; SWIGTYPE_p_ZOOM_options_p options = yaz4jlib.ZOOM_options_create(); diff --git a/src/main/java/org/yaz4j/ConnectionOptionsCollection.java b/src/main/java/org/yaz4j/ConnectionOptionsCollection.java index 3823336..0f4e449 100644 --- a/src/main/java/org/yaz4j/ConnectionOptionsCollection.java +++ b/src/main/java/org/yaz4j/ConnectionOptionsCollection.java @@ -13,15 +13,15 @@ public class ConnectionOptionsCollection { } public void finalize() { - Dispose(); + dispose(); } - public void Dispose() { + public void dispose() { yaz4jlib.ZOOM_options_destroy(zoomOptions); zoomOptions = null; } - SWIGTYPE_p_ZOOM_connection_p CreateConnection() { + SWIGTYPE_p_ZOOM_connection_p createConnection() { return yaz4jlib.ZOOM_connection_create(zoomOptions); } diff --git a/src/main/java/org/yaz4j/Package.java b/src/main/java/org/yaz4j/Package.java index 8de3ab7..5bd6461 100644 --- a/src/main/java/org/yaz4j/Package.java +++ b/src/main/java/org/yaz4j/Package.java @@ -16,18 +16,18 @@ public class Package { } public void finalize() { - Dispose(); + dispose(); } public PackageOptionsCollection getPackageOptions() { return new PackageOptionsCollection(pack); } - public void Send() { + public void send() { yaz4jlib.ZOOM_package_send(pack, type); } - public void Dispose() { + public void dispose() { if (pack != null) { yaz4jlib.ZOOM_package_destroy(pack); connection = null; diff --git a/src/main/java/org/yaz4j/PackageOptionsCollection.java b/src/main/java/org/yaz4j/PackageOptionsCollection.java index 419c742..bb4d0f2 100644 --- a/src/main/java/org/yaz4j/PackageOptionsCollection.java +++ b/src/main/java/org/yaz4j/PackageOptionsCollection.java @@ -11,7 +11,7 @@ public class PackageOptionsCollection { this.pack = pack; } - public void Dispose() { + public void dispose() { pack = null; } diff --git a/src/main/java/org/yaz4j/Record.java b/src/main/java/org/yaz4j/Record.java index 8fcfdc4..b1a93ca 100644 --- a/src/main/java/org/yaz4j/Record.java +++ b/src/main/java/org/yaz4j/Record.java @@ -1,7 +1,5 @@ package org.yaz4j; -import java.io.UnsupportedEncodingException; - import org.yaz4j.jni.SWIGTYPE_p_ZOOM_record_p; import org.yaz4j.jni.SWIGTYPE_p_int; import org.yaz4j.jni.yaz4jlib; @@ -18,7 +16,7 @@ public class Record { } public void finalize() { - Dispose(); + dispose(); } public byte[] get(String type) { @@ -42,7 +40,7 @@ public class Record { return new String(get("database")); } - public void Dispose() { + public void dispose() { if (!disposed) { resultSet = null; record = null; diff --git a/src/main/java/org/yaz4j/ResultSet.java b/src/main/java/org/yaz4j/ResultSet.java index 300cbad..fad095c 100644 --- a/src/main/java/org/yaz4j/ResultSet.java +++ b/src/main/java/org/yaz4j/ResultSet.java @@ -21,7 +21,7 @@ public class ResultSet { } public void finalize() { - this.Dispose(); + this.dispose(); } ResultSetOptionsCollection getResultSetOptions() { @@ -41,14 +41,13 @@ public class ResultSet { return (int) size; } - public void Dispose() { + public void dispose() { if (!disposed) { for (int i = 0; i < records.length; i++) { if (records[i] != null) { - records[i].Dispose(); + records[i].dispose(); } } - yaz4jlib.ZOOM_resultset_destroy(resultSet); connection = null; resultSet = null; diff --git a/src/main/java/org/yaz4j/ScanSet.java b/src/main/java/org/yaz4j/ScanSet.java index da40915..2140cc5 100644 --- a/src/main/java/org/yaz4j/ScanSet.java +++ b/src/main/java/org/yaz4j/ScanSet.java @@ -17,7 +17,7 @@ public class ScanSet { } public void finalize() { - Dispose(); + dispose(); } public ScanTerm get(long index) { @@ -34,7 +34,7 @@ public class ScanSet { return yaz4jlib.ZOOM_scanset_size(scanSet); } - public void Dispose() { + public void dispose() { if (!disposed) { yaz4jlib.ZOOM_scanset_destroy(scanSet); connection = null; diff --git a/src/main/java/org/yaz4j/Yaz4jMain.java b/src/main/java/org/yaz4j/Yaz4jMain.java index 61e3dea..ca895c6 100644 --- a/src/main/java/org/yaz4j/Yaz4jMain.java +++ b/src/main/java/org/yaz4j/Yaz4jMain.java @@ -14,7 +14,7 @@ public class Yaz4jMain { conn.setSyntax("USMarc"); // USMarc, Sutrs, XML, opac, UKMarc PrefixQuery query = new PrefixQuery("@attr 1=4 \"pottering\""); - ResultSet results = conn.Search(query); + ResultSet results = conn.search(query); int resultsSize = results.getSize(); System.out.println("Found " + resultsSize + " records"); @@ -23,6 +23,6 @@ public class Yaz4jMain { Record record = results.getRecord(i); System.out.write(record.getContent()); } - conn.Dispose(); + conn.dispose(); } } diff --git a/src/test/java/yaz4jtest/ConnectionTest.java b/src/test/java/yaz4jtest/ConnectionTest.java index 41e38c9..2550f5b 100644 --- a/src/test/java/yaz4jtest/ConnectionTest.java +++ b/src/test/java/yaz4jtest/ConnectionTest.java @@ -13,7 +13,7 @@ public class ConnectionTest { con.setSyntax("sutrs"); org.yaz4j.PrefixQuery pqf = new org.yaz4j.PrefixQuery("@attr 1=4 utah"); assertNotNull(pqf); - org.yaz4j.ResultSet s = con.Search(pqf); + org.yaz4j.ResultSet s = con.search(pqf); assertNotNull(s); assertEquals(s.getSize(), 9); org.yaz4j.Record rec = s.getRecord(0); diff --git a/src/test/java/yaz4jtest/DinosaurTest.java b/src/test/java/yaz4jtest/DinosaurTest.java index d85a344..efc2247 100644 --- a/src/test/java/yaz4jtest/DinosaurTest.java +++ b/src/test/java/yaz4jtest/DinosaurTest.java @@ -16,7 +16,7 @@ public class DinosaurTest { con.setSyntax("usmarc"); PrefixQuery pqf = new PrefixQuery("@attr 1=7 0253333490"); assertNotNull(pqf); - ResultSet set = con.Search(pqf); + ResultSet set = con.search(pqf); assertNotNull(set); Record rec = set.getRecord(0); assertNotNull(rec); -- 1.7.10.4