You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@clerezza.apache.org by bb...@apache.org on 2011/06/29 21:21:32 UTC
svn commit: r1141207 - in
/incubator/clerezza/trunk/parent/rdf.scala.utils/src:
main/scala/org/apache/clerezza/rdf/scala/utils/EasyGraph.scala
test/scala/org/apache/clerezza/rdf/scala/utils/EasyGraphTest.scala
Author: bblfish
Date: Wed Jun 29 19:21:32 2011
New Revision: 1141207
URL: http://svn.apache.org/viewvc?rev=1141207&view=rev
Log:
CLEREZZA-510: seperated the various styles into subclasses so that working with any one of them is easier from the point of view of IDEs: IDEs will show only methods that belong to a given notation style. The default right now is unicode, but that can easily be changed.
Modified:
incubator/clerezza/trunk/parent/rdf.scala.utils/src/main/scala/org/apache/clerezza/rdf/scala/utils/EasyGraph.scala
incubator/clerezza/trunk/parent/rdf.scala.utils/src/test/scala/org/apache/clerezza/rdf/scala/utils/EasyGraphTest.scala
Modified: incubator/clerezza/trunk/parent/rdf.scala.utils/src/main/scala/org/apache/clerezza/rdf/scala/utils/EasyGraph.scala
URL: http://svn.apache.org/viewvc/incubator/clerezza/trunk/parent/rdf.scala.utils/src/main/scala/org/apache/clerezza/rdf/scala/utils/EasyGraph.scala?rev=1141207&r1=1141206&r2=1141207&view=diff
==============================================================================
--- incubator/clerezza/trunk/parent/rdf.scala.utils/src/main/scala/org/apache/clerezza/rdf/scala/utils/EasyGraph.scala (original)
+++ incubator/clerezza/trunk/parent/rdf.scala.utils/src/main/scala/org/apache/clerezza/rdf/scala/utils/EasyGraph.scala Wed Jun 29 19:21:32 2011
@@ -22,13 +22,13 @@ package org.apache.clerezza.rdf.scala.ut
import java.math.BigInteger
import java.lang.Boolean
import java.net.{URL, URI}
-import org.apache.clerezza.rdf.utils.UnionMGraph
-import org.apache.clerezza.rdf.utils.GraphNode
import org.apache.clerezza.rdf.ontologies.{XSD, RDF}
-import org.apache.clerezza.rdf.core._
-import impl._
import java.util.{HashSet, Date}
import collection.mutable.{ListBuffer, HashMap}
+import org.apache.clerezza.rdf.utils.{GraphNode, UnionMGraph}
+import org.apache.clerezza.rdf.core._
+import org.apache.clerezza.rdf.core.impl._
+import sun.security.krb5.internal.EncASRepPart
object EasyGraph {
@@ -60,6 +60,7 @@ object EasyGraph {
implicit def URLtoUriRef(url: URL) = new UriRef(url.toExternalForm)
+ import EzStyleChoice.unicode
//inspired from http://programming-scala.labs.oreilly.com/ch11.html
@@ -99,7 +100,23 @@ class EzLiteral(lexicalForm: String) ext
override def toString() = lexicalForm
}
+abstract class EzStyle[T<:EasyGraphNode]() {
+ def preferred(ref: NonLiteral, tc: TripleCollection):T
+}
+object EzStyleChoice {
+ implicit val unicode = new EzStyle[EzGraphNodeU](){
+ override def preferred(ref: NonLiteral, tc: TripleCollection): EzGraphNodeU = new EzGraphNodeU(ref,tc)
+ }
+ implicit val ascii = new EzStyle[EzGraphNodeA](){
+ override def preferred(ref: NonLiteral, tc: TripleCollection): EzGraphNodeA = new EzGraphNodeA(ref,tc)
+ }
+ implicit val english = new EzStyle[EzGraphNodeEn](){
+ override def preferred(ref: NonLiteral, tc: TripleCollection): EzGraphNodeEn = new EzGraphNodeEn(ref,tc)
+ }
+
+
+}
/**
* This is really a TripleCollection , should it just extend a TC? Or a MGraph?
*
@@ -109,7 +126,6 @@ class EzLiteral(lexicalForm: String) ext
*/
class EasyGraph(val graph: HashSet[Triple]) extends SimpleMGraph(graph) {
- val namedBnodes = new HashMap[String,EasyGraphNode]
/*
* because we can't jump straight to super constructor in Scala we need to
@@ -129,24 +145,30 @@ class EasyGraph(val graph: HashSet[Tripl
if (graph ne other) graph.addAll(other)
}
- def bnode: EasyGraphNode = {
- new EasyGraphNode(new BNode(), this)
+ def bnode[T<: EasyGraphNode](implicit writingStyle: EzStyle[T]=EzStyleChoice.unicode ): T = {
+ apply(new BNode)(writingStyle)
}
- def bnode(name: String): EasyGraphNode = {
+ val namedBnodes = new HashMap[String,BNode]
+ def b_[T<: EasyGraphNode](name: String)(implicit writingStyle: EzStyle[T]=EzStyleChoice.unicode): T = {
namedBnodes.get(name) match {
- case Some(ezGraphNode) => ezGraphNode
+ case Some(bnode) => writingStyle.preferred(bnode,this)
case None => {
- val ezgn = bnode;
- namedBnodes.put(name, ezgn);
- ezgn
+ val bn = new BNode
+ namedBnodes.put(name, bn);
+ writingStyle.preferred(bn,this)
}
}
}
- def u(url: String) = new EasyGraphNode(new UriRef(url), this)
+ def u[T<: EasyGraphNode](url: String)(implicit writingStyle: EzStyle[T]=EzStyleChoice.unicode): T = {
+ apply(new UriRef(url))(writingStyle)
+ }
- def apply(subj: NonLiteral) = new EasyGraphNode(subj, this)
+ def apply[T<: EasyGraphNode](subj: NonLiteral)(implicit writingStyle: EzStyle[T]=EzStyleChoice.unicode ): T = {
+ writingStyle.preferred(subj,this)
+// new EasyGraphNode(subj, this)
+ }
/**
* Add a a relation
@@ -176,129 +198,92 @@ class EasyGraph(val graph: HashSet[Tripl
//with a missing ref, or perhaps a sublcass of EasyGraphnode that only has the <- operator available
}
-
-/**
- *
- * Because of operator binding rules all the mathematical operators should
- * be used together as they bind at the same strength. Since they bind strongest
- * other operators will need to be strengthened with parenthesis, such as when adding strings
- *
- * @prefix graph: should this be an MGraph, since the EasyGraphNode is really designed for editing
- *
- */
-class EasyGraphNode(val ref: NonLiteral, val graph: TripleCollection) extends GraphNode(ref, graph) {
-
-// lazy val easyGraph = graph match {
-// case eg: EasyGraph => eg
-// case other: TripleCollection => new EasyGraph(graph)
-// }
-
- def +(sub: EasyGraphNode) = {
- if (graph ne sub.graph) graph.addAll(sub.graph)
- this
- }
-
-
- /*
- * create an EasyGraphNode from this one where the backing graph is protected from writes by a new
- * SimpleGraph.
- */
- def protect(): EasyGraphNode = new EasyGraphNode(ref, new UnionMGraph(new SimpleMGraph(), graph))
-
- def this(s: NonLiteral) = this (s, new SimpleMGraph())
-
- def this() = this (new BNode)
-
+class EzGraphNodeU(ref: NonLiteral, graph: TripleCollection) extends EasyGraphNode(ref, graph) {
//
- // Ascii arrow notation
+ // symbolic notation
//
- // (easier to write but has odd precedence implications)
+ // (shorter and more predictable precedence rules, but unicode issues)
+ type T_Pred = PredicateU
+ type T_InvP = InversePredicateU
+ type T_EzGN = EzGraphNodeU
- def --(rel: UriRef): Predicate = new Predicate(rel)
+ override def make(ref: NonLiteral, graph: TripleCollection) = new EzGraphNodeU(ref,graph)
+ override def predicate(rel: UriRef) = new PredicateU(rel)
+ override def inverse(rel: UriRef) = new InversePredicateU(rel)
- def --(rel: String): Predicate = new Predicate(new UriRef(rel))
- /**
- * we Can't have <-- as that messes up the balance of precedence
- */
- def -<-(rel: UriRef) = new InversePredicate(rel)
+ def â(rel: UriRef) = predicate(rel)
- // does not worked as hoped, and does not look that good either
- // def hasQ(yes: Boolean, rel: UriRef )(func: Predicate => EasyGraphNode): EasyGraphNode =
- // if (yes) func(has(rel))
- // else this
+ def â(rel: String) = predicate(new UriRef(rel))
+
+ /* For inverse relationships */
+ def âµ(rel: UriRef) = inverse(rel)
//
// symbolic notation
//
- // (shorter and more predictable precedence rules, but unicode issues)
+ // (shorter and more predictable precedence rules - they are always the weakest, and so very few brakets are need
+ // when symbolic operators are used. But sometimes this notation is grammatically awkward)
- def â(rel: UriRef): Predicate = --(rel)
+ def â(rdfclass: UriRef) = a(rdfclass)
- def â(rel: String): Predicate = --(rel)
+ class InversePredicateU(rel: UriRef) extends InversePredicate(rel) {
+ def â(subj: NonLiteral) = add(subj)
- /* For inverse relationships */
- def âµ(rel: UriRef) = -<-(rel)
+ def â(subj: String) = add(new UriRef(subj))
- def â(rdfclass: UriRef): EasyGraphNode = {
- graph.add(new TripleImpl(ref, RDF.`type`, rdfclass))
- return EasyGraphNode.this
+ def â(sub: EzGraphNodeU) = addGN(sub)
}
+ class PredicateU(rel: UriRef) extends Predicate(rel) {
+ def â¶(obj: String) = add(new EzLiteral(obj))
- //
- // symbolic notation
- //
- // (shorter and more predictable precedence rules - they are always the weakest, and so very few brakets are need
- // when symbolic operators are used. But sometimes this notation is grammatically awkward)
+ def â¶(obj: Resource) = add(obj)
- def a(rdfclass: UriRef) = â(rdfclass)
+ def â¶(list: List[Resource]) = addList(list)
- def has(rel: UriRef): Predicate = --(rel)
+ /**
+ * Add one relation for each member of the iterable collection
+ */
+ def â¶*[T <: Resource](objs: Iterable[T]) = addMany(objs)
- def has(rel: String): Predicate = --(rel)
+ def â¶(sub: EasyGraphNode) = addEG(sub)
- /* For inverse relationships */
- def is(rel: UriRef) = -<-(rel)
+ }
+}
- class InversePredicate(rel: UriRef) {
- def â(subj: NonLiteral) = add(subj)
- def â(subj: String) = add(new UriRef(subj))
+class EzGraphNodeA(ref: NonLiteral, graph: TripleCollection) extends EasyGraphNode(ref, graph) {
- def â(sub: EasyGraphNode): EasyGraphNode = {
- EasyGraphNode.this + sub
- add(sub.ref)
- }
+ type T_Pred = PredicateA
+ type T_InvP = InversePredicateA
+ type T_EzGN = EzGraphNodeA
- def --(subj: NonLiteral) = â(subj)
- def --(subj: String) = â(subj)
- def --(subj: EasyGraphNode) = â(subj)
- // since we can only have inverses from non literals (howto deal with bndoes?)
+ override def make(ref: NonLiteral, graph: TripleCollection) = new EzGraphNodeA(ref,graph)
+ override def predicate(rel: UriRef) = new PredicateA(rel)
+ override def inverse(rel: UriRef) = new InversePredicateA(rel)
- def of(subj: NonLiteral) = â(subj)
- def of(subj: String) = â(subj)
- def of(subj: EasyGraphNode) = â(subj)
+ def --(rel: UriRef) = predicate(rel)
- protected def add(subj: NonLiteral) = {
- graph.add(new TripleImpl(subj, rel, ref))
- EasyGraphNode.this
- }
- }
+ def --(rel: String) = predicate(new UriRef(rel))
- class Predicate(rel: UriRef) {
+ /**
+ * we Can't have <-- as that messes up the balance of precedence
+ */
+ def -<-(rel: UriRef) = inverse(rel)
+ class PredicateA(rel: UriRef) extends Predicate(rel) {
//
// methods that do the work
//
- def -->(obj: Resource): EasyGraphNode = add(obj)
+ def -->(obj: Resource) = add(obj)
- def -->(lit: String): EasyGraphNode = add(new EzLiteral(lit))
+ def -->(lit: String) = add(new EzLiteral(lit))
/**
* Adds a relation to a real linked list.
@@ -306,65 +291,164 @@ class EasyGraphNode(val ref: NonLiteral,
*/
def -->(list: List[Resource]) = addList(list)
- def -->(sub: EasyGraphNode): EasyGraphNode = {
- EasyGraphNode.this + sub
- add(sub.ref)
- }
+ def -->(sub: EasyGraphNode) = addEG(sub)
/**
* Add one relation for each member of the iterable collection
*/
- def -->>[T <: Resource](uris: Iterable[T]): EasyGraphNode = {
- for (u <- uris) addTriple(u)
- EasyGraphNode.this
- }
+ def -->>[T <: Resource](uris: Iterable[T]) = addMany(uris)
- //
- // arrow notation
- //
+ }
- def â¶(obj: String) = -->(obj)
+ class InversePredicateA(ref: UriRef) extends InversePredicate(ref) {
+ def --(subj: NonLiteral) = add(subj)
+ def --(subj: String) = add(new UriRef(subj))
+ def --(subj: EasyGraphNode) = addGN(subj)
+ // since we can only have inverses from non literals (howto deal with bndoes?)
+ }
- def â¶(obj: Resource): EasyGraphNode = -->(obj)
+}
- def â¶(list: List[Resource]): EasyGraphNode = addList(list)
+class EzGraphNodeEn(ref: NonLiteral, graph: TripleCollection) extends EasyGraphNode(ref, graph) {
- /**
- * Add one relation for each member of the iterable collection
- */
- def â¶*[T <: Resource](objs: Iterable[T]) = -->>(objs)
+ type T_Pred = PredicateEn
+ type T_InvP = InversePredicateEn
+ type T_EzGN = EzGraphNodeEn
+
+ override def make(ref: NonLiteral, graph: TripleCollection) = new EzGraphNodeEn(ref,graph)
+ override def predicate(rel: UriRef) = new PredicateEn(rel)
+ override def inverse(rel: UriRef) = new InversePredicateEn(rel)
- def â¶(sub: EasyGraphNode) = -->(sub)
+
+
+ // does not worked as hoped, and does not look that good either
+ // def hasQ(yes: Boolean, rel: UriRef )(func: Predicate => EasyGraphNode): EasyGraphNode =
+ // if (yes) func(has(rel))
+ // else this
+
+
+
+ def has(rel: UriRef) = predicate(rel)
+
+ def has(rel: String) = predicate(new UriRef(rel))
+
+ /* For inverse relationships */
+ def is(rel: UriRef) = inverse(rel)
+
+ class InversePredicateEn(rel: UriRef) extends InversePredicate(rel) {
+
+
+
+ def of(subj: NonLiteral) = add(subj)
+ def of(subj: String) = add(new UriRef(subj))
+ def of(subj: EasyGraphNode) = addGN(subj)
+ }
+
+ class PredicateEn(rel: UriRef) extends Predicate(rel) {
//
// text notation
//
- def to(obj: String) = -->(obj)
+ def to(lit: String) = add(new EzLiteral(lit))
- def to(obj: Resource): EasyGraphNode = -->(obj)
+ def to(obj: Resource) = add(obj)
- def to(list: List[Resource]): EasyGraphNode = addList(list)
+ def to(list: List[Resource]) = addList(list)
/**
* Add one relation for each member of the iterable collection
*/
- def toEach[T <: Resource](objs: Iterable[T]) = -->>(objs)
+ def toEach[T <: Resource](objs: Iterable[T]) = addMany(objs)
+
+ def to(sub: EasyGraphNode) = addEG(sub)
+
+ }
+
+}
+
+/**
+ *
+ * Because of operator binding rules all the mathematical operators should
+ * be used together as they bind at the same strength. Since they bind strongest
+ * other operators will need to be strengthened with parenthesis, such as when adding strings
+ *
+ * @prefix graph: should this be an MGraph, since the EasyGraphNode is really designed for editing
+ *
+ */
+abstract class EasyGraphNode(val ref: NonLiteral, val graph: TripleCollection) extends GraphNode(ref, graph) {
+
+// lazy val easyGraph = graph match {
+// case eg: EasyGraph => eg
+// case other: TripleCollection => new EasyGraph(graph)
+// }
+
+ def +(sub: EasyGraphNode) = {
+ if (graph ne sub.graph) graph.addAll(sub.graph)
+ this
+ }
- def to(sub: EasyGraphNode) = -->(sub)
+ type T_Pred <: Predicate
+ type T_InvP <: InversePredicate
+ type T_EzGN <: EasyGraphNode
+ protected def predicate(rel: UriRef): T_Pred
+ protected def inverse(rel: UriRef): T_InvP
+
+ def a(rdfclass: UriRef): T_EzGN = {
+ graph.add(new TripleImpl(ref, RDF.`type`, rdfclass))
+ return this.asInstanceOf[T_EzGN]
+ }
+
+ def make(ref: NonLiteral, graph: TripleCollection): T_EzGN
+
+ /*
+ * create an EasyGraphNode from this one where the backing graph is protected from writes by a new
+ * SimpleGraph.
+ */
+ def protect(): T_EzGN = make(ref, new UnionMGraph(new SimpleMGraph(), graph))
+
+ def this(s: NonLiteral) = this (s, new SimpleMGraph())
- protected def add(obj: Resource) = {
+ def this() = this (new BNode)
+
+ abstract class InversePredicate(rel: UriRef) {
+
+ protected def addGN(subj: EasyGraphNode) = {
+ EasyGraphNode.this + subj
+ add(subj.ref)
+ }
+
+ protected def add(subj: NonLiteral) = {
+ graph.add(new TripleImpl(subj, rel, ref))
+ EasyGraphNode.this.asInstanceOf[T_EzGN]
+ }
+ }
+
+ abstract class Predicate(rel: UriRef) {
+
+
+ protected def add(obj: Resource): T_EzGN = {
addTriple(obj)
- EasyGraphNode.this
+ EasyGraphNode.this.asInstanceOf[T_EzGN]
}
protected def addTriple(obj: Resource) {
graph.add(new TripleImpl(ref, rel, obj))
}
+ protected def addMany[T<:Resource](uris: Iterable[T]): T_EzGN = {
+ for (u <- uris) addTriple(u)
+ EasyGraphNode.this.asInstanceOf[T_EzGN]
+ }
+
+ protected def addEG(sub: EasyGraphNode): T_EzGN = {
+ EasyGraphNode.this + sub
+ add(sub.ref)
+ }
+
private def toTriples[T <: Resource](head: NonLiteral,list : List[T]): List[Triple] = {
val answer = new ListBuffer[Triple]
var varList = list
@@ -396,11 +480,9 @@ class EasyGraphNode(val ref: NonLiteral,
val tripleLst = toTriples(headNode,list);
graph.add(new TripleImpl(headNode,RDF.`type`,RDF.List))
graph.addAll(collection.JavaConversions.asJavaCollection(tripleLst))
- EasyGraphNode.this
+ EasyGraphNode.this.asInstanceOf[T_EzGN]
}
-
-
}
}
Modified: incubator/clerezza/trunk/parent/rdf.scala.utils/src/test/scala/org/apache/clerezza/rdf/scala/utils/EasyGraphTest.scala
URL: http://svn.apache.org/viewvc/incubator/clerezza/trunk/parent/rdf.scala.utils/src/test/scala/org/apache/clerezza/rdf/scala/utils/EasyGraphTest.scala?rev=1141207&r1=1141206&r2=1141207&view=diff
==============================================================================
--- incubator/clerezza/trunk/parent/rdf.scala.utils/src/test/scala/org/apache/clerezza/rdf/scala/utils/EasyGraphTest.scala (original)
+++ incubator/clerezza/trunk/parent/rdf.scala.utils/src/test/scala/org/apache/clerezza/rdf/scala/utils/EasyGraphTest.scala Wed Jun 29 19:21:32 2011
@@ -137,13 +137,13 @@ class EasyGraphTest {
val ez = new EasyGraph()
import org.apache.clerezza.rdf.scala.utils.EasyGraph._
- (ez.u(retoUri) -- FOAF.knows -->> List(henryUri.uri,danbriUri.uri))
+ (ez.u(retoUri)(EzStyleChoice.ascii) -- FOAF.knows -->> List(henryUri.uri,danbriUri.uri))
Assert.assertEquals("the two graphs should be of same size",gr.size(),ez.size())
Assert.assertEquals("Both graphs should contain exactly the same triples",gr.getGraph,ez.getGraph)
val ez2 = new EasyGraph()
- (ez2.u(retoUri) â FOAF.knows â¶* Set(danbriUri.uri,henryUri.uri))
+ (ez2.u(retoUri)(EzStyleChoice.unicode) â FOAF.knows â¶* Set(danbriUri.uri,henryUri.uri))
Assert.assertEquals("the two graphs should be of same size",gr.size(),ez2.size())
Assert.assertEquals("Both graphs should contain exactly the same triples",gr.getGraph,ez2.getGraph)
@@ -194,7 +194,6 @@ class EasyGraphTest {
import org.apache.clerezza.rdf.scala.utils.EasyGraph._
import org.apache.clerezza.rdf.scala.utils.Lang._
-
val ez = new EasyGraph()
val res : EasyGraphNode = (ez.bnode â OWL.sameAs ⶠ(n3^^"http://example.com/turtle".uri))
@@ -225,10 +224,11 @@ class EasyGraphTest {
def usingSymbolicArrows {
import org.apache.clerezza.rdf.scala.utils.EasyGraph._
import org.apache.clerezza.rdf.scala.utils.Lang._
- val ez = new EasyGraph()
+ val ez = new EasyGraph()
+ import EzStyleChoice.unicode //in IntelliJ this is needed for the moment to remove the red lines
// example using arrows
(
- ez.bnode("reto") â FOAF.Person
+ ez.b_("reto") â FOAF.Person
â FOAF.name ⶠ"Reto Bachman-Gmür".lang(rm)
â FOAF.title ⶠ"Mr"
â FOAF.currentProject ⶠ"http://clerezza.org/".uri
@@ -241,18 +241,18 @@ class EasyGraphTest {
â modulus ⶠ65537
â public_exponent ⶠ(bblfishModulus^^hex) // brackets needed due to precedence
)
- â FOAF.knows â¶* Set(ez.bnode("reto").ref,ez.bnode("danny").ref)
+ â FOAF.knows â¶* Set(ez.b_("reto").ref,ez.b_("danny").ref)
)
â FOAF.knows ⶠ(
- ez.bnode("danny") â FOAF.Person
+ ez.b_("danny") â FOAF.Person
â FOAF.name ⶠ"Danny Ayers".lang(en)
â FOAF.knows ⶠ"http://bblfish.net/#hjs".uri //knows
- â FOAF.knows ⶠez.bnode("reto")
+ â FOAF.knows ⶠez.b_("reto")
)
)
Assert.assertEquals("the two graphs should be of same size",tinyGraph.size(),ez.size())
Assert.assertEquals("Both graphs should contain exactly the same triples",tinyGraph,ez.getGraph)
- ez.bnode("danny") â FOAF.name ⶠ"George"
+ ez.b_("danny") â FOAF.name ⶠ"George"
Assert.assertNotSame("Added one more triple, so graphs should no longer be equal", tinyGraph,ez.getGraph)
}
@@ -260,10 +260,11 @@ class EasyGraphTest {
def usingAsciiArrows {
import org.apache.clerezza.rdf.scala.utils.EasyGraph._
import org.apache.clerezza.rdf.scala.utils.Lang._
+ import EzStyleChoice.ascii
val ez = new EasyGraph()
// example using arrows
(
- ez.bnode("reto").a(FOAF.Person)
+ ez.b_("reto").a(FOAF.Person)
-- FOAF.name --> "Reto Bachman-Gmür".lang(rm)
-- FOAF.title --> "Mr"
-- FOAF.currentProject --> "http://clerezza.org/".uri
@@ -276,17 +277,17 @@ class EasyGraphTest {
-- modulus --> 65537
-- public_exponent --> (bblfishModulus^^hex) // brackets needed due to precedence
)
- -- FOAF.knows -->> List(ez.bnode("reto").ref,ez.bnode("danny").ref)
+ -- FOAF.knows -->> List(ez.b_("reto").ref,ez.b_("danny").ref)
)
- -- FOAF.knows --> (ez.bnode("danny").a(FOAF.Person)
+ -- FOAF.knows --> (ez.b_("danny").a(FOAF.Person)
-- FOAF.name --> "Danny Ayers".lang(en)
-- FOAF.knows --> "http://bblfish.net/#hjs".uri //knows
- -- FOAF.knows --> ez.bnode("reto")
+ -- FOAF.knows --> ez.b_("reto")
)
)
Assert.assertEquals("the two graphs should be of same size",tinyGraph.size(),ez.size())
Assert.assertEquals("Both graphs should contain exactly the same triples",tinyGraph,ez.getGraph)
- ez.bnode("danny") -- FOAF.name --> "George"
+ ez.b_("danny") -- FOAF.name --> "George"
Assert.assertNotSame("Added one more triple, so graphs should no longer be equal",tinyGraph,ez.getGraph)
}
@@ -296,10 +297,12 @@ class EasyGraphTest {
def usingWordOperators {
import org.apache.clerezza.rdf.scala.utils.EasyGraph._
import org.apache.clerezza.rdf.scala.utils.Lang._
+ import EzStyleChoice.english
+
val ez = new EasyGraph()
// example using arrows
(
- ez.bnode("reto") a FOAF.Person
+ ez.b_("reto").asInstanceOf[EzGraphNodeEn] a FOAF.Person
has FOAF.name to "Reto Bachman-Gmür".lang(rm)
has FOAF.title to "Mr"
has FOAF.currentProject to "http://clerezza.org/".uri
@@ -312,17 +315,17 @@ class EasyGraphTest {
has modulus to 65537
has public_exponent to bblfishModulus^^hex // brackets needed due to precedence
)
- has FOAF.knows toEach List(ez.bnode("reto").ref,ez.bnode("danny").ref)
+ has FOAF.knows toEach List(ez.b_("reto").ref,ez.b_("danny").ref)
)
- has FOAF.knows to ( ez.bnode("danny") a FOAF.Person
+ has FOAF.knows to ( ez.b_("danny") a FOAF.Person
has FOAF.name to "Danny Ayers".lang(en)
has FOAF.knows to "http://bblfish.net/#hjs".uri //knows
- has FOAF.knows to ez.bnode("reto")
+ has FOAF.knows to ez.b_("reto")
)
)
Assert.assertEquals("the two graphs should be of same size",tinyGraph.size(),ez.size())
Assert.assertEquals("Both graphs should contain exactly the same triples",tinyGraph,ez.getGraph)
- ez.bnode("danny") has FOAF.name to "George"
+ ez.b_("danny") has FOAF.name to "George"
Assert.assertNotSame("Added one more triple, so graphs should no longer be equal",tinyGraph,ez.getGraph)
}