Property[Double] and Property[DateTime] for Vocabulary Class

5 views
Skip to first unread message

Banduk

unread,
Mar 20, 2012, 9:00:28 AM3/20/12
to sca...@googlegroups.com
Hi guys,

I am interested in extend the Vocabulary class to accept Property[Double] and Property[DateTime]
I extended and implemented the following functions:

    def propDoub( suffix : String ) = Property[Double]( prefix + suffix )
  def propTime( suffix : String ) = Property[DateTime]( prefix + suffix )

However, when trying to use them I receive the following message:
  
  java.lang.IllegalArgumentException: Cannot convert 30.0 of class java.lang.Double to Node

How to extend it correctly??

Thank you

Hrvoje Šimić

unread,
Mar 20, 2012, 9:07:44 AM3/20/12
to sca...@googlegroups.com
Note that method Property.apply has this signature:

apply[T]( uri: String )( implicit nc: NodeToValueConverter[T] )

so it requires a (implicit or explicit) node-to-value converter
object. So you can import NodeConverter.asDouble and .asDateTime
methods, or use them explicitly.

Mauricio Banduk

unread,
Mar 22, 2012, 4:20:48 AM3/22/12
to sca...@googlegroups.com
Right, it worked!

Now, If I create a propInt or a propDouble, how to get this type after??
I mean, if I receive a property without its object and subject, is there a way to know its type?

I tryed something like

if (prop.isInstanceOf[Property[Int]]){...}
else if (prop.isInstanceOf[Property[BigDecimal]]){..}
...

But, of course it did not work.

Thank you

2012/3/20 Hrvoje Šimić <hrvoj...@gmail.com>



--
Maurício Banduk

Mauricio Banduk

unread,
Mar 22, 2012, 5:12:20 AM3/22/12
to sca...@googlegroups.com
Well, I can try to test its converter, right?
is it the best way?

2012/3/22 Mauricio Banduk <ban...@gmail.com>



--
Maurício Banduk

Hrvoje Šimić

unread,
Mar 22, 2012, 6:06:14 AM3/22/12
to sca...@googlegroups.com
I guess you could do that, although it's not a part of the API, so
future versions could possibly break your code.

Mauricio Banduk

unread,
Mar 22, 2012, 7:37:11 AM3/22/12
to sca...@googlegroups.com
Ok that's what I'm doing. 
BTW are you planning to have something that covers this functionallity on future versions?

Thank you again

2012/3/22 Hrvoje Šimić <hrvoj...@gmail.com>



--
Maurício Banduk

Hrvoje Šimić

unread,
Mar 22, 2012, 8:43:46 AM3/22/12
to sca...@googlegroups.com
No plans for this at the moment. I guess you could make special
subclasses of Property for each range type, but I haven't really
looked at the problem. It seems to me that a RDF library shouldn't
provide a parallel ontology with its objects, that should be
integrated with actual statements.
Reply all
Reply to author
Forward
0 new messages