Use Java naming conventions
authorJakub Skoczen <jakub@indexdata.dk>
Wed, 17 Feb 2010 09:02:59 +0000 (10:02 +0100)
committerJakub Skoczen <jakub@indexdata.dk>
Wed, 17 Feb 2010 09:02:59 +0000 (10:02 +0100)
12 files changed:
src/main/java/org/yaz4j/Bib1Diagnostic.java
src/main/java/org/yaz4j/Connection.java
src/main/java/org/yaz4j/ConnectionExtended.java
src/main/java/org/yaz4j/ConnectionOptionsCollection.java
src/main/java/org/yaz4j/Package.java
src/main/java/org/yaz4j/PackageOptionsCollection.java
src/main/java/org/yaz4j/Record.java
src/main/java/org/yaz4j/ResultSet.java
src/main/java/org/yaz4j/ScanSet.java
src/main/java/org/yaz4j/Yaz4jMain.java
src/test/java/yaz4jtest/ConnectionTest.java
src/test/java/yaz4jtest/DinosaurTest.java

index f567112..ad08aef 100644 (file)
@@ -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)) {
index 680dabc..613e3ce 100644 (file)
@@ -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;
index 629e51e..a617f0d 100644 (file)
@@ -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();
index 3823336..0f4e449 100644 (file)
@@ -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);
     }
 
index 8de3ab7..5bd6461 100644 (file)
@@ -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;
index 419c742..bb4d0f2 100644 (file)
@@ -11,7 +11,7 @@ public class PackageOptionsCollection {
         this.pack = pack;
     }
 
-    public void Dispose() {
+    public void dispose() {
         pack = null;
     }
 
index 8fcfdc4..b1a93ca 100644 (file)
@@ -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;
index 300cbad..fad095c 100644 (file)
@@ -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;
index da40915..2140cc5 100644 (file)
@@ -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;
index 61e3dea..ca895c6 100644 (file)
@@ -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();
     }
 }
index 41e38c9..2550f5b 100644 (file)
@@ -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);
index d85a344..efc2247 100644 (file)
@@ -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);