public class NCQueryResult extends Object implements Serializable
Result Type | Factory Method |
---|---|
text |
text(String) |
html |
html(String) |
json |
json(String) |
yaml |
yaml(String) |
text
result type and ignore everything else.Constructor and Description |
---|
NCQueryResult()
No-arg constructor.
|
NCQueryResult(String body,
String type)
Creates new result with given body and type.
|
Modifier and Type | Method and Description |
---|---|
String |
getBody()
Gets result body.
|
Collection<NCToken> |
getTokens()
Gets tokens that were used to produce this query result.
|
String |
getType()
Gets result type.
|
static NCQueryResult |
html(String html)
Creates
html result. |
static NCQueryResult |
json(String json)
Creates
json result. |
void |
setBody(String body)
Sets result body.
|
void |
setTokens(Collection<NCToken> tokens)
Sets a collection of tokens that was used to produce this query result.
|
void |
setType(String type)
Set result type.
|
static NCQueryResult |
text(String txt)
Creates
text result. |
static NCQueryResult |
yaml(String yaml)
Creates
yaml result. |
public NCQueryResult(String body, String type)
body
- Result body.type
- Result type.IllegalArgumentException
- Thrown if type is invalid.public NCQueryResult()
public static NCQueryResult text(String txt)
text
result.txt
- Textual result. Text interpretation will be defined by the client receiving this result.public static NCQueryResult html(String html)
html
result.html
- HTML markup.public static NCQueryResult json(String json)
json
result. Note that this method will test given JSON string
for validness by using com.google.gson.Gson
JSON utility. If JSON string is invalid
the IllegalArgumentException
exception will be thrown.json
- Any JSON string to be rendered on the client.IllegalArgumentException
- Thrown if given JSON string is invalid.public static NCQueryResult yaml(String yaml)
yaml
result.yaml
- Any YAML string to be rendered on the client.public void setBody(String body)
body
- Result body.public void setType(String type)
type
- Result type.IllegalArgumentException
- Thrown if type is invalid.public Collection<NCToken> getTokens()
setTokens(Collection)
public void setTokens(Collection<NCToken> tokens)
Providing these tokens is necessary for proper STM operation. If conversational support isn't used setting these tokens is not required. Note that built-in intent based matched automatically sets these tokens. If intent-based matching isn't used the user of this class is responsible for settings these tokens.
tokens
- Collection of tokens that was used to produce this query result.getTokens()
public String getType()
public String getBody()
Copyright © 2020 NLPCraft. All rights reserved.