@raw = val
@type = 'FAILED'
@value = val
@where = "C_literalRegex failed"
else
@raw = val
@type = "literal"
getNativeValue: ->
if not @ntval?
@ntval = toNative(@value,@literal_type,@isNum,@raw)
if not @ntval?
return @value
return @ntval
toString: ->
@raw
repr: ->
console.log "NO, THIS DOES NOT GET CALLED!"
if @type is 'literal'
if _.isString(@raw)
return "\"#{@raw}\""
else if _.isNumber(@raw)
return @raw
else
throw new Error "RdfObject(#{@raw}) is a literal which is neither a String nor a Number"
else if @type is 'uri'
return "<#{@raw}>"
else
throw new Error "RdfObject(#{@raw}).type is neither literal nor uri"
isUri: ->
@type is "uri"
isLiteral: ->
@type is "literal"
getLiteralType: ->
@literal_type
uri_or_literal: ->
if @isLiteral()
return [@raw]
else
return @raw
getRawOrValue: ->
if @isLiteral()
return @raw
else
return @value
class Quad # TODO change to SPOGI
constructor: (subject, pred, obj, graph, id) ->
@s = new RdfUri(subject)
@p = new RdfUri(pred)
@o = new RdfObject(obj)
@g = new RdfUri(graph)
@i = id
return
toString: ->
id = @i? and " # #{@i}" or ""
"<" + @s + "> <" + @p + "> " + @o.repr() + " <" + @g + "> .#{id}"
repr: ->
@toString()
asLine: ->
@toString() + "\n"
spogiRegex = ///
\s*