public String getString(Long timestamp) { StringBuffer buff = new StringBuffer(); if (messages != null) { for (Iterator<LoggregatorMessage.Message> iterator = messages.iterator(); iterator.hasNext(); ) { LoggregatorMessage.Message loggregatorMessage = iterator.next(); if (timestamp == -1 || loggregatorMessage.getTimestamp() > timestamp) { String message = loggregatorMessage.getMessage().toStringUtf8(); buff.append(message).append("\n"); } } } lastAccess = System.currentTimeMillis(); return buff.toString(); }
public JSONArray getMessagesJSON(Long timestamp) { JSONArray messagesJSON = new JSONArray(); if (messages != null) { for (Iterator<LoggregatorMessage.Message> iterator = messages.iterator(); iterator.hasNext(); ) { LoggregatorMessage.Message loggregatorMessage = iterator.next(); if (timestamp == -1 || loggregatorMessage.getTimestamp() > timestamp) { String message = loggregatorMessage.getMessage().toStringUtf8(); messagesJSON.put(message); } } } lastAccess = System.currentTimeMillis(); return messagesJSON; }