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)


91
92
93
94
95
96
97
# File '/Users/julien/java/vertx-stack/stack-docs/target/rb/vertx/multi_map.rb', line 91

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)


101
102
103
104
105
106
107
# File '/Users/julien/java/vertx-stack/stack-docs/target/rb/vertx/multi_map.rb', line 101

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)


143
144
145
146
147
148
149
# File '/Users/julien/java/vertx-stack/stack-docs/target/rb/vertx/multi_map.rb', line 143

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)


65
66
67
68
69
70
# File '/Users/julien/java/vertx-stack/stack-docs/target/rb/vertx/multi_map.rb', line 65

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)


73
74
75
76
77
78
# File '/Users/julien/java/vertx-stack/stack-docs/target/rb/vertx/multi_map.rb', line 73

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)


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

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)


134
135
136
137
138
139
140
# File '/Users/julien/java/vertx-stack/stack-docs/target/rb/vertx/multi_map.rb', line 134

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)


114
115
116
117
118
119
120
# File '/Users/julien/java/vertx-stack/stack-docs/target/rb/vertx/multi_map.rb', line 114

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)


124
125
126
127
128
129
130
# File '/Users/julien/java/vertx-stack/stack-docs/target/rb/vertx/multi_map.rb', line 124

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)


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

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