Class: Vertx::AsyncFile

Inherits:
Object
  • Object
show all
Includes:
ReadStream, WriteStream
Defined in:
/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx/async_file.rb

Overview

Represents a file on the file-system which can be read from, or written to asynchronously.

This class also implements ReadStream and WriteStream. This allows the data to be pumped to and from other streams, e.g. an HttpClientRequest instance, using the Pump class

Constant Summary

@@j_api_type =
Object.new

Class Method Summary (collapse)

Instance Method Summary (collapse)

Class Method Details

+ (Boolean) accept?(obj)

Returns:

  • (Boolean)


29
30
31
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx/async_file.rb', line 29

def @@j_api_type.accept?(obj)
  obj.class == AsyncFile
end

+ (Object) j_api_type



38
39
40
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx/async_file.rb', line 38

def self.j_api_type
  @@j_api_type
end

+ (Object) j_class



41
42
43
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx/async_file.rb', line 41

def self.j_class
  Java::IoVertxCoreFile::AsyncFile.java_class
end

+ (Object) unwrap(obj)



35
36
37
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx/async_file.rb', line 35

def @@j_api_type.unwrap(obj)
  obj.j_del
end

+ (Object) wrap(obj)



32
33
34
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx/async_file.rb', line 32

def @@j_api_type.wrap(obj)
  AsyncFile.new(obj)
end

Instance Method Details

- (void) close { ... }

This method returns an undefined value.

Close the file. The actual close happens asynchronously. The handler will be called when the close is complete, or an error occurs.

Yields:

  • the handler

Raises:

  • (ArgumentError)


184
185
186
187
188
189
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx/async_file.rb', line 184

def close
  if true
    return @j_del.java_method(:close, [Java::IoVertxCore::Handler.java_class]).call((Proc.new { |ar| yield(ar.failed ? ar.cause : nil) } unless !block_given?))
  end
  raise ArgumentError, "Invalid arguments when calling close()"
end

- (self) drain_handler { ... }

Yields:

Returns:

  • (self)

Raises:

  • (ArgumentError)


155
156
157
158
159
160
161
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx/async_file.rb', line 155

def drain_handler
  if true
    @j_del.java_method(:drainHandler, [Java::IoVertxCore::Handler.java_class]).call(Proc.new { yield unless !block_given? })
    return self
  end
  raise ArgumentError, "Invalid arguments when calling drain_handler()"
end

- (void) end(data = nil) { ... }

This method returns an undefined value.

Same as but with an handler called when the operation completes

Parameters:

Yields:

Raises:

  • (ArgumentError)


69
70
71
72
73
74
75
76
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx/async_file.rb', line 69

def end(data=nil)
  if true && data == nil
    return @j_del.java_method(:end, [Java::IoVertxCore::Handler.java_class]).call((Proc.new { |ar| yield(ar.failed ? ar.cause : nil) } unless !block_given?))
  elsif data.class.method_defined?(:j_del) && true
    return @j_del.java_method(:end, [Java::IoVertxCoreBuffer::Buffer.java_class,Java::IoVertxCore::Handler.java_class]).call(data.j_del,(Proc.new { |ar| yield(ar.failed ? ar.cause : nil) } unless !block_given?))
  end
  raise ArgumentError, "Invalid arguments when calling end(#{data})"
end

- (self) end_handler { ... }

Yields:

Returns:

  • (self)

Raises:

  • (ArgumentError)


137
138
139
140
141
142
143
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx/async_file.rb', line 137

def end_handler
  if true
    @j_del.java_method(:endHandler, [Java::IoVertxCore::Handler.java_class]).call(Proc.new { yield unless !block_given? })
    return self
  end
  raise ArgumentError, "Invalid arguments when calling end_handler()"
end

- (self) exception_handler { ... }

Yields:

Returns:

  • (self)

Raises:

  • (ArgumentError)


164
165
166
167
168
169
170
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx/async_file.rb', line 164

def exception_handler
  if true
    @j_del.java_method(:exceptionHandler, [Java::IoVertxCore::Handler.java_class]).call((Proc.new { |event| yield(::Vertx::Util::Utils.from_throwable(event)) unless !block_given? }))
    return self
  end
  raise ArgumentError, "Invalid arguments when calling exception_handler()"
end

- (self) fetch(amount = nil)

Parameters:

  • amount (Fixnum) (defaults to: nil)

Returns:

  • (self)

Raises:

  • (ArgumentError)


173
174
175
176
177
178
179
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx/async_file.rb', line 173

def fetch(amount=nil)
  if amount.class == Fixnum && !block_given?
    @j_del.java_method(:fetch, [Java::long.java_class]).call(amount)
    return self
  end
  raise ArgumentError, "Invalid arguments when calling fetch(#{amount})"
end

- (self) flush { ... }

Same as #flush but the handler will be called when the flush is complete or if an error occurs

Yields:

Returns:

  • (self)

Raises:

  • (ArgumentError)


214
215
216
217
218
219
220
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx/async_file.rb', line 214

