Class: WWMD::VSStubs::VSHybridDict

Inherits:
Object
  • Object
show all
Includes:
WWMD::VSStubHelpers
Defined in:
lib/wwmd/viewstate/vs_stubs/vs_hybrid_dict.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from WWMD::VSStubHelpers

#opcode, #size, #to_sym

Methods included from WWMD::ViewStateUtils

#deserialize_type, #dlog, #magic?, #next_type, #offset, #putd, #read, #read_7bit_encoded_int, #read_double, #read_int, #read_int32, #read_raw_byte, #read_short, #read_string, #serialize_type, #slog, #throw, #write_7bit_encoded_int, #write_double, #write_int, #write_int32, #write_short

Constructor Details

#initializeVSHybridDict

Returns a new instance of VSHybridDict.



7
8
9
# File 'lib/wwmd/viewstate/vs_stubs/vs_hybrid_dict.rb', line 7

def initialize()
  @value = []
end

Instance Attribute Details

#valueObject

Returns the value of attribute value.



5
6
7
# File 'lib/wwmd/viewstate/vs_stubs/vs_hybrid_dict.rb', line 5

def value
  @value
end

Instance Method Details

#add(obj1, obj2) ⇒ Object



11
12
13
# File 'lib/wwmd/viewstate/vs_stubs/vs_hybrid_dict.rb', line 11

def add(obj1,obj2)
  @value << [obj1,obj2]
end

#serializeObject



15
16
17
18
19
20
21
22
23
# File 'lib/wwmd/viewstate/vs_stubs/vs_hybrid_dict.rb', line 15

def serialize
  stack = super
  stack << self.write_7bit_encoded_int(self.size)
  self.value.each do |k,v|
    stack << k.serialize
    stack << v.serialize
  end
  return stack
end

#to_xmlObject



25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
# File 'lib/wwmd/viewstate/vs_stubs/vs_hybrid_dict.rb', line 25

def to_xml
  xml = super
  xml.add_attribute("size",self.value.size.to_s)
  self.value.each do |k,v|
    pair = REXML::Element.new("Pair")
    key = REXML::Element.new("Key")
    key.add_element(k.to_xml)
    val = REXML::Element.new("Value")
    val.add_element(v.to_xml)
    pair.add_element(key)
    pair.add_element(val)
    xml.add_element(pair)
  end
  xml
end