Class: Embulk::Buffer

Inherits:
String
  • Object
show all
Defined in:
embulk-core/src/main/ruby/embulk/buffer.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.from_java(java_buffer) ⇒ Object



4
5
6
7
8
9
# File 'embulk-core/src/main/ruby/embulk/buffer.rb', line 4

def self.from_java(java_buffer)
  byte_list = org.jruby.util.ByteList.new(java_buffer.array(), java_buffer.offset(), java_buffer.limit(), false)
  buffer = new
  buffer.replace(org.jruby.RubyString.new(JRuby.runtime, self, byte_list).dup)  # TODO simplify
  buffer
end

.from_ruby_string(string) ⇒ Object



11
12
13
14
# File 'embulk-core/src/main/ruby/embulk/buffer.rb', line 11

def self.from_ruby_string(string)
  b = Buffer.new(string)
  b.force_encoding('ASCII-8BIT')
end

Instance Method Details

#to_javaObject



16
17
18
# File 'embulk-core/src/main/ruby/embulk/buffer.rb', line 16

def to_java
  Java::Buffer.wrap(to_java_bytes)
end