def flush
  if true
    @j_del.java_method(:flush, [Java::IoVertxCore::Handler.java_class]).call((Proc.new { |ar| yield(ar.failed ? ar.cause : nil) } unless !block_given?))
    return self
  end
  raise ArgumentError, "Invalid arguments when calling flush()"
end

- (Fixnum) get_write_pos

Returns the current write position the file is at

Returns:

  • (Fixnum)
    the current write position the file is at

Raises:

  • (ArgumentError)


252
253
254
255
256
257
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx/async_file.rb', line 252

def get_write_pos
  if !block_given?
    return @j_del.java_method(:getWritePos, []).call()
  end
  raise ArgumentError, "Invalid arguments when calling get_write_pos()"
end

- (self) handler { ... }

Yields:

Returns:

  • (self)

Raises:

  • (ArgumentError)


112
113
114
115
116
117
118
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx/async_file.rb', line 112

def handler
  if true
    @j_del.java_method(:handler, [Java::IoVertxCore::Handler.java_class]).call((Proc.new { |event| yield(::Vertx::Util::Utils.safe_create(event,::Vertx::Buffer)) unless !block_given? }))
    return self
  end
  raise ArgumentError, "Invalid arguments when calling handler()"
end

- (self) pause

Returns:

  • (self)

Raises:

  • (ArgumentError)


120
121
122
123
124
125
126
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx/async_file.rb', line 120

def pause
  if !block_given?
    @j_del.java_method(:pause, []).call()
    return self
  end
  raise ArgumentError, "Invalid arguments when calling pause()"
end

- (::Vertx::Pipe) pipe

Pause this stream and return a to transfer the elements of this stream to a destination .

The stream will be resumed when the pipe will be wired to a WriteStream.

Returns:

Raises:

  • (ArgumentError)


89
90
91
92
93
94
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx/async_file.rb', line 89

def pipe
  if !block_given?
    return ::Vertx::Util::Utils.safe_create(@j_del.java_method(:pipe, []).call(),::Vertx::Pipe,::Vertx::Buffer.j_api_type)
  end
  raise ArgumentError, "Invalid arguments when calling pipe()"
end

- (void) pipe_to(dst = nil) { ... }

This method returns an undefined value.

Pipe this ReadStream to the WriteStream.

Elements emitted by this stream will be written to the write stream until this stream ends or fails.

Once this stream has ended or failed, the write stream will be ended and the handler will be called with the result.

Parameters:

Yields:

Raises:

  • (ArgumentError)


104
105
106
107
108
109
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx/async_file.rb', line 104

def pipe_to(dst=nil)
  if dst.class.method_defined?(:j_del) && true
    return @j_del.java_method(:pipeTo, [Java::IoVertxCoreStreams::WriteStream.java_class,Java::IoVertxCore::Handler.java_class]).call(dst.j_del,(Proc.new { |ar| yield(ar.failed ? ar.cause : nil) } unless !block_given?))
  end
  raise ArgumentError, "Invalid arguments when calling pipe_to(#{dst})"
end

- (self) read(buffer = nil, offset = nil, position = nil, length = nil) { ... }

Reads length bytes of data from the file at position position in the file, asynchronously.

The read data will be written into the specified Buffer buffer at position offset.

If data is read past the end of the file then zero bytes will be read.

When multiple reads are invoked on the same file there are no guarantees as to order in which those reads actually occur.

The handler will be called when the close is complete, or if an error occurs.

Parameters:

  • buffer (::Vertx::Buffer) (defaults to: nil)
    the buffer to read into
  • offset (Fixnum) (defaults to: nil)
    the offset into the buffer where the data will be read
  • position (Fixnum) (defaults to: nil)
    the position in the file where to start reading
  • length (Fixnum) (defaults to: nil)
    the number of bytes to read

Yields:

  • the handler to call when the write is complete

Returns:

  • (self)

Raises:

  • (ArgumentError)


204
205
206
207
208
209
210
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx/async_file.rb', line 204

def read(buffer=nil,offset=nil,position=nil,length=nil)
  if buffer.class.method_defined?(:j_del) && offset.class == Fixnum && position.class == Fixnum && length.class == Fixnum && true
    @j_del.java_method(:read, [Java::IoVertxCoreBuffer::Buffer.java_class,Java::int.java_class,Java::long.java_class,Java::int.java_class,Java::IoVertxCore::Handler.java_class]).call(buffer.j_del,offset,position,length,(Proc.new { |ar| yield(ar.failed ? ar.cause : nil, ar.succeeded ? ::Vertx::Util::Utils.safe_create(ar.result,::Vertx::Buffer) : nil) } unless !block_given?))
    return self
  end
  raise ArgumentError, "Invalid arguments when calling read(#{buffer},#{offset},#{position},#{length})"
end

- (self) resume

Returns:

  • (self)

Raises:

  • (ArgumentError)


128
129
130
131
132
133
134
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx/async_file.rb', line 128

def resume
  if !block_given?
    @j_del.java_method(:resume, []).call()
    return self
  end
  raise ArgumentError, "Invalid arguments when calling resume()"
end

- (self) set_read_buffer_size(readBufferSize = nil)

Sets the buffer size that will be used to read the data from the file. Changing this value will impact how much the data will be read at a time from the file system.

