saker.build Documentation TaskDoc JavaDoc Packages
public class ByteArraySakerFile extends SakerFileBase
SakerFile implementation with contents that is backed by a byte array.

The file takes a byte array during construction, and will return that when any content requesting methods are called. All opening methods of this file class is efficient.

Warning: This class doesn't make an internal copy of the byte array passed to it during construction. Modifying the contents of the underlying array can result in improper operation, and broken incremental builds.

Constructors
public
Creates a new instance with the given name and no byte contents.
public
Creates a new instance with the given name and byte array region.
public
ByteArraySakerFile(String name, byte[] data)
Creates a new instance with the given name and byte array.
public
ByteArraySakerFile(String name, byte[] data, int start, int end)
Creates a new instance with the given name and range of byte array.
Methods
public ByteArrayRegion
Gets the raw byte contents of this file without implicit synchronization.
public ContentDescriptor
Gets the content descriptor of this file.
public String
Gets the string contents of this file without implicit synchronization.
public int
Gets the efficient opening methods flag of this file.
public InputStream
Opens an input stream to the contents of this file without implicit synchronization.
public void
Writes the contents of this file without implicit synchronization.
Creates a new instance with the given name and no byte contents.

Generally, this constructor is not useful at all, because the created file will have no byte contents at all.

nameThe name of the file.
Creates a new instance with the given name and byte array region.
nameThe name of the file.
dataThe byte contents of the file.
NullPointerExceptionIf any of the arguments are null.
public ByteArraySakerFile(String name, byte[] data) throws NullPointerException
Creates a new instance with the given name and byte array.
nameThe name of the file.
dataThe byte contents of the file.
NullPointerExceptionIf any of the arguments are null.
public ByteArraySakerFile(String name, byte[] data, int start, int end) throws NullPointerException, IllegalArgumentException
Creates a new instance with the given name and range of byte array.
nameThe name of the file.
dataThe byte array for the file.
startThe starting offset of the byte array range. (inclusive)
endThe ending offset of the range. (exclusive)
NullPointerExceptionIf the name or array is null.
IllegalArgumentExceptionIf the specified range is out of bounds.
Overridden from: SakerFile
Gets the raw byte contents of this file without implicit synchronization.

See SakerFile.getBytes().

The byte contents of this file.
Overridden from: SakerFile
Gets the content descriptor of this file.

See ContentDescriptor. Content descriptors are used to determine if the file contents need to be persisted to the file system.

Subclasses should note that if they use posix file permissions then they should return a content descriptor that reflects this behaviour. They are recommended to use PosixFilePermissionsDelegateContentDescriptor to construct the actual content descriptor.

The content descriptor. Never null.
Overridden from: SakerFile
Gets the string contents of this file without implicit synchronization.

See SakerFile.getContent().

The string contents.
IOExceptionIn case of I/O error.
Overridden from: SakerFile
Gets the efficient opening methods flag of this file.

An opening method is considered (performance-wise) efficient if it generally takes less resources (time and memory) to call the appropriate content method instead of trying to employ caching to the disk.

If an opening method is reported as efficient, then the implicit synchronizations will not take place specified by the documentation of SakerFile interface.

If an opening method is not reported as efficient, then calling content retrieval methods which do not end with Impl will check if the file system already has the contents of this file persisted, and will read the contents from there if it has. If not, then the contents will be synchronized with to the disk, and the contents will be retrieved in the most efficient manner. (This manner depends on the nature of the opening method.)

The default implementation returns SakerFile.OPENING_METHODS_NONE.

The efficient opening methods.
Overridden from: SakerFile
Opens an input stream to the contents of this file without implicit synchronization.

See SakerFile.openInputStream().

The opened input stream.
IOExceptionIn case of I/O error.
Overridden from: SakerFile
Writes the contents of this file without implicit synchronization.

See SakerFile.writeTo(OutputStream).

To call this method using a ByteSink, use ByteSink.toOutputStream(ByteSink) to create a delegate object.

Implementations can use ByteSink.valueOf(OutputStream) to convert the argument to a byte sink if required.

osThe output stream.
IOExceptionIn case of I/O error.