wirispluginengine 3.62.0.1322
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/Rakefile +34 -0
- data/app/assets/javascripts/wirispluginengine/WIRISplugins.js +2833 -0
- data/app/controllers/wirispluginengine/application_controller.rb +75 -0
- data/app/helpers/wirispluginengine/application_helper.rb +4 -0
- data/config/routes.rb +4 -0
- data/configuration.ini.dist +104 -0
- data/lib/com/wiris/common/WInteger.rb +57 -0
- data/lib/com/wiris/plugin/api/Cas.rb +8 -0
- data/lib/com/wiris/plugin/api/CleanCache.rb +8 -0
- data/lib/com/wiris/plugin/api/Configuration.rb +8 -0
- data/lib/com/wiris/plugin/api/ConfigurationKeys.rb +96 -0
- data/lib/com/wiris/plugin/api/Editor.rb +8 -0
- data/lib/com/wiris/plugin/api/Filter.rb +8 -0
- data/lib/com/wiris/plugin/api/ImageFormatController.rb +8 -0
- data/lib/com/wiris/plugin/api/ParamsProvider.rb +8 -0
- data/lib/com/wiris/plugin/api/PluginBuilder.rb +79 -0
- data/lib/com/wiris/plugin/api/Render.rb +8 -0
- data/lib/com/wiris/plugin/api/ServiceResourceLoader.rb +8 -0
- data/lib/com/wiris/plugin/api/Test.rb +8 -0
- data/lib/com/wiris/plugin/api/TextService.rb +8 -0
- data/lib/com/wiris/plugin/configuration/ConfigurationUpdater.rb +8 -0
- data/lib/com/wiris/plugin/impl/CasImpl.rb +146 -0
- data/lib/com/wiris/plugin/impl/CleanCacheImpl.rb +111 -0
- data/lib/com/wiris/plugin/impl/ConfigurationImpl.rb +176 -0
- data/lib/com/wiris/plugin/impl/CustomConfigurationUpdater.rb +38 -0
- data/lib/com/wiris/plugin/impl/DefaultConfigurationUpdater.rb +29 -0
- data/lib/com/wiris/plugin/impl/EditorImpl.rb +86 -0
- data/lib/com/wiris/plugin/impl/FileConfigurationUpdater.rb +34 -0
- data/lib/com/wiris/plugin/impl/FileStorageAndCache.rb +59 -0
- data/lib/com/wiris/plugin/impl/FolderTreeStorageAndCache.rb +144 -0
- data/lib/com/wiris/plugin/impl/GenericParamsProviderImpl.rb +56 -0
- data/lib/com/wiris/plugin/impl/HttpImpl.rb +53 -0
- data/lib/com/wiris/plugin/impl/HttpListener.rb +8 -0
- data/lib/com/wiris/plugin/impl/ImageFormatControllerPng.rb +73 -0
- data/lib/com/wiris/plugin/impl/ImageFormatControllerSvg.rb +34 -0
- data/lib/com/wiris/plugin/impl/PluginBuilderImpl.rb +253 -0
- data/lib/com/wiris/plugin/impl/RenderImpl.rb +280 -0
- data/lib/com/wiris/plugin/impl/ServiceResourceLoaderImpl.rb +52 -0
- data/lib/com/wiris/plugin/impl/TestImpl.rb +166 -0
- data/lib/com/wiris/plugin/impl/TextFilter.rb +211 -0
- data/lib/com/wiris/plugin/impl/TextFilterTags.rb +55 -0
- data/lib/com/wiris/plugin/impl/TextServiceImpl.rb +118 -0
- data/lib/com/wiris/plugin/storage/StorageAndCache.rb +8 -0
- data/lib/com/wiris/util/json/JSon.rb +536 -0
- data/lib/com/wiris/util/json/JSonIntegerFormat.rb +21 -0
- data/lib/com/wiris/util/json/StringParser.rb +61 -0
- data/lib/com/wiris/util/sys/HttpConnection.rb +18 -0
- data/lib/com/wiris/util/sys/HttpConnectionListener.rb +8 -0
- data/lib/com/wiris/util/sys/IniFile.rb +143 -0
- data/lib/com/wiris/util/sys/Store.rb +109 -0
- data/lib/com/wiris/util/xml/SerializableImpl.rb +20 -0
- data/lib/com/wiris/util/xml/WCharacterBase.rb +634 -0
- data/lib/com/wiris/util/xml/WEntities.rb +14 -0
- data/lib/com/wiris/util/xml/WXmlUtils.rb +515 -0
- data/lib/com/wiris/util/xml/XmlSerializer.rb +485 -0
- data/lib/com/wiris/util/xml/XmlWriter.rb +279 -0
- data/lib/loader.rb +12 -0
- data/lib/src-generic/Array.rb +23 -0
- data/lib/src-generic/ArrayInt.rb +32 -0
- data/lib/src-generic/Base64.rb +15 -0
- data/lib/src-generic/BaseCode.rb +94 -0
- data/lib/src-generic/Bytes.rb +50 -0
- data/lib/src-generic/BytesInput.rb +38 -0
- data/lib/src-generic/EReg.rb +56 -0
- data/lib/src-generic/File.rb +36 -0
- data/lib/src-generic/FileLock.rb +27 -0
- data/lib/src-generic/FileSystem.rb +37 -0
- data/lib/src-generic/Hash.rb +43 -0
- data/lib/src-generic/Http.rb +107 -0
- data/lib/src-generic/HttpRequest.rb +25 -0
- data/lib/src-generic/HttpResponse.rb +71 -0
- data/lib/src-generic/Iterator.rb +20 -0
- data/lib/src-generic/Math.rb +15 -0
- data/lib/src-generic/Md5.rb +8 -0
- data/lib/src-generic/Md5Tools.rb +12 -0
- data/lib/src-generic/PropertiesTools.rb +33 -0
- data/lib/src-generic/Reflect.rb +17 -0
- data/lib/src-generic/RubyConfigurationUpdater.rb +45 -0
- data/lib/src-generic/Serializer.rb +85 -0
- data/lib/src-generic/Std.rb +74 -0
- data/lib/src-generic/Storage.rb +153 -0
- data/lib/src-generic/StringBuf.rb +41 -0
- data/lib/src-generic/StringTools.rb +46 -0
- data/lib/src-generic/Timer.rb +7 -0
- data/lib/src-generic/Type.rb +19 -0
- data/lib/src-generic/TypeTools.rb +32 -0
- data/lib/src-generic/Unserializer.rb +73 -0
- data/lib/src-generic/Utf8.rb +27 -0
- data/lib/src-generic/Xml.rb +199 -0
- data/lib/src-generic/extended/Integer.rb +5 -0
- data/lib/src-generic/extended/Math.rb +7 -0
- data/lib/src-generic/extended/Properties.rb +12 -0
- data/lib/src-generic/extended/String.rb +39 -0
- data/lib/src-generic/settings/PlatformSettings.rb +19 -0
- data/lib/wirispluginengine.rb +5 -0
- data/lib/wirispluginengine/engine.rb +5 -0
- data/lib/wirispluginengine/integration/cleancache.rb +8 -0
- data/lib/wirispluginengine/integration/configurationjs.rb +16 -0
- data/lib/wirispluginengine/integration/configurationjson.rb +7 -0
- data/lib/wirispluginengine/integration/createimage.rb +8 -0
- data/lib/wirispluginengine/integration/getmathml.rb +18 -0
- data/lib/wirispluginengine/integration/resource.rb +8 -0
- data/lib/wirispluginengine/integration/service.rb +6 -0
- data/lib/wirispluginengine/integration/showimage.rb +21 -0
- data/lib/wirispluginengine/integration/test.rb +6 -0
- data/lib/wirispluginengine/version.rb +3 -0
- data/resources/VERSION +1 -0
- data/resources/default-configuration.ini +45 -0
- data/resources/tech.txt +1 -0
- data/resources/wirisplugin.css +43 -0
- metadata +182 -0
@@ -0,0 +1,485 @@
|
|
1
|
+
module WirisPlugin
|
2
|
+
include Wiris
|
3
|
+
require('com/wiris/util/xml/WXmlUtils.rb')
|
4
|
+
class XmlSerializer
|
5
|
+
include Wiris
|
6
|
+
|
7
|
+
MODE_READ = 0
|
8
|
+
MODE_WRITE = 1
|
9
|
+
MODE_REGISTER = 2
|
10
|
+
MODE_CACHE = 3
|
11
|
+
attr_accessor :mode
|
12
|
+
attr_accessor :element
|
13
|
+
attr_accessor :children
|
14
|
+
attr_accessor :child
|
15
|
+
attr_accessor :elementStack
|
16
|
+
attr_accessor :childrenStack
|
17
|
+
attr_accessor :childStack
|
18
|
+
attr_accessor :tags
|
19
|
+
attr_accessor :rawxmls
|
20
|
+
attr_accessor :currentTag
|
21
|
+
attr_accessor :cache
|
22
|
+
attr_accessor :cacheTagStackCount
|
23
|
+
attr_accessor :ignore
|
24
|
+
attr_accessor :ignoreTagStackCount
|
25
|
+
def initialize()
|
26
|
+
super()
|
27
|
+
@tags = Hash.new()
|
28
|
+
@elementStack = Array.new()
|
29
|
+
@childrenStack = Array.new()
|
30
|
+
@childStack = Array.new()
|
31
|
+
@cacheTagStackCount = 0
|
32
|
+
@ignoreTagStackCount = 0
|
33
|
+
end
|
34
|
+
def getMode()
|
35
|
+
return @mode
|
36
|
+
end
|
37
|
+
def read(xml)
|
38
|
+
document = Xml::parse(xml)
|
39
|
+
setCurrentElement(document)
|
40
|
+
@mode = XmlSerializer::MODE_READ
|
41
|
+
return readNode()
|
42
|
+
end
|
43
|
+
def write(s)
|
44
|
+
@mode = XmlSerializer::MODE_WRITE
|
45
|
+
@element = Xml::createDocument()
|
46
|
+
@rawxmls = Array.new()
|
47
|
+
s::onSerialize(self)
|
48
|
+
res = element::toString()
|
49
|
+
for i in 0..rawxmls::length()-1
|
50
|
+
start = res::indexOf(("<rawXml id=\""+i.to_s)+"\"")
|
51
|
+
if start!=-1
|
52
|
+
_end = res::indexOf(">",start)
|
53
|
+
res = (Std::substr(res,0,start).to_s+rawxmls::_(i).to_s)+Std::substr(res,_end+1).to_s
|
54
|
+
end
|
55
|
+
i+=1
|
56
|
+
end
|
57
|
+
return res
|
58
|
+
end
|
59
|
+
def beginTagIf(tag,current,desired)
|
60
|
+
if @mode==MODE_READ
|
61
|
+
if beginTag(tag)
|
62
|
+
return desired
|
63
|
+
end
|
64
|
+
else
|
65
|
+
if current==desired
|
66
|
+
beginTag(tag)
|
67
|
+
end
|
68
|
+
end
|
69
|
+
return current
|
70
|
+
end
|
71
|
+
def beginTagIfBool(tag,current,desired)
|
72
|
+
if @mode==MODE_READ
|
73
|
+
if beginTag(tag)
|
74
|
+
return desired
|
75
|
+
end
|
76
|
+
else
|
77
|
+
if current==desired
|
78
|
+
beginTag(tag)
|
79
|
+
end
|
80
|
+
end
|
81
|
+
return current
|
82
|
+
end
|
83
|
+
def beginTag(tag)
|
84
|
+
if @mode==MODE_READ
|
85
|
+
if ((currentChild()!=nil)&&(currentChild()::nodeType==Xml::Element))&&(tag==currentChild()::nodeName)
|
86
|
+
pushState()
|
87
|
+
setCurrentElement(currentChild())
|
88
|
+
else
|
89
|
+
return false
|
90
|
+
end
|
91
|
+
else
|
92
|
+
if @mode==MODE_WRITE
|
93
|
+
if isIgnoreTag(tag)||(@ignoreTagStackCount>0)
|
94
|
+
@ignoreTagStackCount+=1
|
95
|
+
else
|
96
|
+
child = @element::createElement_(tag)
|
97
|
+
@element::addChild(child)
|
98
|
+
@element = child
|
99
|
+
end
|
100
|
+
else
|
101
|
+
if (@mode==MODE_REGISTER)&&(@currentTag==nil)
|
102
|
+
@currentTag = tag
|
103
|
+
else
|
104
|
+
if @mode==MODE_CACHE
|
105
|
+
@cacheTagStackCount+=1
|
106
|
+
end
|
107
|
+
end
|
108
|
+
end
|
109
|
+
end
|
110
|
+
return true
|
111
|
+
end
|
112
|
+
def endTag()
|
113
|
+
if @mode==MODE_READ
|
114
|
+
@element = @element::parent_()
|
115
|
+
popState()
|
116
|
+
nextChild()
|
117
|
+
else
|
118
|
+
if @mode==MODE_WRITE
|
119
|
+
if @ignoreTagStackCount>0
|
120
|
+
@ignoreTagStackCount-=1
|
121
|
+
else
|
122
|
+
@element = @element::parent_()
|
123
|
+
end
|
124
|
+
else
|
125
|
+
if @mode==MODE_CACHE
|
126
|
+
if @cacheTagStackCount>0
|
127
|
+
@cacheTagStackCount-=1
|
128
|
+
else
|
129
|
+
@mode = MODE_WRITE
|
130
|
+
@element = @element::parent_()
|
131
|
+
end
|
132
|
+
end
|
133
|
+
end
|
134
|
+
end
|
135
|
+
end
|
136
|
+
def attributeString(name,value,def_)
|
137
|
+
if @mode==XmlSerializer::MODE_READ
|
138
|
+
value = WXmlUtils::getAttribute(@element,name)
|
139
|
+
if value==nil
|
140
|
+
value = def_
|
141
|
+
end
|
142
|
+
else
|
143
|
+
if @mode==XmlSerializer::MODE_WRITE
|
144
|
+
if ((value!=nil)&&!((value==def_)))&&(@ignoreTagStackCount==0)
|
145
|
+
WXmlUtils::setAttribute(@element,name,value)
|
146
|
+
end
|
147
|
+
end
|
148
|
+
end
|
149
|
+
return value
|
150
|
+
end
|
151
|
+
def cacheAttribute(name,value,def_)
|
152
|
+
if @mode==XmlSerializer::MODE_WRITE
|
153
|
+
if @cache
|
154
|
+
value = attributeString(name,value,def_)
|
155
|
+
@mode = XmlSerializer::MODE_CACHE
|
156
|
+
@cacheTagStackCount = 0
|
157
|
+
end
|
158
|
+
else
|
159
|
+
value = attributeString(name,value,def_)
|
160
|
+
end
|
161
|
+
return value
|
162
|
+
end
|
163
|
+
def attributeBoolean(name,value,def_)
|
164
|
+
return XmlSerializer::parseBoolean(attributeString(name,XmlSerializer::booleanToString(value),XmlSerializer::booleanToString(def_)))
|
165
|
+
end
|
166
|
+
def attributeInt(name,value,def_)
|
167
|
+
return Std::parseInt(attributeString(name,""+value.to_s,""+def_.to_s))
|
168
|
+
end
|
169
|
+
def attributeIntArray(name,value,def_)
|
170
|
+
return stringToArray(attributeString(name,arrayToString(value),arrayToString(def_)))
|
171
|
+
end
|
172
|
+
def arrayToString(a)
|
173
|
+
if a==nil
|
174
|
+
return nil
|
175
|
+
end
|
176
|
+
sb = StringBuf.new()
|
177
|
+
for i in 0..a::length-1
|
178
|
+
if i!=0
|
179
|
+
sb::add(",")
|
180
|
+
end
|
181
|
+
sb::add(a[i].to_s+"")
|
182
|
+
i+=1
|
183
|
+
end
|
184
|
+
return sb::toString()
|
185
|
+
end
|
186
|
+
def stringToArray(s)
|
187
|
+
if s==nil
|
188
|
+
return nil
|
189
|
+
end
|
190
|
+
ss = s::split(",")
|
191
|
+
a = []
|
192
|
+
for i in 0..ss::length-1
|
193
|
+
a[i] = Std::parseInt(ss[i])
|
194
|
+
i+=1
|
195
|
+
end
|
196
|
+
return a
|
197
|
+
end
|
198
|
+
def attributeFloat(name,value,def_)
|
199
|
+
return Std::parseFloat(attributeString(name,""+value.to_s,""+def_.to_s))
|
200
|
+
end
|
201
|
+
def textContent(content)
|
202
|
+
if @mode==MODE_READ
|
203
|
+
content = XmlSerializer::getXmlTextContent(@element)
|
204
|
+
else
|
205
|
+
if ((@mode==MODE_WRITE)&&(content!=nil))&&(@ignoreTagStackCount==0)
|
206
|
+
if (content::length()>100)||(StringTools::startsWith(content,"<")&&StringTools::endsWith(content,">"))
|
207
|
+
textNode = @element::createCData_(content)
|
208
|
+
else
|
209
|
+
textNode = WXmlUtils::createPCData(@element,content)
|
210
|
+
end
|
211
|
+
element::addChild(textNode)
|
212
|
+
end
|
213
|
+
end
|
214
|
+
return content
|
215
|
+
end
|
216
|
+
def base64Content(data)
|
217
|
+
b64 = BaseCode.new(Bytes::ofString("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"))
|
218
|
+
if @mode==MODE_READ
|
219
|
+
content = textContent(nil)
|
220
|
+
data = b64::decodeBytes(Bytes::ofString(content))
|
221
|
+
else
|
222
|
+
if @mode==MODE_WRITE
|
223
|
+
textContent(b64::encodeBytes(data)::toString())
|
224
|
+
end
|
225
|
+
end
|
226
|
+
return data
|
227
|
+
end
|
228
|
+
def rawXml(xml)
|
229
|
+
if @mode==MODE_READ
|
230
|
+
raise Exception,"Should not use rawXml() function on read operation!"
|
231
|
+
else
|
232
|
+
if @mode==MODE_WRITE
|
233
|
+
raw = @element::createElement_("rawXml")
|
234
|
+
raw::set("id",""+rawxmls::length().to_s)
|
235
|
+
rawxmls::push(xml)
|
236
|
+
element::addChild(raw)
|
237
|
+
else
|
238
|
+
if @mode==MODE_REGISTER
|
239
|
+
@currentTag = getMainTag(xml)
|
240
|
+
end
|
241
|
+
end
|
242
|
+
end
|
243
|
+
return xml
|
244
|
+
end
|
245
|
+
def booleanContent(content)
|
246
|
+
return XmlSerializer::parseBoolean(textContent(XmlSerializer::booleanToString(content)))
|
247
|
+
end
|
248
|
+
def floatContent(d)
|
249
|
+
return Std::parseFloat(textContent(d.to_s+""))
|
250
|
+
end
|
251
|
+
def self.getXmlTextContent(element)
|
252
|
+
if (element::nodeType==Xml::CData)||(element::nodeType==Xml::PCData)
|
253
|
+
return WXmlUtils::getNodeValue(element)
|
254
|
+
else
|
255
|
+
if (element::nodeType==Xml::Document)||(element::nodeType==Xml::Element)
|
256
|
+
sb = StringBuf.new()
|
257
|
+
children = element::iterator()
|
258
|
+
while children::hasNext()
|
259
|
+
sb::add(getXmlTextContent(children::next()))
|
260
|
+
end
|
261
|
+
return sb::toString()
|
262
|
+
else
|
263
|
+
return ""
|
264
|
+
end
|
265
|
+
end
|
266
|
+
end
|
267
|
+
def serializeChild(s)
|
268
|
+
if @mode==XmlSerializer::MODE_READ
|
269
|
+
child = currentChild()
|
270
|
+
if child!=nil
|
271
|
+
s = (readNode())
|
272
|
+
else
|
273
|
+
s = nil
|
274
|
+
end
|
275
|
+
else
|
276
|
+
if (@mode==XmlSerializer::MODE_WRITE)&&(s!=nil)
|
277
|
+
(s)::onSerialize(self)
|
278
|
+
end
|
279
|
+
end
|
280
|
+
return s
|
281
|
+
end
|
282
|
+
def serializeArray(array,tagName)
|
283
|
+
if @mode==XmlSerializer::MODE_READ
|
284
|
+
array = Array.new()
|
285
|
+
child = currentChild()
|
286
|
+
while (child!=nil)&&((tagName==nil)||(tagName==child::nodeName))
|
287
|
+
elem = (readNode())
|
288
|
+
array::push(elem)
|
289
|
+
child = currentChild()
|
290
|
+
end
|
291
|
+
else
|
292
|
+
if ((@mode==XmlSerializer::MODE_WRITE)&&(array!=nil))&&(array::length()>0)
|
293
|
+
items = array::iterator()
|
294
|
+
while items::hasNext()
|
295
|
+
(items::next())::onSerialize(self)
|
296
|
+
end
|
297
|
+
end
|
298
|
+
end
|
299
|
+
return array
|
300
|
+
end
|
301
|
+
def serializeChildName(s,tagName)
|
302
|
+
if @mode==MODE_READ
|
303
|
+
child = currentChild()
|
304
|
+
if (child!=nil)&&(child::nodeName==tagName)
|
305
|
+
s = serializeChild(s)
|
306
|
+
end
|
307
|
+
else
|
308
|
+
if @mode==MODE_WRITE
|
309
|
+
s = serializeChild(s)
|
310
|
+
end
|
311
|
+
end
|
312
|
+
return s
|
313
|
+
end
|
314
|
+
def serializeArrayName(array,tagName)
|
315
|
+
if @mode==MODE_READ
|
316
|
+
if beginTag(tagName)
|
317
|
+
array = serializeArray(array,nil)
|
318
|
+
endTag()
|
319
|
+
end
|
320
|
+
else
|
321
|
+
if ((@mode==MODE_WRITE)&&(array!=nil))&&(array::length()>0)
|
322
|
+
element = @element
|
323
|
+
@element = element::createElement_(tagName)
|
324
|
+
element::addChild(@element)
|
325
|
+
array = serializeArray(array,nil)
|
326
|
+
@element = element
|
327
|
+
else
|
328
|
+
if @mode==MODE_REGISTER
|
329
|
+
beginTag(tagName)
|
330
|
+
end
|
331
|
+
end
|
332
|
+
end
|
333
|
+
return array
|
334
|
+
end
|
335
|
+
def register(elem)
|
336
|
+
tags::set(getTagName(elem),elem)
|
337
|
+
end
|
338
|
+
def getTagName(elem)
|
339
|
+
mode = @mode
|
340
|
+
@mode = XmlSerializer::MODE_REGISTER
|
341
|
+
@currentTag = nil
|
342
|
+
elem::onSerialize(self)
|
343
|
+
@mode = mode
|
344
|
+
return @currentTag
|
345
|
+
end
|
346
|
+
def readNode()
|
347
|
+
if !tags::exists(currentChild()::nodeName)
|
348
|
+
raise Exception,("Tag "+currentChild()::nodeName.to_s)+" not registered."
|
349
|
+
end
|
350
|
+
model = tags::get(currentChild()::nodeName)
|
351
|
+
return readNodeModel(model)
|
352
|
+
end
|
353
|
+
def readNodeModel(model)
|
354
|
+
node = model::newInstance()
|
355
|
+
node::onSerialize(self)
|
356
|
+
return node
|
357
|
+
end
|
358
|
+
def setCurrentElement(element)
|
359
|
+
@element = element
|
360
|
+
@children = element::elements()
|
361
|
+
@child = nil
|
362
|
+
end
|
363
|
+
def nextChild()
|
364
|
+
if @children::hasNext()
|
365
|
+
@child = @children::next()
|
366
|
+
else
|
367
|
+
@child = nil
|
368
|
+
end
|
369
|
+
return @child
|
370
|
+
end
|
371
|
+
def currentChild()
|
372
|
+
if (@child==nil)&&@children::hasNext()
|
373
|
+
@child = @children::next()
|
374
|
+
end
|
375
|
+
return @child
|
376
|
+
end
|
377
|
+
def pushState()
|
378
|
+
elementStack::push(@element)
|
379
|
+
childrenStack::push(@children)
|
380
|
+
childStack::push(@child)
|
381
|
+
end
|
382
|
+
def popState()
|
383
|
+
@element = elementStack::pop()
|
384
|
+
@children = childrenStack::pop()
|
385
|
+
@child = childStack::pop()
|
386
|
+
end
|
387
|
+
def self.parseBoolean(s)
|
388
|
+
return (s::toLowerCase()=="true")||(s=="1")
|
389
|
+
end
|
390
|
+
def self.booleanToString(b)
|
391
|
+
return b ? "true" : "false"
|
392
|
+
end
|
393
|
+
def childString(name,value,def_)
|
394
|
+
if !((@mode==MODE_WRITE)&&(((value==nil)&&(def_==nil))||((value!=nil)&&(value==def_))))
|
395
|
+
if beginTag(name)
|
396
|
+
value = textContent(value)
|
397
|
+
endTag()
|
398
|
+
end
|
399
|
+
end
|
400
|
+
return value
|
401
|
+
end
|
402
|
+
def childInt(name,value,def_)
|
403
|
+
return Std::parseInt(childString(name,""+value.to_s,""+def_.to_s))
|
404
|
+
end
|
405
|
+
def setCached(cache)
|
406
|
+
@cache = cache
|
407
|
+
end
|
408
|
+
def beginCache()
|
409
|
+
if @cache&&(@mode==XmlSerializer::MODE_WRITE)
|
410
|
+
@mode = XmlSerializer::MODE_CACHE
|
411
|
+
end
|
412
|
+
end
|
413
|
+
def endCache()
|
414
|
+
if @mode==XmlSerializer::MODE_CACHE
|
415
|
+
@mode = XmlSerializer::MODE_WRITE
|
416
|
+
end
|
417
|
+
end
|
418
|
+
def getMainTag(xml)
|
419
|
+
i = 0
|
420
|
+
loop do
|
421
|
+
i = xml::indexOf("<",i)
|
422
|
+
i+=1
|
423
|
+
c = Std::charCodeAt(xml,i)
|
424
|
+
break if not (c!=33)&&(c!=63)
|
425
|
+
end
|
426
|
+
_end = [">", " ", "/"]
|
427
|
+
min = 0
|
428
|
+
for j in 0.._end::length-1
|
429
|
+
n = xml::indexOf(_end[j])
|
430
|
+
if (n!=-1)&&(n<min)
|
431
|
+
n = min
|
432
|
+
end
|
433
|
+
j+=1
|
434
|
+
end
|
435
|
+
return Std::substr(xml,i,min)
|
436
|
+
end
|
437
|
+
def serializeXml(tag,elem)
|
438
|
+
if @mode==MODE_READ
|
439
|
+
if (tag==nil)||((currentChild()!=nil)&&(currentChild()::nodeName==tag))
|
440
|
+
elem = currentChild()
|
441
|
+
nextChild()
|
442
|
+
end
|
443
|
+
else
|
444
|
+
if @mode==MODE_WRITE
|
445
|
+
if (elem!=nil)&&(@ignoreTagStackCount==0)
|
446
|
+
imported = WXmlUtils::importXml(elem,@element)
|
447
|
+
element::addChild(imported)
|
448
|
+
end
|
449
|
+
else
|
450
|
+
if @mode==MODE_REGISTER
|
451
|
+
beginTag(tag)
|
452
|
+
end
|
453
|
+
end
|
454
|
+
end
|
455
|
+
return elem
|
456
|
+
end
|
457
|
+
def setIgnoreTags(ignore)
|
458
|
+
@ignore = ignore
|
459
|
+
end
|
460
|
+
def isIgnoreTag(s)
|
461
|
+
if @ignore!=nil
|
462
|
+
i = ignore::iterator()
|
463
|
+
while i::hasNext()
|
464
|
+
if (i::next()==s)
|
465
|
+
return true
|
466
|
+
end
|
467
|
+
end
|
468
|
+
end
|
469
|
+
return false
|
470
|
+
end
|
471
|
+
def self.compareStrings(a,b)
|
472
|
+
an = a::length()
|
473
|
+
bn = b::length()
|
474
|
+
n = (an>bn) ? bn : an
|
475
|
+
for i in 0..n-1
|
476
|
+
c = Std::charCodeAt(a,i)-Std::charCodeAt(b,i)
|
477
|
+
if c!=0
|
478
|
+
return c
|
479
|
+
end
|
480
|
+
i+=1
|
481
|
+
end
|
482
|
+
return a::length()-b::length()
|
483
|
+
end
|
484
|
+
end
|
485
|
+
end
|