Class List Method List File List

# Class: Vertx::MultiMap

Inherits:
  Object
  - Object
  - Vertx::MultiMap
  show all
Defined in:
  /Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/src/main/resources/vertx/multi_map.rb

## Overview

This class represents a MultiMap of String keys to a List of String values.

It's useful in Vert.x to represent things in Vert.x like HTTP headers and HTTP parameters which allow multiple values for keys.

## Class Method Summary (collapse)

- + (::Vertx::MultiMap) case_insensitive_multi_map
  Create a multi-map implementation with case insensitive keys, for instance it can be used to hold some HTTP headers.

## Instance Method Summary (collapse)

- - (self) add(name = nil, value = nil)
  Adds a new value with the specified name and value.
- - (self) add_all(map = nil)
  Adds all the entries from another MultiMap to this one.
- - (self) clear
  Removes all.
- - (true, false) contains?(name = nil)
  Checks to see if there is a value with the specified name.
- - (true, false) empty?
  Return true if empty.
- - (String) get(name = nil)
  Returns the value of with the specified name.
- - (Array<String>) get_all(name = nil)
  Returns the values with the specified name.
- - (Set<String>) names
  Gets a immutable Set of all names.
- - (self) remove(name = nil)
  Removes the value with the given name.
- - (self) set(name = nil, value = nil)
  Sets a value under the specified name.
- - (self) set_all(map = nil)
  Cleans this instance.
- - (Fixnum) size
  Return the number of keys.

## Class Method Details

### + (`::Vertx::MultiMap`) case_insensitive_multi_map

Create a multi-map implementation with case insensitive keys, for instance it can be used to hold some HTTP headers.

Returns:

- (`::Vertx::MultiMap`) —
  the multi-map

Raises:

- (`ArgumentError`)

    21
    22
    23
    24
    25
    26
    # File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/src/main/resources/vertx/multi_map.rb', line 21

    def self.case_insensitive_multi_map
      if !block_given?
        return ::Vertx::Util::Utils.safe_create(Java::IoVertxCore::MultiMap.java_method(:caseInsensitiveMultiMap, []).call(),::Vertx::MultiMap)
      end
      raise ArgumentError, "Invalid arguments when calling case_insensitive_multi_map()"
    end

## Instance Method Details

### - (`self`) add(name = nil, value = nil)

Adds a new value with the specified name and value.

Parameters:

- name (`String`) (defaults to: `nil`) —
  The name
- value (`String`) (defaults to: `nil`) —
  The value being added

Returns:

- (`self`)

Raises:

- (`ArgumentError`)

    75
    76
    77
    78
    79
    80
    81
    # File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/src/main/resources/vertx/multi_map.rb', line 75

    def add(name=nil,value=nil)
      if name.class == String && value.class == String && !block_given?
        @j_del.java_method(:add, [Java::java.lang.String.java_class,Java::java.lang.String.java_class]).call(name,value)
        return self
      end
      raise ArgumentError, "Invalid arguments when calling add(name,value)"
    end

### - (`self`) add_all(map = nil)

Adds all the entries from another MultiMap to this one

Parameters:

- map (`::Vertx::MultiMap`) (defaults to: `nil`)

Returns:

- (`self`)

Raises:

- (`ArgumentError`)

    85
    86
    87
    88
    89
    90
    91
    # File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/src/main/resources/vertx/multi_map.rb', line 85

    def add_all(map=nil)
      if map.class.method_defined?(:j_del) && !block_given?
        @j_del.java_method(:addAll, [Java::IoVertxCore::MultiMap.java_class]).call(map.j_del)
        return self
      end
      raise ArgumentError, "Invalid arguments when calling add_all(map)"
    end

### - (`self`) clear

Removes all

Returns:

- (`self`)

Raises:

- (`ArgumentError`)

    127
    128
    129
    130
    131
    132
    133
    # File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/src/main/resources/vertx/multi_map.rb', line 127

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

### - (`true`, `false`) contains?(name = nil)

Checks to see if there is a value with the specified name

Parameters:

- name (`String`) (defaults to: `nil`) —
  The name to search for

Returns:

- (`true`, `false`) —
  true if at least one entry is found

Raises:

- (`ArgumentError`)

    49
    50
    51
    52
    53
    54
    # File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/src/main/resources/vertx/multi_map.rb', line 49

    def contains?(name=nil)
      if name.class == String && !block_given?
        return @j_del.java_method(:contains, [Java::java.lang.String.java_class]).call(name)
      end
      raise ArgumentError, "Invalid arguments when calling contains?(name)"
    end

