From: Jakub Skoczen Date: Fri, 12 Apr 2013 12:36:42 +0000 (+0200) Subject: Add simple CLI program X-Git-Tag: v1.3~4 X-Git-Url: http://jsfdemo.indexdata.com/cgi-bin?a=commitdiff_plain;h=51ac9b6a2e6170b6f836cb669dca5aaf7153a977;p=yaz4j-moved-to-github.git Add simple CLI program that opens a connection to a known target, searches and prints records out. For testing sanity of the yaz/java intallation. --- diff --git a/src/main/java/org/yaz4j/ZoomCLI.java b/src/main/java/org/yaz4j/ZoomCLI.java new file mode 100644 index 0000000..c699324 --- /dev/null +++ b/src/main/java/org/yaz4j/ZoomCLI.java @@ -0,0 +1,37 @@ +/* + * Copyright (c) 1995-2013, Index Datassss + * All rights reserved. + * See the file LICENSE for details. + */ +package org.yaz4j; + +import java.util.List; +import org.yaz4j.exception.ZoomException; + +/** + * + * @author jakub + */ +class ZoomCLI { + static public void main(String[] args) { + System.out.println("Open connection to z3950.indexdata.dk:210/gils..."); + Connection con = new Connection("z3950.indexdata.dk:210/gils", 0); + try { + con.setSyntax("sutrs"); + con.connect(); + System.out.println("Search for 'utah'..."); + ResultSet s = con.search(new PrefixQuery("@attr 1=4 utah")); + System.out.println("Retrieve all records.."); + List all = s.getRecords(0, (int) s.getHitCount()); + for (Record r : all) { + System.out.println(r.render()); + } + System.out.println("Success"); + } catch (ZoomException ze) { + System.out.println("Failure"); + ze.printStackTrace(); + } finally { + con.close(); + } + } +}