Module: JMS::MapMessage
- Includes:
- Enumerable
- Defined in:
- lib/jms/map_message.rb
Overview
Interface javax.jms.MapMessage
Instance Method Summary collapse
-
#data ⇒ Object
Return Map Message as a hash.
-
#data=(data) ⇒ Object
Copy values from supplied hash into this MapMessage Converts Ruby types to Java native Data types as follows: Fixnum => long Float => double Bignum => long true => boolean false => boolean nil => null Otherwise it calls ::to_s on the supplied data type.
-
#each(&proc) ⇒ Object
Return each name value pair.
-
#each_pair(&proc) ⇒ Object
Return each name value pair.
-
#include?(key) ⇒ Boolean
Does map include specified key.
-
#to_h ⇒ Object
Return Map Message as a hash.
Instance Method Details
#data ⇒ Object
Return Map Message as a hash
31 32 33 |
# File 'lib/jms/map_message.rb', line 31 def data to_h end |
#data=(data) ⇒ Object
Copy values from supplied hash into this MapMessage Converts Ruby types to Java native Data types as follows:
Fixnum => long
Float => double
Bignum => long
true => boolean
false => boolean
nil => null
Otherwise it calls ::to_s on the supplied data type
44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 |
# File 'lib/jms/map_message.rb', line 44 def data=(data) data.each_pair do |key,val| case when val.class == Fixnum # 1 setLong(key.to_s,val) when val.class == Float #1.1 setDouble(key.to_s,val) when val.class == Bignum # 11111111111111111 setLong(key.to_s,val) when (val.class == TrueClass) || (val.class == FalseClass) setBoolean(key.to_s,val) when val.class == NilClass setObject(key.to_s,val) else setString(key.to_s,val.to_s) end end end |
#each(&proc) ⇒ Object
Return each name value pair
64 65 66 67 68 69 70 71 72 73 74 75 |
# File 'lib/jms/map_message.rb', line 64 def each(&proc) # When key and value are expected separately. Should actually be calling each_pair anyway if proc.arity == 2 each_pair(proc) else enum = getMapNames while enum.has_more_elements key = enum.next_element proc.call [key, getObject(key)] end end end |
#each_pair(&proc) ⇒ Object
Return each name value pair
78 79 80 81 82 83 84 |
# File 'lib/jms/map_message.rb', line 78 def each_pair(&proc) enum = getMapNames while enum.has_more_elements key = enum.next_element proc.call key, getObject(key) end end |
#include?(key) ⇒ Boolean
Does map include specified key
87 88 89 90 |
# File 'lib/jms/map_message.rb', line 87 def include?(key) # Ensure a Ruby true is returned item_exists(key) == true end |
#to_h ⇒ Object
Return Map Message as a hash
24 25 26 27 28 |
# File 'lib/jms/map_message.rb', line 24 def to_h h = {} each_pair {|key, value| h[key] = value} h end |