### - (`true`, `false`) empty?

Return true if empty

Returns:

- (`true`, `false`)

Raises:

- (`ArgumentError`)

    57
    58
    59
    60
    61
    62
    # File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/src/main/resources/vertx/multi_map.rb', line 57

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

### - (`String`) get(name = nil)

Returns the value of with the specified name. If there are more than one values for the specified name, the first value is returned.

Parameters:

- name (`String`) (defaults to: `nil`) —
  The name of the header to search

Returns:

- (`String`) —
  The first header value or `null` if there is no such entry

Raises:

- (`ArgumentError`)

    31
    32
    33
    34
    35
    36
    # File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/src/main/resources/vertx/multi_map.rb', line 31

    def get(name=nil)
      if name.class == String && !block_given?
        return @j_del.java_method(:get, [Java::java.lang.String.java_class]).call(name)
      end
      raise ArgumentError, "Invalid arguments when calling get(name)"
    end

### - (`Array<String>`) get_all(name = nil)

Returns the values with the specified name

Parameters:

- name (`String`) (defaults to: `nil`) —
  The name to search

Returns:

- (`Array<String>`) —
  A immutable List of values which will be empty if no values are found

Raises:

- (`ArgumentError`)

    40
    41
    42
    43
    44
    45
    # File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/src/main/resources/vertx/multi_map.rb', line 40

    def get_all(name=nil)
      if name.class == String && !block_given?
        return @j_del.java_method(:getAll, [Java::java.lang.String.java_class]).call(name).to_a.map { |elt| elt }
      end
      raise ArgumentError, "Invalid arguments when calling get_all(name)"
    end

### - (`Set<String>`) names

Gets a immutable Set of all names

Returns:

- (`Set<String>`) —
  A Set of all names

Raises:

- (`ArgumentError`)

    65
    66
    67
    68
    69
    70
    # File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/src/main/resources/vertx/multi_map.rb', line 65

    def names
      if !block_given?
        return ::Vertx::Util::Utils.to_set(@j_del.java_method(:names, []).call()).map! { |elt| elt }
      end
      raise ArgumentError, "Invalid arguments when calling names()"
    end

### - (`self`) remove(name = nil)

Removes the value with the given name

Parameters:

- name (`String`) (defaults to: `nil`) —
  The name of the value to remove

Returns:

- (`self`)

Raises:

- (`ArgumentError`)

    118
    119
    120
    121
    122
    123
    124
    # File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/src/main/resources/vertx/multi_map.rb', line 118

    def remove(name=nil)
      if name.class == String && !block_given?
        @j_del.java_method(:remove, [Java::java.lang.String.java_class]).call(name)
        return self
      end
      raise ArgumentError, "Invalid arguments when calling remove(name)"
    end

### - (`self`) set(name = nil, value = nil)

Sets a value under the specified name.

If there is an existing header with the same name, it is removed.

Parameters:

- name (`String`) (defaults to: `nil`) —
  The name
- value (`String`) (defaults to: `nil`) —
  The value

Returns:

- (`self`)

Raises:

- (`ArgumentError`)

    98
    99
    100
    101
    102
    103
    104
    # File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/src/main/resources/vertx/multi_map.rb', line 98

    def set(name=nil,value=nil)
      if name.class == String && value.class == String && !block_given?
        @j_del.java_method(:set, [Java::java.lang.String.java_class,Java::java.lang.String.java_class]).call(name,value)
        return self
      end
      raise ArgumentError, "Invalid arguments when calling set(name,value)"
    end

### - (`self`) set_all(map = nil)

Cleans this instance.

Parameters:

- map (`::Vertx::MultiMap`) (defaults to: `nil`)

Returns:

- (`self`)

Raises:

- (`ArgumentError`)

    108
    109
    110
    111
    112
    113
    114
    # File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/src/main/resources/vertx/multi_map.rb', line 108

    def set_all(map=nil)
      if map.class.method_defined?(:j_del) && !block_given?
        @j_del.java_method(:setAll, [Java::IoVertxCore::MultiMap.java_class]).call(map.j_del)
        return self
      end
      raise ArgumentError, "Invalid arguments when calling set_all(map)"
    end

### - (`Fixnum`) size

Return the number of keys.

Returns:

- (`Fixnum`)

Raises:

- (`ArgumentError`)

    136
    137
    138
    139
    140
    141
    # File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/src/main/resources/vertx/multi_map.rb', line 136

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