comparison src/main/java/nl/cwi/monetdb/client/JMonetDB.java @ 33:e67d58485172 embedded

More cleaning
author Pedro Ferreira <pedro.ferreira@monetdbsolutions.com>
date Tue, 01 Nov 2016 13:30:23 +0100 (2016-11-01)
parents a5a898f6886c
children 17365ed26611
comparison
equal deleted inserted replaced
32:57978db4ee57 33:e67d58485172
8 8
9 package nl.cwi.monetdb.client; 9 package nl.cwi.monetdb.client;
10 10
11 import nl.cwi.monetdb.util.*; 11 import nl.cwi.monetdb.util.*;
12 import nl.cwi.monetdb.merovingian.*; 12 import nl.cwi.monetdb.merovingian.*;
13 import java.io.*;
14 import java.util.*; 13 import java.util.*;
15 14
16 /** 15 /**
17 * This program mimics the monetdb tool. It is meant as demonstration 16 * This program mimics the monetdb tool. It is meant as demonstration
18 * and test of the MeroControl library. 17 * and test of the MeroControl library.
20 * @author Fabian Groffen 19 * @author Fabian Groffen
21 * @version 1.0 20 * @version 1.0
22 */ 21 */
23 22
24 public class JMonetDB { 23 public class JMonetDB {
25 private static PrintWriter out;
26 24
27 public final static void main(String[] args) throws Exception { 25 public final static void main(String[] args) throws Exception {
28 CmdLineOpts copts = new CmdLineOpts(); 26 CmdLineOpts copts = new CmdLineOpts();
29 27
30 // arguments which take exactly one argument 28 // arguments which take exactly one argument
72 copts.produceHelpMessage() 70 copts.produceHelpMessage()
73 ); 71 );
74 System.exit(0); 72 System.exit(0);
75 } 73 }
76 74
77 out = new PrintWriter(new BufferedWriter(new OutputStreamWriter(System.out)));
78
79 String pass = copts.getOption("passphrase").getArgument(); 75 String pass = copts.getOption("passphrase").getArgument();
80 76
81 // we need the password from the user, fetch it with a pseudo 77 // we need the password from the user, fetch it with a pseudo
82 // password protector 78 // password protector
83 if (pass == null) { 79 if (pass == null) {
97 sport = host.substring(pos + 1); 93 sport = host.substring(pos + 1);
98 host = host.substring(0, pos); 94 host = host.substring(0, pos);
99 } 95 }
100 int port = Integer.parseInt(sport); 96 int port = Integer.parseInt(sport);
101 97
102 String hash = null; 98 /*String hash; TODO check this, the hash algorithm is not being used
103 if (copts.getOption("Xhash").isPresent()) 99 if (copts.getOption("Xhash").isPresent())
104 hash = copts.getOption("Xhash").getArgument(); 100 hash = copts.getOption("Xhash").getArgument();*/
105 101
106 if (!copts.getOption("command").isPresent()) { 102 if (!copts.getOption("command").isPresent()) {
107 System.err.println("need a command to execute (-c)"); 103 System.err.println("need a command to execute (-c)");
108 System.exit(1); 104 System.exit(1);
109 } 105 }
126 if (commands[0].equals("status")) { 122 if (commands[0].equals("status")) {
127 List<SabaothDB> sdbs; 123 List<SabaothDB> sdbs;
128 if (commands.length == 1) { 124 if (commands.length == 1) {
129 sdbs = ctl.getAllStatuses(); 125 sdbs = ctl.getAllStatuses();
130 } else { 126 } else {
131 sdbs = new ArrayList<SabaothDB>(); 127 sdbs = new ArrayList<>();
132 for (int i = 1; i < commands.length; i++) 128 for (int i = 1; i < commands.length; i++)
133 sdbs.add(ctl.getStatus(commands[i])); 129 sdbs.add(ctl.getStatus(commands[i]));
134 } 130 }
135 Iterator<SabaothDB> it = sdbs.iterator(); 131 for (SabaothDB sdb : sdbs) {
136 while (it.hasNext()) {
137 SabaothDB sdb = it.next();
138 System.out.println(sdb.getName() + " " + sdb.getURI()); 132 System.out.println(sdb.getName() + " " + sdb.getURI());
139 } 133 }
140 } 134 }
141 } 135 }
142 } 136 }