@Override public String toString() { return String.format("name=%s userInfo={%s}", name, StringUtils.toString(userInfo)); } }
public static String table(Object[][] rows, String title) { int[] columnSizes = new int[rows[0].length]; for (Object[] row : rows) { for (int i = 0; i < row.length; ++i) { columnSizes[i] = Math.max(columnSizes[i], toString(row[i]).length()); } } StringBuilder line = new StringBuilder(); int totalSize = 0; for (int i = 0; i < columnSizes.length; ++i) { totalSize += columnSizes[i]; } totalSize += columnSizes.length > 0 ? (columnSizes.length - 1) * " | ".length() : 0; while (totalSize-- > 0) { line.append('-'); } StringBuilder result = new StringBuilder(line); for (Object[] row : rows) { result.append("\n"); for (int i = 0; i < row.length; ++i) { if (i > 0) { result.append(" | "); } result.append(String.format("%-" + columnSizes[i] + "s", row[i])); } } result.append("\n").append(line); return result.toString(); }
private static String toPrettyDate(Object value) { if (value instanceof Apptentive.DateTime) { Apptentive.DateTime date = (Apptentive.DateTime) value; return StringUtils.toPrettyDate(date.getDateTime()); } return StringUtils.toString(value); } }
/** * Creates a notification with a given name and user info and posts it to the receiver. */ public synchronized void postNotification(final String name, final Map<String, Object> userInfo) { ApptentiveLog.v(NOTIFICATIONS, "Post notification: name=%s userInfo={%s}", name, StringUtils.toString(userInfo)); final ApptentiveNotificationObserverList list = findObserverList(name); if (list != null) { list.notifyObservers(new ApptentiveNotification(name, userInfo)); } }
@Override public void onReceiveNotification(ApptentiveNotification notification) { addResult(String.format("%s: %s {%s}", name, notification.getName(), StringUtils.toString(notification.getUserInfo()))); } }