public FsOutputSocketSink(final FsOutputSocketSink sink) { this.options = sink.getOptions(); this.socket = sink.getSocket(); }
/** * Called to prepare writing an archive file artifact of this driver to * the node {@code name} in {@code controller} using {@code options} and * the nullable {@code template}. * <p> * This method is overridable to enable modifying the given options * before forwarding the call to the given controller. * The implementation in the class {@link FsArchiveDriver} simply forwards * the call to the given controller with the given options unaltered. * * @param options the options for accessing the file system node. * @param controller the controller to use for writing an artifact of this * driver. * @param name the node name. * @return A sink for writing an artifact of this driver. * @see #newOutput(FsModel, BitField, FsController, FsNodeName, InputService) */ protected FsOutputSocketSink sink( BitField<FsAccessOption> options, FsController controller, FsNodeName name) { return new FsOutputSocketSink(options, controller.output(options, name, null)); }
throws IOException { super( sink, null != source && sink.getOptions().get(GROW) ? source : null, driver); this.driver = driver; this.model = Objects.requireNonNull(model); if (null != source) { if (!sink.getOptions().get(GROW)) {
@Override public OutputStream stream() throws IOException { return getSocket().stream(null); }
/** * This implementation modifies {@code options} in the following way before * it forwards the call to {@code controller}: * <ol> * <li>{@link FsAccessOption#STORE} is set. * <li>If {@link FsAccessOption#GROW} is set, then * {@link FsAccessOption#APPEND} gets set, too, and * {@link FsAccessOption#CACHE} gets cleared. * </ol> * <p> * The resulting output socket is then wrapped in a private nested class * for an upcast in {@link #newOutput}. * Thus, when overriding this method, {@link #newOutput} should get * overridden, too. * Otherwise, a class cast exception will be thrown in {@link #newOutput}. */ @Override protected FsOutputSocketSink sink( BitField<FsAccessOption> options, final FsController controller, final FsNodeName name) { // Leave FsAccessOption.COMPRESS untouched - the driver shall be given // opportunity to get its own preferences to sort out such a conflict. options = options.set(STORE); if (options.get(GROW)) options = options.set(APPEND).clear(CACHE); return new FsOutputSocketSink(options, controller.output(options, name, null)); }
@Override public SeekableByteChannel channel() throws IOException { return getSocket().channel(null); } }