public static Matrix fromURL(String url, Object... parameters) throws Exception { if (parameters.length < 2) { throw new RuntimeException("this methods needs additional parameters: user, password, [foldername]"); } String user = StringUtil.convert(parameters[0]); String password = StringUtil.convert(parameters[1]); String foldername = "INBOX"; if (parameters.length > 2) { foldername = StringUtil.convert(parameters[2]); } return new MessagesMatrix(url, user, password, foldername); }
public static String getString(Object object, boolean returnEmptyStringInsteadOfNull) { if (object == null) { if (returnEmptyStringInsteadOfNull) { return ""; } else { return null; } } else { return format(object); } }
public static String getString(Object object) { return getString(object, false); }
private final File getFileNameForKey(Object o) throws IOException { String key; String suffix = ".dat"; if (useGZip) { suffix += ".gz"; } if (o instanceof String && StringUtil.isSuitedAsFilename((String) o) && !((String) o).contains(".")) { key = (String) o; } else { suffix = ".obj" + suffix; key = StringUtil.reverse(StringUtil.encodeToHex((Serializable) o)); } StringBuilder result = new StringBuilder(); result.append(getPath().getAbsolutePath()); result.append(File.separator); for (int i = 0; i < maxDepth && i < key.length() - 1; i++) { char c = key.charAt(i); result.append(c); result.append(File.separator); } result.append(key); result.append(suffix); return new File(result.toString()); }
public static String toString(Matrix m, Object... parameters) { int width = 10; long maxRows = UJMPSettings.getInstance().getMaxRowsToPrint(); long maxColumns = UJMPSettings.getInstance().getMaxColumnsToPrint(); StringBuilder s = new StringBuilder(); final String EOL = System.getProperty("line.separator"); long rowCount = m.getRowCount(); long columnCount = m.getColumnCount(); for (int row = 0; row < rowCount && row < maxRows; row++) { for (int col = 0; col < columnCount && col < maxColumns; col++) { Object o = m.getAsObject(row, col); String v = StringUtil.format(o); v = StringUtil.padLeft(v, width); s.append(v); } s.append(EOL); } if (rowCount == 0 || columnCount == 0) { s.append("[" + rowCount + "x" + columnCount + "]" + EOL); } else if (rowCount > UJMPSettings.getInstance().getMaxRowsToPrint() || columnCount > UJMPSettings.getInstance().getMaxColumnsToPrint()) { s.append("[...]"); } return s.toString(); }
private static String getUniqueString(Object o) throws IOException { if (o == null) { return ""; } else if (o instanceof String) { return (String) o; } else { return StringUtil.encodeToHex((Serializable) o); } }
public Selection(Matrix m, String selectionString) { this(m, StringUtil.parseSelection(selectionString, m.getSize())); }
public void runAll() throws Exception { List<AbstractMatrix2DBenchmark> benchmarks = getDenseBenchmarks(); UJMPSettings.getInstance().setNumberOfThreads(getConfig().getNumberOfThreads()); ConcurrencyUtils.setNumberOfThreads(getConfig().getNumberOfThreads()); System.setProperty("ATLAS_NUM_THREADS", "" + getConfig().getNumberOfThreads()); if (getConfig().isShuffle()) { Collections.shuffle(benchmarks); } if (getConfig().isReverse()) { Collections.reverse(benchmarks); } long t0 = System.currentTimeMillis(); for (int j = 0; j < benchmarks.size(); j++) { AbstractMatrix2DBenchmark benchmark = benchmarks.get(j); benchmark.run(); } long t1 = System.currentTimeMillis(); System.out.println(); System.out.println("Finished."); System.out.println("Total Time: " + StringUtil.duration(t1 - t0)); System.out.println(); System.out.println(); }
private static String getUniqueString(Object o) throws IOException { if (o == null) { return ""; } else if (o instanceof String) { return (String) o; } else { return StringUtil.encodeToHex((Serializable) o); } }
public Deletion(Matrix m, String deletionString) { this(m, StringUtil.parseSelection(deletionString, m.getSize())); }
System.out.println("Benchmark runtime: " + StringUtil.duration(t1 - t0)); System.out.println();
public Map<String, Object> calculateObjects(Map<String, Object> input) { try { Map<String, Object> result = new HashMap<String, Object>(); String command = StringUtil.convert(input.get(SOURCE)); Process p = Runtime.getRuntime().exec(command); int ret = p.waitFor(); result.put(TARGET, ret); return result; } catch (Exception e) { throw new RuntimeException(e); } } }
public static final String format(Number value) { if (value == null) return ""; if (value instanceof Double) return format((Double) value); return DefaultNF.format(value); }
public String getLabel() { return StringUtil.getString(label); }
public static final String encodeToHex(Serializable o) throws IOException { return encodeToHex(SerializationUtil.serialize(o)); }
@Test public void testParseSelectionMatlab() { try { long[][] sel = StringUtil.parseSelection(":,2", new long[] { 3, 4 }); } catch (Exception e) { // should not work yet return; } throw new RuntimeException("Matlab selection is available. Add tests"); }
public Sample get(Object key) { try { return index.getSample(StringUtil.convert(key)); } catch (Exception e) { e.printStackTrace(); return null; } }
protected void setValue(Object value) { setText((value == null) ? "" : StringUtil.format(value)); }
public String getLabel() { return StringUtil.getString(label); }