net.bottegaio.agent.storage.TimedData Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of bottegaio-remote-agent Show documentation
Show all versions of bottegaio-remote-agent Show documentation
Bottegaio Remote Manager by Rossonet. Remote Agent component.
The newest version!
package net.bottegaio.agent.storage;
import java.util.Date;
public class TimedData {
private final String data;
private final long receivedTime;
public TimedData(final String value) {
receivedTime = new Date().getTime();
data = value;
}
public TimedData(final String value, final long time) {
receivedTime = time;
data = value;
}
public TimedData checkSize(final int maxMessageSize) {
if (data != null && !data.isEmpty() && data.length() > maxMessageSize) {
return new TimedData(data.substring(0, maxMessageSize), getReceivedTime());
} else {
return new TimedData(data, getReceivedTime());
}
}
public String getData() {
return data;
}
public long getReceivedTime() {
return receivedTime;
}
}