wirispluginengine 3.62.0.1322 → 7.14.0.1422
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 +4 -4
- data/Rakefile +34 -34
- data/app/assets/javascripts/wirispluginengine/WIRISplugins.js +1040 -64
- data/app/controllers/wirispluginengine/application_controller.rb +84 -75
- data/app/helpers/wirispluginengine/application_helper.rb +4 -4
- data/config/routes.rb +4 -4
- data/lib/com/wiris/common/WInteger.rb +52 -51
- data/lib/com/wiris/plugin/api/Cas.rb +5 -5
- data/lib/com/wiris/plugin/api/CleanCache.rb +5 -5
- data/lib/com/wiris/plugin/api/Configuration.rb +5 -5
- data/lib/com/wiris/plugin/api/ConfigurationKeys.rb +94 -91
- data/lib/com/wiris/plugin/api/Editor.rb +5 -5
- data/lib/com/wiris/plugin/api/Filter.rb +5 -5
- data/lib/com/wiris/plugin/api/ImageFormatController.rb +5 -5
- data/lib/com/wiris/plugin/api/ParamsProvider.rb +5 -5
- data/lib/com/wiris/plugin/api/PluginBuilder.rb +88 -74
- data/lib/com/wiris/plugin/api/Render.rb +5 -5
- data/lib/com/wiris/plugin/api/ServiceResourceLoader.rb +5 -5
- data/lib/com/wiris/plugin/api/Test.rb +5 -5
- data/lib/com/wiris/plugin/api/TextService.rb +5 -5
- data/lib/com/wiris/plugin/configuration/ConfigurationUpdater.rb +5 -5
- data/lib/com/wiris/plugin/impl/CacheFormulaImpl.rb +15 -0
- data/lib/com/wiris/plugin/impl/CacheImpl.rb +124 -0
- data/lib/com/wiris/plugin/impl/CasImpl.rb +140 -138
- data/lib/com/wiris/plugin/impl/CleanCacheImpl.rb +103 -101
- data/lib/com/wiris/plugin/impl/ConfigurationImpl.rb +165 -166
- data/lib/com/wiris/plugin/impl/CustomConfigurationUpdater.rb +32 -30
- data/lib/com/wiris/plugin/impl/DefaultConfigurationUpdater.rb +24 -22
- data/lib/com/wiris/plugin/impl/EditorImpl.rb +80 -78
- data/lib/com/wiris/plugin/impl/FileConfigurationUpdater.rb +29 -27
- data/lib/com/wiris/plugin/impl/FileStorageAndCache.rb +55 -53
- data/lib/com/wiris/plugin/impl/FolderTreeStorageAndCache.rb +65 -134
- data/lib/com/wiris/plugin/impl/GenericParamsProviderImpl.rb +50 -48
- data/lib/com/wiris/plugin/impl/HttpImpl.rb +49 -48
- data/lib/com/wiris/plugin/impl/HttpListener.rb +5 -5
- data/lib/com/wiris/plugin/impl/ImageFormatControllerPng.rb +71 -63
- data/lib/com/wiris/plugin/impl/ImageFormatControllerSvg.rb +37 -28
- data/lib/com/wiris/plugin/impl/PluginBuilderImpl.rb +280 -248
- data/lib/com/wiris/plugin/impl/RenderImpl.rb +303 -257
- data/lib/com/wiris/plugin/impl/ServiceResourceLoaderImpl.rb +41 -39
- data/lib/com/wiris/plugin/impl/TestImpl.rb +177 -157
- data/lib/com/wiris/plugin/impl/TextFilter.rb +210 -194
- data/lib/com/wiris/plugin/impl/TextFilterTags.rb +57 -50
- data/lib/com/wiris/plugin/impl/TextServiceImpl.rb +158 -107
- data/lib/com/wiris/plugin/storage/StorageAndCache.rb +5 -5
- data/lib/com/wiris/util/json/JSon.rb +505 -493
- data/lib/com/wiris/util/json/JSonIntegerFormat.rb +17 -16
- data/lib/com/wiris/util/json/JsonAPIResponse.rb +70 -0
- data/lib/com/wiris/util/json/StringParser.rb +57 -56
- data/lib/com/wiris/util/sys/AccessProvider.rb +8 -0
- data/lib/com/wiris/util/sys/Cache.rb +8 -0
- data/lib/com/wiris/util/sys/HttpConnection.rb +14 -13
- data/lib/com/wiris/util/sys/HttpConnectionListener.rb +5 -5
- data/lib/com/wiris/util/sys/HttpSync.rb +28 -0
- data/lib/com/wiris/util/sys/IniFile.rb +132 -131
- data/lib/com/wiris/util/sys/Lock.rb +8 -0
- data/lib/com/wiris/util/sys/LockProvider.rb +8 -0
- data/lib/com/wiris/util/sys/Store.rb +126 -101
- data/lib/com/wiris/util/sys/StoreCache.rb +63 -0
- data/lib/com/wiris/util/sys/TimerProxy.rb +21 -0
- data/lib/com/wiris/util/sys/TimerTask.rb +8 -0
- data/lib/com/wiris/util/type/Arrays.rb +275 -0
- data/lib/com/wiris/util/type/ByteBuffer.rb +69 -0
- data/lib/com/wiris/util/type/Comparator.rb +8 -0
- data/lib/com/wiris/util/type/DataUtils.rb +24 -0
- data/lib/com/wiris/util/type/DoubleTools.rb +14 -0
- data/lib/com/wiris/util/type/HashCache.rb +43 -0
- data/lib/com/wiris/util/type/IntegerTools.rb +32 -0
- data/lib/com/wiris/util/type/Queue.rb +31 -0
- data/lib/com/wiris/util/type/SortArrayByStringLength.rb +26 -0
- data/lib/com/wiris/util/type/SortStringByLength.rb +26 -0
- data/lib/com/wiris/util/type/SortedHash.rb +45 -0
- data/lib/com/wiris/util/type/Stack.rb +31 -0
- data/lib/com/wiris/util/type/StringUtils.rb +56 -0
- data/lib/com/wiris/util/type/Tokenizer.rb +40 -0
- data/lib/com/wiris/util/type/UrlUtils.rb +78 -0
- data/lib/com/wiris/util/xml/ContentHandler.rb +8 -0
- data/lib/com/wiris/util/xml/DefaultHandler.rb +25 -0
- data/lib/com/wiris/util/xml/EntityResolver.rb +8 -0
- data/lib/com/wiris/util/xml/MathMLEntityResolver.rb +19 -0
- data/lib/com/wiris/util/xml/SAXParser.rb +470 -0
- data/lib/com/wiris/util/xml/SerializableImpl.rb +16 -15
- data/lib/com/wiris/util/xml/WCharacterBase.rb +968 -627
- data/lib/com/wiris/util/xml/WEntities.rb +11 -9
- data/lib/com/wiris/util/xml/WXmlUtils.rb +660 -490
- data/lib/com/wiris/util/xml/XmlSerializer.rb +517 -471
- data/lib/com/wiris/util/xml/XmlWriter.rb +260 -262
- data/lib/loader.rb +15 -12
- data/lib/src-generic/Array.rb +22 -22
- data/lib/src-generic/ArrayInt.rb +31 -31
- data/lib/src-generic/Base64.rb +14 -14
- data/lib/src-generic/BaseCode.rb +93 -93
- data/lib/src-generic/Boolean.rb +27 -0
- data/lib/src-generic/Bytes.rb +50 -50
- data/lib/src-generic/BytesInput.rb +37 -37
- data/lib/src-generic/EReg.rb +55 -55
- data/lib/src-generic/File.rb +35 -35
- data/lib/src-generic/FileLock.rb +26 -26
- data/lib/src-generic/FileSystem.rb +37 -37
- data/lib/src-generic/Hash.rb +42 -42
- data/lib/src-generic/Http.rb +111 -107
- data/lib/src-generic/HttpRequest.rb +25 -25
- data/lib/src-generic/HttpResponse.rb +70 -70
- data/lib/src-generic/Iterator.rb +20 -19
- data/lib/src-generic/Math.rb +14 -14
- data/lib/src-generic/Md5.rb +8 -8
- data/lib/src-generic/Md5Tools.rb +11 -11
- data/lib/src-generic/PropertiesTools.rb +32 -32
- data/lib/src-generic/Reflect.rb +16 -16
- data/lib/src-generic/RubyConfigurationUpdater.rb +49 -45
- data/lib/src-generic/Serializer.rb +84 -84
- data/lib/src-generic/Std.rb +74 -74
- data/lib/src-generic/Storage.rb +152 -152
- data/lib/src-generic/StringBuf.rb +40 -40
- data/lib/src-generic/StringTools.rb +44 -46
- data/lib/src-generic/Timer.rb +6 -6
- data/lib/src-generic/Type.rb +18 -18
- data/lib/src-generic/TypeTools.rb +31 -31
- data/lib/src-generic/Unserializer.rb +72 -72
- data/lib/src-generic/Utf8.rb +26 -26
- data/lib/src-generic/Xml.rb +199 -198
- data/lib/src-generic/extended/Integer.rb +5 -5
- data/lib/src-generic/extended/Math.rb +6 -6
- data/lib/src-generic/extended/Properties.rb +11 -11
- data/lib/src-generic/extended/String.rb +38 -38
- data/lib/src-generic/settings/PlatformSettings.rb +18 -18
- data/lib/src-generic/system/HttpProxy.rb +23 -0
- data/lib/src-generic/system/HttpProxyAuth.rb +10 -0
- data/lib/wirispluginengine.rb +5 -5
- data/lib/wirispluginengine/engine.rb +5 -5
- data/lib/wirispluginengine/integration/cleancache.rb +8 -8
- data/lib/wirispluginengine/integration/configurationjs.rb +8 -15
- data/lib/wirispluginengine/integration/configurationjson.rb +6 -6
- data/lib/wirispluginengine/integration/createimage.rb +7 -7
- data/lib/wirispluginengine/integration/getmathml.rb +18 -18
- data/lib/wirispluginengine/integration/resource.rb +8 -8
- data/lib/wirispluginengine/integration/service.rb +5 -5
- data/lib/wirispluginengine/integration/showimage.rb +28 -21
- data/lib/wirispluginengine/integration/test.rb +5 -5
- data/lib/wirispluginengine/integration/testfilter.rb +10 -0
- data/lib/wirispluginengine/version.rb +2 -2
- data/resources/VERSION +1 -1
- data/resources/WEB-INF/web.xml +25 -0
- data/resources/WIRISplugins.js +3809 -0
- data/resources/default-configuration.ini +47 -45
- data/resources/tech.txt +1 -1
- data/resources/wirisplugin.css +43 -42
- metadata +40 -4
- data/configuration.ini.dist +0 -104
@@ -0,0 +1,69 @@
|
|
1
|
+
module WirisPlugin
|
2
|
+
include Wiris
|
3
|
+
class ByteBuffer
|
4
|
+
include Wiris
|
5
|
+
|
6
|
+
def initialize()
|
7
|
+
super()
|
8
|
+
end
|
9
|
+
def self.bytesTo64bitsFloat(bytes)
|
10
|
+
doubleResult = nil
|
11
|
+
returnedArraySize = (bytes::length()/8)
|
12
|
+
doubleResult = []
|
13
|
+
byteArray = bytes::getData()
|
14
|
+
k = 0
|
15
|
+
for = 0
|
16
|
+
returnedArraySize - 1
|
17
|
+
longResult = 0
|
18
|
+
shift = 0
|
19
|
+
high = 0
|
20
|
+
low = 0
|
21
|
+
shiftAuxiliar = 0
|
22
|
+
for = 0
|
23
|
+
8 - 1
|
24
|
+
longAuxiliar = 0
|
25
|
+
longAuxiliarHL = 0
|
26
|
+
longAuxiliar ||=255&byteArray[k]
|
27
|
+
longAuxiliar <<=shift
|
28
|
+
longResult ||=longAuxiliar
|
29
|
+
longAuxiliarHL ||=(255&byteArray[k])
|
30
|
+
longAuxiliarHL <<=shiftAuxiliar
|
31
|
+
if j < 4
|
32
|
+
low ||=longAuxiliarHL
|
33
|
+
if j == 3
|
34
|
+
shiftAuxiliar = -8
|
35
|
+
end
|
36
|
+
else
|
37
|
+
high ||=longAuxiliarHL
|
38
|
+
end
|
39
|
+
shift += 8
|
40
|
+
shiftAuxiliar += 8
|
41
|
+
k+=1
|
42
|
+
j+=1
|
43
|
+
end
|
44
|
+
high32 = Int32::ofInt(high)
|
45
|
+
low32 = Int32::ofInt(low)
|
46
|
+
doubleResult[i] = TypeTools::longBitsToDouble(longResult,high32,low32)
|
47
|
+
i+=1
|
48
|
+
end
|
49
|
+
return doubleResult
|
50
|
+
end
|
51
|
+
def self.bytesTo32bitsFloat(bytes)
|
52
|
+
doubleResult = nil
|
53
|
+
returnedArraySize = (bytes::length()/4)
|
54
|
+
doubleResult = []
|
55
|
+
byteArray = bytes::getData()
|
56
|
+
k = 0
|
57
|
+
for = 0
|
58
|
+
returnedArraySize - 1
|
59
|
+
intResult = ((((byteArray[k + 3]&255) << 24)|((byteArray[k + 2]&255) << 16))|((byteArray[k + 1]&255) << 8))|(byteArray[k]&255)
|
60
|
+
number = TypeTools::intBitsToFloat(intResult)
|
61
|
+
doubleResult[i] = number
|
62
|
+
k += 4
|
63
|
+
i+=1
|
64
|
+
end
|
65
|
+
return doubleResult
|
66
|
+
end
|
67
|
+
|
68
|
+
end
|
69
|
+
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
module WirisPlugin
|
2
|
+
include Wiris
|
3
|
+
require('com/wiris/util/type/Arrays.rb')
|
4
|
+
class DataUtils
|
5
|
+
include Wiris
|
6
|
+
|
7
|
+
def initialize()
|
8
|
+
super()
|
9
|
+
end
|
10
|
+
def self.makeHashInt(definition)
|
11
|
+
hashItems = Arrays::fromCSV(definition)
|
12
|
+
result = Hash.new()
|
13
|
+
hashItems separatorIndex = itemPair::indexOf(":")
|
14
|
+
if separatorIndex == -1
|
15
|
+
next
|
16
|
+
end
|
17
|
+
key = itemPair::substring(0,separatorIndex)::trim()
|
18
|
+
value = Std::parseInt(itemPair::substring(separatorIndex + 1)::trim())
|
19
|
+
result::set(key,value)
|
20
|
+
return result
|
21
|
+
end
|
22
|
+
|
23
|
+
end
|
24
|
+
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
module WirisPlugin
|
2
|
+
include Wiris
|
3
|
+
class DoubleTools
|
4
|
+
include Wiris
|
5
|
+
|
6
|
+
def initialize()
|
7
|
+
super()
|
8
|
+
end
|
9
|
+
def self.isFinite(x)
|
10
|
+
return (!Double::isNaN(x) && (x != Double::POSITIVE_INFINITY)) && (x != Double::NEGATIVE_INFINITY)
|
11
|
+
end
|
12
|
+
|
13
|
+
end
|
14
|
+
end
|
@@ -0,0 +1,43 @@
|
|
1
|
+
module WirisPlugin
|
2
|
+
include Wiris
|
3
|
+
class HashCache < HashT
|
4
|
+
include Wiris
|
5
|
+
|
6
|
+
attr_accessor :maxSize
|
7
|
+
attr_accessor :sortedKeys
|
8
|
+
def initialize(maxSize)
|
9
|
+
super()
|
10
|
+
self.maxSize = maxSize
|
11
|
+
self.sortedKeys = Array.new()
|
12
|
+
end
|
13
|
+
def getMaxSize()
|
14
|
+
return self.maxSize
|
15
|
+
end
|
16
|
+
def setMaxSize(maxSize)
|
17
|
+
self.maxSize = maxSize
|
18
|
+
end
|
19
|
+
def getSortedKeys()
|
20
|
+
return self.sortedKeys
|
21
|
+
end
|
22
|
+
def remove(key)
|
23
|
+
if self.sortedKeys::remove(key)
|
24
|
+
return super(key)
|
25
|
+
end
|
26
|
+
return false
|
27
|
+
end
|
28
|
+
def keys()
|
29
|
+
return self.sortedKeys::iterator()
|
30
|
+
end
|
31
|
+
def set(key, value)
|
32
|
+
if (self.sortedKeys != nil) && (self.sortedKeys::length() >= self.maxSize)
|
33
|
+
removed = self.sortedKeys::_(0)
|
34
|
+
if self.sortedKeys::remove(removed)
|
35
|
+
super(removed)
|
36
|
+
end
|
37
|
+
end
|
38
|
+
self.sortedKeys::push(key)
|
39
|
+
super(key,value)
|
40
|
+
end
|
41
|
+
|
42
|
+
end
|
43
|
+
end
|
@@ -0,0 +1,32 @@
|
|
1
|
+
module WirisPlugin
|
2
|
+
include Wiris
|
3
|
+
class IntegerTools
|
4
|
+
include Wiris
|
5
|
+
|
6
|
+
def initialize()
|
7
|
+
super()
|
8
|
+
end
|
9
|
+
def self.sign(value)
|
10
|
+
return (value >= 0) ? 1 : -1
|
11
|
+
end
|
12
|
+
def self.signBool(value)
|
13
|
+
return value ? 1 : -1
|
14
|
+
end
|
15
|
+
def self.max(x, y)
|
16
|
+
return (x > y) ? x : y
|
17
|
+
end
|
18
|
+
def self.min(x, y)
|
19
|
+
return (x < y) ? x : y
|
20
|
+
end
|
21
|
+
def self.clamp(x, a, b)
|
22
|
+
return IntegerTools.min(IntegerTools.max(a,x),b)
|
23
|
+
end
|
24
|
+
def self.inRange(x, start, _end)
|
25
|
+
return (x >= start) && (x < _end)
|
26
|
+
end
|
27
|
+
def self.isInt(x)
|
28
|
+
return (EReg.new("[\\+\\-]?\\d+",""))::match(x)
|
29
|
+
end
|
30
|
+
|
31
|
+
end
|
32
|
+
end
|
@@ -0,0 +1,31 @@
|
|
1
|
+
module WirisPlugin
|
2
|
+
include Wiris
|
3
|
+
class Queue
|
4
|
+
include Wiris
|
5
|
+
|
6
|
+
attr_accessor :array
|
7
|
+
attr_accessor :size
|
8
|
+
def initialize()
|
9
|
+
super()
|
10
|
+
self.array = Array.new()
|
11
|
+
self.size = 0
|
12
|
+
end
|
13
|
+
def front()
|
14
|
+
return @array::_(0)
|
15
|
+
end
|
16
|
+
def pop()
|
17
|
+
if @size > 0
|
18
|
+
@size-=1
|
19
|
+
@array::splice(0,1)
|
20
|
+
end
|
21
|
+
end
|
22
|
+
def push(e)
|
23
|
+
@array::push(e)
|
24
|
+
@size+=1
|
25
|
+
end
|
26
|
+
def empty()
|
27
|
+
return @size == 0
|
28
|
+
end
|
29
|
+
|
30
|
+
end
|
31
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
module WirisPlugin
|
2
|
+
include Wiris
|
3
|
+
require('com/wiris/util/type/Arrays.rb')
|
4
|
+
class SortArrayByStringLength
|
5
|
+
extend Comparator<String>Interface
|
6
|
+
|
7
|
+
include Wiris
|
8
|
+
|
9
|
+
attr_accessor :arrayToSort
|
10
|
+
def initialize(arrayToSort)
|
11
|
+
super()
|
12
|
+
self.arrayToSort = arrayToSort
|
13
|
+
Arrays::sort(self.arrayToSort,self)
|
14
|
+
end
|
15
|
+
def getSorted()
|
16
|
+
return self.arrayToSort
|
17
|
+
end
|
18
|
+
def compare(a, b)
|
19
|
+
if a::length() < b::length()
|
20
|
+
return 1
|
21
|
+
end
|
22
|
+
return -1
|
23
|
+
end
|
24
|
+
|
25
|
+
end
|
26
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
module WirisPlugin
|
2
|
+
include Wiris
|
3
|
+
require('com/wiris/util/type/Arrays.rb')
|
4
|
+
class SortStringByLength
|
5
|
+
extend Comparator<String>Interface
|
6
|
+
|
7
|
+
include Wiris
|
8
|
+
|
9
|
+
attr_accessor :arrayToSort
|
10
|
+
def initialize(arrayToSort)
|
11
|
+
super()
|
12
|
+
self.arrayToSort = arrayToSort
|
13
|
+
Arrays::sort(self.arrayToSort,self)
|
14
|
+
end
|
15
|
+
def getSorted()
|
16
|
+
return self.arrayToSort
|
17
|
+
end
|
18
|
+
def compare(a, b)
|
19
|
+
if a::length() < b::length()
|
20
|
+
return 1
|
21
|
+
end
|
22
|
+
return -1
|
23
|
+
end
|
24
|
+
|
25
|
+
end
|
26
|
+
end
|
@@ -0,0 +1,45 @@
|
|
1
|
+
module WirisPlugin
|
2
|
+
include Wiris
|
3
|
+
require('com/wiris/util/type/Arrays.rb')
|
4
|
+
class SortedHash < HashT
|
5
|
+
include Wiris
|
6
|
+
|
7
|
+
attr_accessor :sortedKeys
|
8
|
+
def initialize()
|
9
|
+
super()
|
10
|
+
self.sortedKeys = Array.new()
|
11
|
+
end
|
12
|
+
def set(key, value)
|
13
|
+
i = Arrays::indexOfElement(self.sortedKeys,key)
|
14
|
+
if i >= 0
|
15
|
+
self.sortedKeys::_(i,key)
|
16
|
+
else
|
17
|
+
self.sortedKeys::push(key)
|
18
|
+
end
|
19
|
+
super(key,value)
|
20
|
+
end
|
21
|
+
def remove(key)
|
22
|
+
self.sortedKeys::remove(key)
|
23
|
+
return super(key)
|
24
|
+
end
|
25
|
+
def keys()
|
26
|
+
return self.sortedKeys::iterator()
|
27
|
+
end
|
28
|
+
def getSortedKeys()
|
29
|
+
return self.sortedKeys
|
30
|
+
end
|
31
|
+
def push(key, value, limit)
|
32
|
+
idx = Arrays::indexOfElement(self.sortedKeys,key)
|
33
|
+
if idx >= 0
|
34
|
+
self.sortedKeys::splice(idx,1)
|
35
|
+
self.sortedKeys::push(key)
|
36
|
+
else
|
37
|
+
if ((limit >= 0) && (self.sortedKeys::length() > 0)) && (self.sortedKeys::length() >= limit)
|
38
|
+
self.remove(self.sortedKeys::_(0))
|
39
|
+
end
|
40
|
+
self.set(key,value)
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
end
|
45
|
+
end
|
@@ -0,0 +1,31 @@
|
|
1
|
+
module WirisPlugin
|
2
|
+
include Wiris
|
3
|
+
class Stack
|
4
|
+
include Wiris
|
5
|
+
|
6
|
+
attr_accessor :array
|
7
|
+
attr_accessor :size
|
8
|
+
def initialize()
|
9
|
+
super()
|
10
|
+
self.array = Array.new()
|
11
|
+
self.size = 0
|
12
|
+
end
|
13
|
+
def top()
|
14
|
+
return @array::_(@size - 1)
|
15
|
+
end
|
16
|
+
def pop()
|
17
|
+
if @size > 0
|
18
|
+
@size-=1
|
19
|
+
@array::pop()
|
20
|
+
end
|
21
|
+
end
|
22
|
+
def push(e)
|
23
|
+
@array::push(e)
|
24
|
+
@size+=1
|
25
|
+
end
|
26
|
+
def empty()
|
27
|
+
return @size == 0
|
28
|
+
end
|
29
|
+
|
30
|
+
end
|
31
|
+
end
|
@@ -0,0 +1,56 @@
|
|
1
|
+
module WirisPlugin
|
2
|
+
include Wiris
|
3
|
+
require('com/wiris/util/type/IntegerTools.rb')
|
4
|
+
require('com/wiris/util/xml/WCharacterBase.rb')
|
5
|
+
class StringUtils
|
6
|
+
include Wiris
|
7
|
+
|
8
|
+
def initialize()
|
9
|
+
super()
|
10
|
+
end
|
11
|
+
def self.stripAccents(s)
|
12
|
+
sb = StringBuf.new()
|
13
|
+
i = Utf8::getIterator(s)
|
14
|
+
while i::hasNext()
|
15
|
+
sb::add(WCharacterBase::stripAccent(i::next()))
|
16
|
+
end
|
17
|
+
return sb::toString()
|
18
|
+
end
|
19
|
+
def self.padLeftZeros(s, length)
|
20
|
+
if (s == nil) || (s::length() >= length)
|
21
|
+
return s
|
22
|
+
end
|
23
|
+
stringBuf = StringBuf.new()
|
24
|
+
for = s::length()
|
25
|
+
length - 1
|
26
|
+
stringBuf::add("0")
|
27
|
+
i+=1
|
28
|
+
end
|
29
|
+
stringBuf::add(s)
|
30
|
+
return stringBuf::toString()
|
31
|
+
end
|
32
|
+
def self.compareIgnoringAccents(a, b)
|
33
|
+
return (StringUtils::stripAccents(a) == StringUtils::stripAccents(b))
|
34
|
+
end
|
35
|
+
def self.slice(s, beginIndex, endIndex)
|
36
|
+
stringLength = s::length()
|
37
|
+
if beginIndex < 0
|
38
|
+
beginIndex = IntegerTools::max(0,stringLength + beginIndex)
|
39
|
+
else
|
40
|
+
if beginIndex > stringLength
|
41
|
+
beginIndex = stringLength
|
42
|
+
end
|
43
|
+
end
|
44
|
+
if endIndex < 0
|
45
|
+
endIndex = IntegerTools::max(0,s::length() + endIndex)
|
46
|
+
else
|
47
|
+
if endIndex > stringLength
|
48
|
+
endIndex = stringLength
|
49
|
+
end
|
50
|
+
end
|
51
|
+
span = IntegerTools::max(0,endIndex - beginIndex)
|
52
|
+
return Std::substr(s,beginIndex,span)
|
53
|
+
end
|
54
|
+
|
55
|
+
end
|
56
|
+
end
|
@@ -0,0 +1,40 @@
|
|
1
|
+
module WirisPlugin
|
2
|
+
include Wiris
|
3
|
+
class Tokenizer
|
4
|
+
include Wiris
|
5
|
+
|
6
|
+
attr_accessor :delimiters
|
7
|
+
attr_accessor :takeDelimiters
|
8
|
+
def initialize(delimiters, takeDelimiters)
|
9
|
+
super()
|
10
|
+
self.delimiters = delimiters
|
11
|
+
self.takeDelimiters = takeDelimiters
|
12
|
+
end
|
13
|
+
def getDelimiters()
|
14
|
+
return self.delimiters
|
15
|
+
end
|
16
|
+
def splitTokens(text)
|
17
|
+
tokens = Array.new()
|
18
|
+
it = Utf8::getIterator(text)
|
19
|
+
block = StringBuf.new()
|
20
|
+
while it::hasNext()
|
21
|
+
c = Utf8::uchr(it::next())
|
22
|
+
if self.delimiters::indexOf(c) >= 0
|
23
|
+
tokens::push(block::toString())
|
24
|
+
if self.takeDelimiters
|
25
|
+
tokens::push(c)
|
26
|
+
end
|
27
|
+
block = StringBuf.new()
|
28
|
+
else
|
29
|
+
block::add(c)
|
30
|
+
end
|
31
|
+
end
|
32
|
+
last = block::toString()
|
33
|
+
if !(last == "")
|
34
|
+
tokens::push(last)
|
35
|
+
end
|
36
|
+
return tokens
|
37
|
+
end
|
38
|
+
|
39
|
+
end
|
40
|
+
end
|