|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectcom.github.fge.jsonschema.core.report.ProcessingMessage
@NotThreadSafe public final class ProcessingMessage
One processing message
Internally, a processing message has a Map whose keys are strings
and values are JsonNodes. Note that all methods altering the message
contents accept null: in this case, the value for that key will be a
NullNode. If you submit null keys, the whole value will be
ignored.
Some methods to append contents to a message accept arbitrary inputs: in
this case, it is your responsibility to ensure that these inputs have a
correct implementation of Object.toString().
You can use formatted strings as messages using the capabilities of Formatter; in order to pass arguments to the different placeholders, you
will then use the .putArgument() methods instead of .put().
Arguments will appear in the order you submit them.
Please note that if you do:
message.setMessage("foo %s").putArgument("something", "here")
.setMessage("another %s message")
then the argument list is cleared.
You can alter the behaviour of a processing message in two ways: its log
level and its ExceptionProvider (used in asException().
All mutation methods of a message return this.
| Constructor Summary | |
|---|---|
ProcessingMessage()
Constructor |
|
| Method Summary | ||
|---|---|---|
ProcessingException |
asException()
Build an exception out of this message |
|
JsonNode |
asJson()
Return a JSON representation of this object |
|
LogLevel |
getLogLevel()
Get the log level for this message |
|
String |
getMessage()
Get the main message |
|
ProcessingMessage |
put(String key,
AsJson asJson)
Add a key/value pair to this message |
|
ProcessingMessage |
put(String key,
int value)
Add a key/value pair to this message |
|
|
put(String key,
Iterable<T> values)
Add a key/value pair to this message, where the value is a collection of items |
|
ProcessingMessage |
put(String key,
JsonNode value)
Add a key/value pair to this message |
|
ProcessingMessage |
put(String key,
String value)
Add a key/value pair to this message |
|
|
put(String key,
T value)
Add a key/value pair to this message |
|
ProcessingMessage |
putArgument(String key,
AsJson asJson)
Add a key/value pair to this message, which is also a formatter argument |
|
ProcessingMessage |
putArgument(String key,
int value)
Add a key/value pair to this message, which is also a formatter argument |
|
|
putArgument(String key,
Iterable<T> values)
Add a key/value pair to this message, which is also a formatter argument |
|
ProcessingMessage |
putArgument(String key,
JsonNode value)
Add a key/value pair to this message, which is also a formatter argument |
|
|
putArgument(String key,
T value)
Add a key/value pair to this message, which is also a formatter argument |
|
ProcessingMessage |
setExceptionProvider(ExceptionProvider exceptionProvider)
Set the exception provider for that particular message |
|
ProcessingMessage |
setLogLevel(LogLevel level)
Set the log level for this message |
|
ProcessingMessage |
setMessage(String message)
Set the main message |
|
String |
toString()
|
|
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Constructor Detail |
|---|
public ProcessingMessage()
By default, a message is generated with a log level of LogLevel.INFO.
| Method Detail |
|---|
public String getMessage()
public LogLevel getLogLevel()
public ProcessingMessage setMessage(String message)
message - the message as a string
public ProcessingMessage setLogLevel(LogLevel level)
level - the log level
NullPointerException - log level is nullpublic ProcessingMessage setExceptionProvider(ExceptionProvider exceptionProvider)
exceptionProvider - the exception provider
NullPointerException - exception provider is null
public ProcessingMessage put(String key,
JsonNode value)
This is the main method. All other put methods call this one.
Note that if the key is null, the content is ignored.
key - the keyvalue - the value as a JsonNode
public ProcessingMessage putArgument(String key,
JsonNode value)
key - the keyvalue - the value
public ProcessingMessage put(String key,
AsJson asJson)
key - the keyasJson - the value, which implements AsJson
public ProcessingMessage putArgument(String key,
AsJson asJson)
key - the keyasJson - the value
public ProcessingMessage put(String key,
String value)
key - the keyvalue - the value
public ProcessingMessage put(String key,
int value)
key - the keyvalue - the value as an integer
public ProcessingMessage putArgument(String key,
int value)
key - the keyvalue - the value
public <T> ProcessingMessage put(String key,
T value)
Ensure that toString() is correctly implemented.
T - the type of the valuekey - the keyvalue - the value
public <T> ProcessingMessage putArgument(String key,
T value)
T - the type of the valuekey - the keyvalue - the value
public <T> ProcessingMessage put(String key,
Iterable<T> values)
This will put all values (again, using toString() of the
collection into an array.
T - the element type of the collectionkey - the keyvalues - the collection of values
public <T> ProcessingMessage putArgument(String key,
Iterable<T> values)
Note that the collection will not be "exploded" into its individual arguments.
T - type of valueskey - the keyvalues - the collection of values
public JsonNode asJson()
AsJson
asJson in interface AsJsonJsonNodepublic ProcessingException asException()
This uses the ExceptionProvider built into the message and
invokes ExceptionProvider.doException(ProcessingMessage) with
this as an argument.
setExceptionProvider(ExceptionProvider)public String toString()
toString in class Object
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||