Use Maven for building yaz4j.
authorAdam Dickmeiss <adam@indexdata.dk>
Mon, 21 Sep 2009 13:31:54 +0000 (15:31 +0200)
committerAdam Dickmeiss <adam@indexdata.dk>
Mon, 21 Sep 2009 13:31:54 +0000 (15:31 +0200)
55 files changed:
.classpath
.gitignore
.project
AUTHORS
README
build-windows.xml [deleted file]
build.xml [deleted file]
dependencies/JUnit-4.3.1/junit-4.3.1.jar [deleted file]
libyaz4j/build.sh
pom.xml [new file with mode: 0644]
src/main/java/org/yaz4j/Bib1Diagnostic.java [new file with mode: 0644]
src/main/java/org/yaz4j/Bib1Exception.java [new file with mode: 0644]
src/main/java/org/yaz4j/CQLQuery.java [new file with mode: 0644]
src/main/java/org/yaz4j/Connection.java [new file with mode: 0644]
src/main/java/org/yaz4j/ConnectionExtended.java [new file with mode: 0644]
src/main/java/org/yaz4j/ConnectionOptionsCollection.java [new file with mode: 0644]
src/main/java/org/yaz4j/ConnectionTimeoutException.java [new file with mode: 0644]
src/main/java/org/yaz4j/ConnectionUnavailableException.java [new file with mode: 0644]
src/main/java/org/yaz4j/InitRejectedException.java [new file with mode: 0644]
src/main/java/org/yaz4j/InvalidQueryException.java [new file with mode: 0644]
src/main/java/org/yaz4j/Package.java [new file with mode: 0644]
src/main/java/org/yaz4j/PackageOptionsCollection.java [new file with mode: 0644]
src/main/java/org/yaz4j/PrefixQuery.java [new file with mode: 0644]
src/main/java/org/yaz4j/Record.java [new file with mode: 0644]
src/main/java/org/yaz4j/ResultSet.java [new file with mode: 0644]
src/main/java/org/yaz4j/ResultSetOptionsCollection.java [new file with mode: 0644]
src/main/java/org/yaz4j/ScanSet.java [new file with mode: 0644]
src/main/java/org/yaz4j/ScanTerm.java [new file with mode: 0644]
src/main/java/org/yaz4j/Yaz4jMain.java [new file with mode: 0644]
src/main/java/org/yaz4j/ZoomImplementationException.java [new file with mode: 0644]
src/main/java/org/yaz4j/jni/.gitignore [new file with mode: 0644]
src/org/yaz4j/Bib1Diagnostic.java [deleted file]
src/org/yaz4j/Bib1Exception.java [deleted file]
src/org/yaz4j/CQLQuery.java [deleted file]
src/org/yaz4j/Connection.java [deleted file]
src/org/yaz4j/ConnectionExtended.java [deleted file]
src/org/yaz4j/ConnectionOptionsCollection.java [deleted file]
src/org/yaz4j/ConnectionTimeoutException.java [deleted file]
src/org/yaz4j/ConnectionUnavailableException.java [deleted file]
src/org/yaz4j/InitRejectedException.java [deleted file]
src/org/yaz4j/InvalidQueryException.java [deleted file]
src/org/yaz4j/Package.java [deleted file]
src/org/yaz4j/PackageOptionsCollection.java [deleted file]
src/org/yaz4j/PrefixQuery.java [deleted file]
src/org/yaz4j/Record.java [deleted file]
src/org/yaz4j/ResultSet.java [deleted file]
src/org/yaz4j/ResultSetOptionsCollection.java [deleted file]
src/org/yaz4j/ScanSet.java [deleted file]
src/org/yaz4j/ScanTerm.java [deleted file]
src/org/yaz4j/Yaz4jMain.java [deleted file]
src/org/yaz4j/ZoomImplementationException.java [deleted file]
src/org/yaz4j/jni/.gitignore [deleted file]
src/site/site.xml [new file with mode: 0644]
src/test/java/yaz4jtest/ConnectionTest.java [new file with mode: 0644]
test/ConnectionTest.java [deleted file]

index c1e85ad..caa7eba 100644 (file)
@@ -1,11 +1,8 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <classpath>
-       <classpathentry kind="src" path="src">
-               <attributes>
-                       <attribute name="org.eclipse.jdt.launching.CLASSPATH_ATTR_LIBRARY_PATH_ENTRY" value="yaz4j/lib"/>
-               </attributes>
-       </classpathentry>
+       <classpathentry including="**/*.java" kind="src" output="target/test-classes" path="src/test/java"/>
+       <classpathentry including="**/*.java" kind="src" path="src/main/java"/>
+       <classpathentry kind="con" path="org.eclipse.iam.jdt.core.mavenClasspathContainer"/>
        <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
-       <classpathentry kind="lib" path="dependencies/JUnit-4.3.1/junit-4.3.1.jar"/>
-       <classpathentry kind="output" path="bin"/>
+       <classpathentry kind="output" path="target/classes"/>
 </classpath>
index f904b11..eb5a316 100644 (file)
@@ -1,2 +1 @@
-bin
-distributions
+target
index 0bf3351..1b79910 100644 (file)
--- a/.project
+++ b/.project
@@ -4,14 +4,20 @@
        <comment></comment>
        <projects>
        </projects>
-       <buildSpec>
-               <buildCommand>
-                       <name>org.eclipse.jdt.core.javabuilder</name>
-                       <arguments>
-                       </arguments>
-               </buildCommand>
-       </buildSpec>
-       <natures>
-               <nature>org.eclipse.jdt.core.javanature</nature>
-       </natures>
+    <buildSpec>
+        <buildCommand>
+            <name>org.eclipse.jdt.core.javabuilder</name>
+            <arguments>
+            </arguments>
+        </buildCommand>
+        <buildCommand>
+            <name>org.eclipse.iam.jdt.core.mavenIncrementalBuilder</name>
+            <arguments>
+            </arguments>
+        </buildCommand>
+    </buildSpec>
+    <natures>
+        <nature>org.eclipse.iam.jdt.core.mavenNature</nature>
+        <nature>org.eclipse.jdt.core.javanature</nature>
+    </natures>
 </projectDescription>
diff --git a/AUTHORS b/AUTHORS
index c40cdd9..e310170 100644 (file)
--- a/AUTHORS
+++ b/AUTHORS
@@ -1,7 +1,5 @@
-Most of the work on yaz4j was done by:
-
 Rob Styles <Rob.Styles@talis.com>
+Adam Dickmeiss <adam@indexdata.dk>
+J. Cayetano <juancayetano.delgado@gmail.com>
 
-Current version is maintained by:
 
-Adam Dickmeiss <adam@indexdata.dk>
diff --git a/README b/README
index 5f06606..b974b3e 100644 (file)
--- a/README
+++ b/README
@@ -7,11 +7,11 @@ Copyright (C) 2006-2007, Talis Group Ltd.
 Copyright (C) 2008-2009, Index Data.
 See LICENSE for details.
 
-In order to built yaz4j the Java JDK, ant, YAZ and Swig must be installed.
+In order to built yaz4j the Java JDK, Maven, YAZ and Swig must be installed.
 The exact process varies from platform to platform.
 
 For example, on Ubuntu/Debian the following installs the components:
-  apt-get install sun-java6-jdk ant libyaz3-dev swig
+  apt-get install sun-java6-jdk maven2 libyaz3-dev swig
 
 The compilation is a two-step process. The environment variable JAVA_HOME
 should point to the Java JDK of your preference. For example,
@@ -21,9 +21,9 @@ Build the shared libary (.so) with:
   cd libyaz4j
   ./build.sh
 
-Rest is built by ant which reads build.xml:
+Rest is built by maven which reads pom.xml:
   cd ..
-  ant
+  mvn compile
 
 If you network-connected you should be able to run tests with:
-  ant unit-test
+  mvn test
diff --git a/build-windows.xml b/build-windows.xml
deleted file mode 100644 (file)
index 883c460..0000000
+++ /dev/null
@@ -1,48 +0,0 @@
-<!-- To build distribution:  ant -f build-windows.xml         -->\r
-<!-- To compile only:        ant compile -f build-windows.xml -->\r
-<!-- To clean dir structure: ant clean -f build-windows.xml   -->\r
-\r
-<project name="yaz4j" default="build-dist" basedir=".">\r
-\r
-  <description>Build the java side of Yaz4J</description>\r
-\r
-  <property name="version" value="0.9.3-windows-x86-32"/>      \r
-  <property name="src" location="src"/>\r
-  <property name="bin" location="bin"/>\r
-  <property name="distributions"  location="distributions"/>\r
-       \r
-  <path id="project.classpath">\r
-    <pathelement location="${bin}"/>\r
-  </path>\r
-\r
-  <target name="init">\r
-    <mkdir dir="${bin}"/>\r
-  </target>\r
-\r
-  <target name="compile" depends="init" description="compile the source">\r
-    <javac srcdir="${src}" destdir="${bin}">\r
-       <classpath refid="project.classpath"/>\r
-    </javac>\r
-  </target>\r
-\r
-  <target name="build-dist" depends="compile" description="generate the distribution">\r
-    <mkdir dir="${distributions}/${version}"/>\r
-    <copy file="libyaz4j/lib/yaz4j.dll" tofile="${distributions}/${version}/yaz4j.dll"/>\r
-    <!-- copy file="dependencies/yaz_3.0.14/bin/yaz3.dll" tofile="${distributions}/${version}/yaz3.dll"/ -->\r
-    <jar jarfile="${distributions}/${version}/yaz4j.jar" basedir="${bin}">\r
-      <manifest>\r
-        <attribute name="Version" value="${version}"/>\r
-        <attribute name="Author" value="Talis Information Ltd"/>\r
-        <attribute name="About" value="Java wrapper for the ZOOM API of YAZ"/>\r
-        <attribute name="Main-Class" value="org.yaz4j.Yaz4jMain"/>\r
-      </manifest>\r
-    </jar>\r
-  </target>\r
-\r
-  <target name="clean" description="clean up" >\r
-    <!-- Delete various paths as part of the clean trees -->\r
-    <delete dir="${bin}"/>\r
-    <!-- delete dir="${distributions}/${version}"/ -->    \r
-  </target>\r
-\r
-</project>\r
diff --git a/build.xml b/build.xml
deleted file mode 100644 (file)
index 16bc930..0000000
--- a/build.xml
+++ /dev/null
@@ -1,61 +0,0 @@
-<project name="yaz4j" default="compile" basedir=".">
-
-  <description>Build the java side of Yaz4J</description>
-
-  <property name="version" value="0.9.3"/>     
-  <property name="src" location="src"/>
-  <property name="test" location="test"/>
-  <property name="bin" location="bin"/>
-  <property name="distributions"  location="distributions"/>
-       
-  <path id="project.classpath">
-    <pathelement location="${bin}"/>
-    <pathelement location="dependencies/JUnit-4.3.1/junit-4.3.1.jar"/>
-  </path>
-
-  <target name="init">
-    <mkdir dir="${bin}"/>
-  </target>
-
-  <target name="compile" depends="init" description="compile the source">
-    <javac srcdir="${src}" destdir="${bin}">
-       <classpath refid="project.classpath"/>
-    </javac>
-  </target>
-
-  <target name="compile-test" depends="compile" description="compile test the code">
-    <javac srcdir="${test}" destdir="${bin}">
-       <classpath refid="project.classpath"/>
-    </javac>
-  </target>
-
-  <!-- LD_LIBRARY_PATH=libyaz4j/lib java -cp bin:dependencies/JUnit-4.3.1/junit-4.3.1.jar org.junit.runner.JUnitCore yaz4jtest.ConnectionTest -->
-
-  <target name="unit-test" depends="compile-test" description="test the code">
-    <junit fork="on">
-       <env key="LD_LIBRARY_PATH" value="libyaz4j/lib"/>
-       <classpath refid="project.classpath"/>
-       <test name="yaz4jtest.ConnectionTest"/>
-    </junit>
-  </target>
-
-  <target name="build-dist" depends="compile" description="generate the distribution">
-    <mkdir dir="${distributions}/${version}"/>
-    <jar jarfile="${distributions}/${version}/yaz4j.jar" basedir="${bin}">
-      <manifest>
-        <attribute name="Version" value="${version}"/>
-        <attribute name="Author" value="Talis Information Ltd"/>
-        <attribute name="About" value="Java wrapper for the ZOOM API of YAZ"/>
-        <attribute name="Main-Class" value="org.yaz4j.Yaz4jMain"/>
-      </manifest>
-    </jar>
-    <copy file="libyaz4j/lib/libyaz4j.so" tofile="${distributions}/${version}/libyaz4j.so"/>
-  </target>
-
-  <target name="clean" description="clean up" >
-    <!-- Delete various paths as part of the clean trees -->
-    <delete dir="${bin}"/>
-    <!-- delete dir="${distributions}/${version}"/ -->
-  </target>
-
-</project>
diff --git a/dependencies/JUnit-4.3.1/junit-4.3.1.jar b/dependencies/JUnit-4.3.1/junit-4.3.1.jar
deleted file mode 100644 (file)
index ff5d188..0000000
Binary files a/dependencies/JUnit-4.3.1/junit-4.3.1.jar and /dev/null differ
index 98f55d9..d4687ad 100755 (executable)
@@ -6,7 +6,7 @@ YAZ_PREFIX=`${YAZ_CONFIG} --prefix`
 YAZ_CFLAGS=`${YAZ_CONFIG} --cflags`
 YAZ_LIBS=`${YAZ_CONFIG} --libs`
 
