- About Scala
- Documentation
- Code Examples
- Software
- Scala Developers
overloaded method call problem
Wed, 2009-01-14, 10:58
Hello,
I am new to Scala. I'm trying to access Jena Semantic Web Framework from
Scala. The following Java code was taken from Jena Tutorial and works fine:
package hello;
import com.hp.hpl.jena.datatypes.xsd.XSDDatatype;
import com.hp.hpl.jena.rdf.model.Model;
import com.hp.hpl.jena.rdf.model.ModelFactory;
import com.hp.hpl.jena.rdf.model.Property;
import com.hp.hpl.jena.rdf.model.Resource;
public class HelloWorld {
public static void main(String[] args)
{
Model m = ModelFactory.createDefaultModel();
String NS = "http://example.com/test/";
Resource r = m.createResource(NS + "r");
Property p = m.createProperty(NS + "p");
r.addProperty(p, "hello world", XSDDatatype.XSDstring);
m.write(System.out, "Turtle");
}
}
I've created its Scala equivalent and it doesn't work:
package hello
import com.hp.hpl.jena.datatypes.xsd.XSDDatatype
import com.hp.hpl.jena.rdf.model.Model
import com.hp.hpl.jena.rdf.model.ModelFactory
import com.hp.hpl.jena.rdf.model.Property
import com.hp.hpl.jena.rdf.model.Resource
object HelloWorld extends Application {
val m = ModelFactory.createDefaultModel
val NS = "http://example.com/test/"
val r = m.createResource(NS + "r")
val p = m.createProperty(NS + "p")
r.addProperty(p, "hello world",XSDDataType.XSDstring)
m.write(System.out)
}
Compiler throws "wrong number of arguments" errors for overloaded
methods createResource, addProperty and Model.write. Am I doing
something wrong?
<rdf:RDF
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:j.0="http://example.com/test/" >
<rdf:Description rdf:about="http://example.com/test/r">
<j.0:p rdf:datatype="http://www.w3.org/2001/XMLSchema#string">hello world</j.0:p>
</rdf:Description>
</rdf:RDF>
It's probably something wrong with your environment.
-Sebastien
2009/1/14 Pavel Shapkin <psnet@yandex.ru>