class WirisPlugin::StringParser

Attributes

c[RW]
i[RW]
n[RW]
str[RW]

Public Class Methods

isBlank(c) click to toggle source
# File lib/com/wiris/util/json/StringParser.rb, line 39
def self.isBlank(c)
    return ((((c == 32) || (c == 10)) || (c == 13)) || (c == 9)) || (c == 160)
end
new() click to toggle source
Calls superclass method
# File lib/com/wiris/util/json/StringParser.rb, line 11
def initialize()
    super()
end

Public Instance Methods

getPositionRepresentation() click to toggle source
# File lib/com/wiris/util/json/StringParser.rb, line 42
def getPositionRepresentation()
    i0 = WInteger::min(@i,@n)
    s0 = WInteger::max(0,@i - 20)
    e0 = WInteger::min(@n,@i + 20)
    return (("..." + Std::substr(@str,s0,i0 - s0).to_s) + " >>> . <<<") + Std::substr(@str,i0,e0).to_s
end
init(str) click to toggle source
# File lib/com/wiris/util/json/StringParser.rb, line 14
def init(str)
    self.str = str
    @i = 0
    @n = str::length()
    nextToken()
end
isHexDigit(c) click to toggle source
# File lib/com/wiris/util/json/StringParser.rb, line 48
def isHexDigit(c)
    if (c >= 48) && (c <= 58)
        return true
    end
    if (c >= 97) && (c <= 102)
        return true
    end
    if (c >= 65) && (c <= 70)
        return true
    end
    return false
end
nextSafeToken() click to toggle source
# File lib/com/wiris/util/json/StringParser.rb, line 31
def nextSafeToken()
    if @i < @n
        @c = Utf8::charCodeAt(Std::substr(@str,@i),0)
        @i += (Utf8::uchr(@c))::length()
    else 
        @c = -1
    end
end
nextToken() click to toggle source
# File lib/com/wiris/util/json/StringParser.rb, line 25
def nextToken()
    if @c == -1
        raise Exception,"End of string"
    end
    nextSafeToken()
end
skipBlanks() click to toggle source
# File lib/com/wiris/util/json/StringParser.rb, line 20
def skipBlanks()
    while (@i < @n) && StringParser.isBlank(@c)
        nextToken()
    end
end