-swig -I"include" -I"${YAZ_PREFIX}/include" -outdir ../src/org/yaz4j/jni -package org.yaz4j.jni -o src/libyaz4j.cpp -c++ -java libyaz4j.i
+swig -I"include" -I"${YAZ_PREFIX}/include" -outdir ../src/main/java/org/yaz4j/jni -package org.yaz4j.jni -o src/libyaz4j.cpp -c++ -java libyaz4j.i
 
 g++ -fPIC -I"include" -I"$JNI_DIR" -I"$JNI_DIR/linux" ${YAZ_CFLAGS} -c -Wall -o obj/libyaz4j.o src/libyaz4j.cpp
 
diff --git a/pom.xml b/pom.xml
new file mode 100644 (file)
index 0000000..94760c0
--- /dev/null
+++ b/pom.xml
@@ -0,0 +1,173 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+    xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+
+    <!-- POM Relationships -->
+    <modelVersion>4.0.0</modelVersion>
+    <groupId>org.yaz4j</groupId>
+    <artifactId>yaz4j</artifactId>
+    <version>1.0-SNAPSHOT</version>
+    <packaging>jar</packaging>
+
+    <!-- Project Information -->
+    <name>yaz4j</name>
+    <url>http://indexdata.com/yaz4j</url>
+    <inceptionYear>2008</inceptionYear>
+    <licenses>
+        <license>
+            <name>BSD</name>
+            <url>http://www.opensource.org/licenses/bsd-license.php</url>
+        </license>
+    </licenses>
+    <description>Java wrapper for the ZOOM API of YAZ</description>
+
+    <developers>
+        <developer>
+            <name>Rob Styles</name>
+            <id />
+            <email>Rob.Styles@talis.com</email>
+            <organization />
+            <organizationUrl />
+            <roles />
+            <timezone />
+        </developer>
+        <developer>
+            <name>Adam Dickmeiss</name>
+            <id />
+            <email>adam@indexdata.dk</email>
+            <organization />
+            <organizationUrl />
+            <roles />
+            <timezone />
+        </developer>
+    </developers>
+    <!-- ///////////////// -->
+
+    <!-- Project Dependencies -->
+    <dependencies>
+        <dependency>
+            <groupId>junit</groupId>
+            <artifactId>junit</artifactId>
+            <version>4.3.1</version>
+            <scope>test</scope>
+        </dependency>
+    </dependencies>
+    <!-- ///////////////// -->
+
+    <!-- Build Settings -->
+    <build>
+        <plugins>
+            <plugin>
+                <groupId>org.apache.maven.plugins</groupId>
+                <artifactId>maven-resources-plugin</artifactId>
+                <configuration>
+                    <encoding>UTF-8</encoding>
+                </configuration>
+            </plugin>
+
+            <plugin>
+                <groupId>org.apache.maven.plugins</groupId>
+                <artifactId>maven-compiler-plugin</artifactId>
+                <configuration>
+                    <encoding>UTF-8</encoding>
+                    <source>1.5</source>
+                    <target>1.5</target>
+                    <showDeprecation>true</showDeprecation>
+                    <showWarnings>true</showWarnings>
+                </configuration>
+            </plugin>
+
+            <plugin>
+                <groupId>org.apache.maven.plugins</groupId>
+                <artifactId>maven-surefire-plugin</artifactId>
+                <configuration>
+                    <forkMode>once</forkMode>
+                    <workingDirectory>target</workingDirectory>
+                    <argLine>-Djava.library.path=${basedir}/libyaz4j/lib</argLine>
+                </configuration>
+            </plugin>
+        </plugins>
+    </build>
+
+    <!-- Reporting -->
+    <reporting>
+        <plugins>
+            <plugin>
+                <groupId>org.apache.maven.plugins</groupId>
+                <artifactId>maven-checkstyle-plugin</artifactId>
+                <configuration>
+                    <enableRSS>false</enableRSS>
+                    <include>**/*.java</include>
+                    <sourceDirectory>src/main/java</sourceDirectory>
+                </configuration>
+            </plugin>
+
+            <plugin>
+                <groupId>org.apache.maven.plugins</groupId>
+                <artifactId>
+                maven-project-info-reports-plugin
+                </artifactId>
+                <reportSets>
+                    <reportSet>
+                        <reports>
+                            <report>dependencies</report>
+                            <report>project-team</report>
+                            <report>mailing-list</report>
+                            <report>issue-tracking</report>
+                            <report>summary</report>
+                            <report>scm</report>
+                            <report>index</report>
+                        </reports>
+                    </reportSet>
+                </reportSets>
+            </plugin>
+            <plugin>
+                <groupId>org.apache.maven.plugins</groupId>
+                <artifactId>maven-javadoc-plugin</artifactId>
+                <configuration>
+                    <chartset>UTF-8</chartset>
+                </configuration>
+            </plugin>
+        </plugins>
+    </reporting>
+    <!-- ////////////// -->
+
+    <!-- Build Environment -->
+    <!-- Environment Information -->
+    <mailingLists>
+        <mailingList>
+            <name />
+            <subscribe />
+            <unsubscribe />
+            <post />
+            <archive />
+        </mailingList>
+    </mailingLists>
+
+    <scm>
+        <connection />
+        <url />
+    </scm>
+
+    <issueManagement>
+        <system />
+        <url />
+    </issueManagement>
+
+    <ciManagement>
+        <system />
+        <url />
+    </ciManagement>
+    <!-- /////////////////////// -->
+
+    <!-- Maven Environment -->
+    <repositories />
+    <pluginRepositories />
+    <!-- ///////////////// -->
+
+    <!-- Maven Common Properties -->
+    <properties />
+    <!-- /////////////////// -->
+</project>
+
+
diff --git a/src/main/java/org/yaz4j/Bib1Diagnostic.java b/src/main/java/org/yaz4j/Bib1Diagnostic.java
new file mode 100644 (file)
index 0000000..5dd8c11
--- /dev/null
@@ -0,0 +1,134 @@
+package org.yaz4j;
+
+import java.util.Hashtable;
+
+class Bib1Diagnostic
+{
+       private static Hashtable<Integer, String> errorCodes = new Hashtable<Integer, String>();
+
+       static
+       {
+               errorCodes.put(   1, "PermanentSystemError" ) ;
+               errorCodes.put(   2, "TemporarySystemError" ) ;
+               errorCodes.put(   3, "UnsupportedSearch" ) ;
+               errorCodes.put(   4, "TermsOnlyIncludesExclusionOrStopWords" ) ;
+               errorCodes.put(   5, "TooManyArgumentWords" ) ;
+               errorCodes.put(   6, "TooManyBooleanOperators" ) ;
+               errorCodes.put(   7, "TooManyTruncatedWords" ) ;
+               errorCodes.put(   8, "TooManyIncompleteSubfields" ) ;
+               errorCodes.put(   9, "TruncatedWordsTooShort" ) ;
+               errorCodes.put(  10, "InvalidFormatForRecordNumberInSearchTerm" ) ;
+               errorCodes.put(  11, "TooManyCharactersInSearchStatement" ) ;
+               errorCodes.put(  12, "TooManyRecordsRetrieved" ) ;
+               errorCodes.put(  13, "PresentRequestOutOfRange" ) ;
+               errorCodes.put(  14, "SystemErrorInPresentingRecords" ) ;
+               errorCodes.put(  15, "RecordNotAuthorizedToBeSentIntersystem" ) ;
+               errorCodes.put(  16, "RecordExceedsPreferredMessageSize" ) ;
+               errorCodes.put(  17, "RecordExceedsExceptionalRecordSize" ) ;
+               errorCodes.put(  18, "ResultSetNotSupportedAsASearchTerm" ) ;
+               errorCodes.put(  19, "OnlySingleResultSetAsSearchTermSupported" ) ;
+               errorCodes.put(  20, "OnlyAndingOfASingleResultSetAsSearchTerm" ) ;
+               errorCodes.put(  21, "ResultSetExistsAndReplaceIndicatorOff" ) ;
+               errorCodes.put(  22, "ResultSetNamingNotSupported" ) ;
+               errorCodes.put(  23, "SpecifiedCombinationOfDatabasesNotSupported" ) ;
+               errorCodes.put(  24, "ElementSetNamesNotSupported" ) ;
+               errorCodes.put(  25, "SpecifiedElementSetNameNotValidForSpecifiedDatabase" ) ;
+               errorCodes.put(  26, "OnlyGenericFormOfElementSetNameSupported" ) ;
+               errorCodes.put(  27, "ResultSetNoLongerExistsUnilaterallyDeletedByTarget" ) ;
+               errorCodes.put(  28, "ResultSetIsInUse" ) ;
+               errorCodes.put(  29, "OneOfTheSpecifiedDatabasesIsLocked" ) ;
+               errorCodes.put(  30, "SpecifiedResultSetDoesNotExist" ) ;
+               errorCodes.put(  31, "ResourcesExhaustedNoResultsAvailable" ) ;
+               errorCodes.put(  32, "ResourcesExhaustedUnpredictablePartialResultsAvailable" ) ;
+               errorCodes.put(  33, "ResourcesExhaustedValidSubsetOfResultsAvailable" ) ;
+               errorCodes.put( 100, "UnspecifiedError" ) ;
+               errorCodes.put( 101, "AccessControlFailure" ) ;
+               errorCodes.put( 102, "ChallengeRequiredCouldNotBeIssuedOperationTerminated" ) ;
+               errorCodes.put( 103, "ChallengeRequiredCouldNotBeIssuedRecordNotIncluded" ) ;
+               errorCodes.put( 104, "ChallengeFailedRecordNotIncluded" ) ;
+               errorCodes.put( 105, "TerminatedAtOriginRequest" ) ;
+               errorCodes.put( 106, "NoAbstractSyntaxesAgreedToForThisRecord" ) ;
+               errorCodes.put( 107, "QueryTypeNotSupported" ) ;
+               errorCodes.put( 108, "MalformedQuery" ) ;
+               errorCodes.put( 109, "DatabaseUnavailable" ) ;
+               errorCodes.put( 110, "OperatorUnsupported" ) ;
+               errorCodes.put( 111, "TooManyDatabasesSpecified" ) ;
+               errorCodes.put( 112, "TooManyResultSetsCreated" ) ;
+               errorCodes.put( 113, "UnsupportedAttributeType" ) ;
+               errorCodes.put( 114, "UnsupportedUseAttribute" ) ;
+               errorCodes.put( 115, "UnsupportedTermValueForUseAttribute" ) ;
+               errorCodes.put( 116, "UseAttributeRequiredButNotSupplied" ) ;
+               errorCodes.put( 117, "UnsupportedRelationAttribute" ) ;
+               errorCodes.put( 118, "UnsupportedStructureAttribute" ) ;
+               errorCodes.put( 119, "UnsupportedPositionAttribute" ) ;
+               errorCodes.put( 120, "UnsupportedTruncationAttribute" ) ;
+               errorCodes.put( 121, "UnsupportedAttributeSet" ) ;
+               errorCodes.put( 122, "UnsupportedCompletenessAttribute" ) ;
+               errorCodes.put( 123, "UnsupportedAttributeCombination" ) ;
+               errorCodes.put( 124, "UnsupportedCodedValueForTerm" ) ;
+               errorCodes.put( 125, "MalformedSearchTerm" ) ;
+               errorCodes.put( 126, "IllegalTermValueForAttribute" ) ;
+               errorCodes.put( 127, "UnparsableFormatForUnNormalizedValue" ) ;
+               errorCodes.put( 128, "IllegalResultSetName" ) ;
+               errorCodes.put( 129, "ProximitySearchOfSetsNotSupported" ) ;
+               errorCodes.put( 130, "IllegalResultSetInProximitySearch" ) ;
+               errorCodes.put( 131, "UnsupportedProximityRelation" ) ;
+               errorCodes.put( 132, "UnsupportedProximityUnitCode" ) ;
+               errorCodes.put( 201, "ProximityNotSupportedWithThisAttributeCombinationAttribute" ) ;
+               errorCodes.put( 202, "UnsupportedDistanceForProximity" ) ;
+               errorCodes.put( 203, "OrderedFlagNotSupportedForProximity" ) ;
+               errorCodes.put( 205, "OnlyZeroStepSizeSupportedForScan" ) ;
+               errorCodes.put( 206, "SpecifiedStepSizeNotSupportedForScanStep" ) ;
+               errorCodes.put( 207, "CannotSortAccordingToSequence" ) ;
+               errorCodes.put( 208, "NoResultSetNameSuppliedOnSort" ) ;
+               errorCodes.put( 209, "GenericSortNotSupported" ) ;
+               errorCodes.put( 210, "DatabaseSpecificSortNotSupported" ) ;
+               errorCodes.put( 211, "TooManySortKeys" ) ;
+               errorCodes.put( 212, "DuplicateSortKeys" ) ;
+               errorCodes.put( 213, "UnsupportedMissingDataAction" ) ;
+               errorCodes.put( 214, "IllegalSortRelation" ) ;
+               errorCodes.put( 215, "IllegalCaseValue" ) ;
+               errorCodes.put( 216, "IllegalMissingDataAction" ) ;
+               errorCodes.put( 217, "SegmentationCannotGuaranteeRecordsWillFitInSpecifiedSegments" ) ;
+               errorCodes.put( 218, "EsPackageNameAlreadyInUse" ) ;
+               errorCodes.put( 219, "EsNoSuchPackageOnModifyDelete" ) ;
+               errorCodes.put( 220, "EsQuotaExceeded" ) ;
+               errorCodes.put( 221, "EsExtendedServiceTypeNotSupported" ) ;
+               errorCodes.put( 222, "EsPermissionDeniedOnEsIdNotAuthorized" ) ;
+               errorCodes.put( 223, "EsPermissionDeniedOnEsCannotModifyOrDelete" ) ;
+               errorCodes.put( 224, "EsImmediateExecutionFailed" ) ;
+               errorCodes.put( 225, "EsImmediateExecutionNotSupportedForThisService" ) ;
+               errorCodes.put( 226, "EsImmediateExecutionNotSupportedForTheseParameters" ) ;
+               errorCodes.put( 227, "NoDataAvailableInRequestedRecordSyntax" ) ;
+               errorCodes.put( 228, "ScanMalformedScan" ) ;
+               errorCodes.put( 229, "TermTypeNotSupported" ) ;
+               errorCodes.put( 230, "SortTooManyInputResults" ) ;
+               errorCodes.put( 231, "SortIncompatibleRecordFormats" ) ;
+               errorCodes.put( 232, "ScanTermListNotSupported" ) ;
+               errorCodes.put( 233, "ScanUnsupportedValueOfPositionInResponse" ) ;
+               errorCodes.put( 234, "TooManyIndexTermsProcessed" ) ;
+               errorCodes.put( 235, "DatabaseDoesNotExist" ) ;
+               errorCodes.put( 236, "AccessToSpecifiedDatabaseDenied" ) ;
+               errorCodes.put( 237, "SortIllegalSort" ) ;
+               errorCodes.put( 238, "RecordNotAvailableInRequestedSyntax" ) ;
+               errorCodes.put( 239, "RecordSyntaxNotSupported" ) ;
+               errorCodes.put( 240, "ScanResourcesExhaustedLookingForSatisfyingTerms" ) ;
+               errorCodes.put( 241, "ScanBeginningOrEndOfTermList" ) ;
+               errorCodes.put( 242, "SegmentationMaxSegmentSizeTooSmallToSegmentRecord" ) ;
+               errorCodes.put( 243, "PresentAdditionalRangesParameterNotSupported" ) ;
+               errorCodes.put( 244, "PresentCompSpecParameterNotSupported" ) ;
+               errorCodes.put( 245, "Type1QueryRestrictionOperandNotSupported" ) ;
+               errorCodes.put( 246, "Type1QueryComplexAttributevalueNotSupported" ) ;
+               errorCodes.put( 247, "Type1QueryAttributesetAsPartOfAttributeelementNotSupported" ) ;           
+       }
+
+       public static String GetError( int errorCode )
+       {
+               String errorText = "Unknown Error" ;
+               
+               if( errorCodes.containsKey(errorCode) )
+                       errorText = errorCodes.get( errorCode );
+
+               return errorText;       
+       }       
+}
diff --git a/src/main/java/org/yaz4j/Bib1Exception.java b/src/main/java/org/yaz4j/Bib1Exception.java
new file mode 100644 (file)
index 0000000..742b9ab
--- /dev/null
@@ -0,0 +1,16 @@
+package org.yaz4j;
+
+public class Bib1Exception extends RuntimeException
+{
+       private static final long serialVersionUID = 1L;
+
+       public Bib1Exception()
+       {
+               super();
+       }
+       
+       public Bib1Exception(String message )
+       {
+               super( message );
+       }
+}
diff --git a/src/main/java/org/yaz4j/CQLQuery.java b/src/main/java/org/yaz4j/CQLQuery.java
new file mode 100644 (file)
index 0000000..1411e28
--- /dev/null
@@ -0,0 +1,21 @@
+package org.yaz4j;
+
+public class CQLQuery
+{
+       private String query = null;
+       
+       public CQLQuery(String query)
+       {
+               this.query = query;
+       }
+
+       public String getQueryString()
+       {
+               return query ;
+       }
+       
+       public void setQueryString( String query)
+       {
+               this.query = query ;
+       }
+}
diff --git a/src/main/java/org/yaz4j/Connection.java b/src/main/java/org/yaz4j/Connection.java
new file mode 100644 (file)
index 0000000..2c5fcf2
--- /dev/null
@@ -0,0 +1,235 @@
+package org.yaz4j;
+
+import org.yaz4j.jni.SWIGTYPE_p_ZOOM_connection_p;
+import org.yaz4j.jni.SWIGTYPE_p_ZOOM_query_p;
+import org.yaz4j.jni.SWIGTYPE_p_ZOOM_resultset_p;
+import org.yaz4j.jni.SWIGTYPE_p_ZOOM_scanset_p;
+import org.yaz4j.jni.SWIGTYPE_p_p_char;
+import org.yaz4j.jni.yaz4jlib;
+import org.yaz4j.jni.yaz4jlibConstants;
+
+import sun.reflect.generics.reflectiveObjects.NotImplementedException;
+
+public class Connection
+{
+       private String host ;
+       private int port ;
+       private ConnectionOptionsCollection options = null ;
+       protected SWIGTYPE_p_ZOOM_connection_p zoomConnection = null ;
+       private boolean connected = false;
+       private boolean disposed = false;
+       
+       static
+       {
+               // on Linux   'yaz4j' maps to 'libyaz4j.so' (i.e. 'lib' prefix & '.so'  extension)
+               // on Windows 'yaz4j' maps to 'yaz4j.dll'   (i.e.                '.dll' extension)              
+               String libName = "yaz4j" ;
+               try
+               {
+                       // System.err.println( "Loading library '"+ System.mapLibraryName( libName ) + "'" );
+                       System.loadLibrary( libName );
+               }
+               catch( Throwable e )
+               {
+                       System.err.println( "Fatal Error: Failed to load library '" + System.mapLibraryName( libName ) + "'");
+                       e.printStackTrace();
+               }               
+       }
+       
+       public Connection(String host, int port)
+       {
+               this.host = host ;
+               this.port = port ;
+
+               options = new ConnectionOptionsCollection();
+               zoomConnection = yaz4jlib.ZOOM_connection_create(options.zoomOptions);
+
+               SWIGTYPE_p_p_char cp = null;
+               SWIGTYPE_p_p_char addinfo = null ;              
+               int errorCode = yaz4jlib.ZOOM_connection_error(zoomConnection, cp, addinfo);
+               CheckErrorCodeAndThrow(errorCode);
+       }
+       
+       public void finalize()
+       {
+               Dispose();
+       }
+       
+       private void CheckErrorCodeAndThrow(int errorCode)
+       {
+               String message;
+               
+               if( errorCode == yaz4jlibConstants.ZOOM_ERROR_NONE )
+               {
+                       return ;
+               }
+               else if( errorCode == yaz4jlib.ZOOM_ERROR_CONNECT ) 
+               {
+                       message = String.format("Connection could not be made to %s:%d", host, port);
+                       throw new ConnectionUnavailableException(message);
+               }
+               else if( errorCode == yaz4jlib.ZOOM_ERROR_INVALID_QUERY )
+               {
+                       message = String.format("The query requested is not valid or not supported");
+                       throw new InvalidQueryException(message);
+               }
+               else if( errorCode == yaz4jlib.ZOOM_ERROR_INIT )
+               {
+                       message = String.format("Server %s:%d rejected our init request", host, port);
+                       throw new InitRejectedException(message);                       
+               }
+               else if( errorCode == yaz4jlib.ZOOM_ERROR_TIMEOUT )
+               {
+                       message = String.format("Server %s:%d timed out handling our request", host, port);
+                       throw new ConnectionTimeoutException(message);                  
+               }
+        else if(    ( errorCode == yaz4jlib.ZOOM_ERROR_MEMORY ) 
+                        || ( errorCode == yaz4jlib.ZOOM_ERROR_ENCODE )
+                                || ( errorCode == yaz4jlib.ZOOM_ERROR_DECODE )
+                        || ( errorCode == yaz4jlib.ZOOM_ERROR_CONNECTION_LOST )
+                        || ( errorCode == yaz4jlib.ZOOM_ERROR_INTERNAL )
+                        || ( errorCode == yaz4jlib.ZOOM_ERROR_UNSUPPORTED_PROTOCOL )
+                        || ( errorCode == yaz4jlib.ZOOM_ERROR_UNSUPPORTED_QUERY ) )                     
+        {
+                       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) + ")" ; 
+                       throw new Bib1Exception( errMsgBib1 );
+        }
+       }
+
+       private enum QueryType { CQLQuery, PrefixQuery };
+       
+       public ResultSet Search(PrefixQuery query)
+       {
+               return Search( query.getQueryString(), QueryType.PrefixQuery);
+       }
+       
+       public ResultSet Search(CQLQuery query)
+       {
+               return Search( query.getQueryString(), QueryType.CQLQuery);
+       }
+       
+       private ResultSet Search(String query, QueryType queryType)
+       {       
+               EnsureConnected();
+
+               SWIGTYPE_p_ZOOM_query_p yazQuery = yaz4jlib.ZOOM_query_create();
+        ResultSet resultSet = null;
+
+        try
+        {
+               if( queryType == QueryType.CQLQuery )
+                       yaz4jlib.ZOOM_query_cql(yazQuery, query);
+               else if( queryType == QueryType.PrefixQuery )
+                       yaz4jlib.ZOOM_query_prefix(yazQuery, query);
+               else
+                       throw new NotImplementedException();
+               
+               SWIGTYPE_p_ZOOM_resultset_p yazResultSet = yaz4jlib.ZOOM_connection_search(zoomConnection, yazQuery);
+            
+            int errorCode = yaz4jlib.ZOOM_connection_errcode( zoomConnection );
+            if (errorCode != yaz4jlib.ZOOM_ERROR_NONE)
+            {
+               yaz4jlib.ZOOM_resultset_destroy(yazResultSet);
+            }
+            CheckErrorCodeAndThrow(errorCode);
+
+            resultSet = new ResultSet(yazResultSet, zoomConnection);
+        }
+        finally
+        {
+               yaz4jlib.ZOOM_query_destroy(yazQuery); // deallocate yazQuery also when exceptions
+            yazQuery = null;
+        }
+        return resultSet;
+       }
+       
+       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);
+
+               ScanSet scanSet = new ScanSet(yazScanSet, this);
+               return scanSet;
+       }
+       
+       public ConnectionOptionsCollection getOptions()
+       {
+               return options;
+       }
+
+       protected void EnsureConnected()
+       {
+               if (! connected )
+                       Connect();
+       }
+       
+       public void Connect()
+       {
+               yaz4jlib.ZOOM_connection_connect( zoomConnection, host, port);
+               int errorCode = yaz4jlib.ZOOM_connection_errcode(zoomConnection);
+               CheckErrorCodeAndThrow(errorCode);
+               connected = true;
+       }
+       
+       public void Dispose()
+       {
+               if (! disposed )
+               {
+                       yaz4jlib.ZOOM_connection_destroy(zoomConnection);
+                       zoomConnection = null;
+                       disposed = true;
+               }
+       }
+
+       public String getSyntax()
+       {
+               return options.get("preferredRecordSyntax");
+       }
+       
+       public void setSyntax( String value)
+       {
+               options.set("preferredRecordSyntax", value ) ;
+       }
+
+       public String getDatabaseName()
+       {
+               return options.get("databaseName");
+       }
+       
+       public void setDatabaseName( String value )
+       {
+               options.set("databaseName", value);
+       }
+
+       public String getUsername()
+       {
+               return options.get("user");
+       }
+       
+       public void setUsername( String value )
+       {
+               options.set("user", value);
+       }
+
+       public String getPassword()
+       {
+               return options.get("password");
+       }
+       
+       public void setPassword( String value )
+       {
+               options.set("password", value);
+       }
+}
diff --git a/src/main/java/org/yaz4j/ConnectionExtended.java b/src/main/java/org/yaz4j/ConnectionExtended.java
new file mode 100644 (file)
index 0000000..8d9744b
--- /dev/null
@@ -0,0 +1,25 @@
+package org.yaz4j;
+
+import org.yaz4j.jni.SWIGTYPE_p_ZOOM_options_p;
+import org.yaz4j.jni.SWIGTYPE_p_ZOOM_package_p;
+import org.yaz4j.jni.yaz4jlib;
+
+public class ConnectionExtended extends Connection
+{
+    public ConnectionExtended(String host, int port) 
+       {
+       super(host, port);
+       }
+
+    public Package Package(String type)
+    {
+        EnsureConnected();
+        Package pack = null;
+        
+        SWIGTYPE_p_ZOOM_options_p options = yaz4jlib.ZOOM_options_create();
+
+        SWIGTYPE_p_ZOOM_package_p yazPackage = yaz4jlib.ZOOM_connection_package( zoomConnection, options);
+        pack = new Package(yazPackage, this, type);
+        return pack;
+    }
+}
diff --git a/src/main/java/org/yaz4j/ConnectionOptionsCollection.java b/src/main/java/org/yaz4j/ConnectionOptionsCollection.java
new file mode 100644 (file)
index 0000000..fb60263
--- /dev/null
@@ -0,0 +1,42 @@
+package org.yaz4j;
+
+import org.yaz4j.jni.SWIGTYPE_p_ZOOM_connection_p;
+import org.yaz4j.jni.SWIGTYPE_p_ZOOM_options_p;
+import org.yaz4j.jni.yaz4jlib;
+
+public class ConnectionOptionsCollection
+{
+       SWIGTYPE_p_ZOOM_options_p zoomOptions = null ;
+
+       ConnectionOptionsCollection()
+       {
+               zoomOptions = yaz4jlib.ZOOM_options_create();
+       }
+
+       public void finalize()
+       {
+               Dispose();
+       }
+       
+       public void Dispose()
+       {
+               yaz4jlib.ZOOM_options_destroy( zoomOptions );
+               zoomOptions = null ;
+       }
+       
+       SWIGTYPE_p_ZOOM_connection_p CreateConnection()
+       {
+               return yaz4jlib.ZOOM_connection_create(zoomOptions);
+       }
+       
+       public String get(String key)
+       {
+               return yaz4jlib.ZOOM_options_get(zoomOptions, key) ;
+       }
+       
+       public void set(String key, String value)
+       {
+               yaz4jlib.ZOOM_options_set(zoomOptions, key, value) ;
+       }
+       
+}
diff --git a/src/main/java/org/yaz4j/ConnectionTimeoutException.java b/src/main/java/org/yaz4j/ConnectionTimeoutException.java
new file mode 100644 (file)
index 0000000..7f6c574
--- /dev/null
@@ -0,0 +1,16 @@
+package org.yaz4j;
+
+public class ConnectionTimeoutException extends RuntimeException
+{
+       private static final long serialVersionUID = 1L;
+
+       public ConnectionTimeoutException()
+       {
+               super();
+       }
+       
+       public ConnectionTimeoutException(String message )
+       {
+               super( message );
+       }
+}
diff --git a/src/main/java/org/yaz4j/ConnectionUnavailableException.java b/src/main/java/org/yaz4j/ConnectionUnavailableException.java
new file mode 100644 (file)
index 0000000..25c7226
--- /dev/null
@@ -0,0 +1,16 @@
+package org.yaz4j;
+
+public class ConnectionUnavailableException extends RuntimeException
+{
+       private static final long serialVersionUID = 1L;
+
+       public ConnectionUnavailableException()
+       {
+               super();
+       }
+       
+       public ConnectionUnavailableException(String message )
+       {
+               super( message );
+       }
+}
diff --git a/src/main/java/org/yaz4j/InitRejectedException.java b/src/main/java/org/yaz4j/InitRejectedException.java
new file mode 100644 (file)
index 0000000..83c3c8d
--- /dev/null
@@ -0,0 +1,16 @@
+package org.yaz4j;
+
+public class InitRejectedException extends RuntimeException
+{
+       private static final long serialVersionUID = 1L;
+
+       public InitRejectedException()
+       {
+               super();
+       }
+       
+       public InitRejectedException(String message )
+       {
+               super( message );
+       }
+}
diff --git a/src/main/java/org/yaz4j/InvalidQueryException.java b/src/main/java/org/yaz4j/InvalidQueryException.java
new file mode 100644 (file)
index 0000000..4f265c2
--- /dev/null
@@ -0,0 +1,16 @@
+package org.yaz4j;
+
+public class InvalidQueryException extends RuntimeException
+{
+       private static final long serialVersionUID = 1L;
+
+       public InvalidQueryException()
+       {
+               super();
+       }
+       
+       public InvalidQueryException(String message )
+       {
+               super( message );
+       }
+}
diff --git a/src/main/java/org/yaz4j/Package.java b/src/main/java/org/yaz4j/Package.java
new file mode 100644 (file)
index 0000000..590b172
--- /dev/null
@@ -0,0 +1,43 @@
+package org.yaz4j;
+
+import org.yaz4j.jni.SWIGTYPE_p_ZOOM_package_p;
+import org.yaz4j.jni.yaz4jlib;
+
+public class Package
+{
+       private SWIGTYPE_p_ZOOM_package_p pack = null ;
+       private ConnectionExtended connection = null ;  
+       private String type;
+
+       Package(SWIGTYPE_p_ZOOM_package_p pack, ConnectionExtended connection, String type)
+       {
+               this.type = type;
+               this.connection = connection;
+               this.pack = pack;
+       }
+       
+       public void finalize()
+       {
+               Dispose();
+       }
+       
+       public PackageOptionsCollection getPackageOptions()
+       {
+          return new PackageOptionsCollection(pack);
+       }
+       
+       public void Send()
+       { 
+               yaz4jlib.ZOOM_package_send( pack, type );
+       }
+       
+       public void Dispose()
+       {
+               if ( pack != null )
+               {
+                       yaz4jlib.ZOOM_package_destroy( pack );
+                       connection = null;
+                       pack = null ;
+               }
+       }
+}
diff --git a/src/main/java/org/yaz4j/PackageOptionsCollection.java b/src/main/java/org/yaz4j/PackageOptionsCollection.java
new file mode 100644 (file)
index 0000000..7cff946
--- /dev/null
@@ -0,0 +1,29 @@
+package org.yaz4j;
+
+import org.yaz4j.jni.SWIGTYPE_p_ZOOM_package_p;
+import org.yaz4j.jni.yaz4jlib;
+
+public class PackageOptionsCollection
+{
+    private SWIGTYPE_p_ZOOM_package_p pack = null;     
+       
+    PackageOptionsCollection(SWIGTYPE_p_ZOOM_package_p pack)
+    {
+        this.pack = pack;
+    }
+    
+    public void Dispose()
+    {
+        pack = null;
+    }
+    
+    public String get(String key)
+    {
+       return yaz4jlib.ZOOM_package_option_get( pack, key) ;
+    }
+
+    public void set(String key, String value)
+    {
+       yaz4jlib.ZOOM_package_option_set( pack, key, value) ;
+    }
+}
diff --git a/src/main/java/org/yaz4j/PrefixQuery.java b/src/main/java/org/yaz4j/PrefixQuery.java
new file mode 100644 (file)
index 0000000..f8d2e53
--- /dev/null
@@ -0,0 +1,21 @@
+package org.yaz4j;
+
+public class PrefixQuery
+{
+       private String query = null;
+       
+       public PrefixQuery(String query)
+       {
+               this.query = query;
+       }
+
+       public String getQueryString()
+       {
+               return query ;
+       }
+       
+       public void setQueryString( String query)
+       {
+               this.query = query ;
+       }       
+}
diff --git a/src/main/java/org/yaz4j/Record.java b/src/main/java/org/yaz4j/Record.java
new file mode 100644 (file)
index 0000000..e1990a7
--- /dev/null
@@ -0,0 +1,71 @@
+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;
+
+public class Record
+{
+       private SWIGTYPE_p_ZOOM_record_p record = null ;
+       private ResultSet resultSet = null ;
+       private boolean disposed = false;       
+
+       Record(SWIGTYPE_p_ZOOM_record_p record, ResultSet resultSet)
+       {
+               this.resultSet = resultSet;
+               this.record = record;
+       }
+
+       public void finalize()
+       {
+               Dispose();
+       }
+       
+       public byte[] getContent()
+       {
+               String type = "raw";
+               SWIGTYPE_p_int length = null ;  
+               return yaz4jlib.ZOOM_record_get_bytes(record, type, length) ;
+//             String contentString = yaz4jlib.ZOOM_record_get(record, type, length) ;
+//             System.err.println("!!!!!");
+//             System.err.println(contentString);
+//             System.err.println(contentString.length());
+//             System.err.println("!!!!!");
+//             try {
+//                     byte[] bytes = contentString.getBytes("UTF8");
+//                     System.err.println(bytes.length);
+//                     return bytes ;
+//             } catch (UnsupportedEncodingException e) {
+//                     throw new RuntimeException(e);
+//             }
+       }
+
+       public String getSyntax()
+       {
+               String type = "syntax";
+               SWIGTYPE_p_int length = null ;          
+               String syntax = yaz4jlib.ZOOM_record_get(record, type, length);
+               return syntax ;
+       }
+       
+       public String getDatabase()
+       {
+               String type = "database";
+               SWIGTYPE_p_int length = null ;          
+               String database = yaz4jlib.ZOOM_record_get(record, type, length);
+       
+               return database ;
+       }
+
+       public void Dispose()
+       {
+               if (!disposed)
+               {
+                       resultSet = null;
+                       record = null;
+                       disposed = true;
+               }
+       }
+}
diff --git a/src/main/java/org/yaz4j/ResultSet.java b/src/main/java/org/yaz4j/ResultSet.java
new file mode 100644 (file)
index 0000000..b70a03e
--- /dev/null
@@ -0,0 +1,66 @@
+package org.yaz4j;
+
+import org.yaz4j.jni.SWIGTYPE_p_ZOOM_connection_p;
+import org.yaz4j.jni.SWIGTYPE_p_ZOOM_record_p;
+import org.yaz4j.jni.SWIGTYPE_p_ZOOM_resultset_p;
+import org.yaz4j.jni.yaz4jlib;
+
+public class ResultSet
+{
+       private SWIGTYPE_p_ZOOM_resultset_p resultSet;  
+       private SWIGTYPE_p_ZOOM_connection_p connection;
+       private long size = 0 ;
+       private Record[] records = null ;
+       private boolean disposed = false;       
+       
+       ResultSet(SWIGTYPE_p_ZOOM_resultset_p resultSet, SWIGTYPE_p_ZOOM_connection_p connection)
+       {
+               this.resultSet = resultSet ;
+               this.connection = connection ;
+               size = yaz4jlib.ZOOM_resultset_size(this.resultSet);
+               records = new Record[(int)size];
+       }
+       
+       public void finalize()
+       {
+               this.Dispose();         
+       }       
+
+    ResultSetOptionsCollection getResultSetOptions()
+    {
+       return new ResultSetOptionsCollection(resultSet);
+    }
+       
+       public Record getRecord(int index)
+       {
+               if ( records[index] == null)
+               {
+                       SWIGTYPE_p_ZOOM_record_p recordTemp = yaz4jlib.ZOOM_resultset_record(resultSet, index);
+                       records[index] = new Record(recordTemp, this);
+               }
+       
+               return this.records[index];
+       }
+       
+       public int getSize()
+       {
+               return (int)size ;
+       }
+       
+       public void Dispose()
+       {
+               if (! disposed )
+               {
+                       for( int i=0 ; i<records.length ; i++)
+                       {
+                               if (records[i] != null)
+                                       records[i].Dispose();
+                       }
+
+                       yaz4jlib.ZOOM_resultset_destroy(resultSet);
+                       connection = null;
+                       resultSet = null;
+                       disposed = true;
+               }
+       }
+}
diff --git a/src/main/java/org/yaz4j/ResultSetOptionsCollection.java b/src/main/java/org/yaz4j/ResultSetOptionsCollection.java
new file mode 100644 (file)
index 0000000..2cfdd99
--- /dev/null
@@ -0,0 +1,29 @@
+package org.yaz4j;
+
+import org.yaz4j.jni.SWIGTYPE_p_ZOOM_resultset_p;
+import org.yaz4j.jni.yaz4jlib;
+
+public class ResultSetOptionsCollection
+{
+       private SWIGTYPE_p_ZOOM_resultset_p resultSet = null ;  
+       
+    ResultSetOptionsCollection(SWIGTYPE_p_ZOOM_resultset_p resultSet)
+    {
+       this.resultSet = resultSet;
+    }
+    
+    public void finalize()
+    {
+       resultSet = null ;
+    }
+
+       public String get(String key)
+       {
+               return yaz4jlib.ZOOM_resultset_option_get(resultSet, key) ;
+       }
+       
+       public void set(String key, String value)
+       {
+               yaz4jlib.ZOOM_resultset_option_set(resultSet, key, value) ;
+       }
+}
diff --git a/src/main/java/org/yaz4j/ScanSet.java b/src/main/java/org/yaz4j/ScanSet.java
new file mode 100644 (file)
index 0000000..3e23046
--- /dev/null
@@ -0,0 +1,50 @@
+package org.yaz4j;
+
+import org.yaz4j.jni.SWIGTYPE_p_ZOOM_scanset_p;
+import org.yaz4j.jni.SWIGTYPE_p_int;
+import org.yaz4j.jni.yaz4jlib;
+
+public class ScanSet
+{
+       private SWIGTYPE_p_ZOOM_scanset_p scanSet = null ;
+       private Connection connection;
+       private boolean disposed = false;
+       
+       ScanSet(SWIGTYPE_p_ZOOM_scanset_p scanSet, Connection connection)
+       {
+               this.connection = connection;
+               this.scanSet = scanSet;
+       }
+
+       public void finalize()
+       {
+               Dispose();
+       }
+
+       public ScanTerm get(long index)
+       {
+               SWIGTYPE_p_int occ = yaz4jlib.new_intp();
+               SWIGTYPE_p_int length = yaz4jlib.new_intp();
+               String term = yaz4jlib.ZOOM_scanset_term( scanSet, (long)index, occ, length ) ;
+               int occurences = yaz4jlib.intp_value(occ);
+               yaz4jlib.delete_intp(occ);
+               yaz4jlib.delete_intp(length);
+               return new ScanTerm(term, occurences);
+       }
+
+       public long getSize()
+       {
+               return yaz4jlib.ZOOM_scanset_size(scanSet);
+       }
+
+       public void Dispose()
+       {
+               if (! disposed)
+               {
+                       yaz4jlib.ZOOM_scanset_destroy(scanSet);
+                       connection = null;
+                       scanSet = null;
+                       disposed = true;
+               }
+       }
+}
diff --git a/src/main/java/org/yaz4j/ScanTerm.java b/src/main/java/org/yaz4j/ScanTerm.java
new file mode 100644 (file)
index 0000000..5f02952
--- /dev/null
@@ -0,0 +1,23 @@
+package org.yaz4j;
+
+public class ScanTerm
+{
+       private String term;
+       private long occurences;
+       
+       ScanTerm( String term, long occurences )
+       {
+               this.term = term;
+               this.occurences = occurences;
+       }
+
+       public String getTerm()
+       {
+               return term;
+       }
+
+       public long getOccurences()
+       {
+               return occurences;
+       }
+}
diff --git a/src/main/java/org/yaz4j/Yaz4jMain.java b/src/main/java/org/yaz4j/Yaz4jMain.java
new file mode 100644 (file)
index 0000000..b7e4352
--- /dev/null
@@ -0,0 +1,31 @@
+package org.yaz4j;
+
+import java.io.UnsupportedEncodingException;
+import java.io.IOException;
+
+public class Yaz4jMain
+{
+       // java -cp ./bin: -Djava.library.path=./libyaz4j org.yaz4j.Yaz4jMain
+       
+       public static void main(String[] args) throws UnsupportedEncodingException, IOException
+       {
+               Connection conn = new Connection("talisbase.talis.com", 210);           
+               conn.setDatabaseName("unionm21");
+               conn.setUsername("fred");
+               conn.setPassword("apple");
+               conn.setSyntax("USMarc"); // USMarc, Sutrs, XML, opac, UKMarc           
+               
+               PrefixQuery query = new PrefixQuery( "@attr 1=4 \"pottering\"" );
+               ResultSet results = conn.Search( query );
+               
+               int resultsSize = results.getSize() ;
+               System.out.println( "Found " + resultsSize + " records");               
+               
+               for( int i=0; i<resultsSize ; i++)
+               {
+                       Record record = results.getRecord(i);
+                       System.out.write(record.getContent());
+               }
+               conn.Dispose();
+       }
+}
diff --git a/src/main/java/org/yaz4j/ZoomImplementationException.java b/src/main/java/org/yaz4j/ZoomImplementationException.java
new file mode 100644 (file)
index 0000000..f08bc88
--- /dev/null
@@ -0,0 +1,16 @@
+package org.yaz4j;
+
+public class ZoomImplementationException extends RuntimeException
+{
+       private static final long serialVersionUID = 1L;
+
+       public ZoomImplementationException()
+       {
+               super();
+       }
+       
+       public ZoomImplementationException(String message )
+       {
+               super( message );
+       }
+}
diff --git a/src/main/java/org/yaz4j/jni/.gitignore b/src/main/java/org/yaz4j/jni/.gitignore
new file mode 100644 (file)
index 0000000..27d1535
--- /dev/null
@@ -0,0 +1 @@
+*.java
diff --git a/src/org/yaz4j/Bib1Diagnostic.java b/src/org/yaz4j/Bib1Diagnostic.java
deleted file mode 100644 (file)
index 5dd8c11..0000000
+++ /dev/null
@@ -1,134 +0,0 @@
-package org.yaz4j;
-
-import java.util.Hashtable;
-
-class Bib1Diagnostic
-{
-       private static Hashtable<Integer, String> errorCodes = new Hashtable<Integer, String>();
-
-       static
-       {
-               errorCodes.put(   1, "PermanentSystemError" ) ;
-               errorCodes.put(   2, "TemporarySystemError" ) ;
-               errorCodes.put(   3, "UnsupportedSearch" ) ;
-               errorCodes.put(   4, "TermsOnlyIncludesExclusionOrStopWords" ) ;
-               errorCodes.put(   5, "TooManyArgumentWords" ) ;
-               errorCodes.put(   6, "TooManyBooleanOperators" ) ;
-               errorCodes.put(   7, "TooManyTruncatedWords" ) ;
-               errorCodes.put(   8, "TooManyIncompleteSubfields" ) ;
-               errorCodes.put(   9, "TruncatedWordsTooShort" ) ;
-               errorCodes.put(  10, "InvalidFormatForRecordNumberInSearchTerm" ) ;
-               errorCodes.put(  11, "TooManyCharactersInSearchStatement" ) ;
-               errorCodes.put(  12, "TooManyRecordsRetrieved" ) ;
-               errorCodes.put(  13, "PresentRequestOutOfRange" ) ;
-               errorCodes.put(  14, "SystemErrorInPresentingRecords" ) ;
-               errorCodes.put(  15, "RecordNotAuthorizedToBeSentIntersystem" ) ;
-               errorCodes.put(  16, "RecordExceedsPreferredMessageSize" ) ;
-               errorCodes.put(  17, "RecordExceedsExceptionalRecordSize" ) ;
-               errorCodes.put(  18, "ResultSetNotSupportedAsASearchTerm" ) ;
-               errorCodes.put(  19, "OnlySingleResultSetAsSearchTermSupported" ) ;
-               errorCodes.put(  20, "OnlyAndingOfASingleResultSetAsSearchTerm" ) ;
-               errorCodes.put(  21, "ResultSetExistsAndReplaceIndicatorOff" ) ;
-               errorCodes.put(  22, "ResultSetNamingNotSupported" ) ;
-               errorCodes.put(  23, "SpecifiedCombinationOfDatabasesNotSupported" ) ;
-               errorCodes.put(  24, "ElementSetNamesNotSupported" ) ;
-               errorCodes.put(  25, "SpecifiedElementSetNameNotValidForSpecifiedDatabase" ) ;
-               errorCodes.put(  26, "OnlyGenericFormOfElementSetNameSupported" ) ;
-               errorCodes.put(  27, "ResultSetNoLongerExistsUnilaterallyDeletedByTarget" ) ;
-               errorCodes.put(  28, "ResultSetIsInUse" ) ;
-               errorCodes.put(  29, "OneOfTheSpecifiedDatabasesIsLocked" ) ;
-               errorCodes.put(  30, "SpecifiedResultSetDoesNotExist" ) ;
-               errorCodes.put(  31, "ResourcesExhaustedNoResultsAvailable" ) ;
-               errorCodes.put(  32, "ResourcesExhaustedUnpredictablePartialResultsAvailable" ) ;
-               errorCodes.put(  33, "ResourcesExhaustedValidSubsetOfResultsAvailable" ) ;
-               errorCodes.put( 100, "UnspecifiedError" ) ;
-               errorCodes.put( 101, "AccessControlFailure" ) ;
-               errorCodes.put( 102, "ChallengeRequiredCouldNotBeIssuedOperationTerminated" ) ;
-               errorCodes.put( 103, "ChallengeRequiredCouldNotBeIssuedRecordNotIncluded" ) ;
-               errorCodes.put( 104, "ChallengeFailedRecordNotIncluded" ) ;
-               errorCodes.put( 105, "TerminatedAtOriginRequest" ) ;
-               errorCodes.put( 106, "NoAbstractSyntaxesAgreedToForThisRecord" ) ;
-               errorCodes.put( 107, "QueryTypeNotSupported" ) ;
-               errorCodes.put( 108, "MalformedQuery" ) ;
-               errorCodes.put( 109, "DatabaseUnavailable" ) ;
-               errorCodes.put( 110, "OperatorUnsupported" ) ;
-               errorCodes.put( 111, "TooManyDatabasesSpecified" ) ;
-               errorCodes.put( 112, "TooManyResultSetsCreated" ) ;
-               errorCodes.put( 113, "UnsupportedAttributeType" ) ;
-               errorCodes.put( 114, "UnsupportedUseAttribute" ) ;
-               errorCodes.put( 115, "UnsupportedTermValueForUseAttribute" ) ;
-               errorCodes.put( 116, "UseAttributeRequiredButNotSupplied" ) ;
-               errorCodes.put( 117, "UnsupportedRelationAttribute" ) ;
-               errorCodes.put( 118, "UnsupportedStructureAttribute" ) ;
-               errorCodes.put( 119, "UnsupportedPositionAttribute" ) ;
-               errorCodes.put( 120, "UnsupportedTruncationAttribute" ) ;
-               errorCodes.put( 121, "UnsupportedAttributeSet" ) ;
-               errorCodes.put( 122, "UnsupportedCompletenessAttribute" ) ;
-               errorCodes.put( 123, "UnsupportedAttributeCombination" ) ;
-               errorCodes.put( 124, "UnsupportedCodedValueForTerm" ) ;
-               errorCodes.put( 125, "MalformedSearchTerm" ) ;
-               errorCodes.put( 126, "IllegalTermValueForAttribute" ) ;
-               errorCodes.put( 127, "UnparsableFormatForUnNormalizedValue" ) ;
-               errorCodes.put( 128, "IllegalResultSetName" ) ;
-               errorCodes.put( 129, "ProximitySearchOfSetsNotSupported" ) ;
-               errorCodes.put( 130, "IllegalResultSetInProximitySearch" ) ;
-               errorCodes.put( 131, "UnsupportedProximityRelation" ) ;
-               errorCodes.put( 132, "UnsupportedProximityUnitCode" ) ;
-               errorCodes.put( 201, "ProximityNotSupportedWithThisAttributeCombinationAttribute" ) ;
-               errorCodes.put( 202, "UnsupportedDistanceForProximity" ) ;
-               errorCodes.put( 203, "OrderedFlagNotSupportedForProximity" ) ;
-               errorCodes.put( 205, "OnlyZeroStepSizeSupportedForScan" ) ;
-               errorCodes.put( 206, "SpecifiedStepSizeNotSupportedForScanStep" ) ;
-               errorCodes.put( 207, "CannotSortAccordingToSequence" ) ;
-               errorCodes.put( 208, "NoResultSetNameSuppliedOnSort" ) ;
-               errorCodes.put( 209, "GenericSortNotSupported" ) ;
-               errorCodes.put( 210, "DatabaseSpecificSortNotSupported" ) ;
-               errorCodes.put( 211, "TooManySortKeys" ) ;
-               errorCodes.put( 212, "DuplicateSortKeys" ) ;
-               errorCodes.put( 213, "UnsupportedMissingDataAction" ) ;
-               errorCodes.put( 214, "IllegalSortRelation" ) ;
-               errorCodes.put( 215, "IllegalCaseValue" ) ;
-               errorCodes.put( 216, "IllegalMissingDataAction" ) ;
-               errorCodes.put( 217, "SegmentationCannotGuaranteeRecordsWillFitInSpecifiedSegments" ) ;
-               errorCodes.put( 218, "EsPackageNameAlreadyInUse" ) ;
-               errorCodes.put( 219, "EsNoSuchPackageOnModifyDelete" ) ;
-               errorCodes.put( 220, "EsQuotaExceeded" ) ;
-               errorCodes.put( 221, "EsExtendedServiceTypeNotSupported" ) ;
-               errorCodes.put( 222, "EsPermissionDeniedOnEsIdNotAuthorized" ) ;
-               errorCodes.put( 223, "EsPermissionDeniedOnEsCannotModifyOrDelete" ) ;
-               errorCodes.put( 224, "EsImmediateExecutionFailed" ) ;
-               errorCodes.put( 225, "EsImmediateExecutionNotSupportedForThisService" ) ;
-               errorCodes.put( 226, "EsImmediateExecutionNotSupportedForTheseParameters" ) ;
-               errorCodes.put( 227, "NoDataAvailableInRequestedRecordSyntax" ) ;
-               errorCodes.put( 228, "ScanMalformedScan" ) ;
-               errorCodes.put( 229, "TermTypeNotSupported" ) ;
-               errorCodes.put( 230, "SortTooManyInputResults" ) ;
-               errorCodes.put( 231, "SortIncompatibleRecordFormats" ) ;
-               errorCodes.put( 232, "ScanTermListNotSupported" ) ;
-               errorCodes.put( 233, "ScanUnsupportedValueOfPositionInResponse" ) ;
-               errorCodes.put( 234, "TooManyIndexTermsProcessed" ) ;
-               errorCodes.put( 235, "DatabaseDoesNotExist" ) ;
-               errorCodes.put( 236, "AccessToSpecifiedDatabaseDenied" ) ;
-               errorCodes.put( 237, "SortIllegalSort" ) ;
-               errorCodes.put( 238, "RecordNotAvailableInRequestedSyntax" ) ;
-               errorCodes.put( 239, "RecordSyntaxNotSupported" ) ;
-               errorCodes.put( 240, "ScanResourcesExhaustedLookingForSatisfyingTerms" ) ;
-               errorCodes.put( 241, "ScanBeginningOrEndOfTermList" ) ;
-               errorCodes.put( 242, "SegmentationMaxSegmentSizeTooSmallToSegmentRecord" ) ;
-               errorCodes.put( 243, "PresentAdditionalRangesParameterNotSupported" ) ;
-               errorCodes.put( 244, "PresentCompSpecParameterNotSupported" ) ;
-               errorCodes.put( 245, "Type1QueryRestrictionOperandNotSupported" ) ;
-               errorCodes.put( 246, "Type1QueryComplexAttributevalueNotSupported" ) ;
-               errorCodes.put( 247, "Type1QueryAttributesetAsPartOfAttributeelementNotSupported" ) ;           
-       }
-
-       public static String GetError( int errorCode )
-       {
-               String errorText = "Unknown Error" ;
-               
-               if( errorCodes.containsKey(errorCode) )
-                       errorText = errorCodes.get( errorCode );
-
-               return errorText;       
-       }       
-}
diff --git a/src/org/yaz4j/Bib1Exception.java b/src/org/yaz4j/Bib1Exception.java
deleted file mode 100644 (file)
index 742b9ab..0000000
+++ /dev/null
@@ -1,16 +0,0 @@
-package org.yaz4j;
-
-public class Bib1Exception extends RuntimeException
-{
-       private static final long serialVersionUID = 1L;
-
-       public Bib1Exception()
-       {
-               super();
-       }
-       
-       public Bib1Exception(String message )
-       {
-               super( message );
-       }
-}
diff --git a/src/org/yaz4j/CQLQuery.java b/src/org/yaz4j/CQLQuery.java
deleted file mode 100644 (file)
index 1411e28..0000000
+++ /dev/null
@@ -1,21 +0,0 @@
-package org.yaz4j;
-
-public class CQLQuery
-{
-       private String query = null;
-       
-       public CQLQuery(String query)
-       {
-               this.query = query;
-       }
-
-       public String getQueryString()
-       {
-               return query ;
-       }
-       
-       public void setQueryString( String query)
-       {
-               this.query = query ;
-       }
-}
diff --git a/src/org/yaz4j/Connection.java b/src/org/yaz4j/Connection.java
deleted file mode 100644 (file)
index 2c5fcf2..0000000
+++ /dev/null
@@ -1,235 +0,0 @@
-package org.yaz4j;
-
-import org.yaz4j.jni.SWIGTYPE_p_ZOOM_connection_p;
-import org.yaz4j.jni.SWIGTYPE_p_ZOOM_query_p;
-import org.yaz4j.jni.SWIGTYPE_p_ZOOM_resultset_p;
-import org.yaz4j.jni.SWIGTYPE_p_ZOOM_scanset_p;
-import org.yaz4j.jni.SWIGTYPE_p_p_char;
-import org.yaz4j.jni.yaz4jlib;
-import org.yaz4j.jni.yaz4jlibConstants;
-
-import sun.reflect.generics.reflectiveObjects.NotImplementedException;
-
-public class Connection
-{
-       private String host ;
-       private int port ;
-       private ConnectionOptionsCollection options = null ;
-       protected SWIGTYPE_p_ZOOM_connection_p zoomConnection = null ;
-       private boolean connected = false;
-       private boolean disposed = false;
-       
-       static
-       {
-               // on Linux   'yaz4j' maps to 'libyaz4j.so' (i.e. 'lib' prefix & '.so'  extension)
-               // on Windows 'yaz4j' maps to 'yaz4j.dll'   (i.e.                '.dll' extension)              
-               String libName = "yaz4j" ;
-               try
-               {
-                       // System.err.println( "Loading library '"+ System.mapLibraryName( libName ) + "'" );
-                       System.loadLibrary( libName );
-               }
-               catch( Throwable e )
-               {
-                       System.err.println( "Fatal Error: Failed to load library '" + System.mapLibraryName( libName ) + "'");
-                       e.printStackTrace();
-               }               
-       }
-       
-       public Connection(String host, int port)
-       {
-               this.host = host ;
-               this.port = port ;
-
-               options = new ConnectionOptionsCollection();
-               zoomConnection = yaz4jlib.ZOOM_connection_create(options.zoomOptions);
-
-               SWIGTYPE_p_p_char cp = null;
-               SWIGTYPE_p_p_char addinfo = null ;              
-               int errorCode = yaz4jlib.ZOOM_connection_error(zoomConnection, cp, addinfo);
-               CheckErrorCodeAndThrow(errorCode);
-       }
-       
-       public void finalize()
-       {
-               Dispose();
-       }
-       
-       private void CheckErrorCodeAndThrow(int errorCode)
-       {
-               String message;
-               
-               if( errorCode == yaz4jlibConstants.ZOOM_ERROR_NONE )
-               {
-                       return ;
-               }
-               else if( errorCode == yaz4jlib.ZOOM_ERROR_CONNECT ) 
-               {
-                       message = String.format("Connection could not be made to %s:%d", host, port);
-                       throw new ConnectionUnavailableException(message);
-               }
-               else if( errorCode == yaz4jlib.ZOOM_ERROR_INVALID_QUERY )
-               {
-                       message = String.format("The query requested is not valid or not supported");
-                       throw new InvalidQueryException(message);
-               }
-               else if( errorCode == yaz4jlib.ZOOM_ERROR_INIT )
-               {
-                       message = String.format("Server %s:%d rejected our init request", host, port);
-                       throw new InitRejectedException(message);                       
-               }
-               else if( errorCode == yaz4jlib.ZOOM_ERROR_TIMEOUT )
-               {
-                       message = String.format("Server %s:%d timed out handling our request", host, port);
-                       throw new ConnectionTimeoutException(message);                  
-               }
-        else if(    ( errorCode == yaz4jlib.ZOOM_ERROR_MEMORY ) 
-                        || ( errorCode == yaz4jlib.ZOOM_ERROR_ENCODE )
-                                || ( errorCode == yaz4jlib.ZOOM_ERROR_DECODE )
-                        || ( errorCode == yaz4jlib.ZOOM_ERROR_CONNECTION_LOST )
-                        || ( errorCode == yaz4jlib.ZOOM_ERROR_INTERNAL )
-                        || ( errorCode == yaz4jlib.ZOOM_ERROR_UNSUPPORTED_PROTOCOL )
-                        || ( errorCode == yaz4jlib.ZOOM_ERROR_UNSUPPORTED_QUERY ) )                     
-        {
-                       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) + ")" ; 
-                       throw new Bib1Exception( errMsgBib1 );
-        }
-       }
-
-       private enum QueryType { CQLQuery, PrefixQuery };
-       
-       public ResultSet Search(PrefixQuery query)
-       {
-               return Search( query.getQueryString(), QueryType.PrefixQuery);
-       }
-       
-       public ResultSet Search(CQLQuery query)
-       {
-               return Search( query.getQueryString(), QueryType.CQLQuery);
-       }
-       
-       private ResultSet Search(String query, QueryType queryType)
-       {       
-               EnsureConnected();
-
-               SWIGTYPE_p_ZOOM_query_p yazQuery = yaz4jlib.ZOOM_query_create();
-        ResultSet resultSet = null;
-
-        try
-        {
-               if( queryType == QueryType.CQLQuery )
-                       yaz4jlib.ZOOM_query_cql(yazQuery, query);
-               else if( queryType == QueryType.PrefixQuery )
-                       yaz4jlib.ZOOM_query_prefix(yazQuery, query);
-               else
-                       throw new NotImplementedException();
-               
-               SWIGTYPE_p_ZOOM_resultset_p yazResultSet = yaz4jlib.ZOOM_connection_search(zoomConnection, yazQuery);
-            
-            int errorCode = yaz4jlib.ZOOM_connection_errcode( zoomConnection );
-            if (errorCode != yaz4jlib.ZOOM_ERROR_NONE)
-            {
-               yaz4jlib.ZOOM_resultset_destroy(yazResultSet);
-            }
-            CheckErrorCodeAndThrow(errorCode);
-
-            resultSet = new ResultSet(yazResultSet, zoomConnection);
-        }
-        finally
-        {
-               yaz4jlib.ZOOM_query_destroy(yazQuery); // deallocate yazQuery also when exceptions
-            yazQuery = null;
-        }
-        return resultSet;
-       }
-       
-       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);
-
-               ScanSet scanSet = new ScanSet(yazScanSet, this);
-               return scanSet;
-       }
-       
-       public ConnectionOptionsCollection getOptions()
-       {
-               return options;
-       }
-
-       protected void EnsureConnected()
-       {
-               if (! connected )
-                       Connect();
-       }
-       
-       public void Connect()
-       {
-               yaz4jlib.ZOOM_connection_connect( zoomConnection, host, port);
-               int errorCode = yaz4jlib.ZOOM_connection_errcode(zoomConnection);
-               CheckErrorCodeAndThrow(errorCode);
-               connected = true;
-       }
-       
-       public void Dispose()
-       {
-               if (! disposed )
-               {
-                       yaz4jlib.ZOOM_connection_destroy(zoomConnection);
-                       zoomConnection = null;
-                       disposed = true;
-               }
-       }
-
-       public String getSyntax()
-       {
-               return options.get("preferredRecordSyntax");
-       }
-       
-       public void setSyntax( String value)
-       {
-               options.set("preferredRecordSyntax", value ) ;
-       }
-
-       public String getDatabaseName()
-       {
-               return options.get("databaseName");
-       }
-       
-       public void setDatabaseName( String value )
-       {
-               options.set("databaseName", value);
-       }
-
-       public String getUsername()
-       {
-               return options.get("user");
-       }
-       
-       public void setUsername( String value )
-       {
-               options.set("user", value);
-       }
-
-       public String getPassword()
-       {
-               return options.get("password");
-       }
-       
-       public void setPassword( String value )
-       {
-               options.set("password", value);
-       }
-}
diff --git a/src/org/yaz4j/ConnectionExtended.java b/src/org/yaz4j/ConnectionExtended.java
deleted file mode 100644 (file)
index 8d9744b..0000000
+++ /dev/null
@@ -1,25 +0,0 @@
-package org.yaz4j;
-
-import org.yaz4j.jni.SWIGTYPE_p_ZOOM_options_p;
-import org.yaz4j.jni.SWIGTYPE_p_ZOOM_package_p;
-import org.yaz4j.jni.yaz4jlib;
-
-public class ConnectionExtended extends Connection
-{
-    public ConnectionExtended(String host, int port) 
-       {
-       super(host, port);
-       }
-
-    public Package Package(String type)
-    {
-        EnsureConnected();
-        Package pack = null;
-        
-        SWIGTYPE_p_ZOOM_options_p options = yaz4jlib.ZOOM_options_create();
-
-        SWIGTYPE_p_ZOOM_package_p yazPackage = yaz4jlib.ZOOM_connection_package( zoomConnection, options);
-        pack = new Package(yazPackage, this, type);
-        return pack;
-    }
-}
diff --git a/src/org/yaz4j/ConnectionOptionsCollection.java b/src/org/yaz4j/ConnectionOptionsCollection.java
deleted file mode 100644 (file)
index fb60263..0000000
+++ /dev/null
@@ -1,42 +0,0 @@
-package org.yaz4j;
-
-import org.yaz4j.jni.SWIGTYPE_p_ZOOM_connection_p;
-import org.yaz4j.jni.SWIGTYPE_p_ZOOM_options_p;
-import org.yaz4j.jni.yaz4jlib;
-
-public class ConnectionOptionsCollection
-{
-       SWIGTYPE_p_ZOOM_options_p zoomOptions = null ;
-
-       ConnectionOptionsCollection()
-       {
-               zoomOptions = yaz4jlib.ZOOM_options_create();
-       }
-
-       public void finalize()
-       {
-               Dispose();
-       }
-       
-       public void Dispose()
-       {
-               yaz4jlib.ZOOM_options_destroy( zoomOptions );
-               zoomOptions = null ;
-       }
-       
-       SWIGTYPE_p_ZOOM_connection_p CreateConnection()
-       {
-               return yaz4jlib.ZOOM_connection_create(zoomOptions);
-       }
-       
-       public String get(String key)
-       {
-               return yaz4jlib.ZOOM_options_get(zoomOptions, key) ;
-       }
-       
-       public void set(String key, String value)
-       {
-               yaz4jlib.ZOOM_options_set(zoomOptions, key, value) ;
-       }
-       
-}
diff --git a/src/org/yaz4j/ConnectionTimeoutException.java b/src/org/yaz4j/ConnectionTimeoutException.java
deleted file mode 100644 (file)
index 7f6c574..0000000
+++ /dev/null
@@ -1,16 +0,0 @@
-package org.yaz4j;
-
-public class ConnectionTimeoutException extends RuntimeException
-{
-       private static final long serialVersionUID = 1L;
-
-       public ConnectionTimeoutException()
-       {
-               super();
-       }
-       
-       public ConnectionTimeoutException(String message )
-       {
-               super( message );
-       }
-}
diff --git a/src/org/yaz4j/ConnectionUnavailableException.java b/src/org/yaz4j/ConnectionUnavailableException.java
deleted file mode 100644 (file)
index 25c7226..0000000
+++ /dev/null
@@ -1,16 +0,0 @@
-package org.yaz4j;
-
-public class ConnectionUnavailableException extends RuntimeException
-{
-       private static final long serialVersionUID = 1L;
-
-       public ConnectionUnavailableException()
-       {
-               super();
-       }
-       
-       public ConnectionUnavailableException(String message )
-       {
-               super( message );
-       }
-}
diff --git a/src/org/yaz4j/InitRejectedException.java b/src/org/yaz4j/InitRejectedException.java
deleted file mode 100644 (file)
index 83c3c8d..0000000
+++ /dev/null
@@ -1,16 +0,0 @@
-package org.yaz4j;
-
-public class InitRejectedException extends RuntimeException
-{
-       private static final long serialVersionUID = 1L;
-
-       public InitRejectedException()
-       {
-               super();
-       }
-       
-       public InitRejectedException(String message )
-       {
-               super( message );
-       }
-}
diff --git a/src/org/yaz4j/InvalidQueryException.java b/src/org/yaz4j/InvalidQueryException.java
deleted file mode 100644 (file)
index 4f265c2..0000000
+++ /dev/null
@@ -1,16 +0,0 @@
-package org.yaz4j;
-
-public class InvalidQueryException extends RuntimeException
-{
-       private static final long serialVersionUID = 1L;
-
-       public InvalidQueryException()
-       {
-               super();
-       }
-       
-       public InvalidQueryException(String message )
-       {
-               super( message );
-       }
-}
diff --git a/src/org/yaz4j/Package.java b/src/org/yaz4j/Package.java
deleted file mode 100644 (file)
index 590b172..0000000
+++ /dev/null
@@ -1,43 +0,0 @@
-package org.yaz4j;
-
-import org.yaz4j.jni.SWIGTYPE_p_ZOOM_package_p;
-import org.yaz4j.jni.yaz4jlib;
-
-public class Package
-{
-       private SWIGTYPE_p_ZOOM_package_p pack = null ;
-       private ConnectionExtended connection = null ;  
-       private String type;
-
-       Package(SWIGTYPE_p_ZOOM_package_p pack, ConnectionExtended connection, String type)
-       {
-               this.type = type;
-               this.connection = connection;
-               this.pack = pack;
-       }
-       
-       public void finalize()
-       {
-               Dispose();
-       }
-       
-       public PackageOptionsCollection getPackageOptions()
-       {
-          return new PackageOptionsCollection(pack);
-       }
-       
-       public void Send()
-       { 
-               yaz4jlib.ZOOM_package_send( pack, type );
-       }
-       
-       public void Dispose()
-       {
-               if ( pack != null )
-               {
-                       yaz4jlib.ZOOM_package_destroy( pack );
-                       connection = null;
-                       pack = null ;
-               }
-       }
-}
diff --git a/src/org/yaz4j/PackageOptionsCollection.java b/src/org/yaz4j/PackageOptionsCollection.java
deleted file mode 100644 (file)
index 7cff946..0000000
+++ /dev/null
@@ -1,29 +0,0 @@
-package org.yaz4j;
-
-import org.yaz4j.jni.SWIGTYPE_p_ZOOM_package_p;
-import org.yaz4j.jni.yaz4jlib;
-
-public class PackageOptionsCollection
-{
-    private SWIGTYPE_p_ZOOM_package_p pack = null;     
-       
-    PackageOptionsCollection(SWIGTYPE_p_ZOOM_package_p pack)
-    {
-        this.pack = pack;
-    }
-    
-    public void Dispose()
-    {
-        pack = null;
-    }
-    
-    public String get(String key)
-    {
-       return yaz4jlib.ZOOM_package_option_get( pack, key) ;
-    }
-
-    public void set(String key, String value)
-    {
-       yaz4jlib.ZOOM_package_option_set( pack, key, value) ;
-    }
-}
diff --git a/src/org/yaz4j/PrefixQuery.java b/src/org/yaz4j/PrefixQuery.java
deleted file mode 100644 (file)
index f8d2e53..0000000
+++ /dev/null
@@ -1,21 +0,0 @@
-package org.yaz4j;
-
-public class PrefixQuery
-{
-       private String query = null;
-       
-       public PrefixQuery(String query)
-       {
-               this.query = query;
-       }
-
-       public String getQueryString()
-       {
-               return query ;
-       }
-       
-       public void setQueryString( String query)
-       {
-               this.query = query ;
-       }       
-}
diff --git a/src/org/yaz4j/Record.java b/src/org/yaz4j/Record.java
deleted file mode 100644 (file)
index e1990a7..0000000
+++ /dev/null
@@ -1,71 +0,0 @@
-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;
-
-public class Record
-{
-       private SWIGTYPE_p_ZOOM_record_p record = null ;
-       private ResultSet resultSet = null ;
-       private boolean disposed = false;       
-
-       Record(SWIGTYPE_p_ZOOM_record_p record, ResultSet resultSet)
-       {
-               this.resultSet = resultSet;
-               this.record = record;
-       }
-
-       public void finalize()
-       {
-               Dispose();
-       }
-       
-       public byte[] getContent()
-       {
-               String type = "raw";
-               SWIGTYPE_p_int length = null ;  
-               return yaz4jlib.ZOOM_record_get_bytes(record, type, length) ;
-//             String contentString = yaz4jlib.ZOOM_record_get(record, type, length) ;
-//             System.err.println("!!!!!");
-//             System.err.println(contentString);
-//             System.err.println(contentString.length());
-//             System.err.println("!!!!!");
-//             try {
-//                     byte[] bytes = contentString.getBytes("UTF8");
-//                     System.err.println(bytes.length);
-//                     return bytes ;
-//             } catch (UnsupportedEncodingException e) {
-//                     throw new RuntimeException(e);
-//             }
-       }
-
-       public String getSyntax()
-       {
-               String type = "syntax";
-               SWIGTYPE_p_int length = null ;          
-               String syntax = yaz4jlib.ZOOM_record_get(record, type, length);
-               return syntax ;
-       }
-       
-       public String getDatabase()
-       {
-               String type = "database";
-               SWIGTYPE_p_int length = null ;          
-               String database = yaz4jlib.ZOOM_record_get(record, type, length);
-       
-               return database ;
-       }
-
-       public void Dispose()
-       {
-               if (!disposed)
-               {
-                       resultSet = null;
-                       record = null;
-                       disposed = true;
-               }
-       }
-}
diff --git a/src/org/yaz4j/ResultSet.java b/src/org/yaz4j/ResultSet.java
deleted file mode 100644 (file)
index b70a03e..0000000
+++ /dev/null
@@ -1,66 +0,0 @@
-package org.yaz4j;
-
-import org.yaz4j.jni.SWIGTYPE_p_ZOOM_connection_p;
-import org.yaz4j.jni.SWIGTYPE_p_ZOOM_record_p;
-import org.yaz4j.jni.SWIGTYPE_p_ZOOM_resultset_p;
-import org.yaz4j.jni.yaz4jlib;
-
-public class ResultSet
-{
-       private SWIGTYPE_p_ZOOM_resultset_p resultSet;  
-       private SWIGTYPE_p_ZOOM_connection_p connection;
-       private long size = 0 ;
-       private Record[] records = null ;
-       private boolean disposed = false;       
-       
-       ResultSet(SWIGTYPE_p_ZOOM_resultset_p resultSet, SWIGTYPE_p_ZOOM_connection_p connection)
-       {
-               this.resultSet = resultSet ;
-               this.connection = connection ;
-               size = yaz4jlib.ZOOM_resultset_size(this.resultSet);
-               records = new Record[(int)size];
-       }
-       
-       public void finalize()
-       {
-               this.Dispose();         
-       }       
-
-    ResultSetOptionsCollection getResultSetOptions()
-    {
-       return new ResultSetOptionsCollection(resultSet);
-    }
-       
-       public Record getRecord(int index)
-       {
-               if ( records[index] == null)
-               {
-                       SWIGTYPE_p_ZOOM_record_p recordTemp = yaz4jlib.ZOOM_resultset_record(resultSet, index);
-                       records[index] = new Record(recordTemp, this);
-               }
-       
-               return this.records[index];
-       }
-       
-       public int getSize()
-       {
-               return (int)size ;
-       }
-       
-       public void Dispose()
-       {
-               if (! disposed )
-               {
-                       for( int i=0 ; i<records.length ; i++)
-                       {
-                               if (records[i] != null)
-                                       records[i].Dispose();
-                       }
-
-                       yaz4jlib.ZOOM_resultset_destroy(resultSet);
-                       connection = null;
-                       resultSet = null;
-                       disposed = true;
-               }
-       }
-}
diff --git a/src/org/yaz4j/ResultSetOptionsCollection.java b/src/org/yaz4j/ResultSetOptionsCollection.java
deleted file mode 100644 (file)
index 2cfdd99..0000000
+++ /dev/null
@@ -1,29 +0,0 @@
-package org.yaz4j;
-
-import org.yaz4j.jni.SWIGTYPE_p_ZOOM_resultset_p;
-import org.yaz4j.jni.yaz4jlib;
-
-public class ResultSetOptionsCollection
-{
-       private SWIGTYPE_p_ZOOM_resultset_p resultSet = null ;  
-       
-    ResultSetOptionsCollection(SWIGTYPE_p_ZOOM_resultset_p resultSet)
-    {
-       this.resultSet = resultSet;
-    }
-    
-    public void finalize()
-    {
-       resultSet = null ;
-    }
-
-       public String get(String key)
-       {
-               return yaz4jlib.ZOOM_resultset_option_get(resultSet, key) ;
-       }
-       
-       public void set(String key, String value)
-       {
-               yaz4jlib.ZOOM_resultset_option_set(resultSet, key, value) ;
-       }
-}
diff --git a/src/org/yaz4j/ScanSet.java b/src/org/yaz4j/ScanSet.java
deleted file mode 100644 (file)
index 3e23046..0000000
+++ /dev/null
@@ -1,50 +0,0 @@
-package org.yaz4j;
-
-import org.yaz4j.jni.SWIGTYPE_p_ZOOM_scanset_p;
-import org.yaz4j.jni.SWIGTYPE_p_int;
-import org.yaz4j.jni.yaz4jlib;
-
-public class ScanSet
-{
-       private SWIGTYPE_p_ZOOM_scanset_p scanSet = null ;
-       private Connection connection;
-       private boolean disposed = false;
-       
-       ScanSet(SWIGTYPE_p_ZOOM_scanset_p scanSet, Connection connection)
-       {
-               this.connection = connection;
-               this.scanSet = scanSet;
-       }
-
-       public void finalize()
-       {
-               Dispose();
-       }
-
-       public ScanTerm get(long index)
-       {
-               SWIGTYPE_p_int occ = yaz4jlib.new_intp();
-               SWIGTYPE_p_int length = yaz4jlib.new_intp();
-               String term = yaz4jlib.ZOOM_scanset_term( scanSet, (long)index, occ, length ) ;
-               int occurences = yaz4jlib.intp_value(occ);
-               yaz4jlib.delete_intp(occ);
-               yaz4jlib.delete_intp(length);
-               return new ScanTerm(term, occurences);
-       }
-
-       public long getSize()
-       {
-               return yaz4jlib.ZOOM_scanset_size(scanSet);
-       }
-
-       public void Dispose()
-       {
-               if (! disposed)
-               {
-                       yaz4jlib.ZOOM_scanset_destroy(scanSet);
-                       connection = null;
-                       scanSet = null;
-                       disposed = true;
-               }
-       }
-}
diff --git a/src/org/yaz4j/ScanTerm.java b/src/org/yaz4j/ScanTerm.java
deleted file mode 100644 (file)
index 5f02952..0000000
+++ /dev/null
@@ -1,23 +0,0 @@
-package org.yaz4j;
-
-public class ScanTerm
-{
-       private String term;
-       private long occurences;
-       
-       ScanTerm( String term, long occurences )
-       {
-               this.term = term;
-               this.occurences = occurences;
-       }
-
-       public String getTerm()
-       {
-               return term;
-       }
-
-       public long getOccurences()
-       {
-               return occurences;
-       }
-}
diff --git a/src/org/yaz4j/Yaz4jMain.java b/src/org/yaz4j/Yaz4jMain.java
deleted file mode 100644 (file)
index b7e4352..0000000
+++ /dev/null
@@ -1,31 +0,0 @@
-package org.yaz4j;
-
-import java.io.UnsupportedEncodingException;
-import java.io.IOException;
-
-public class Yaz4jMain
-{
-       // java -cp ./bin: -Djava.library.path=./libyaz4j org.yaz4j.Yaz4jMain
-       
-       public static void main(String[] args) throws UnsupportedEncodingException, IOException
-       {
-               Connection conn = new Connection("talisbase.talis.com", 210);           
-               conn.setDatabaseName("unionm21");
-               conn.setUsername("fred");
-               conn.setPassword("apple");
-               conn.setSyntax("USMarc"); // USMarc, Sutrs, XML, opac, UKMarc           
-               
-               PrefixQuery query = new PrefixQuery( "@attr 1=4 \"pottering\"" );
-               ResultSet results = conn.Search( query );
-               
-               int resultsSize = results.getSize() ;
-               System.out.println( "Found " + resultsSize + " records");               
-               
-               for( int i=0; i<resultsSize ; i++)
-               {
-                       Record record = results.getRecord(i);
-                       System.out.write(record.getContent());
-               }
-               conn.Dispose();
-       }
-}
diff --git a/src/org/yaz4j/ZoomImplementationException.java b/src/org/yaz4j/ZoomImplementationException.java
deleted file mode 100644 (file)
index f08bc88..0000000
+++ /dev/null
@@ -1,16 +0,0 @@
-package org.yaz4j;
-
-public class ZoomImplementationException extends RuntimeException
-{
-       private static final long serialVersionUID = 1L;
-
-       public ZoomImplementationException()
-       {
-               super();
-       }
-       
-       public ZoomImplementationException(String message )
-       {
-               super( message );
-       }
-}
diff --git a/src/org/yaz4j/jni/.gitignore b/src/org/yaz4j/jni/.gitignore
deleted file mode 100644 (file)
index 27d1535..0000000
+++ /dev/null
@@ -1 +0,0 @@
-*.java
diff --git a/src/site/site.xml b/src/site/site.xml
new file mode 100644 (file)
index 0000000..3ed07a9
--- /dev/null
@@ -0,0 +1,19 @@
+<?xml version="1.0" encoding="ISO-8859-1"?>\r
+<project name="librae-common-yaz4j">\r
+    <bannerLeft>\r
+        <name>yaz4j</name>\r
+        <src>http://www.indexdata.com/sites/indexdata.com/themes/indexd/topbar.gif</src>\r
+        <href>http://indexdata.com/yaz</href>\r
+    </bannerLeft>\r
+    <publishDate format="dd MMM yyyy"/>\r
+    <skin>\r
+        <groupId>org.apache.tapestry</groupId>\r
+        <artifactId>maven-skin</artifactId>\r
+        <version>1.1</version>\r
+    </skin>\r
+    <body>\r
+        <menu ref="modules"/>\r
+        ${reports}\r
+    </body>\r
+</project>\r
+\r
diff --git a/src/test/java/yaz4jtest/ConnectionTest.java b/src/test/java/yaz4jtest/ConnectionTest.java
new file mode 100644 (file)
index 0000000..2f143af
--- /dev/null
@@ -0,0 +1,24 @@
+package yaz4jtest;
+import org.junit.*;
+import static org.junit.Assert.*;
+import java.util.*;
+
+public class ConnectionTest {
+       @Test
+       public void testConnection() {
+               org.yaz4j.Connection con = new org.yaz4j.Connection("z3950.indexdata.dk:210/gils", 0);
+               assertNotNull(con);
+               con.setSyntax("sutrs");
+               org.yaz4j.PrefixQuery pqf = new org.yaz4j.PrefixQuery("@attr 1=4 utah");
+               assertNotNull(pqf);
+               org.yaz4j.ResultSet s = con.Search(pqf);
+               assertNotNull(s);
+               assertEquals(s.getSize(), 9);
+               org.yaz4j.Record rec = s.getRecord(0);
+               assertNotNull(rec);
+               byte [] content = rec.getContent();
+               // first SUTRS record
+               assertEquals(content.length, 1940);
+               assertEquals(content[0], 103);
+       }
+}
diff --git a/test/ConnectionTest.java b/test/ConnectionTest.java
deleted file mode 100644 (file)
index 2f143af..0000000
+++ /dev/null
@@ -1,24 +0,0 @@
-package yaz4jtest;
-import org.junit.*;
-import static org.junit.Assert.*;
-import java.util.*;
-
-public class ConnectionTest {
-       @Test
-       public void testConnection() {
-               org.yaz4j.Connection con = new org.yaz4j.Connection("z3950.indexdata.dk:210/gils", 0);
-               assertNotNull(con);
-               con.setSyntax("sutrs");
-               org.yaz4j.PrefixQuery pqf = new org.yaz4j.PrefixQuery("@attr 1=4 utah");
-               assertNotNull(pqf);
-               org.yaz4j.ResultSet s = con.Search(pqf);
-               assertNotNull(s);
-               assertEquals(s.getSize(), 9);
-               org.yaz4j.Record rec = s.getRecord(0);
-               assertNotNull(rec);
-               byte [] content = rec.getContent();
-               // first SUTRS record
-               assertEquals(content.length, 1940);
-               assertEquals(content[0], 103);
-       }
-}