saker.build Documentation TaskDoc JavaDoc Packages
public class DelegateSakerFile extends SakerFileBase
SakerFile implementation that delegates its calls to another file.

This file will have the same contents, content descriptor, as the subject file. This class can be basically used to construct a link to another file.

The delegate file cannot be initialized with a directory as a subject.

This class shouldn't be extended by clients.

Fields
protected final SakerFile
The file that is the subject of delegation.
Constructors
public
Creates a new delegate file initialized with the specified name and subject.
public
Creates a new delegate file initialized with the given subject.
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 Set<PosixFilePermission>
Gets the posix file permissions that are associated with this file.
public ByteSource
Opens a byte source to the contents of this file without implicit synchronization.
public InputStream
Opens an input stream to the contents of this file without implicit synchronization.
public void
Synchronizing implementation for persisting the contents of this file to the target file system location.
public boolean
synchronizeImpl(ProviderHolderPathKey pathkey, ByteSink additionalwritestream)
Overloaded synchronizing method with additional output stream to write the contents to.
public void
Writes the contents of this file without implicit synchronization.
protected final SakerFile file
The file that is the subject of delegation.
Creates a new delegate file initialized with the specified name and subject.
nameThe name to set for the created file.
fileThe subject file.
IllegalArgumentExceptionIf the file is a directory.
NullPointerExceptionIf any of the arguments are null.
Creates a new delegate file initialized with the given subject.

The created file will have the same name as the argument.

fileThe subject file.
IllegalArgumentExceptionIf the file is a directory.
NullPointerExceptionIf the file is null.
Overridden from: SakerFile
Gets the raw byte contents of this file without implicit synchronization.

See SakerFile.getBytes().

The byte contents of this file.
IOExceptionIn case of I/O error.
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
Gets the posix file permissions that are associated with this file.

This method returns the set of posix file permissions that were associated with the given file as part of the build execution.

Subclasses can override this method to explicitly set the permissions, however, if they do so then they also need to return a content descriptor that reflects this association. They are encouraged to use PosixFilePermissionsDelegateContentDescriptor to construct the actual content descriptor if posix file permissions are set for a file.

Subclasses that return non-null from this method are also required to set these permissions in the synchronization methods.

Note that this method will return null by default even when the build is running on file systems that support posix file permissions. The posix file permissions are not automatically queried by the build system but only if a build execution previously set it.

The set of permissions or null if none are associated.
saker.build 0.8.13
Overridden from: SakerFile
Opens a byte source to the contents of this file without implicit synchronization.

See SakerFile.openByteSource().

If subclasses override this method, they must override SakerFile.openInputStreamImpl() as well. (Simply returning ByteSource.toInputStream(openByteSourceImpl()) is fine.)

The opened byte input.
IOExceptionIn case of I/O error.
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
Synchronizing implementation for persisting the contents of this file to the target file system location.

This method will not check if the contents of the disk have been changes in relation to this file, but will always persist it to the given location.

Subclasses should implement this method to persist its contents to the location specified by the parameter.

If subclasses override this method, they must override SakerFile.synchronizeImpl(ProviderHolderPathKey, ByteSink) as well. (They can just simply call SakerFile.synchronizeImpl(ProviderHolderPathKey) and return false.)

Subclasses should set any posix file permissions there are associated with the file during synchronization.

pathkeyThe target location of the synchronization.
IOExceptionIn case of I/O error.
public boolean synchronizeImpl(ProviderHolderPathKey pathkey, ByteSink additionalwritestream) throws SecondaryStreamException, IOException
Overridden from: SakerFile
Overloaded synchronizing method with additional output stream to write the contents to.

This method will not check if the contents of the disk have been changes in relation to this file, but will always persist it to the given location.

This method exists for performance optimization. Subclasses should override this method and attempt to concurrently persist the contents of the file to the target location and write the contents to the additional stream.

Subclasses must not throw an IOException if the writing to the additional stream failed, but rethrow them as a SecondaryStreamException. If a SecondaryStreamException is thrown, the synchronization is going to be considered as successful, and only the writing to the secondary stream is considered as failure. If an IOException is thrown, both stream writings is considered to be failed.

The implementations are not required to handle concurrent writing. This method should return true if it was able to concurrently synchronize and write the contents to the additional stream. The PriorityMultiplexOutputStream utility class can help implementations in implementing this functionality.

Overriding this method will improve the overall synchronization performance.

If subclasses override this method, they must override SakerFile.synchronizeImpl(ProviderHolderPathKey) as well.

Subclasses should set any posix file permissions there are associated with the file during synchronization.

pathkeyThe target location of the synchronization.
additionalwritestreamThe additional stream to write the contents to.
true if the contents of the file was successfully written to the additional stream.
SecondaryStreamExceptionIn case of I/O error during writing to the additional stream.
IOExceptionIn case of I/O error during synchronization.
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.