Parameters:

  • readBufferSize (Fixnum) (defaults to: nil)
    the buffer size

Returns:

  • (self)

Raises:

  • (ArgumentError)


262
263
264
265
266
267
268
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx/async_file.rb', line 262

def set_read_buffer_size(readBufferSize=nil)
  if readBufferSize.class == Fixnum && !block_given?
    @j_del.java_method(:setReadBufferSize, [Java::int.java_class]).call(readBufferSize)
    return self
  end
  raise ArgumentError, "Invalid arguments when calling set_read_buffer_size(#{readBufferSize})"
end

- (self) set_read_length(readLength = nil)

Sets the number of bytes that will be read when using the file as a ReadStream.

Parameters:

  • readLength (Fixnum) (defaults to: nil)
    the bytes that will be read from the file

Returns:

  • (self)

Raises:

  • (ArgumentError)


234
235
236
237
238
239
240
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx/async_file.rb', line 234

def set_read_length(readLength=nil)
  if readLength.class == Fixnum && !block_given?
    @j_del.java_method(:setReadLength, [Java::long.java_class]).call(readLength)
    return self
  end
  raise ArgumentError, "Invalid arguments when calling set_read_length(#{readLength})"
end

- (self) set_read_pos(readPos = nil)

Sets the position from which data will be read from when using the file as a ReadStream.

Parameters:

  • readPos (Fixnum) (defaults to: nil)
    the position in the file

Returns:

  • (self)

Raises:

  • (ArgumentError)


224
225
226
227
228
229
230
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx/async_file.rb', line 224

def set_read_pos(readPos=nil)
  if readPos.class == Fixnum && !block_given?
    @j_del.java_method(:setReadPos, [Java::long.java_class]).call(readPos)
    return self
  end
  raise ArgumentError, "Invalid arguments when calling set_read_pos(#{readPos})"
end

- (self) set_write_pos(writePos = nil)

Sets the position from which data will be written when using the file as a WriteStream.

Parameters:

  • writePos (Fixnum) (defaults to: nil)
    the position in the file

Returns:

  • (self)

Raises:

  • (ArgumentError)


244
245
246
247
248
249
250
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx/async_file.rb', line 244

def set_write_pos(writePos=nil)
  if writePos.class == Fixnum && !block_given?
    @j_del.java_method(:setWritePos, [Java::long.java_class]).call(writePos)
    return self
  end
  raise ArgumentError, "Invalid arguments when calling set_write_pos(#{writePos})"
end

- (self) set_write_queue_max_size(maxSize = nil)

Parameters:

  • maxSize (Fixnum) (defaults to: nil)

Returns:

  • (self)

Raises:

  • (ArgumentError)


146
147
148
149
150
151
152
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx/async_file.rb', line 146

def set_write_queue_max_size(maxSize=nil)
  if maxSize.class == Fixnum && !block_given?
    @j_del.java_method(:setWriteQueueMaxSize, [Java::int.java_class]).call(maxSize)
    return self
  end
  raise ArgumentError, "Invalid arguments when calling set_write_queue_max_size(#{maxSize})"
end

- (void) write(buffer = nil, position = nil) { ... }

This method returns an undefined value.

Write a Buffer to the file at position position in the file, asynchronously.

If position lies outside of the current size of the file, the file will be enlarged to encompass it.

When multiple writes are invoked on the same file there are no guarantees as to order in which those writes actually occur

The handler will be called when the write is complete, or if an error occurs.

Parameters:

  • buffer (::Vertx::Buffer) (defaults to: nil)
    the buffer to write
  • position (Fixnum) (defaults to: nil)
    the position in the file to write it at

Yields:

  • the handler to call when the write is complete

Raises:

  • (ArgumentError)


57
58
59
60
61
62
63
64
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx/async_file.rb', line 57

def write(buffer=nil,position=nil)
  if buffer.class.method_defined?(:j_del) && true && position == nil
    return @j_del.java_method(:write, [Java::IoVertxCoreBuffer::Buffer.java_class,Java::IoVertxCore::Handler.java_class]).call(buffer.j_del,(Proc.new { |ar| yield(ar.failed ? ar.cause : nil) } unless !block_given?))
  elsif buffer.class.method_defined?(:j_del) && position.class == Fixnum && true
    return @j_del.java_method(:write, [Java::IoVertxCoreBuffer::Buffer.java_class,Java::long.java_class,Java::IoVertxCore::Handler.java_class]).call(buffer.j_del,position,(Proc.new { |ar| yield(ar.failed ? ar.cause : nil) } unless !block_given?))
  end
  raise ArgumentError, "Invalid arguments when calling write(#{buffer},#{position})"
end

- (true, false) write_queue_full?

This will return true if there are more bytes in the write queue than the value set using #set_write_queue_max_size

Returns:

  • (true, false)
    true if write queue is full

Raises:

  • (ArgumentError)


79
80
81
82
83
84
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx/async_file.rb', line 79

def write_queue_full?
  if !block_given?
    return @j_del.java_method(:writeQueueFull, []).call()
  end
  raise ArgumentError, "Invalid arguments when calling write_queue_full?()"
end