Class List Method List File List

# Class: VertxWebCommon::BodyCodec

Inherits:
  Object
  - Object
  - VertxWebCommon::BodyCodec
  show all
Defined in:
  /Users/julien/java/vertx-stack/stack-docs/target/rb/vertx-web-common/body_codec.rb

## Overview

A codec for encoding and decoding HTTP bodies.

## Class Method Summary (collapse)

- + (::VertxWebCommon::BodyCodec) buffer
  The codec.
- + (::VertxWebCommon::BodyCodec) create(decode = nil) { ... }
  Create a codec that buffers the entire body and then apply the decode function and returns the result.
- + (::VertxWebCommon::BodyCodec) json(type = nil)
  Create and return a codec for Java objects encoded using Jackson mapper.
- + (::VertxWebCommon::BodyCodec) json_array
  The codec.
- + (::VertxWebCommon::BodyCodec) json_object
  The codec.
- + (::VertxWebCommon::BodyCodec) none
  A codec that simply discards the response.
- + (::VertxWebCommon::BodyCodec) pipe(stream = nil)
  A body codec that pipes the body to a write stream.
- + (::VertxWebCommon::BodyCodec) string(encoding = nil)
  A codec for strings using a specific encoding.

## Class Method Details

### + (`::VertxWebCommon::BodyCodec`) buffer

Returns the codec

Returns:

- (`::VertxWebCommon::BodyCodec`) —
  the codec

Raises:

- (`ArgumentError`)

    31
    32
    33
    34
    35
    36
    # File '/Users/julien/java/vertx-stack/stack-docs/target/rb/vertx-web-common/body_codec.rb', line 31

    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:

- (`::VertxWebCommon::BodyCodec`) —
  the created codec

Raises:

- (`ArgumentError`)

    70
    71
    72
    73
    74
    75
    # File '/Users/julien/java/vertx-stack/stack-docs/target/rb/vertx-web-common/body_codec.rb', line 70

    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))) })),::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:

- (`::VertxWebCommon::BodyCodec`) —
  a codec for mapping POJO to Json

Raises:

- (`ArgumentError`)

    54
    55
    56
    57
    58
    59
    # File '/Users/julien/java/vertx-stack/stack-docs/target/rb/vertx-web-common/body_codec.rb', line 54

    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:

- (`::VertxWebCommon::BodyCodec`) —
  the codec

Raises:

- (`ArgumentError`)

    45
    46
    47
    48
    49
    50
    # File '/Users/julien/java/vertx-stack/stack-docs/target/rb/vertx-web-common/body_codec.rb', line 45

    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:

- (`::VertxWebCommon::BodyCodec`) —
  the codec

Raises:

- (`ArgumentError`)

    38
    39
    40
    41
    42
    43
    # File '/Users/julien/java/vertx-stack/stack-docs/target/rb/vertx-web-common/body_codec.rb', line 38

    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`) none

Returns a codec that simply discards the response

Returns:

- (`::VertxWebCommon::BodyCodec`) —
  a codec that simply discards the response

Raises:

- (`ArgumentError`)

    61
    62
    63
    64
    65
    66
    # File '/Users/julien/java/vertx-stack/stack-docs/target/rb/vertx-web-common/body_codec.rb', line 61

    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)

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

Parameters:

- stream (`::Vertx::WriteStream`) (defaults to: `nil`) —
  the destination tream

Returns:

- (`::VertxWebCommon::BodyCodec`) —
  the body codec for a write stream

Raises:

- (`ArgumentError`)

    79
    80
    81
    82
    83
    84
    # File '/Users/julien/java/vertx-stack/stack-docs/target/rb/vertx-web-common/body_codec.rb', line 79

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

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

A codec for strings using a specific `encoding`.

Parameters:

- encoding (`String`) (defaults to: `nil`) —
  the encoding

Returns:

- (`::VertxWebCommon::BodyCodec`) —
  the codec

Raises:

- (`ArgumentError`)

    22
    23
    24
    25
    26
    27
    28
    29
    # File '/Users/julien/java/vertx-stack/stack-docs/target/rb/vertx-web-common/body_codec.rb', line 22

    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