Class: Vertx::MultiMap

Inherits:
Object
  • Object
show all
Defined in:
lib/vertx/http.rb

Overview

A map which can hold multiple values for one name / key

Author:

  • Norman Maurer

Instance Method Summary collapse

Constructor Details

#initialize(j_map) ⇒ MultiMap

Returns a new instance of MultiMap.



549
550
551
# File 'lib/vertx/http.rb', line 549

def initialize(j_map)
  @j_map = j_map
end

Instance Method Details

#[](name) ⇒ Object

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

    The name of the header to search

Returns:

  • The first header value or nil if there is no such entry



579
580
581
# File 'lib/vertx/http.rb', line 579

def [](name)
  @j_map.get(name)
end

#[]=(name, value) ⇒ Object

Set a value with the specified name and value.

Parameters:

  • name

    The name

  • value

    The value being added

Returns:

  • self



589
590
591
592
# File 'lib/vertx/http.rb', line 589

def []=(name, value)
  @j_map.set(name, value)
  self
end

#_j_mapObject



673
674
675
# File 'lib/vertx/http.rb', line 673

def _j_map
  @j_map
end

#add(name, value) ⇒ Object

Adds a new value with the specified name and value.

Parameters:

  • name

    The name

  • value

    The value being added

Returns:

  • self



626
627
628
629
# File 'lib/vertx/http.rb', line 626

def add(name, value)
  @j_map.add(name, value)
  self
end

#clearObject

Remove all entries

Returns:

  • self



663
664
665
666
# File 'lib/vertx/http.rb', line 663

def clear
  @j_map.clear()
  self
end

#contains(name) ⇒ Object

Returns true if an entry with the given name was found



604
605
606
# File 'lib/vertx/http.rb', line 604

def contains(name)
  @j_map.contains(name)
end

#each(&hndlr) ⇒ Object

Call the handler for each header name and its value. If there are multiple values are stored for a header name it will be called for each of them



556
557
558
559
560
561
562
563
# File 'lib/vertx/http.rb', line 556

def each(&hndlr)
  names.each do |name|
    values = @j_map.getAll(name)
    for v in values
      hndlr.call(name, v)
    end
  end
end

#empty?Boolean

Returns true if the map is empty

Returns:

  • (Boolean)


609
610
611
# File 'lib/vertx/http.rb', line 609

def empty?
  @j_map.isEmpty()
end

#get(name) ⇒ Object

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

    The name of the header to search

Returns:

  • The first header value or nil if there is no such entry



570
571
572
# File 'lib/vertx/http.rb', line 570

def get(name)
  @j_map.get(name)
end

#get_all(name) ⇒ Array

Returns the values with the specified name

Parameters:

  • name

    The name to search

Returns:

  • (Array)

    A immutable array of values which will be empty if no values are found



599
600
601
# File 'lib/vertx/http.rb', line 599

def get_all(name)
  @j_map.getAll(name).to_a
end

#namesSet

Return a Set which holds all names of the entries

Returns:

  • (Set)

    The set which holds all names or an empty set if it is empty



616
617
618
# File 'lib/vertx/http.rb', line 616

def names
 @j_map.names()
end

#remove(name) ⇒ Object

Remove the values with the given name

Parameters:

  • name

    The name

Returns:

  • self



655
656
657
658
# File 'lib/vertx/http.rb', line 655

def remove(name)
  @j_map.remove(name)
  self
end

#set(name, value) ⇒ Object

Set a value with the specified name and value.

Parameters:

  • name

    The name

  • value

    The value being added

Returns:

  • self



636
637
638
639
# File 'lib/vertx/http.rb', line 636

def set(name, value)
  @j_map.set(name, value)
  self
end

#set_all(map) ⇒ Object

Set a value with the specified name and value.

Parameters:

  • name

    The name

  • value

    The value being added

Returns:

  • self



646
647
648
649
# File 'lib/vertx/http.rb', line 646

def set_all(map)
  @j_map.set(map._j_map)
  self
end

#sizeObject

Return the number of names in this instance



669
670
671
# File 'lib/vertx/http.rb', line 669

def size
  @j_map.size()
end