public class SimpleProgressMonitor extends Object implements ProgressMonitorReporter, JSONWritable
| Modifier and Type | Field and Description |
|---|---|
protected String |
id |
static String |
ID_FIELD |
protected List<ProgressMessage> |
messages |
static String |
MESSAGES_FIELD |
protected int |
progress |
static String |
PROGRESS_FIELD |
protected TaskState |
state |
static String |
STATE_FIELD |
protected boolean |
succeeded |
static String |
SUCEEDED_FIELD |
protected long |
timestamp |
static String |
TYPE_ERROR |
static String |
TYPE_MAIN |
| Constructor and Description |
|---|
SimpleProgressMonitor() |
SimpleProgressMonitor(org.apache.jena.atlas.json.JsonObject stored) |
SimpleProgressMonitor(String id) |
| Modifier and Type | Method and Description |
|---|---|
String |
getId()
Return an ID string for this monitor/reporter.
|
List<ProgressMessage> |
getMessages()
Return all progress messages logged so far.
|
List<ProgressMessage> |
getMessagesSince(int offset)
Return all progress messages since the given message number.
|
int |
getProgress()
Get the progress of the task as a percentage.
|
TaskState |
getState()
Return the state of the task.
|
long |
getTimestamp() |
boolean |
moreMessagesSince(int offset)
Return true if there are more progress messages available since the given message number.
|
void |
report(String message)
Log a progress message, this may be timestamped by the reporter implementation.
|
void |
report(String message,
int lineNumber)
Log a progress message with an associated line number, this may be timestamped by the reporter implementation.
|
void |
report(String message,
int lineNumber,
String type)
Log a progress message with an associated line number, this may be timestamped by the reporter implementation.
|
void |
report(String message,
String type)
Log a progress message, this may be timestamped by the reporter implementation.
|
void |
reportError(String message)
Report an error as a progress message of type "error" and set the status to failed
|
void |
reportError(String message,
int lineNumber)
Report an error as a progress message of type "error" and set the status to failed
|
protected void |
reportNewMessage(ProgressMessage message) |
protected void |
reportStateChange() |
void |
setFailed()
Record that a task has completed but with an error.
|
void |
setProgress(int progress)
Set the progress percentage.
|
void |
setState(TaskState state)
Change the state of the progress report.
|
void |
setSucceeded()
Record that a task has completed but successfully
|
void |
setSuccess(boolean wasSuccessful)
Record whether the task was successful or not.
|
boolean |
succeeded()
Return true if the task has Terminated and was successful.
|
String |
toString() |
SimpleProgressMonitor |
truncate(int offset)
Return a truncated version of the monitor only containing message since a given offset point
|
JSONWritable |
viewUpdatesSince(int offset)
Return a JSON view onto the status of the monitor including any messages
since the given offset.
|
protected void |
writeIncrement(JSFullWriter out,
int offset) |
void |
writeTo(JSFullWriter out) |
public static final String ID_FIELD
public static final String PROGRESS_FIELD
public static final String STATE_FIELD
public static final String SUCEEDED_FIELD
public static final String MESSAGES_FIELD
public static final String TYPE_ERROR
public static final String TYPE_MAIN
protected String id
protected TaskState state
protected int progress
protected boolean succeeded
protected List<ProgressMessage> messages
protected long timestamp
public SimpleProgressMonitor()
public SimpleProgressMonitor(String id)
public SimpleProgressMonitor(org.apache.jena.atlas.json.JsonObject stored)
public long getTimestamp()
public void setState(TaskState state)
ProgressReportersetState in interface ProgressReporterpublic String getId()
ProgressReportergetId in interface ProgressReporterpublic void setProgress(int progress)
ProgressReportersetProgress in interface ProgressReporterpublic void setSuccess(boolean wasSuccessful)
ProgressReportersetSuccess in interface ProgressReporterpublic void setFailed()
ProgressReportersetFailed in interface ProgressReporterpublic void report(String message)
ProgressReporterreport in interface ProgressReporterpublic void report(String message, int lineNumber)
ProgressReporterreport in interface ProgressReportermessage - the message textlineNumber - the number in some input file corresponding the the messagepublic void report(String message, String type)
ProgressReporterreport in interface ProgressReportermessage - the message texttype - the nature of the message e.g. "error", application dependent what types are supportedpublic void report(String message, int lineNumber, String type)
ProgressReporterreport in interface ProgressReportermessage - the message textlineNumber - the number in some input file corresponding the the messagetype - the nature of the message e.g. "error", application dependent what types are supportedpublic void reportError(String message)
ProgressReporterreportError in interface ProgressReporterpublic void reportError(String message, int lineNumber)
ProgressReporterreportError in interface ProgressReporterprotected void reportStateChange()
protected void reportNewMessage(ProgressMessage message)
public TaskState getState()
ProgressMonitorgetState in interface ProgressMonitorgetState in interface ProgressReporterpublic int getProgress()
ProgressMonitorgetProgress in interface ProgressMonitorpublic boolean succeeded()
ProgressMonitorsucceeded in interface ProgressMonitorpublic List<ProgressMessage> getMessages()
ProgressMonitorgetMessages in interface ProgressMonitorpublic List<ProgressMessage> getMessagesSince(int offset)
ProgressMonitorgetMessagesSince in interface ProgressMonitorpublic boolean moreMessagesSince(int offset)
ProgressMonitormoreMessagesSince in interface ProgressMonitorpublic SimpleProgressMonitor truncate(int offset)
public void writeTo(JSFullWriter out)
writeTo in interface JSONWritableprotected void writeIncrement(JSFullWriter out, int offset)
public JSONWritable viewUpdatesSince(int offset)
viewUpdatesSince in interface ProgressMonitorpublic void setSucceeded()
ProgressReportersetSucceeded in interface ProgressReporterCopyright © 2015. All rights reserved.