1 | /*
|
---|
2 | * Library1.java
|
---|
3 | * Copyright (C) 2002 New Zealand Digital Library, http://www.nzdl.org
|
---|
4 | *
|
---|
5 | * This program is free software; you can redistribute it and/or modify
|
---|
6 | * it under the terms of the GNU General Public License as published by
|
---|
7 | * the Free Software Foundation; either version 2 of the License, or
|
---|
8 | * (at your option) any later version.
|
---|
9 | *
|
---|
10 | * This program is distributed in the hope that it will be useful,
|
---|
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
---|
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
---|
13 | * GNU General Public License for more details.
|
---|
14 | *
|
---|
15 | * You should have received a copy of the GNU General Public License
|
---|
16 | * along with this program; if not, write to the Free Software
|
---|
17 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
---|
18 | */
|
---|
19 | package org.greenstone.gsdl3;
|
---|
20 |
|
---|
21 | import org.greenstone.gsdl3.core.*;
|
---|
22 |
|
---|
23 | import java.io.BufferedReader;
|
---|
24 | import java.io.InputStreamReader;
|
---|
25 |
|
---|
26 | /** sample command line interface to gsdl3 site
|
---|
27 | *
|
---|
28 | * enter XML queries at the prompt
|
---|
29 | * @author <a href="mailto:[email protected]">Katherine Don</a>
|
---|
30 | * @version $Revision: 10296 $
|
---|
31 | */
|
---|
32 | final public class Library1 {
|
---|
33 |
|
---|
34 | public static void main(String args[]) {
|
---|
35 |
|
---|
36 | if (args.length != 1) {
|
---|
37 | System.out.println("Usage: Library1 <sitename>");
|
---|
38 | System.exit(1);
|
---|
39 | }
|
---|
40 | String site_name = args[0];
|
---|
41 |
|
---|
42 | MessageRouter mr = new MessageRouter();
|
---|
43 | mr.setSiteName(site_name);
|
---|
44 | mr.configure();
|
---|
45 |
|
---|
46 | BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
|
---|
47 | String query=null;
|
---|
48 | String result=null;
|
---|
49 | while (true) {
|
---|
50 | System.out.println("Please enter an XML query all on one line, or 'exit' to quit");
|
---|
51 | try {
|
---|
52 | query = br.readLine();
|
---|
53 | } catch (Exception e) {
|
---|
54 | System.err.println("Library1 exception:"+e.getMessage());
|
---|
55 | }
|
---|
56 | if (query.startsWith("exit")) {
|
---|
57 | System.exit(1);
|
---|
58 | }
|
---|
59 | System.out.println("\nProcessing query");
|
---|
60 |
|
---|
61 | result = mr.process(query);
|
---|
62 |
|
---|
63 | System.out.println("Result:\n"+result+"\n");
|
---|
64 |
|
---|
65 |
|
---|
66 | }
|
---|
67 |
|
---|
68 | }
|
---|
69 | }
|
---|