public static String getString(Object object, boolean returnEmptyStringInsteadOfNull) { if (object == null) { if (returnEmptyStringInsteadOfNull) { return ""; } else { return null; } } else { return format(object); } }
public static final String format(Number value) { if (value == null) return ""; if (value instanceof Double) return format((Double) value); return DefaultNF.format(value); }
protected void setValue(Object value) { setText((value == null) ? "" : StringUtil.format(value)); }
public String toString() { StringBuilder s = new StringBuilder(); s.append(getClass().getSimpleName()); s.append(" [ "); for (String key : keySet()) { Matrix v = getAsMatrix(key); s.append(key + "="); s.append(StringUtil.format(v)); s.append(" "); } s.append("]"); return s.toString(); }
public static String getAllAsString(Collection<Matrix> collection) { StringBuffer s = new StringBuffer(); int i = 0; for (Matrix m : collection) { if (m != null && !m.isEmpty()) { s.append(StringUtil.format(m.stringValue())); } if (i < collection.size() - 1) { s.append(", "); } i++; } return s.toString(); }
public Map<String, Object> calculateObjects(Map<String, Object> input) { try { FileFormat format = defaultFormat; Map<String, Object> result = new HashMap<String, Object>(); String file = StringUtil.format(input.get(SOURCE)); Object o2 = input.get(FORMAT); if (o2 != null) { format = FileFormat.valueOf(StringUtil.format(o2)); } Matrix target = Matrix.Factory.importFrom().file(file).asDenseCSV(); result.put(TARGET, target); return result; } catch (Exception e) { throw new RuntimeException(e); } } }
public Map<String, Object> calculateObjects(Map<String, Object> input) { try { String file = null; Map<String, Object> result = new HashMap<String, Object>(); Matrix matrix = MathUtil.getMatrix(input.get(SOURCE)); Object o1 = input.get(FILE); if (o1 != null) { file = StringUtil.format(o1); } else { file = File.createTempFile("jdmp_matrix", ".CSV").getAbsolutePath(); } matrix.exportTo().file(new File(file)).asDenseCSV(); result.put(TARGET, matrix); return result; } catch (Exception e) { throw new RuntimeException(e); } } }
public static final String format(Object o) { if (o == null) { return ""; } if (o instanceof String) { return (String) o; } if (o instanceof Matrix) { Matrix m = (Matrix) o; if (m.getLabel() != null) { return "[" + m.getLabel() + "]"; } else { return "[Matrix]"; } } if (o instanceof Number) { return format((Number) o); } return o.toString(); }
writer.write("set title '" + StringUtil.format(matrix.getLabel()) + "'" + EOL); writer.write("plot ");
break; case MatrixListTableModel.LABELCOLUMN: o = StringUtil.format(matrix.getLabel()); break; default:
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(); }
String s = StringUtil.format(v); try { double d = Double.parseDouble(s);
field.setParameter("class", "variable"); LinkTag varlink = new LinkTag(path + "variables/" + var.getId(), StringUtil.format(key)); SpanTag keyTag = new SpanTag(new BTag(varlink, new Text(":"))); keyTag.setParameter("class", "key"); for (long[] c : matrix.availableCoordinates()) { String value = matrix.getAsString(c); EmphasizedText text = new EmphasizedText(StringUtil.format(value), highlightedWords); String qstring = new String(query + " +" + key + ":" + value).trim(); LinkTag link = new LinkTag(path + "?q=" + URLEncoder.encode(qstring, "utf-8"), text);
field.setParameter("class", "variable"); LinkTag varlink = new LinkTag(path + "variables/" + var.getId(), StringUtil.format(key)); SpanTag keyTag = new SpanTag(new BTag(varlink, new Text(":"))); keyTag.setParameter("class", "key"); for (long[] c : matrix.availableCoordinates()) { String value = matrix.getAsString(c); EmphasizedText text = new EmphasizedText(StringUtil.format(value), highlightedWords); String qstring = new String(query + " +" + key + ":" + value).trim(); LinkTag link = new LinkTag(path + "?q=" + URLEncoder.encode(qstring, "utf-8"), text);
String xLabel = StringUtil.format(getMatrix().getMatrix().getDimensionLabel(Matrix.ROW)); String yLabel = null;
String xLabel = StringUtil.format(getMatrix().getMatrix().getDimensionLabel(Matrix.ROW)); String yLabel = null;