Class: Vertx::MultiMap

Inherits:
Object
  • Object
show all
Defined in:
/Users/julien/java/vertx-stack/stack-docs/target/rb/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.

Constant Summary

@@j_api_type =
Object.new

Class Method Summary (collapse)

Instance Method Summary (collapse)

Class Method Details

+ (Boolean) accept?(obj)

Returns:

  • (Boolean)

20
21
22
# File '/Users/julien/java/vertx-stack/stack-docs/target/rb/vertx/multi_map.rb', line 20

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

+ (::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:

Raises:

  • (ArgumentError)

37
38
39
40
41
42
# File '/Users/julien/java/vertx-stack/stack-docs/target/rb/vertx/multi_map.rb', line 37

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

+ (Object) j_api_type


29
30
31
# File '/Users/julien/java/vertx-stack/stack-docs/target/rb/vertx/multi_map.rb', line 29

def self.j_api_type
  @@j_api_type
end

+ (Object) j_class


32
33
34
# File '/Users/julien/java/vertx-stack/stack-docs/target/rb/vertx/multi_map.rb', line 32

def self.j_class
  Java::IoVertxCore::MultiMap.java_class
end

+ (Object) unwrap(obj)


26
27
28
# File '/Users/julien/java/vertx-stack/stack-docs/target/rb/vertx/multi_map.rb', line 26

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

+ (Object) wrap(obj)


23
24
25
# File '/Users/julien/java/vertx-stack/stack-docs/target/rb/vertx/multi_map.rb', line 23

def @@j_api_type.wrap(obj)
  MultiMap.new(obj)
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)

97
98
99
100
101
102
103
# File '/Users/julien/java/vertx-stack/stack-docs/target/rb/vertx/multi_map.rb', line 97

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:

Returns:

  • (self)

Raises:

  • (ArgumentError)

107
108
109
110
111
112
113
# File '/Users/julien/java/vertx-stack/stack-docs/target/rb/vertx/multi_map.rb', line 107

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)

149
150
151
152
153
154
155
# File '/Users/julien/java/vertx-stack/stack-docs/target/rb/vertx/multi_map.rb', line 149

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, value = nil, caseInsensitive = nil)

Check if there is a header with the specified name and value. If caseInsensitive is true, value is compared in a case-insensitive way.

Parameters:

  • name (String) (defaults to: nil)
    the name to search for
  • value (String) (defaults to: nil)
    the value to search for
  • caseInsensitive (true, false) (defaults to: nil)

Returns:

  • (true, false)
    true if at least one entry is found

Raises:

  • (ArgumentError)

69
70
71
72
73
74
75
76
# File '/Users/julien/java/vertx-stack/stack-docs/target/rb/vertx/multi_map.rb', line 69

def contains?(name=nil,value=nil,caseInsensitive=nil)
  if name.class == String && !block_given? && value == nil && caseInsensitive == nil
    return @j_del.java_method(:contains, [Java::java.lang.String.java_class]).call(name)
  elsif name.class == String && value.class == String && (caseInsensitive.class == TrueClass || caseInsensitive.class == FalseClass) && !block_given?
    return @j_del.java_method(:contains, [Java::java.lang.String.java_class,Java::java.lang.String.java_class,Java::boolean.java_class]).call(name,value,caseInsensitive)
  end
  raise ArgumentError, "Invalid arguments when calling contains?(#{name},#{value},#{caseInsensitive})"
end

- (true, false) empty?

Return true if empty

Returns:

  • (true, false)

Raises:

  • (ArgumentError)

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

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)

47
48
49
50
51
52
# File '/Users/julien/java/vertx-stack/stack-docs/target/rb/vertx/multi_map.rb', line 47

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)

56
57
58
59
60
61
# File '/Users/julien/java/vertx-stack/stack-docs/target/rb/vertx/multi_map.rb', line 56

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)

87
88
89
90
91
92
# File '/Users/julien/java/vertx-stack/stack-docs/target/rb/vertx/multi_map.rb', line 87

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)

140
141
142
143
144
145
146
# File '/Users/julien/java/vertx-stack/stack-docs/target/rb/vertx/multi_map.rb', line 140

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)

120
121
122
123
124
125
126
# File '/Users/julien/java/vertx-stack/stack-docs/target/rb/vertx/multi_map.rb', line 120

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:

Returns:

  • (self)

Raises:

  • (ArgumentError)

130
131
132
133
134
135
136
# File '/Users/julien/java/vertx-stack/stack-docs/target/rb/vertx/multi_map.rb', line 130

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)

158
159
160
161
162
163
# File '/Users/julien/java/vertx-stack/stack-docs/target/rb/vertx/multi_map.rb', line 158

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