/** * returns the contentents of the collection as a string a collections with * "a", "b", null, and new Integer(1) would return: {[a][b][null][1]} */ public String toString(Collection strings) { return toString(strings, "[", "][", "]"); }
/** * returns the contentents of the collection as a string a collections with * "a", "b", null, and new Integer(1) would return: {[a][b][null][1]} */ public String toString(Object[] objects) { return toString(Arrays.asList(objects)); }
public Process exec(String[] cmdarray, String[] envp, File dir) throws IOException { Object[] params = new Object[] { cmdarray, envp, dir }; String msg = new Str().toString(params); throw new IOException("Not implemented: " + msg); }
public void start(String threadName, Map mysqldArgs) { if (running != null) { Str str = new Str(); String msg = "already running " + running + " mysqldArgs: " + str.toString(mysqldArgs.entrySet()); throw new RuntimeException(msg); } currentOptions.putAll(mysqldArgs); running = threadName; }
public NotImplementedException(Object[] arg0) { this(new Str().toString(arg0)); }
public void testToString() throws Exception { Str str = new Str(); assertEquals("[foo]", str.toString(new Object[] { "foo" })); assertEquals("[foo][bar]", str.toString(new Object[] { "foo", "bar" })); Object[] objects = new Object[] { "foo", new Object[] { "bar", "baz" }, "wiz" }; assertEquals("[foo][[bar][baz]][wiz]", str.toString(objects)); objects = new Object[] { "foo", Arrays.asList(new Object[] { "bar", "baz" }), "wiz" }; assertEquals("[foo][[bar][baz]][wiz]", str.toString(objects)); } }
/** * @param objs * collection * @param prefix * @param separator * @param postfix * @return the contentents of the collection as a string */ public String toString(Collection objs, String prefix, String separator, String postfix) { StringBuffer buf = new StringBuffer(prefix); for (Iterator iter = objs.iterator(); iter.hasNext();) { Object next = iter.next(); if (next instanceof Object[]) { next = toString((Object[]) next); } else if (next instanceof Collection) { next = toString((Collection) next); } buf.append(next); if (iter.hasNext()) { buf.append(separator); } } buf.append(postfix); return buf.toString(); }
public static void shutdown(String hostColonPort, PrintStream out) { synchronized (startedMysqlds) { Object obj = startedMysqlds.get(hostColonPort); MysqldResourceI mysqld = (MysqldResourceI) obj; if (mysqld != null) { startedMysqlds.remove(hostColonPort); mysqld.shutdown(); } else { String list = new Str().toString(startedMysqlds.keySet()); out.println("mysqld [" + hostColonPort + "] not found in " + list); } } } }
private Shell launchShell(String threadName, String[] args, int seconds) { Shell shell = shellFactory.newShell(args, threadName, out, err); shell.start(); int fraction = 20; int loops = (fraction * seconds); do { threads.pause((1000/fraction)); } while(!shell.hasReturned() && loops-- > 0); if (!shell.hasReturned()) { err.println("Thread \"" +threadName + "\" may be hung"); err.println("(did not return after " + seconds + " seconds)"); err.println("command line used: "); err.println(str.toString(Arrays.asList(args), "", " ", "")); } return shell; }
/** called from option parser as well */ synchronized Shell exec(String threadName, Map mysqldArgs, PrintStream outStream, PrintStream errStream, boolean withListeners) { mysqldArgs.put(MysqldResourceI.BASEDIR, baseDir.getPath()); mysqldArgs.put(MysqldResourceI.PID_FILE, pidFile().getPath()); socket(mysqldArgs); File dataDir = dataDir(mysqldArgs); makeMysqld(); ensureEssentialFilesExist(dataDir); String[] args = constructArgs(mysqldArgs); outStream.println(str.toString(args)); Shell launch = shellFactory.newShell(args, threadName, outStream, errStream); if (withListeners) { for (int i = 0; i < completionListensers.size(); i++) { Runnable listener = (Runnable) completionListensers.get(i); launch.addCompletionListener(listener); } } launch.setDaemon(true); printMessage("launching mysqld (" + threadName + ")"); launch.start(); return launch; }