From 51ac9b6a2e6170b6f836cb669dca5aaf7153a977 Mon Sep 17 00:00:00 2001 From: Jakub Skoczen Date: Fri, 12 Apr 2013 14:36:42 +0200 Subject: [PATCH] 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. --- src/main/java/org/yaz4j/ZoomCLI.java | 37 ++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100644 src/main/java/org/yaz4j/ZoomCLI.java 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(); + } + } +} -- 1.7.10.4