public class JSONFormatter extends Formatter
Constructor and Description |
---|
JSONFormatter() |
Modifier and Type | Method and Description |
---|---|
protected org.json.JSONObject |
asJSON(Document document,
List<ValidationError> errors)
Render as a JSON object a list of errors for a given document
|
protected org.json.JSONObject |
asJSON(int startLine,
int startOffset,
int endLine,
int endOffset)
Render a start and end coordinates as a 'position'
|
protected org.json.JSONObject |
asJSON(LineOffset lineOffset)
Render a line offset as JSON
|
protected org.json.JSONObject |
asJSON(LineOffset startLineOffset,
LineOffset endLineOffset)
Render a start and end line offset as a 'position'
|
protected org.json.JSONObject |
asJSON(Sentence sentence,
LineOffset startLineOffset,
LineOffset endLineOffset)
Render a start and end line offsets (ie: source text coordinates) as a description of a section of the sentence.getContent() string
|
protected org.json.JSONObject |
asJSON(ValidationError error)
Render a single redpen error as JSON
|
String |
format(Document document,
List<ValidationError> errors)
Format the errors for a given document
|
void |
format(PrintWriter pw,
Map<Document,List<ValidationError>> docErrorsMap)
Format and print the errors for a set of documents
|
String |
formatError(Document document,
ValidationError error)
Format a single error as a string
|
public void format(PrintWriter pw, Map<Document,List<ValidationError>> docErrorsMap) throws RedPenException, IOException
Formatter
format
in class Formatter
pw
- The printwriter destination for the errorsdocErrorsMap
- a map of documents to the corresponding list of errorsRedPenException
IOException
public String format(Document document, List<ValidationError> errors)
Formatter
public String formatError(Document document, ValidationError error) throws RedPenException
Formatter
formatError
in class Formatter
document
- the document the error is forerror
- the error to formatRedPenException
protected org.json.JSONObject asJSON(ValidationError error) throws org.json.JSONException
error
- the redpen errororg.json.JSONException
protected org.json.JSONObject asJSON(LineOffset lineOffset) throws org.json.JSONException
lineOffset
- the line offsetorg.json.JSONException
protected org.json.JSONObject asJSON(LineOffset startLineOffset, LineOffset endLineOffset) throws org.json.JSONException
startLineOffset
- the line offset denoting the start positionendLineOffset
- the line offset denoting the end positionorg.json.JSONException
protected org.json.JSONObject asJSON(int startLine, int startOffset, int endLine, int endOffset) throws org.json.JSONException
startLine
- the line this position startsstartOffset
- the offset within startLine the position startsendLine
- the line offset denoting the end positionendOffset
- the offset within endLine the position endsorg.json.JSONException
protected org.json.JSONObject asJSON(Sentence sentence, LineOffset startLineOffset, LineOffset endLineOffset) throws org.json.JSONException
sentence
- the sentence in which the offsets are locatedstartLineOffset
- the line offset denoting the start positionendLineOffset
- the line offset denoting the end positionorg.json.JSONException
protected org.json.JSONObject asJSON(Document document, List<ValidationError> errors)
document
- the document that has the errorserrors
- a list of errorsCopyright © 2015. All rights reserved.