|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectcom.tngtech.jgiven.attachment.Attachment
public class Attachment
Represents an attachment of a step. Attachments must be representable as a String so that it can be stored as JSON. For binary attachments this means that they have to be encoded with Base64. In addition, attachments must have a media type so that reporters know how to present an attachment.
| Constructor Summary | |
|---|---|
protected |
Attachment(java.lang.String content,
MediaType mediaType)
Convenience constructor, where title is set to null |
protected |
Attachment(java.lang.String content,
MediaType mediaType,
java.lang.String title)
Creates a new instance of this Attachment |
| Method Summary | |
|---|---|
java.lang.String |
content()
The content of the attachment represented as a string. |
static Attachment |
fromBase64(java.lang.String base64encodedContent,
MediaType mediaType)
Equivalent to Attachment(String, MediaType) |
static Attachment |
fromBinaryBytes(byte[] bytes,
MediaType mediaType)
Creates an attachment from a given array of bytes. |
static Attachment |
fromBinaryFile(java.io.File file,
MediaType mediaType)
Creates an attachment from the given binary file file. |
static Attachment |
fromBinaryInputStream(java.io.InputStream inputStream,
MediaType mediaType)
Creates an attachment from a binary input stream. |
static Attachment |
fromText(java.lang.String content,
MediaType mediaType)
Equivalent to Attachment(String, MediaType) |
static Attachment |
fromTextFile(java.io.File file,
MediaType mediaType,
java.nio.charset.Charset charSet)
Creates a non-binary attachment from the given file. |
static Attachment |
fromTextInputStream(java.io.InputStream inputStream,
MediaType mediaType,
java.nio.charset.Charset charset)
Creates a non-binary attachment from the given file. |
MediaType |
getMediaType()
The type of the attachment. |
java.lang.String |
getTitle()
An optional title |
java.lang.String |
title()
An optional title of the attachment. |
Attachment |
withTitle(java.lang.String title)
Sets the title and returns this |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
protected Attachment(java.lang.String content,
MediaType mediaType)
null
protected Attachment(java.lang.String content,
MediaType mediaType,
java.lang.String title)
content - the content of this attachment. In case of a binary attachment, this must be
Base64 encoded. Must not be nullmediaType - the mediaType. Must not be nulltitle - an optional title, may be null| Method Detail |
|---|
public java.lang.String title()
null.
public java.lang.String content()
public MediaType getMediaType()
public java.lang.String getTitle()
public Attachment withTitle(java.lang.String title)
this
public static Attachment fromBinaryBytes(byte[] bytes,
MediaType mediaType)
java.lang.IllegalArgumentException - if mediaType is not binary
public static Attachment fromBinaryInputStream(java.io.InputStream inputStream,
MediaType mediaType)
throws java.io.IOException
java.io.IOException - if an I/O error occurs
java.lang.IllegalArgumentException - if mediaType is not binary
public static Attachment fromBinaryFile(java.io.File file,
MediaType mediaType)
throws java.io.IOException
file.
The content of the file will be transformed into a Base64 encoded string.
java.io.IOException - if an I/O error occurs
java.lang.IllegalArgumentException - if mediaType is not binary
public static Attachment fromTextFile(java.io.File file,
MediaType mediaType,
java.nio.charset.Charset charSet)
throws java.io.IOException
java.io.IOException - if an I/O error occurs
java.lang.IllegalArgumentException - if mediaType is binary
public static Attachment fromTextInputStream(java.io.InputStream inputStream,
MediaType mediaType,
java.nio.charset.Charset charset)
throws java.io.IOException
java.io.IOException - if an I/O error occurs
java.lang.IllegalArgumentException - if mediaType is binary
public static Attachment fromText(java.lang.String content,
MediaType mediaType)
Attachment(String, MediaType)
java.lang.IllegalArgumentException - if mediaType is binary
public static Attachment fromBase64(java.lang.String base64encodedContent,
MediaType mediaType)
Attachment(String, MediaType)
java.lang.IllegalArgumentException - if mediaType is not binary
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||