Files

Class Index [+]

Quicksearch

SOAP::EncodingStyle::LiteralHandler

Constants

Namespace

Public Class Methods

new(charset = nil) click to toggle source
    # File lib/soap/encodingstyle/literalHandler.rb, line 20
20:   def initialize(charset = nil)
21:     super(charset)
22:     @textbuf = []
23:   end

Public Instance Methods

decode_epilogue() click to toggle source
     # File lib/soap/encodingstyle/literalHandler.rb, line 143
143:   def decode_epilogue
144:   end
decode_parent(parent, node) click to toggle source
     # File lib/soap/encodingstyle/literalHandler.rb, line 146
146:   def decode_parent(parent, node)
147:     return unless parent.node
148:     case parent.node
149:     when SOAPElement
150:       parent.node.add(node)
151:       node.parent = parent.node
152:     when SOAPStruct
153:       parent.node.add(node.elename.name, node)
154:       node.parent = parent.node
155:     when SOAPArray
156:       if node.position
157:         parent.node[*(decode_arypos(node.position))] = node
158:         parent.node.sparse = true
159:       else
160:         parent.node.add(node)
161:       end
162:       node.parent = parent.node
163:     else
164:       raise EncodingStyleError.new("illegal parent: #{parent.node}")
165:     end
166:   end
decode_prologue() click to toggle source
     # File lib/soap/encodingstyle/literalHandler.rb, line 140
140:   def decode_prologue
141:   end
decode_tag(ns, elename, attrs, parent) click to toggle source

decode interface.

     # File lib/soap/encodingstyle/literalHandler.rb, line 112
112:   def decode_tag(ns, elename, attrs, parent)
113:     @textbuf.clear
114:     if attrs[XSD::AttrNilName] == 'true'
115:       o = SOAPNil.decode(elename)
116:     else
117:       o = SOAPElement.decode(elename)
118:     end
119:     if definedtype = attrs[XSD::AttrTypeName]
120:       o.type = ns.parse(definedtype)
121:     end
122:     o.parent = parent
123:     o.extraattr.update(attrs)
124:     decode_parent(parent, o)
125:     o
126:   end
decode_tag_end(ns, node) click to toggle source
     # File lib/soap/encodingstyle/literalHandler.rb, line 128
128:   def decode_tag_end(ns, node)
129:     textbufstr = @textbuf.join
130:     @textbuf.clear
131:     o = node.node
132:     decode_textbuf(o, textbufstr)
133:   end
decode_text(ns, text) click to toggle source
     # File lib/soap/encodingstyle/literalHandler.rb, line 135
135:   def decode_text(ns, text)
136:     # @textbuf is set at decode_tag_end.
137:     @textbuf << text
138:   end
encode_data(generator, ns, data, parent) click to toggle source

encode interface.

    # File lib/soap/encodingstyle/literalHandler.rb, line 29
29:   def encode_data(generator, ns, data, parent)
30:     attrs = {}
31:     name = generator.encode_name(ns, data, attrs)
32:     data.extraattr.each do |key, value|
33:       next if !@generate_explicit_type and key == XSD::AttrTypeName
34:       keytag = key
35:       if key.is_a?(XSD::QName)
36:         keytag = encode_attr_key(attrs, ns, key)
37:       end
38:       if value.is_a?(XSD::QName)
39:         value = encode_qname(attrs, ns, value)
40:       end
41:       attrs[keytag] = value
42:     end
43:     case data
44:     when SOAPExternalReference
45:       # do not encode SOAPExternalReference in
46:       # literalHandler (which is used for literal service)
47:       data.referred
48:     when SOAPRawString
49:       generator.encode_tag(name, attrs)
50:       generator.encode_rawstring(data.to_s)
51:     when XSD::XSDString
52:       generator.encode_tag(name, attrs)
53:       str = decode_str(data.to_s)
54:       generator.encode_string(str)
55:     when XSD::XSDAnySimpleType
56:       generator.encode_tag(name, attrs)
57:       generator.encode_string(data.to_s)
58:     when SOAPStruct
59:       generator.encode_tag(name, attrs)
60:       data.each do |key, value|
61:         generator.encode_child(ns, value, data)
62:       end
63:     when SOAPArray
64:       generator.encode_tag(name, attrs)
65:       data.traverse do |child, *rank|
66:         data.position = nil
67:         generator.encode_child(ns, child, data)
68:       end
69:     when SOAPElement
70:       unless generator.use_default_namespace
71:         # passes 2 times for simplifying namespace definition
72:         data.each do |key, value|
73:           if value.elename.namespace
74:             Generator.assign_ns(attrs, ns, value.elename.namespace)
75:           end
76:         end
77:       end
78:       if data.text and data.text.is_a?(XSD::QName)
79:         Generator.assign_ns(attrs, ns, data.text.namespace)
80:       end
81:       generator.encode_tag(name, attrs)
82:       if data.text
83:         if data.text.is_a?(XSD::QName)
84:           text = ns.name(data.text)
85:         else
86:           text = data.text
87:         end
88:         generator.encode_string(text)
89:       end
90:       data.each do |key, value|
91:         generator.encode_child(ns, value, data)
92:       end
93:     else
94:       raise EncodingStyleError.new(
95:         "unknown object:#{data} in this encodingStyle")
96:     end
97:   end
encode_data_end(generator, ns, data, parent) click to toggle source
     # File lib/soap/encodingstyle/literalHandler.rb, line 99
 99:   def encode_data_end(generator, ns, data, parent)
100:     # do not encode SOAPExternalReference in
101:     # literalHandler (which is used for literal service)
102:     return nil if data.is_a?(SOAPExternalReference)
103:     name = generator.encode_name_end(ns, data)
104:     cr = (data.is_a?(SOAPCompoundtype) and data.have_member)
105:     generator.encode_tag_end(name, cr)
106:   end

Private Instance Methods

decode_str(str) click to toggle source
     # File lib/soap/encodingstyle/literalHandler.rb, line 183
183:   def decode_str(str)
184:     @charset ? XSD::Charset.encoding_from_xml(str, @charset) : str
185:   end
decode_textbuf(node, textbufstr) click to toggle source
     # File lib/soap/encodingstyle/literalHandler.rb, line 170
170:   def decode_textbuf(node, textbufstr)
171:     case node
172:     when XSD::XSDString, SOAPElement
173:       if @charset
174:         node.set(decode_str(textbufstr))
175:       else
176:         node.set(textbufstr)
177:       end
178:     else
179:       # Nothing to do...
180:     end
181:   end

Disabled; run with --debug to generate this.

[Validate]

Generated with the Darkfish Rdoc Generator 1.1.6.