Class: VertxWebCommon::BodyCodec

Inherits:
Object
  • Object
show all
Defined in:
/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-web-common/body_codec.rb

Overview

A codec for encoding and decoding HTTP bodies.

Class Method Summary (collapse)

Class Method Details

+ (::VertxWebCommon::BodyCodec) buffer

Returns the codec

Returns:

Raises:

  • (ArgumentError)


32
33
34
35
36
37
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-web-common/body_codec.rb', line 32

def self.buffer
  if !block_given?
    return ::Vertx::Util::Utils.safe_create(Java::IoVertxExtWebCodec::BodyCodec.java_method(:buffer, []).call(),::VertxWebCommon::BodyCodec,::Vertx::Buffer.j_api_type)
  end
  raise ArgumentError, "Invalid arguments when calling buffer()"
end

+ (::VertxWebCommon::BodyCodec) create(decode = nil) { ... }

Create a codec that buffers the entire body and then apply the decode function and returns the result.

Yields:

  • the decode function

Returns:

Raises:

  • (ArgumentError)


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

def self.create(decode=nil)
  if block_given? && decode == nil
    return ::Vertx::Util::Utils.safe_create(Java::IoVertxExtWebCodec::BodyCodec.java_method(:create, [Java::JavaUtilFunction::Function.java_class]).call((Proc.new { |event| ::Vertx::Util::Utils.to_object(yield(::Vertx::Util::Utils.safe_create(event,::Vertx::Buffer))) unless !block_given? })),::VertxWebCommon::BodyCodec, nil)
  end
  raise ArgumentError, "Invalid arguments when calling create(#{decode})"
end

+ (::VertxWebCommon::BodyCodec) json(type = nil)

Create and return a codec for Java objects encoded using Jackson mapper.

Parameters:

  • type (Nil) (defaults to: nil)

Returns:

Raises:

  • (ArgumentError)


55
56
57
58
59
60
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-web-common/body_codec.rb', line 55

def self.json(type=nil)
  if type.class == Class && !block_given?
    return ::Vertx::Util::Utils.safe_create(Java::IoVertxExtWebCodec::BodyCodec.java_method(:json, [Java::JavaLang::Class.java_class]).call(::Vertx::Util::Utils.j_class_of(type)),::VertxWebCommon::BodyCodec, ::Vertx::Util::Utils.v_type_of(type))
  end
  raise ArgumentError, "Invalid arguments when calling json(#{type})"
end

+ (::VertxWebCommon::BodyCodec) json_array

Returns the codec

Returns:

Raises:

  • (ArgumentError)


46
47
48
49
50
51
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-web-common/body_codec.rb', line 46

def self.json_array
  if !block_given?
    return ::Vertx::Util::Utils.safe_create(Java::IoVertxExtWebCodec::BodyCodec.java_method(:jsonArray, []).call(),::VertxWebCommon::BodyCodec, nil)
  end
  raise ArgumentError, "Invalid arguments when calling json_array()"
end

+ (::VertxWebCommon::BodyCodec) json_object

Returns the codec

Returns:

Raises:

  • (ArgumentError)


39
40
41
42
43
44
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-web-common/body_codec.rb', line 39

def self.json_object
  if !block_given?
    return ::Vertx::Util::Utils.safe_create(Java::IoVertxExtWebCodec::BodyCodec.java_method(:jsonObject, []).call(),::VertxWebCommon::BodyCodec, nil)
  end
  raise ArgumentError, "Invalid arguments when calling json_object()"
end

+ (::VertxWebCommon::BodyCodec) json_stream(parser = nil)

A body codec that parse the response as a JSON stream.

Parameters:

  • parser (::Vertx::JsonParser) (defaults to: nil)
    the non-null JSON parser to emits the JSON object. The parser must be configured for the stream. Not e that you need to keep a reference on the parser to retrieved the JSON events.

Returns:

Raises:

  • (ArgumentError)


92
93
94
95
96
97
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-web-common/body_codec.rb', line 92

def self.json_stream(parser=nil)
  if parser.class.method_defined?(:j_del) && !block_given?
    return ::Vertx::Util::Utils.safe_create(Java::IoVertxExtWebCodec::BodyCodec.java_method(:jsonStream, [Java::IoVertxCoreParsetools::JsonParser.java_class]).call(parser.j_del),::VertxWebCommon::BodyCodec, nil)
  end
  raise ArgumentError, "Invalid arguments when calling json_stream(#{parser})"
end

+ (::VertxWebCommon::BodyCodec) none

Returns a codec that simply discards the response

Returns:

Raises:

  • (ArgumentError)


62
63
64
65
66
67
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-web-common/body_codec.rb', line 62

def self.none
  if !block_given?
    return ::Vertx::Util::Utils.safe_create(Java::IoVertxExtWebCodec::BodyCodec.java_method(:none, []).call(),::VertxWebCommon::BodyCodec, nil)
  end
  raise ArgumentError, "Invalid arguments when calling none()"
end

+ (::VertxWebCommon::BodyCodec) pipe(stream = nil, close = nil)

A body codec that pipes the body to a write stream.

Parameters:

  • stream (::Vertx::WriteStream) (defaults to: nil)
    the destination stream
  • close (true, false) (defaults to: nil)
    whether the destination stream should be closed

Returns:

Raises:

  • (ArgumentError)


81
82
83
84
85
86
87
88
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-web-common/body_codec.rb', line 81

def self.pipe(stream=nil,close=nil)
  if stream.class.method_defined?(:j_del) && !block_given? && close == nil
    return ::Vertx::Util::Utils.safe_create(Java::IoVertxExtWebCodec::BodyCodec.java_method(:pipe, [Java::IoVertxCoreStreams::WriteStream.java_class]).call(stream.j_del),::VertxWebCommon::BodyCodec, nil)
  elsif stream.class.method_defined?(:j_del) && (close.class == TrueClass || close.class == FalseClass) && !block_given?
    return ::Vertx::Util::Utils.safe_create(Java::IoVertxExtWebCodec::BodyCodec.java_method(:pipe, [Java::IoVertxCoreStreams::WriteStream.java_class,Java::boolean.java_class]).call(stream.j_del,close),::VertxWebCommon::BodyCodec, nil)
  end
  raise ArgumentError, "Invalid arguments when calling pipe(#{stream},#{close})"
end

+ (::VertxWebCommon::BodyCodec) string(encoding = nil)

A codec for strings using a specific encoding.

Parameters:

  • encoding (String) (defaults to: nil)
    the encoding

Returns:

Raises:

  • (ArgumentError)


23
24
25
26
27
28
29
30
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-web-common/body_codec.rb', line 23

def self.string(encoding=nil)
  if !block_given? && encoding == nil
    return ::Vertx::Util::Utils.safe_create(Java::IoVertxExtWebCodec::BodyCodec.java_method(:string, []).call(),::VertxWebCommon::BodyCodec, nil)
  elsif encoding.class == String && !block_given?
    return ::Vertx::Util::Utils.safe_create(Java::IoVertxExtWebCodec::BodyCodec.java_method(:string, [Java::java.lang.String.java_class]).call(encoding),::VertxWebCommon::BodyCodec, nil)
  end
  raise ArgumentError, "Invalid arguments when calling string(#{encoding})"
end