Top Description Fields Constructors Methods
org.opentest4j

public Class FileInfo

extends Object
implements Serializable
Class Inheritance
All Implemented Interfaces
java.io.Serializable
Imports
java.io.Serializable, java.nio.charset.Charset, java.util.Arrays

FileInfo is a pair of a file path and the contents of the file.

Its main use case is for actual and expected values in AssertionFailedError.

The semantics of the path can be defined by the users of this class.

Authors
Marc Philipp, Reinhold Degenfellner
Since
1.3

Field Summary

Modifier and TypeField and Description
private final byte[]
private final String
private static final long

Constructor Summary

AccessConstructor and Description
public
FileInfo(String
the path to the file; must not be null
path
,
byte[]
the contents of the file; must not be null;
contents
)

Constructs a FileInfo with a path to a file and the contents of the file.

Method Summary

Modifier and TypeMethod and Description
public boolean
equals(Object
the reference object with which to compare.
obj
)

Overrides java.lang.Object.equals.

Determines if the supplied object is an instance of FileInfo with the same path and contents as this FileInfo.
public byte[]

Returns:

the contents of the file; never null
getContents
()

Returns the contents of the file.

public String

Returns:

the contents of the file as a String; never null
getContentsAsString
(Charset charset)

Returns the contents of the file as a String.

public String

Returns:

the path to the file; never null
getPath
()

Returns the path to the file.

public int
hashCode()

Overrides java.lang.Object.hashCode.

Generates a unique hash code for this FileInfo based on its path.
public String
toString()

Overrides java.lang.Object.toString.

Generates a string representation of this FileInfo based on the path and contents.
private static void
Inherited from java.lang.Object:
clonefinalizegetClassnotifynotifyAllwaitwaitwait

Field Detail

contentsback to summary
private final byte[] contents
pathback to summary
private final String path
serialVersionUIDback to summary
private static final long serialVersionUID

Constructor Detail

FileInfoback to summary
public FileInfo(String path, byte[] contents)

Constructs a FileInfo with a path to a file and the contents of the file.

Be cautious with large files (limiting the size may be a good idea).

The supplied byte array is not copied to avoid unnecessary memory allocations. However, callers of this constructors should not modify the byte array after calling this constructor. This behavior may change in a future release without prior notice.

Parameters
path:String

the path to the file; must not be null

contents:byte[]

the contents of the file; must not be null;

Method Detail

equalsback to summary
public boolean equals(Object obj)

Overrides java.lang.Object.equals.

Determines if the supplied object is an instance of FileInfo with the same path and contents as this FileInfo.

Parameters
obj:Object

Doc from java.lang.Object.equals.

the reference object with which to compare.

Returns:boolean

Doc from java.lang.Object.equals.

true if this object is the same as the obj argument; false otherwise.

Annotations
@Override
getContentsback to summary
public byte[] getContents()

Returns the contents of the file.

This method does currently not return a defensive copy of the contained byte array to avoid unnecessary memory allocations. However, callers of this method should not modify the returned byte array. This behavior may change in a future release without prior notice.

Returns:byte[]

the contents of the file; never null

getContentsAsStringback to summary
public String getContentsAsString(Charset charset)

Returns the contents of the file as a String.

Returns:String

the contents of the file as a String; never null

getPathback to summary
public String getPath()

Returns the path to the file.

Returns:String

the path to the file; never null

hashCodeback to summary
public int hashCode()

Overrides java.lang.Object.hashCode.

Generates a unique hash code for this FileInfo based on its path.

Returns:int

Doc from java.lang.Object.hashCode.

a hash code value for this object

Annotations
@Override
toStringback to summary
public String toString()

Overrides java.lang.Object.toString.

Generates a string representation of this FileInfo based on the path and contents.

Returns:String

Doc from java.lang.Object.toString.

a string representation of the object

Annotations
@Override
validatePathback to summary
private static void validatePath(String path)