Package com.trafficparrot.sdk.file
Class FileMessageResponse
java.lang.Object
com.trafficparrot.sdk.file.FileMessageResponse
- All Implemented Interfaces:
Comparable<FileMessageResponse>
-
Field Summary
FieldsModifier and TypeFieldDescriptionfinal StringA__files/<name>sidecar holding the response body, used instead of an inlinetext.final MessageBodyTypefinal Destinationfinal Stringfinal StringThe name of the response file WRITTEN to the response directory - a transport output name, Handlebars-templated liketext.static final Stringfinal StringContent resolved frombodyFileNameat load time.final String -
Constructor Summary
ConstructorsConstructorDescriptionFileMessageResponse(Destination destination, String fileName, String text) FileMessageResponse(Destination destination, String fileMessageResponseTransformerClassName, String fileName, String text, MessageBodyType bodyType) FileMessageResponse(Destination destination, String fileName, String text) FileMessageResponse(Destination destination, String fileMessageResponseTransformerClassName, String fileName, String text, MessageBodyType bodyType) The inline-body constructor kept forFileMessageResponseTransformerimplementations, which are customer code.FileMessageResponse(Destination destination, String fileMessageResponseTransformerClassName, String fileName, String text, String bodyFileName, MessageBodyType bodyType) -
Method Summary
Modifier and TypeMethodDescriptionintcompareTo(FileMessageResponse other) A body file held by reference is copied as it is.The response body content to write: the file-resolvedresolvedTextwhen set, otherwise the inlinetext.booleanThe body file a reply is copied from, for a body too large to read into memory; empty otherwise.The size ofresolvedBodyFile()in bytes, or null when the body is not held by reference.toString()A BYTES body is given by its length: it can be megabytes of base64, and every response sent is logged.voidvalidate()withResolvedBodyFile(Path bodyFile, long bytes) Returns a copy whose body is thebodyFileNamesidecarbodyFile, ofbytesbytes, held by reference because it is too large to read into memory:createResponseMessage()copies it, andeffectiveText()is null.withResolvedText(String resolvedText) Returns a copy withresolvedTextset (the content read frombodyFileNameat load time).
-
Field Details
-
NO_TRANSFORMER
- See Also:
-
destination
-
fileMessageResponseTransformerClassName
-
fileName
The name of the response file WRITTEN to the response directory - a transport output name, Handlebars-templated liketext. Not to be confused withbodyFileName, which names a__filessidecar the body is READ from. -
text
-
bodyFileName
A__files/<name>sidecar holding the response body, used instead of an inlinetext. Mutually exclusive with it - seevalidate(). -
bodyType
-
resolvedText
Content resolved frombodyFileNameat load time. Held here rather than intextso the persisted model keepsbodyFileNameset andtextnull (non-destructive).transientso the filesystem mapper never writes it to disk; set only viawithResolvedText(String)and read viaeffectiveText(). The web-UI mapper re-includes it (via a mix-in) so the editor can display the content.
-
-
Constructor Details
-
FileMessageResponse
public FileMessageResponse(Destination destination, String fileMessageResponseTransformerClassName, String fileName, String text, String bodyFileName, MessageBodyType bodyType) -
FileMessageResponse
public FileMessageResponse(Destination destination, String fileMessageResponseTransformerClassName, String fileName, String text, MessageBodyType bodyType) The inline-body constructor kept forFileMessageResponseTransformerimplementations, which are customer code. Deliberately NOT annotated for Jackson - the constructor above is the single creator. -
FileMessageResponse
-
FileMessageResponse
public FileMessageResponse(Destination destination, String fileMessageResponseTransformerClassName, String fileName, String text, MessageBodyType bodyType) -
FileMessageResponse
-
-
Method Details
-
withResolvedText
Returns a copy withresolvedTextset (the content read frombodyFileNameat load time). Every persisted field is preserved so a subsequent save re-writesbodyFileNamewith nulltext, keeping the sidecar reference intact. -
withResolvedBodyFile
Returns a copy whose body is thebodyFileNamesidecarbodyFile, ofbytesbytes, held by reference because it is too large to read into memory:createResponseMessage()copies it, andeffectiveText()is null. Every persisted field is preserved, as bywithResolvedText(String). -
resolvedBodyFile
The body file a reply is copied from, for a body too large to read into memory; empty otherwise. Read it, do not modify it: it is the mapping's__filessidecar. -
resolvedBodyFileBytes
The size ofresolvedBodyFile()in bytes, or null when the body is not held by reference. -
effectiveText
The response body content to write: the file-resolvedresolvedTextwhen set, otherwise the inlinetext. -
validate
- Throws:
IOException
-
toString
A BYTES body is given by its length: it can be megabytes of base64, and every response sent is logged. A long inline text is given by its start and length. -
compareTo
- Specified by:
compareToin interfaceComparable<FileMessageResponse>
-
createResponseMessage
A body file held by reference is copied as it is. A BYTES body is base64 (inline, or resolved from a__filessidecar), written as the exact bytes it encodes; any other body is written as its text. -
hasTransformer
public boolean hasTransformer()
-