public final class Outcome extends Object implements Comparable<Outcome>, Serializable
An Outcome
instance encodes the outcome of an Operation
invocation. It stores:
Outcome.Status
code specifying whether and how the invocation was successful or failed
(see getStatus()
);getInvocationID()
);getObjectID()
);getMessage()
)
Outcome
instances can be created using one of the static factory methods
create(Status, URI)
, create(Status, URI, URI)
,
create(Status, URI, URI, String)
. Equality and comparison are performed based on the
invocation ID. This class is immutable and thus thread safe.
Modifier and Type | Class and Description |
---|---|
static class |
Outcome.Status
Enumeration of
Outcome status codes. |
Modifier and Type | Method and Description |
---|---|
int |
compareTo(Outcome other)
Comparison is done on the invocation ID.
|
static Outcome |
create(Outcome.Status status,
org.openrdf.model.URI invocationID)
Creates a new
Outcome with the status code and invocation ID supplied. |
static Outcome |
create(Outcome.Status status,
org.openrdf.model.URI invocationID,
org.openrdf.model.URI objectID)
Creates a new
Outcome with the status code, invocation ID and optional object ID
supplied. |
static Outcome |
create(Outcome.Status status,
org.openrdf.model.URI invocationID,
org.openrdf.model.URI objectID,
String message)
Creates a new
Outcome with the status code, invocation ID, optional object ID and
optional message supplied. |
static Outcome |
create(Record record)
Creates a new
Outcome starting from the Record supplied. |
static Stream<Outcome> |
decode(Stream<org.openrdf.model.Statement> stream,
Boolean chunked)
Performs RDF-to-outcome decoding by converting a stream of RDF statements in a stream of
outcomes.
|
static Stream<org.openrdf.model.Statement> |
encode(Stream<? extends Outcome> stream)
Performs outcome-to-RDF encoding by converting a stream of outcomes in a stream of RDF
statements.
|
boolean |
equals(Object object)
Two
Outcome instances are equal if the have the same invocation ID. |
org.openrdf.model.URI |
getInvocationID()
Returns the ID of the invocation, which may link to relevant logged information.
|
String |
getMessage()
Return an optional message providing further information about the outcome.
|
org.openrdf.model.URI |
getObjectID()
Returns the ID of the processed object, if applicable.
|
Outcome.Status |
getStatus()
Returns the status code for this outcome.
|
int |
hashCode()
The returned code depends on the invocation ID.
|
Record |
toRecord()
Return a
Record version of this Outcome object. |
String |
toString()
The method returns a string of the form
status invocationID (objectID) message . |
public static Outcome create(Outcome.Status status, org.openrdf.model.URI invocationID)
Outcome
with the status code and invocation ID supplied.status
- the status code, not nullinvocationID
- the invocation ID, not nullOutcome
public static Outcome create(Outcome.Status status, org.openrdf.model.URI invocationID, @Nullable org.openrdf.model.URI objectID)
Outcome
with the status code, invocation ID and optional object ID
supplied.status
- the status code, not nullinvocationID
- the invocation ID, not nullobjectID
- the optional object ID, possibly nullOutcome
public static Outcome create(Outcome.Status status, org.openrdf.model.URI invocationID, @Nullable org.openrdf.model.URI objectID, @Nullable String message)
Outcome
with the status code, invocation ID, optional object ID and
optional message supplied.status
- the status code, not nullinvocationID
- the invocation ID, not nullobjectID
- the optional object ID, possibly nullmessage
- the optional message, possibly nullOutcome
public static Outcome create(Record record)
Outcome
starting from the Record
supplied. The record ID is
used as the invocation ID, while properties KSR.STATUS
, KSR.OBJECT
and
KSR.MESSAGE
are read, respectively, to recover the status code, the optional object
ID and the optional message.record
- the recordOutcome
public Outcome.Status getStatus()
public org.openrdf.model.URI getInvocationID()
@Nullable public org.openrdf.model.URI getObjectID()
@Nullable public String getMessage()
public int compareTo(Outcome other)
compareTo
in interface Comparable<Outcome>
public boolean equals(@Nullable Object object)
Outcome
instances are equal if the have the same invocation ID.public int hashCode()
public Record toRecord()
Record
version of this Outcome
object. The returned record is
identified by this invocation ID; it is associated to the status URI via property
KSR.STATUS
, to the optional object ID via property KSR.OBJECT
and to the
optional message via property KSR.MESSAGE
.public String toString()
status invocationID (objectID) message
.public static Stream<org.openrdf.model.Statement> encode(Stream<? extends Outcome> stream)
stream
- the stream of outcomes to encode.public static Stream<Outcome> decode(Stream<org.openrdf.model.Statement> stream, @Nullable Boolean chunked)
chunked
specifies whether the input statement stream is
chunked, i.e., organized as a sequence of statement chunks with each chunk containing the
statements for an outcome. Chunked RDF streams noticeably speed up decoding, and are always
produced by the KnowledgeStore API. Chunking information may be set to null (e.g., because
unknown at the time the method is called): in this case, it will be read from metadata
attribute "chunked"
attached to the stream; reading will happen just before
decoding will take place, i.e., when a terminal stream operation will be called.stream
- the stream of statements to decodechunked
- true if the input statement stream is chunked, null if to be read from stream
metadataCopyright © 2015–2016 FBK-irst. All rights reserved.