Return-Path: X-Original-To: apmail-clerezza-commits-archive@www.apache.org Delivered-To: apmail-clerezza-commits-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 0AD97104F3 for ; Wed, 4 Dec 2013 15:21:37 +0000 (UTC) Received: (qmail 6397 invoked by uid 500); 4 Dec 2013 15:21:34 -0000 Delivered-To: apmail-clerezza-commits-archive@clerezza.apache.org Received: (qmail 6192 invoked by uid 500); 4 Dec 2013 15:21:23 -0000 Mailing-List: contact commits-help@clerezza.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@clerezza.apache.org Delivered-To: mailing list commits@clerezza.apache.org Received: (qmail 6021 invoked by uid 99); 4 Dec 2013 15:21:19 -0000 Received: from tyr.zones.apache.org (HELO tyr.zones.apache.org) (140.211.11.114) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 04 Dec 2013 15:21:19 +0000 Received: by tyr.zones.apache.org (Postfix, from userid 65534) id 1B1C2B34B; Wed, 4 Dec 2013 15:21:19 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit From: reto@apache.org To: commits@clerezza.apache.org Date: Wed, 04 Dec 2013 15:21:20 -0000 Message-Id: <8209090d55fc4de5aeb1d31f97ac2a2f@git.apache.org> In-Reply-To: <1f142b8ebee54188999069f70f15e0b3@git.apache.org> References: <1f142b8ebee54188999069f70f15e0b3@git.apache.org> X-Mailer: ASF-Git Admin Mailer Subject: [3/9] CLEREZZA-435: repaced tabs with spaces in scala files http://git-wip-us.apache.org/repos/asf/clerezza/blob/35448624/rdf.scala.utils/src/main/scala/org/apache/clerezza/rdf/scala/utils/RichGraphNode.scala ---------------------------------------------------------------------- diff --git a/rdf.scala.utils/src/main/scala/org/apache/clerezza/rdf/scala/utils/RichGraphNode.scala b/rdf.scala.utils/src/main/scala/org/apache/clerezza/rdf/scala/utils/RichGraphNode.scala index 4b10708..95f6aab 100644 --- a/rdf.scala.utils/src/main/scala/org/apache/clerezza/rdf/scala/utils/RichGraphNode.scala +++ b/rdf.scala.utils/src/main/scala/org/apache/clerezza/rdf/scala/utils/RichGraphNode.scala @@ -39,202 +39,202 @@ import org.apache.clerezza.rdf.utils.UnionMGraph */ class RichGraphNode(resource: Resource, graph: TripleCollection ) extends GraphNode(resource, graph) { - /** - * Construct a RichGraphNode given an existing [[GraphNde]] - * - * @param node The GraphNode to be wrapped - */ - def this(node: GraphNode) = this(node.getNode, node.getGraph) - - /** - * Operator syntax shortcut to get all objects as RichGraphNode - * - * @return all objects of the specified property of the node wrapped by this object - */ - def /(property: UriRef): CollectedIter[RichGraphNode] = { - new CollectedIter[RichGraphNode](() => new GraphNodeIter(getObjects(property)), readLock) - } - - /** - * Operator syntax shortcut to get all subjects as RichGraphNoderef - * - * @param property the property for which the subjects pointing to this node by that property are requested - * @return the matching resources - */ - def /-(property: UriRef): CollectedIter[RichGraphNode] = { - new CollectedIter[RichGraphNode](() => new GraphNodeIter(getSubjects(property)), readLock) - } - - /** - * Get the elements of the rdf:List represented by this node - * @return a List with the elements of the rdf:List represented by this node - */ - def !! = (for (listElem <- asList) yield { - new RichGraphNode(new GraphNode(listElem, getGraph)) - }).toList - - /** - * get a specified of the rdf:List represented by this node - * - * @return the specified index value - */ - def %!!(index: Int) = new RichGraphNode(new GraphNode(asList.get(index), - getGraph)) - - /** - * produces a default String representation for the node, this is the lexical form of literals, - * the unicode-string for UriRef and for BNodes the value returned by toString - * - * @return the default string representation of the node - */ - def * : String = { - getNode() match { - case lit: Literal => lit.getLexicalForm - case uri: UriRef => uri.getUnicodeString - case wrappedNode => wrappedNode.toString - } - } - - private def asClass[T](clazz : Class[T]) : T= { - val typedLiteral = getNode().asInstanceOf[TypedLiteral] - clazz match { - case c if(c == classOf[Boolean]) => LiteralFactory.getInstance().createObject( - classOf[java.lang.Boolean], typedLiteral).booleanValue.asInstanceOf[T] - case _ => LiteralFactory.getInstance().createObject(clazz, typedLiteral) - } - } - - /** - * Creates an instance of specified Class-Type representing the value of the literal wrapped by this - * GraphNode - * - * @return the literal represented by this node as instance of the specified type - */ - def as[T](implicit m: Manifest[T]): T = { - asClass(m.erasure.asInstanceOf[Class[T]]) - } - - /** - * Operator syntax shortcut to get the Resource wrapped by this - * GraphNode - * - * @return the node represented by this GraphNode as Resource, same as getNode - */ - def ! = { - getNode() - } - - private class GraphNodeIter[T <: Resource](base: Iterator[T]) extends Iterator[RichGraphNode] { - override def hasNext() = { - base.hasNext(); - } - - override def next() : RichGraphNode = { - new RichGraphNode(new GraphNode(base.next(), getGraph)); - } - - override def remove() { - base.remove() - } - } - - /** - *Sets the RDF:type of the subject */ - def a(rdfclass: UriRef): RichGraphNode = { - addProperty(RDF.`type`, rdfclass) - return this - } - - /* - * create an RichGraphNode from this one where the backing graph is protected from writes by a new - * SimpleGraph. - */ - def protect(): RichGraphNode = new RichGraphNode(getNode, new UnionMGraph(new SimpleMGraph(), graph)) - - - /** - * relate the subject via the given relation to.... - */ - def --(rel: Resource): DashTuple = new DashTuple(rel) - - def --(rel: RichGraphNode): DashTuple = new DashTuple(rel.getNode) - - - /** - * relate the subject via the inverse of the given relation to.... - */ - def <--(tuple: RichGraphNode#DashTuple): RichGraphNode = { - val inversePropertyRes = tuple.first.getNode - val inverseProperty: UriRef = inversePropertyRes match { - case p: UriRef => p - case _ => throw new RuntimeException("DashTuple must be a UriRef") - } - RichGraphNode.this.addInverseProperty(inverseProperty, tuple.second) - RichGraphNode.this - } - - - /** class for Inverse relations with the current RichGraphNode.ref as object */ - //TODO add support for adding many for symmetry reasons -// class InverseDashTuple(rel: DashTuple) { + /** + * Construct a RichGraphNode given an existing [[GraphNde]] + * + * @param node The GraphNode to be wrapped + */ + def this(node: GraphNode) = this(node.getNode, node.getGraph) + + /** + * Operator syntax shortcut to get all objects as RichGraphNode + * + * @return all objects of the specified property of the node wrapped by this object + */ + def /(property: UriRef): CollectedIter[RichGraphNode] = { + new CollectedIter[RichGraphNode](() => new GraphNodeIter(getObjects(property)), readLock) + } + + /** + * Operator syntax shortcut to get all subjects as RichGraphNoderef + * + * @param property the property for which the subjects pointing to this node by that property are requested + * @return the matching resources + */ + def /-(property: UriRef): CollectedIter[RichGraphNode] = { + new CollectedIter[RichGraphNode](() => new GraphNodeIter(getSubjects(property)), readLock) + } + + /** + * Get the elements of the rdf:List represented by this node + * @return a List with the elements of the rdf:List represented by this node + */ + def !! = (for (listElem <- asList) yield { + new RichGraphNode(new GraphNode(listElem, getGraph)) + }).toList + + /** + * get a specified of the rdf:List represented by this node + * + * @return the specified index value + */ + def %!!(index: Int) = new RichGraphNode(new GraphNode(asList.get(index), + getGraph)) + + /** + * produces a default String representation for the node, this is the lexical form of literals, + * the unicode-string for UriRef and for BNodes the value returned by toString + * + * @return the default string representation of the node + */ + def * : String = { + getNode() match { + case lit: Literal => lit.getLexicalForm + case uri: UriRef => uri.getUnicodeString + case wrappedNode => wrappedNode.toString + } + } + + private def asClass[T](clazz : Class[T]) : T= { + val typedLiteral = getNode().asInstanceOf[TypedLiteral] + clazz match { + case c if(c == classOf[Boolean]) => LiteralFactory.getInstance().createObject( + classOf[java.lang.Boolean], typedLiteral).booleanValue.asInstanceOf[T] + case _ => LiteralFactory.getInstance().createObject(clazz, typedLiteral) + } + } + + /** + * Creates an instance of specified Class-Type representing the value of the literal wrapped by this + * GraphNode + * + * @return the literal represented by this node as instance of the specified type + */ + def as[T](implicit m: Manifest[T]): T = { + asClass(m.erasure.asInstanceOf[Class[T]]) + } + + /** + * Operator syntax shortcut to get the Resource wrapped by this + * GraphNode + * + * @return the node represented by this GraphNode as Resource, same as getNode + */ + def ! = { + getNode() + } + + private class GraphNodeIter[T <: Resource](base: Iterator[T]) extends Iterator[RichGraphNode] { + override def hasNext() = { + base.hasNext(); + } + + override def next() : RichGraphNode = { + new RichGraphNode(new GraphNode(base.next(), getGraph)); + } + + override def remove() { + base.remove() + } + } + + /** + *Sets the RDF:type of the subject */ + def a(rdfclass: UriRef): RichGraphNode = { + addProperty(RDF.`type`, rdfclass) + return this + } + + /* + * create an RichGraphNode from this one where the backing graph is protected from writes by a new + * SimpleGraph. + */ + def protect(): RichGraphNode = new RichGraphNode(getNode, new UnionMGraph(new SimpleMGraph(), graph)) + + + /** + * relate the subject via the given relation to.... + */ + def --(rel: Resource): DashTuple = new DashTuple(rel) + + def --(rel: RichGraphNode): DashTuple = new DashTuple(rel.getNode) + + + /** + * relate the subject via the inverse of the given relation to.... + */ + def <--(tuple: RichGraphNode#DashTuple): RichGraphNode = { + val inversePropertyRes = tuple.first.getNode + val inverseProperty: UriRef = inversePropertyRes match { + case p: UriRef => p + case _ => throw new RuntimeException("DashTuple must be a UriRef") + } + RichGraphNode.this.addInverseProperty(inverseProperty, tuple.second) + RichGraphNode.this + } + + + /** class for Inverse relations with the current RichGraphNode.ref as object */ + //TODO add support for adding many for symmetry reasons +// class InverseDashTuple(rel: DashTuple) { // -// /** -// * ...to the following non literal -// */ -// def --(subj: NonLiteral): RichGraphNode = { -// RichGraphNode.this.addInverseProperty(rel, subj) -// RichGraphNode.this -// } +// /** +// * ...to the following non literal +// */ +// def --(subj: NonLiteral): RichGraphNode = { +// RichGraphNode.this.addInverseProperty(rel, subj) +// RichGraphNode.this +// } // -// /** -// * ...to the following resource (given as a string) -// */ -// def --(subj: String): RichGraphNode = --(new UriRef(subj)) +// /** +// * ...to the following resource (given as a string) +// */ +// def --(subj: String): RichGraphNode = --(new UriRef(subj)) // -// /** -// * ...to the following EzGraphNode -// * (useful for opening a new parenthesis and specifying other things in more detail -// */ -// def --(subj: GraphNode): RichGraphNode = { -// --(subj.getNode.asInstanceOf[NonLiteral]) -// } -// // since we can only have inverses from non literals (howto deal with bndoes?) -// } - - /** - * class for relations with the current RichGraphNode.ref as subject - */ - class DashTuple(val second: Resource) { - - val first = RichGraphNode.this - /** - * ...to the following non resource - */ - def -->(obj: Resource): RichGraphNode = { - val property = second match { - case u: UriRef => u; - case _ => throw new RuntimeException("Property must be a UriRef") - } - RichGraphNode.this.addProperty(property, obj) - RichGraphNode.this - } - - - /** - * ...to the EzGraphNode, which is useful for opening a parenthesis. - */ - def -->(sub: GraphNode): RichGraphNode = { - //RichGraphNode.this + sub - -->(sub.getNode) - } - /** - * Add one relation for each member of the iterable collection - */ - def -->>[T <: Resource](uris: Iterable[T]): RichGraphNode = { - for (u <- uris) -->(u) - RichGraphNode.this - } - } +// /** +// * ...to the following EzGraphNode +// * (useful for opening a new parenthesis and specifying other things in more detail +// */ +// def --(subj: GraphNode): RichGraphNode = { +// --(subj.getNode.asInstanceOf[NonLiteral]) +// } +// // since we can only have inverses from non literals (howto deal with bndoes?) +// } + + /** + * class for relations with the current RichGraphNode.ref as subject + */ + class DashTuple(val second: Resource) { + + val first = RichGraphNode.this + /** + * ...to the following non resource + */ + def -->(obj: Resource): RichGraphNode = { + val property = second match { + case u: UriRef => u; + case _ => throw new RuntimeException("Property must be a UriRef") + } + RichGraphNode.this.addProperty(property, obj) + RichGraphNode.this + } + + + /** + * ...to the EzGraphNode, which is useful for opening a parenthesis. + */ + def -->(sub: GraphNode): RichGraphNode = { + //RichGraphNode.this + sub + -->(sub.getNode) + } + /** + * Add one relation for each member of the iterable collection + */ + def -->>[T <: Resource](uris: Iterable[T]): RichGraphNode = { + for (u <- uris) -->(u) + RichGraphNode.this + } + } } http://git-wip-us.apache.org/repos/asf/clerezza/blob/35448624/rdf.scala.utils/src/test/scala/org/apache/clerezza/rdf/scala/utils/EzMGraphTest.scala ---------------------------------------------------------------------- diff --git a/rdf.scala.utils/src/test/scala/org/apache/clerezza/rdf/scala/utils/EzMGraphTest.scala b/rdf.scala.utils/src/test/scala/org/apache/clerezza/rdf/scala/utils/EzMGraphTest.scala index b4dbe6d..946d77e 100644 --- a/rdf.scala.utils/src/test/scala/org/apache/clerezza/rdf/scala/utils/EzMGraphTest.scala +++ b/rdf.scala.utils/src/test/scala/org/apache/clerezza/rdf/scala/utils/EzMGraphTest.scala @@ -29,7 +29,7 @@ import org.apache.clerezza.rdf.ontologies._ */ class EzMGraphTest { - val bblfishModulus = """ + val bblfishModulus = """ 9D ☮ 79 ☮ BF ☮ E2 ☮ F4 ☮ 98 ☮ BC ☮ 79 ☮ 6D ☮ AB ☮ 73 ☮ E2 ☮ 8B ☮ 39 ☮ 4D ☮ B5 26 ✜ 68 ✜ 49 ✜ EE ✜ 71 ✜ 87 ✜ 06 ✜ 32 ✜ C9 ✜ 9F ✜ 3F ✜ 94 ✜ E5 ✜ CB ✜ 4D ✜ B5 12 ☮ 35 ☮ 13 ☮ 69 ☮ 60 ☮ 81 ☮ 58 ☮ 79 ☮ 66 ☮ F3 ☮ 79 ☮ 20 ☮ 91 ☮ 6A ☮ 3F ☮ 42 5A ✜ F6 ✜ 54 ✜ 42 ✜ 88 ✜ B2 ✜ E9 ✜ 19 ✜ 4A ✜ 79 ✜ 87 ✜ 2E ✜ 62 ✜ 44 ✜ 2D ✜ 7C 06 ☽ 78 ☽ F8 @@ -38,116 +38,116 @@ class EzMGraphTest { ☾ 56 87 ☮ 8D ☮ B8 ☮ 7C ☮ C6 ☮ FE ☮ E9 ☮ 61 ☮ 88 ☮ 08 ☮ 61 ☮ DD ☮ E3 ☮ B8 ☮ B5 ☮ 47 ♥ """ - /**import some references in order to reduce dependencies */ - - final val hex: UriRef = new UriRef("http://www.w3.org/ns/auth/cert#hex") - final val identity: UriRef = new UriRef("http://www.w3.org/ns/auth/cert#identity") - final val RSAPublicKey: UriRef = new UriRef("http://www.w3.org/ns/auth/rsa#RSAPublicKey") - final val modulus: UriRef = new UriRef("http://www.w3.org/ns/auth/rsa#modulus") - final val public_exponent: UriRef = new UriRef("http://www.w3.org/ns/auth/rsa#public_exponent") - - val henryUri: String = "http://bblfish.net/#hjs" - val retoUri: String = "http://farewellutopia.com/reto/#me" - val danbriUri: String = "http://danbri.org/foaf.rdf#danbri" - - - private val tinyGraph: Graph = { - val gr = new SimpleMGraph - val reto = new BNode() - val danny = new BNode() - val henry = new UriRef(henryUri) - - gr.add(new TripleImpl(reto, RDF.`type`, FOAF.Person)) - gr.add(new TripleImpl(reto, FOAF.name, new PlainLiteralImpl("Reto Bachman-Gmür", new Language("rm")))) - //it is difficult to remember that one needs to put a string literal if one does not want to specify a language - gr.add(new TripleImpl(reto, FOAF.title, new TypedLiteralImpl("Mr", XSD.string))) - gr.add(new TripleImpl(reto, FOAF.currentProject, new UriRef("http://clerezza.org/"))) - gr.add(new TripleImpl(reto, FOAF.knows, henry)) - gr.add(new TripleImpl(reto, FOAF.knows, danny)) - - gr.add(new TripleImpl(danny, FOAF.name, new PlainLiteralImpl("Danny Ayers", new Language("en")))) - gr.add(new TripleImpl(danny, RDF.`type`, FOAF.Person)) - gr.add(new TripleImpl(danny, FOAF.knows, henry)) - gr.add(new TripleImpl(danny, FOAF.knows, reto)) - - gr.add(new TripleImpl(henry, FOAF.name, new TypedLiteralImpl("Henry Story", XSD.string))) //It is tricky to remember that one needs this for pure strings - gr.add(new TripleImpl(henry, FOAF.currentProject, new UriRef("http://webid.info/"))) - gr.add(new TripleImpl(henry, RDF.`type`, FOAF.Person)) - gr.add(new TripleImpl(henry, FOAF.knows, danny)) - gr.add(new TripleImpl(henry, FOAF.knows, reto)) - - val pk = new BNode() - gr.add(new TripleImpl(pk, RDF.`type`, RSAPublicKey)) - gr.add(new TripleImpl(pk, identity, henry)) - gr.add(new TripleImpl(pk, modulus, LiteralFactory.getInstance().createTypedLiteral(65537))) - gr.add(new TripleImpl(pk, public_exponent, new TypedLiteralImpl(bblfishModulus, hex))) - gr.getGraph - } - - - @Test - def singleTriple { - val expected = { - val s = new SimpleMGraph - s.add(new TripleImpl(henryUri.uri, FOAF.knows, retoUri.uri)) - s.getGraph - } - val ez = new EzMGraph() { - henryUri.uri -- FOAF.knows --> retoUri.uri - } - Assert.assertEquals("The two graphs should be equals", expected, ez.getGraph) - } - - @Test - def inverseTriple { - val expected = { - val s = new SimpleMGraph - s.add(new TripleImpl(retoUri.uri, FOAF.knows, henryUri.uri)) - s.getGraph - } - val ez = new EzMGraph() { - henryUri.uri <-- FOAF.knows -- retoUri.uri - } - Assert.assertEquals("The two graphs should be equals", expected, ez.getGraph) - } - - @Test - def usingAsciiArrows { - val ez = new EzMGraph() {( - b_("reto").a(FOAF.Person) -- FOAF.name --> "Reto Bachman-Gmür".lang("rm") - -- FOAF.title --> "Mr" - -- FOAF.currentProject --> "http://clerezza.org/".uri - -- FOAF.knows --> ( - "http://bblfish.net/#hjs".uri.a(FOAF.Person) - -- FOAF.name --> "Henry Story" - -- FOAF.currentProject --> "http://webid.info/".uri - -- FOAF.knows -->> List(b_("reto"), b_("danny")) - //one need to list properties before inverse properties, or use brackets - <-- identity -- ( - bnode.a(RSAPublicKey) //. notation because of precedence of operators - -- modulus --> 65537 - -- public_exponent --> (bblfishModulus^^hex) // brackets needed due to precedence - ) - ) - -- FOAF.knows --> ( - b_("danny").a(FOAF.Person) - -- FOAF.name --> "Danny Ayers".lang("en") - -- FOAF.knows --> "http://bblfish.net/#hjs".uri //knows - -- FOAF.knows --> 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) - //We can add triples by creating a new anonymous instance - new EzMGraph(ez) {( - "http://bblfish.net/#hjs".uri -- FOAF.name --> "William" - -- FOAF.name --> "Bill" - )} - Assert.assertEquals("the triple colletion has grown by one",tinyGraph.size()+2,ez.size) - //or by just importing it - import ez._ - ez.b_("danny") -- FOAF.name --> "George" - Assert.assertEquals("the triple colletion has grown by one",tinyGraph.size()+3,ez.size) - } + /**import some references in order to reduce dependencies */ + + final val hex: UriRef = new UriRef("http://www.w3.org/ns/auth/cert#hex") + final val identity: UriRef = new UriRef("http://www.w3.org/ns/auth/cert#identity") + final val RSAPublicKey: UriRef = new UriRef("http://www.w3.org/ns/auth/rsa#RSAPublicKey") + final val modulus: UriRef = new UriRef("http://www.w3.org/ns/auth/rsa#modulus") + final val public_exponent: UriRef = new UriRef("http://www.w3.org/ns/auth/rsa#public_exponent") + + val henryUri: String = "http://bblfish.net/#hjs" + val retoUri: String = "http://farewellutopia.com/reto/#me" + val danbriUri: String = "http://danbri.org/foaf.rdf#danbri" + + + private val tinyGraph: Graph = { + val gr = new SimpleMGraph + val reto = new BNode() + val danny = new BNode() + val henry = new UriRef(henryUri) + + gr.add(new TripleImpl(reto, RDF.`type`, FOAF.Person)) + gr.add(new TripleImpl(reto, FOAF.name, new PlainLiteralImpl("Reto Bachman-Gmür", new Language("rm")))) + //it is difficult to remember that one needs to put a string literal if one does not want to specify a language + gr.add(new TripleImpl(reto, FOAF.title, new TypedLiteralImpl("Mr", XSD.string))) + gr.add(new TripleImpl(reto, FOAF.currentProject, new UriRef("http://clerezza.org/"))) + gr.add(new TripleImpl(reto, FOAF.knows, henry)) + gr.add(new TripleImpl(reto, FOAF.knows, danny)) + + gr.add(new TripleImpl(danny, FOAF.name, new PlainLiteralImpl("Danny Ayers", new Language("en")))) + gr.add(new TripleImpl(danny, RDF.`type`, FOAF.Person)) + gr.add(new TripleImpl(danny, FOAF.knows, henry)) + gr.add(new TripleImpl(danny, FOAF.knows, reto)) + + gr.add(new TripleImpl(henry, FOAF.name, new TypedLiteralImpl("Henry Story", XSD.string))) //It is tricky to remember that one needs this for pure strings + gr.add(new TripleImpl(henry, FOAF.currentProject, new UriRef("http://webid.info/"))) + gr.add(new TripleImpl(henry, RDF.`type`, FOAF.Person)) + gr.add(new TripleImpl(henry, FOAF.knows, danny)) + gr.add(new TripleImpl(henry, FOAF.knows, reto)) + + val pk = new BNode() + gr.add(new TripleImpl(pk, RDF.`type`, RSAPublicKey)) + gr.add(new TripleImpl(pk, identity, henry)) + gr.add(new TripleImpl(pk, modulus, LiteralFactory.getInstance().createTypedLiteral(65537))) + gr.add(new TripleImpl(pk, public_exponent, new TypedLiteralImpl(bblfishModulus, hex))) + gr.getGraph + } + + + @Test + def singleTriple { + val expected = { + val s = new SimpleMGraph + s.add(new TripleImpl(henryUri.uri, FOAF.knows, retoUri.uri)) + s.getGraph + } + val ez = new EzMGraph() { + henryUri.uri -- FOAF.knows --> retoUri.uri + } + Assert.assertEquals("The two graphs should be equals", expected, ez.getGraph) + } + + @Test + def inverseTriple { + val expected = { + val s = new SimpleMGraph + s.add(new TripleImpl(retoUri.uri, FOAF.knows, henryUri.uri)) + s.getGraph + } + val ez = new EzMGraph() { + henryUri.uri <-- FOAF.knows -- retoUri.uri + } + Assert.assertEquals("The two graphs should be equals", expected, ez.getGraph) + } + + @Test + def usingAsciiArrows { + val ez = new EzMGraph() {( + b_("reto").a(FOAF.Person) -- FOAF.name --> "Reto Bachman-Gmür".lang("rm") + -- FOAF.title --> "Mr" + -- FOAF.currentProject --> "http://clerezza.org/".uri + -- FOAF.knows --> ( + "http://bblfish.net/#hjs".uri.a(FOAF.Person) + -- FOAF.name --> "Henry Story" + -- FOAF.currentProject --> "http://webid.info/".uri + -- FOAF.knows -->> List(b_("reto"), b_("danny")) + //one need to list properties before inverse properties, or use brackets + <-- identity -- ( + bnode.a(RSAPublicKey) //. notation because of precedence of operators + -- modulus --> 65537 + -- public_exponent --> (bblfishModulus^^hex) // brackets needed due to precedence + ) + ) + -- FOAF.knows --> ( + b_("danny").a(FOAF.Person) + -- FOAF.name --> "Danny Ayers".lang("en") + -- FOAF.knows --> "http://bblfish.net/#hjs".uri //knows + -- FOAF.knows --> 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) + //We can add triples by creating a new anonymous instance + new EzMGraph(ez) {( + "http://bblfish.net/#hjs".uri -- FOAF.name --> "William" + -- FOAF.name --> "Bill" + )} + Assert.assertEquals("the triple colletion has grown by one",tinyGraph.size()+2,ez.size) + //or by just importing it + import ez._ + ez.b_("danny") -- FOAF.name --> "George" + Assert.assertEquals("the triple colletion has grown by one",tinyGraph.size()+3,ez.size) + } } http://git-wip-us.apache.org/repos/asf/clerezza/blob/35448624/rdf.scala.utils/src/test/scala/org/apache/clerezza/rdf/scala/utils/RichGraphNodeTest.scala ---------------------------------------------------------------------- diff --git a/rdf.scala.utils/src/test/scala/org/apache/clerezza/rdf/scala/utils/RichGraphNodeTest.scala b/rdf.scala.utils/src/test/scala/org/apache/clerezza/rdf/scala/utils/RichGraphNodeTest.scala index 0f507ed..0131691 100644 --- a/rdf.scala.utils/src/test/scala/org/apache/clerezza/rdf/scala/utils/RichGraphNodeTest.scala +++ b/rdf.scala.utils/src/test/scala/org/apache/clerezza/rdf/scala/utils/RichGraphNodeTest.scala @@ -27,139 +27,139 @@ import Preamble._ class RichGraphNodeTest { - private val johnUri = new UriRef("http://example.org/john") - private val susanneUri = new UriRef("http://example.org/susanne") - private val listUri = new UriRef("http://example.org/list") - private val greetingsUri = new UriRef("http://example.org/greetings") - private val billBNode = new BNode() - private var node : RichGraphNode = null; - private var mGraph = new SimpleMGraph() - - @Before - def prepare() = { - mGraph.add(new TripleImpl(johnUri, FOAF.name, new PlainLiteralImpl("John"))); - mGraph.add(new TripleImpl(johnUri, FOAF.nick, new PlainLiteralImpl("johny"))); - mGraph.add(new TripleImpl(johnUri, FOAF.name, new PlainLiteralImpl("Johnathan Guller"))); - mGraph.add(new TripleImpl(johnUri, FOAF.knows, billBNode)) - mGraph.add(new TripleImpl(johnUri, RDF.`type`, FOAF.Person)); - mGraph.add(new TripleImpl(billBNode, FOAF.nick, new PlainLiteralImpl("Bill"))); - mGraph.add(new TripleImpl(billBNode, FOAF.name, new PlainLiteralImpl("William"))); - mGraph.add(new TripleImpl(billBNode, RDF.`type`, FOAF.Person)); - mGraph.add(new TripleImpl(susanneUri, FOAF.knows, johnUri)); - mGraph.add(new TripleImpl(susanneUri, FOAF.name, new PlainLiteralImpl("Susanne"))); - mGraph.add(new TripleImpl(susanneUri, RDF.`type`, FOAF.Person)); - val rdfList = new RdfList(listUri, mGraph); - rdfList.add(johnUri) - rdfList.add(new PlainLiteralImpl("foo")) - rdfList.add(new PlainLiteralImpl("bar")) - mGraph.add(new TripleImpl(johnUri, SKOS.related, listUri)) - val litEn = new PlainLiteralImpl("hello", - new Language("en")) - val litFr = new PlainLiteralImpl("satul", - new Language("fr")) - mGraph.add(new TripleImpl(greetingsUri, RDF.value, litEn)) - mGraph.add(new TripleImpl(greetingsUri, RDF.value, litFr)) - node = new GraphNode(johnUri, mGraph) - } - - @Test - def testBaseGraph { - val preamble = new Preamble(mGraph) - import preamble._ - def asGn(gn: GraphNode) = gn - val johnUriNode = asGn(johnUri) - Assert.assertEquals(johnUriNode, node) - } - - @Test - def testSlash = { - val rNode = new RichGraphNode(node) - Assert.assertEquals(new PlainLiteralImpl("johny"), (rNode/FOAF.nick)(0).getNode) - Assert.assertEquals(2, (rNode/FOAF.name).length(20)) - val stringNames = (for(name <- (rNode/FOAF.name).iterator) yield { - name.toString - }).toList - Assert.assertTrue(stringNames.contains("\"Johnathan Guller\"")) - Assert.assertTrue(stringNames.contains("\"John\"")) - } - - @Test - def testIterate = { - val simple: MGraph = new SimpleMGraph(); - val node = new GraphNode(new BNode(), simple); - node.addProperty(DCTERMS.provenance, new UriRef("http://example.org/foo")); - node.addProperty(DCTERMS.language, new UriRef("http://www.bluewin.ch/")); - simple.add(new TripleImpl(new UriRef("http://www.bluewin.ch/"),RDF.`type`, RDFS.Container)); - node.addProperty(RDF.`type`, PLATFORM.HeadedPage); - node.addProperty(RDF.`type`, RDFS.Class); - val test: CollectedIter[RichGraphNode] = node/DCTERMS.language/RDF.`type`; - Assert.assertEquals(1, test.length) - var counter = 0; - for(k <- test) { counter = counter + 1 } - Assert.assertEquals(1, counter) - } - - @Test - def testInverse = { - val rNode = new RichGraphNode(node) - Assert.assertEquals(1, (rNode/-FOAF.knows).length) - } - - @Test - def testMissingProperty = { - val rNode = new RichGraphNode(node) - Assert.assertEquals(0, (rNode/FOAF.thumbnail).length) - Assert.assertEquals("", rNode/FOAF.thumbnail*) - - } - - @Test - def testInverseImplicit = { - Assert.assertEquals(1, (node/-FOAF.knows).length) - } - - @Test - def testPath = { - Assert.assertEquals(1, (node/-FOAF.knows).length) - Assert.assertEquals(new PlainLiteralImpl("Susanne"), node/-FOAF.knows%0/FOAF.name%0!) - Assert.assertEquals(new PlainLiteralImpl("Susanne"), ((node/-FOAF.knows)(0)/FOAF.name)(0)!) - Assert.assertEquals(new PlainLiteralImpl("Susanne"), node/-FOAF.knows/FOAF.name!) - Assert.assertEquals(new PlainLiteralImpl("Bill"), node/FOAF.knows/FOAF.nick!) - Assert.assertEquals("Bill", (node/FOAF.knows/FOAF.nick)(0)*) - Assert.assertEquals("Bill", node/FOAF.knows/FOAF.nick*) - } - - @Test - def testLists = { - Assert.assertEquals(new PlainLiteralImpl("foo"),(node/SKOS.related).asList().get(1)) - Assert.assertEquals(new PlainLiteralImpl("foo"), (node/SKOS.related%0!!)(1)!) - Assert.assertEquals(new PlainLiteralImpl("foo"), - (for (value <- node/SKOS.related%0!!) yield value!).toList(1)) - Assert.assertEquals(new PlainLiteralImpl("bar"), - (for (value <- node/SKOS.related%0!!) yield value!).toList(2)) - Assert.assertEquals(new PlainLiteralImpl("foo"), node/SKOS.related%0%!!1!) - } - - @Test - def sortProperties = { - Assert.assertEquals(new PlainLiteralImpl("bar"), (node/SKOS.related%0!!).sortWith((a,b) => ((a*) < (b*)))(0)!) - Assert.assertEquals(johnUri, (node/SKOS.related%0!!).sortWith((a,b) => ((a*) > (b*)))(0)!) - } - - @Test - def literalAsObject = { - val dateLiteral = new TypedLiteralImpl("2009-01-01T01:33:58Z", - new UriRef("http://www.w3.org/2001/XMLSchema#dateTime")) - val node = new GraphNode(dateLiteral, new SimpleMGraph()) - Assert.assertNotNull(node.as[java.util.Date]) - } - - @Test - def literalLanguage = { - node = new GraphNode(greetingsUri, mGraph) - val lang = new Language("en") - val enValue = (node/RDF.value).find(l=>(l!).asInstanceOf[PlainLiteral].getLanguage == lang).get - Assert.assertEquals("hello", enValue*) - } + private val johnUri = new UriRef("http://example.org/john") + private val susanneUri = new UriRef("http://example.org/susanne") + private val listUri = new UriRef("http://example.org/list") + private val greetingsUri = new UriRef("http://example.org/greetings") + private val billBNode = new BNode() + private var node : RichGraphNode = null; + private var mGraph = new SimpleMGraph() + + @Before + def prepare() = { + mGraph.add(new TripleImpl(johnUri, FOAF.name, new PlainLiteralImpl("John"))); + mGraph.add(new TripleImpl(johnUri, FOAF.nick, new PlainLiteralImpl("johny"))); + mGraph.add(new TripleImpl(johnUri, FOAF.name, new PlainLiteralImpl("Johnathan Guller"))); + mGraph.add(new TripleImpl(johnUri, FOAF.knows, billBNode)) + mGraph.add(new TripleImpl(johnUri, RDF.`type`, FOAF.Person)); + mGraph.add(new TripleImpl(billBNode, FOAF.nick, new PlainLiteralImpl("Bill"))); + mGraph.add(new TripleImpl(billBNode, FOAF.name, new PlainLiteralImpl("William"))); + mGraph.add(new TripleImpl(billBNode, RDF.`type`, FOAF.Person)); + mGraph.add(new TripleImpl(susanneUri, FOAF.knows, johnUri)); + mGraph.add(new TripleImpl(susanneUri, FOAF.name, new PlainLiteralImpl("Susanne"))); + mGraph.add(new TripleImpl(susanneUri, RDF.`type`, FOAF.Person)); + val rdfList = new RdfList(listUri, mGraph); + rdfList.add(johnUri) + rdfList.add(new PlainLiteralImpl("foo")) + rdfList.add(new PlainLiteralImpl("bar")) + mGraph.add(new TripleImpl(johnUri, SKOS.related, listUri)) + val litEn = new PlainLiteralImpl("hello", + new Language("en")) + val litFr = new PlainLiteralImpl("satul", + new Language("fr")) + mGraph.add(new TripleImpl(greetingsUri, RDF.value, litEn)) + mGraph.add(new TripleImpl(greetingsUri, RDF.value, litFr)) + node = new GraphNode(johnUri, mGraph) + } + + @Test + def testBaseGraph { + val preamble = new Preamble(mGraph) + import preamble._ + def asGn(gn: GraphNode) = gn + val johnUriNode = asGn(johnUri) + Assert.assertEquals(johnUriNode, node) + } + + @Test + def testSlash = { + val rNode = new RichGraphNode(node) + Assert.assertEquals(new PlainLiteralImpl("johny"), (rNode/FOAF.nick)(0).getNode) + Assert.assertEquals(2, (rNode/FOAF.name).length(20)) + val stringNames = (for(name <- (rNode/FOAF.name).iterator) yield { + name.toString + }).toList + Assert.assertTrue(stringNames.contains("\"Johnathan Guller\"")) + Assert.assertTrue(stringNames.contains("\"John\"")) + } + + @Test + def testIterate = { + val simple: MGraph = new SimpleMGraph(); + val node = new GraphNode(new BNode(), simple); + node.addProperty(DCTERMS.provenance, new UriRef("http://example.org/foo")); + node.addProperty(DCTERMS.language, new UriRef("http://www.bluewin.ch/")); + simple.add(new TripleImpl(new UriRef("http://www.bluewin.ch/"),RDF.`type`, RDFS.Container)); + node.addProperty(RDF.`type`, PLATFORM.HeadedPage); + node.addProperty(RDF.`type`, RDFS.Class); + val test: CollectedIter[RichGraphNode] = node/DCTERMS.language/RDF.`type`; + Assert.assertEquals(1, test.length) + var counter = 0; + for(k <- test) { counter = counter + 1 } + Assert.assertEquals(1, counter) + } + + @Test + def testInverse = { + val rNode = new RichGraphNode(node) + Assert.assertEquals(1, (rNode/-FOAF.knows).length) + } + + @Test + def testMissingProperty = { + val rNode = new RichGraphNode(node) + Assert.assertEquals(0, (rNode/FOAF.thumbnail).length) + Assert.assertEquals("", rNode/FOAF.thumbnail*) + + } + + @Test + def testInverseImplicit = { + Assert.assertEquals(1, (node/-FOAF.knows).length) + } + + @Test + def testPath = { + Assert.assertEquals(1, (node/-FOAF.knows).length) + Assert.assertEquals(new PlainLiteralImpl("Susanne"), node/-FOAF.knows%0/FOAF.name%0!) + Assert.assertEquals(new PlainLiteralImpl("Susanne"), ((node/-FOAF.knows)(0)/FOAF.name)(0)!) + Assert.assertEquals(new PlainLiteralImpl("Susanne"), node/-FOAF.knows/FOAF.name!) + Assert.assertEquals(new PlainLiteralImpl("Bill"), node/FOAF.knows/FOAF.nick!) + Assert.assertEquals("Bill", (node/FOAF.knows/FOAF.nick)(0)*) + Assert.assertEquals("Bill", node/FOAF.knows/FOAF.nick*) + } + + @Test + def testLists = { + Assert.assertEquals(new PlainLiteralImpl("foo"),(node/SKOS.related).asList().get(1)) + Assert.assertEquals(new PlainLiteralImpl("foo"), (node/SKOS.related%0!!)(1)!) + Assert.assertEquals(new PlainLiteralImpl("foo"), + (for (value <- node/SKOS.related%0!!) yield value!).toList(1)) + Assert.assertEquals(new PlainLiteralImpl("bar"), + (for (value <- node/SKOS.related%0!!) yield value!).toList(2)) + Assert.assertEquals(new PlainLiteralImpl("foo"), node/SKOS.related%0%!!1!) + } + + @Test + def sortProperties = { + Assert.assertEquals(new PlainLiteralImpl("bar"), (node/SKOS.related%0!!).sortWith((a,b) => ((a*) < (b*)))(0)!) + Assert.assertEquals(johnUri, (node/SKOS.related%0!!).sortWith((a,b) => ((a*) > (b*)))(0)!) + } + + @Test + def literalAsObject = { + val dateLiteral = new TypedLiteralImpl("2009-01-01T01:33:58Z", + new UriRef("http://www.w3.org/2001/XMLSchema#dateTime")) + val node = new GraphNode(dateLiteral, new SimpleMGraph()) + Assert.assertNotNull(node.as[java.util.Date]) + } + + @Test + def literalLanguage = { + node = new GraphNode(greetingsUri, mGraph) + val lang = new Language("en") + val enValue = (node/RDF.value).find(l=>(l!).asInstanceOf[PlainLiteral].getLanguage == lang).get + Assert.assertEquals("hello", enValue*) + } } http://git-wip-us.apache.org/repos/asf/clerezza/blob/35448624/rdf.scala.utils/src/test/scala/org/apache/clerezza/rdf/scala/utils/TypeConversionTest.scala ---------------------------------------------------------------------- diff --git a/rdf.scala.utils/src/test/scala/org/apache/clerezza/rdf/scala/utils/TypeConversionTest.scala b/rdf.scala.utils/src/test/scala/org/apache/clerezza/rdf/scala/utils/TypeConversionTest.scala index aa86c35..6190d4e 100644 --- a/rdf.scala.utils/src/test/scala/org/apache/clerezza/rdf/scala/utils/TypeConversionTest.scala +++ b/rdf.scala.utils/src/test/scala/org/apache/clerezza/rdf/scala/utils/TypeConversionTest.scala @@ -25,47 +25,47 @@ import com.sun.xml.internal.ws.developer.MemberSubmissionAddressing.Validation class TypeConversionTest { - private val literalFactory = LiteralFactory.getInstance() + private val literalFactory = LiteralFactory.getInstance() - import Preamble._ + import Preamble._ - @Test - def useStringAsObject { - val t = new TripleImpl(new UriRef(("http://example.org/subject")), new UriRef(("http://example.org/predicate")), "a value") - Assert.assertEquals(literalFactory.createTypedLiteral("a value"), t.getObject) - } + @Test + def useStringAsObject { + val t = new TripleImpl(new UriRef(("http://example.org/subject")), new UriRef(("http://example.org/predicate")), "a value") + Assert.assertEquals(literalFactory.createTypedLiteral("a value"), t.getObject) + } - /*@Test - def useStringWithLanguageTag { - val t = new TripleImpl(new UriRef(("http://example.org/subject")), new UriRef(("http://example.org/predicate")), "a value"("en")) - Assert.assertEquals(new PlainLiteralImpl("a value", new Language("en")), t.getObject) - }*/ + /*@Test + def useStringWithLanguageTag { + val t = new TripleImpl(new UriRef(("http://example.org/subject")), new UriRef(("http://example.org/predicate")), "a value"("en")) + Assert.assertEquals(new PlainLiteralImpl("a value", new Language("en")), t.getObject) + }*/ - @Test - def useStringWithLanguageTag { - val lit = new PlainLiteralImpl("a value", new Language("en")) - val t = new TripleImpl(new UriRef(("http://example.org/subject")), new UriRef(("http://example.org/predicate")), "a value" lang "en") - Assert.assertEquals(lit, t.getObject) - } + @Test + def useStringWithLanguageTag { + val lit = new PlainLiteralImpl("a value", new Language("en")) + val t = new TripleImpl(new UriRef(("http://example.org/subject")), new UriRef(("http://example.org/predicate")), "a value" lang "en") + Assert.assertEquals(lit, t.getObject) + } - @Test - def useStringWithType { - val typeUri = new UriRef("http://example.org/dt") - val t = new TripleImpl(new UriRef(("http://example.org/subject")), new UriRef(("http://example.org/predicate")), "a value"^^typeUri) - Assert.assertEquals(new TypedLiteralImpl("a value", typeUri), t.getObject) - } + @Test + def useStringWithType { + val typeUri = new UriRef("http://example.org/dt") + val t = new TripleImpl(new UriRef(("http://example.org/subject")), new UriRef(("http://example.org/predicate")), "a value"^^typeUri) + Assert.assertEquals(new TypedLiteralImpl("a value", typeUri), t.getObject) + } - @Test - def literaToString { - val lit = literalFactory.createTypedLiteral("a value") - val s: String = lit - Assert.assertEquals("a value", s) - } + @Test + def literaToString { + val lit = literalFactory.createTypedLiteral("a value") + val s: String = lit + Assert.assertEquals("a value", s) + } - @Test - def dotUri { - val t = new TripleImpl(new UriRef(("http://example.org/subject")), new UriRef(("http://example.org/predicate")), "http://example.org".uri) - Assert.assertEquals(new UriRef("http://example.org"), t.getObject) - } + @Test + def dotUri { + val t = new TripleImpl(new UriRef(("http://example.org/subject")), new UriRef(("http://example.org/predicate")), "http://example.org".uri) + Assert.assertEquals(new UriRef("http://example.org"), t.getObject) + } } http://git-wip-us.apache.org/repos/asf/clerezza/blob/35448624/rdf.storage.web/src/main/scala/WebProxy.scala ---------------------------------------------------------------------- diff --git a/rdf.storage.web/src/main/scala/WebProxy.scala b/rdf.storage.web/src/main/scala/WebProxy.scala index 08ac5a9..c482dd2 100644 --- a/rdf.storage.web/src/main/scala/WebProxy.scala +++ b/rdf.storage.web/src/main/scala/WebProxy.scala @@ -40,229 +40,229 @@ import java.sql.Time */ class WebProxy extends WeightedTcProvider with Logging { - val networkTimeoutKey = "network-timeout" - - private var networkTimeout: Int = _ - - private var tcProvider: TcProviderMultiplexer = new TcProviderMultiplexer - - /** - * Register a provider - * - * @param provider - * the provider to be registered - */ - protected def bindWeightedTcProvider(provider: WeightedTcProvider): Unit = { - tcProvider.addWeightedTcProvider(provider) - } - - /** - * Deregister a provider - * - * @param provider - * the provider to be deregistered - */ - protected def unbindWeightedTcProvider(provider: WeightedTcProvider): Unit = { - tcProvider.removeWeightedTcProvider(provider) - } - - /**OSGI method, called on activation */ - protected def activate(context: ComponentContext) = { - networkTimeout = Integer.parseInt(context.getProperties.get(networkTimeoutKey).toString) - } - - - private var parser: Parser = null - - protected def bindParser(p: Parser) = { - parser = p - } - - protected def unbindParser(p: Parser) = { - parser = null - } - - def getWeight: Int = { - return 0 - } - - /** - * Any TripleCollection is available as Graph as well as immutable MGraph - * - * @param name - * @return - * @throws NoSuchEntityException - */ - def getMGraph(name: UriRef): MGraph = { - val graph = getGraph(name) - return new AbstractMGraph() { - protected def performFilter(subject: NonLiteral, predicate: UriRef, `object` : Resource): java.util.Iterator[Triple] = { - graph.filter(subject, predicate, `object`) - } - - def size = graph.size - } - } - - def getGraph(name: UriRef): Graph = { - try { - getGraph(name, Cache.Fetch) - } catch { - case e: IOException => { - logger.debug("could not get graph by dereferencing uri", e) - throw new NoSuchEntityException(name) - } - - } - } - - def getTriples(name: UriRef): TripleCollection = { - return getMGraph(name) - } - - def createMGraph(name: UriRef): MGraph = { - throw new UnsupportedOperationException - } - - def createGraph(name: UriRef, triples: TripleCollection): Graph = { - throw new UnsupportedOperationException - } - - def deleteTripleCollection(name: UriRef): Unit = { - throw new UnsupportedOperationException - } - - def getNames(graph: Graph): java.util.Set[UriRef] = { - var result: java.util.Set[UriRef] = new java.util.HashSet[UriRef] - import collection.JavaConversions._ - for (name <- listGraphs) { - if (getGraph(name).equals(graph)) { - result.add(name) - } - } - return result - } - - def listTripleCollections: java.util.Set[UriRef] = { - var result: java.util.Set[UriRef] = new java.util.HashSet[UriRef] - result.addAll(listGraphs) - result.addAll(listMGraphs) - return result - } - - def listGraphs: java.util.Set[UriRef] = { - //or should we list graphs for which we have a cached version? - return java.util.Collections.emptySet[UriRef] - } - - def listMGraphs: java.util.Set[UriRef] = { - return java.util.Collections.emptySet[UriRef] - } - - /** - * The semantics of this resource - * @param update if a remote URI, update information on the resource first - */ - def getGraph(name: UriRef, updatePolicy: Cache.Value): Graph = { - logger.debug("getting graph " + name) - if (name.getUnicodeString.indexOf('#') != -1) { - logger.debug("not dereferencing URI with hash sign. Please see CLEREZZA-533 for debate.") - throw new NoSuchEntityException(name) - } - if (name.getUnicodeString.startsWith("urn")) { - //these are not dereferenceable - throw new NoSuchEntityException(name) - } - val cacheGraphName = new UriRef("urn:x-localinstance:/cache/" + name.getUnicodeString) - //todo: follow redirects and keep track of them - //todo: keep track of headers especially date and etag. test for etag similarity - //todo: for https connection allow user to specify his webid and send his key: ie allow web server to be an agent - //todo: add GRDDL functionality, so that other return types can be processed too - //todo: enable ftp and other formats (though content negotiation won't work there) - def updateGraph() { - val url = new URL(name.getUnicodeString) - val connection = url.openConnection() - connection match { - case hc: HttpURLConnection => { - hc.addRequestProperty("Accept", acceptHeader) - hc.setReadTimeout(networkTimeout) - hc.setConnectTimeout(networkTimeout) - }; - } - connection.connect() - val in = connection.getInputStream() - val mediaType = connection.getContentType() - val remoteTriples = parser.parse(in, mediaType, name) - tcProvider.synchronized { - try { - tcProvider.deleteTripleCollection(cacheGraphName) - } catch { - case e: NoSuchEntityException =>; - } - tcProvider.createGraph(cacheGraphName, remoteTriples) - } - } - try { - //the logic here is not quite right, as we don't look at time of previous fetch. - updatePolicy match { - case Cache.Fetch => try { - tcProvider.getGraph(cacheGraphName) - } catch { - case e: NoSuchEntityException => updateGraph(); tcProvider.getGraph(cacheGraphName) - } - case Cache.ForceUpdate => updateGraph(); tcProvider.getGraph(cacheGraphName) - case Cache.CacheOnly => tcProvider.getGraph(cacheGraphName) - } - } catch { - case ex: PrivilegedActionException => { - var cause: Throwable = ex.getCause - if (cause.isInstanceOf[UnsupportedOperationException]) { - throw cause.asInstanceOf[UnsupportedOperationException] - } - if (cause.isInstanceOf[EntityAlreadyExistsException]) { - throw cause.asInstanceOf[EntityAlreadyExistsException] - } - if (cause.isInstanceOf[RuntimeException]) { - throw cause.asInstanceOf[RuntimeException] - } - throw new RuntimeException(cause) - } - } - } - - - private lazy val acceptHeader = { - - import scala.collection.JavaConversions._ - - (for (f <- parser.getSupportedFormats) yield { - val qualityOfFormat = { - f match { - //the default, well established format - case SupportedFormat.RDF_XML => "1.0"; - //n3 is a bit less well defined and/or many parsers supports only subsets - case SupportedFormat.N3 => "0.6"; - //we prefer most dedicated formats to (X)HTML, not because those are "better", - //but just because it is quite likely that the pure RDF format will be - //lighter (contain less presentation markup), and it is also possible that HTML does not - //contain any RDFa, but just points to another format. - case SupportedFormat.XHTML => "0.5"; - //we prefer XHTML over html, because parsing (should) be easier - case SupportedFormat.HTML => "0.4"; - //all other formats known currently are structured formats - case _ => "0.8" - } - } - f + "; q=" + qualityOfFormat + "," - }).mkString + " *; q=.1" //is that for GRDDL? - } + val networkTimeoutKey = "network-timeout" + + private var networkTimeout: Int = _ + + private var tcProvider: TcProviderMultiplexer = new TcProviderMultiplexer + + /** + * Register a provider + * + * @param provider + * the provider to be registered + */ + protected def bindWeightedTcProvider(provider: WeightedTcProvider): Unit = { + tcProvider.addWeightedTcProvider(provider) + } + + /** + * Deregister a provider + * + * @param provider + * the provider to be deregistered + */ + protected def unbindWeightedTcProvider(provider: WeightedTcProvider): Unit = { + tcProvider.removeWeightedTcProvider(provider) + } + + /**OSGI method, called on activation */ + protected def activate(context: ComponentContext) = { + networkTimeout = Integer.parseInt(context.getProperties.get(networkTimeoutKey).toString) + } + + + private var parser: Parser = null + + protected def bindParser(p: Parser) = { + parser = p + } + + protected def unbindParser(p: Parser) = { + parser = null + } + + def getWeight: Int = { + return 0 + } + + /** + * Any TripleCollection is available as Graph as well as immutable MGraph + * + * @param name + * @return + * @throws NoSuchEntityException + */ + def getMGraph(name: UriRef): MGraph = { + val graph = getGraph(name) + return new AbstractMGraph() { + protected def performFilter(subject: NonLiteral, predicate: UriRef, `object` : Resource): java.util.Iterator[Triple] = { + graph.filter(subject, predicate, `object`) + } + + def size = graph.size + } + } + + def getGraph(name: UriRef): Graph = { + try { + getGraph(name, Cache.Fetch) + } catch { + case e: IOException => { + logger.debug("could not get graph by dereferencing uri", e) + throw new NoSuchEntityException(name) + } + + } + } + + def getTriples(name: UriRef): TripleCollection = { + return getMGraph(name) + } + + def createMGraph(name: UriRef): MGraph = { + throw new UnsupportedOperationException + } + + def createGraph(name: UriRef, triples: TripleCollection): Graph = { + throw new UnsupportedOperationException + } + + def deleteTripleCollection(name: UriRef): Unit = { + throw new UnsupportedOperationException + } + + def getNames(graph: Graph): java.util.Set[UriRef] = { + var result: java.util.Set[UriRef] = new java.util.HashSet[UriRef] + import collection.JavaConversions._ + for (name <- listGraphs) { + if (getGraph(name).equals(graph)) { + result.add(name) + } + } + return result + } + + def listTripleCollections: java.util.Set[UriRef] = { + var result: java.util.Set[UriRef] = new java.util.HashSet[UriRef] + result.addAll(listGraphs) + result.addAll(listMGraphs) + return result + } + + def listGraphs: java.util.Set[UriRef] = { + //or should we list graphs for which we have a cached version? + return java.util.Collections.emptySet[UriRef] + } + + def listMGraphs: java.util.Set[UriRef] = { + return java.util.Collections.emptySet[UriRef] + } + + /** + * The semantics of this resource + * @param update if a remote URI, update information on the resource first + */ + def getGraph(name: UriRef, updatePolicy: Cache.Value): Graph = { + logger.debug("getting graph " + name) + if (name.getUnicodeString.indexOf('#') != -1) { + logger.debug("not dereferencing URI with hash sign. Please see CLEREZZA-533 for debate.") + throw new NoSuchEntityException(name) + } + if (name.getUnicodeString.startsWith("urn")) { + //these are not dereferenceable + throw new NoSuchEntityException(name) + } + val cacheGraphName = new UriRef("urn:x-localinstance:/cache/" + name.getUnicodeString) + //todo: follow redirects and keep track of them + //todo: keep track of headers especially date and etag. test for etag similarity + //todo: for https connection allow user to specify his webid and send his key: ie allow web server to be an agent + //todo: add GRDDL functionality, so that other return types can be processed too + //todo: enable ftp and other formats (though content negotiation won't work there) + def updateGraph() { + val url = new URL(name.getUnicodeString) + val connection = url.openConnection() + connection match { + case hc: HttpURLConnection => { + hc.addRequestProperty("Accept", acceptHeader) + hc.setReadTimeout(networkTimeout) + hc.setConnectTimeout(networkTimeout) + }; + } + connection.connect() + val in = connection.getInputStream() + val mediaType = connection.getContentType() + val remoteTriples = parser.parse(in, mediaType, name) + tcProvider.synchronized { + try { + tcProvider.deleteTripleCollection(cacheGraphName) + } catch { + case e: NoSuchEntityException =>; + } + tcProvider.createGraph(cacheGraphName, remoteTriples) + } + } + try { + //the logic here is not quite right, as we don't look at time of previous fetch. + updatePolicy match { + case Cache.Fetch => try { + tcProvider.getGraph(cacheGraphName) + } catch { + case e: NoSuchEntityException => updateGraph(); tcProvider.getGraph(cacheGraphName) + } + case Cache.ForceUpdate => updateGraph(); tcProvider.getGraph(cacheGraphName) + case Cache.CacheOnly => tcProvider.getGraph(cacheGraphName) + } + } catch { + case ex: PrivilegedActionException => { + var cause: Throwable = ex.getCause + if (cause.isInstanceOf[UnsupportedOperationException]) { + throw cause.asInstanceOf[UnsupportedOperationException] + } + if (cause.isInstanceOf[EntityAlreadyExistsException]) { + throw cause.asInstanceOf[EntityAlreadyExistsException] + } + if (cause.isInstanceOf[RuntimeException]) { + throw cause.asInstanceOf[RuntimeException] + } + throw new RuntimeException(cause) + } + } + } + + + private lazy val acceptHeader = { + + import scala.collection.JavaConversions._ + + (for (f <- parser.getSupportedFormats) yield { + val qualityOfFormat = { + f match { + //the default, well established format + case SupportedFormat.RDF_XML => "1.0"; + //n3 is a bit less well defined and/or many parsers supports only subsets + case SupportedFormat.N3 => "0.6"; + //we prefer most dedicated formats to (X)HTML, not because those are "better", + //but just because it is quite likely that the pure RDF format will be + //lighter (contain less presentation markup), and it is also possible that HTML does not + //contain any RDFa, but just points to another format. + case SupportedFormat.XHTML => "0.5"; + //we prefer XHTML over html, because parsing (should) be easier + case SupportedFormat.HTML => "0.4"; + //all other formats known currently are structured formats + case _ => "0.8" + } + } + f + "; q=" + qualityOfFormat + "," + }).mkString + " *; q=.1" //is that for GRDDL? + } } object Cache extends Enumeration { - /**fetch if not in cache, if version in cache is out of date, or return cache */ - val Fetch = Value - /**fetch from source whatever is in cache */ - val ForceUpdate = Value - /**only get cached version. If none exists return empty graph */ - val CacheOnly = Value + /**fetch if not in cache, if version in cache is out of date, or return cache */ + val Fetch = Value + /**fetch from source whatever is in cache */ + val ForceUpdate = Value + /**only get cached version. If none exists return empty graph */ + val CacheOnly = Value } http://git-wip-us.apache.org/repos/asf/clerezza/blob/35448624/scala-scripting/script-engine/src/main/scala/org/apache/clerezza/scala/scripting/BundleContextScalaCompiler.scala ---------------------------------------------------------------------- diff --git a/scala-scripting/script-engine/src/main/scala/org/apache/clerezza/scala/scripting/BundleContextScalaCompiler.scala b/scala-scripting/script-engine/src/main/scala/org/apache/clerezza/scala/scripting/BundleContextScalaCompiler.scala index 1221212..bdce763 100644 --- a/scala-scripting/script-engine/src/main/scala/org/apache/clerezza/scala/scripting/BundleContextScalaCompiler.scala +++ b/scala-scripting/script-engine/src/main/scala/org/apache/clerezza/scala/scripting/BundleContextScalaCompiler.scala @@ -54,8 +54,8 @@ import scala.collection.mutable.ListBuffer * TODO: check if this is still true with Scala 2.20 */ class BundleContextScalaCompiler(bundleContext : BundleContext, - settings: Settings, reporter: Reporter) - extends Global(settings, reporter) with ReplGlobal with Logging { self => + settings: Settings, reporter: Reporter) + extends Global(settings, reporter) with ReplGlobal with Logging { self => override lazy val platform: ThisPlatform = { @@ -85,33 +85,33 @@ class BundleContextScalaCompiler(bundleContext : BundleContext, } new MergedClassPath(result.toList.reverse, original.context) } - /*override lazy val classPath: ClassPath[AbstractFile] = { + /*override lazy val classPath: ClassPath[AbstractFile] = { - val classPathOrig: ClassPath[AbstractFile] = new PathResolver(settings).result - var bundles: Array[Bundle] = bundleContext.getBundles - val classPathAbstractFiles = for (bundle <- bundles; - val url = bundle.getResource("/"); - if url != null) yield { - if ("file".equals(url.getProtocol())) { - new PlainFile(new File(url.toURI())) - } - else { - BundleFS.create(bundle); - } - } - val classPaths: List[ClassPath[AbstractFile]] = (for (abstractFile <- classPathAbstractFiles) - yield { - new DirectoryClassPath(abstractFile, classPathOrig.context) - }) toList + val classPathOrig: ClassPath[AbstractFile] = new PathResolver(settings).result + var bundles: Array[Bundle] = bundleContext.getBundles + val classPathAbstractFiles = for (bundle <- bundles; + val url = bundle.getResource("/"); + if url != null) yield { + if ("file".equals(url.getProtocol())) { + new PlainFile(new File(url.toURI())) + } + else { + BundleFS.create(bundle); + } + } + val classPaths: List[ClassPath[AbstractFile]] = (for (abstractFile <- classPathAbstractFiles) + yield { + new DirectoryClassPath(abstractFile, classPathOrig.context) + }) toList - new MergedClassPath[AbstractFile](classPathOrig :: classPaths, - classPathOrig.context) + new MergedClassPath[AbstractFile](classPathOrig :: classPaths, + classPathOrig.context) - }*/ + }*/ - /*override def rootLoader: LazyType = { - new loaders.JavaPackageLoader(classPath) - }*/ + /*override def rootLoader: LazyType = { + new loaders.JavaPackageLoader(classPath) + }*/ } http://git-wip-us.apache.org/repos/asf/clerezza/blob/35448624/scala-scripting/script-engine/src/main/scala/org/apache/clerezza/scala/scripting/BundleContextScalaInterpreter.scala ---------------------------------------------------------------------- diff --git a/scala-scripting/script-engine/src/main/scala/org/apache/clerezza/scala/scripting/BundleContextScalaInterpreter.scala b/scala-scripting/script-engine/src/main/scala/org/apache/clerezza/scala/scripting/BundleContextScalaInterpreter.scala index f713e30..0f174ba 100644 --- a/scala-scripting/script-engine/src/main/scala/org/apache/clerezza/scala/scripting/BundleContextScalaInterpreter.scala +++ b/scala-scripting/script-engine/src/main/scala/org/apache/clerezza/scala/scripting/BundleContextScalaInterpreter.scala @@ -29,18 +29,18 @@ import scala.tools.nsc.reporters.Reporter class BundleContextScalaInterpreter(bundleContext : BundleContext, out: PrintWriter) - extends IMain(new Settings, out) { + extends IMain(new Settings, out) { - def this(bundleContext : BundleContext) = { - this(bundleContext, new PrintWriter(System.out)) - } + def this(bundleContext : BundleContext) = { + this(bundleContext, new PrintWriter(System.out)) + } - override lazy val classLoader: AbstractFileClassLoader = { - new AbstractFileClassLoader(virtualDirectory, this.getClass.getClassLoader()) - } - override protected def newCompiler(settings: Settings, reporter: Reporter) = { - settings.outputDirs setSingleOutput virtualDirectory - new BundleContextScalaCompiler(bundleContext, settings, reporter) - } + override lazy val classLoader: AbstractFileClassLoader = { + new AbstractFileClassLoader(virtualDirectory, this.getClass.getClassLoader()) + } + override protected def newCompiler(settings: Settings, reporter: Reporter) = { + settings.outputDirs setSingleOutput virtualDirectory + new BundleContextScalaCompiler(bundleContext, settings, reporter) + } } http://git-wip-us.apache.org/repos/asf/clerezza/blob/35448624/scala-scripting/script-engine/src/main/scala/org/apache/clerezza/scala/scripting/BundleFS.scala ---------------------------------------------------------------------- diff --git a/scala-scripting/script-engine/src/main/scala/org/apache/clerezza/scala/scripting/BundleFS.scala b/scala-scripting/script-engine/src/main/scala/org/apache/clerezza/scala/scripting/BundleFS.scala index c66a9e3..32de7a6 100644 --- a/scala-scripting/script-engine/src/main/scala/org/apache/clerezza/scala/scripting/BundleFS.scala +++ b/scala-scripting/script-engine/src/main/scala/org/apache/clerezza/scala/scripting/BundleFS.scala @@ -27,161 +27,161 @@ package org.apache.clerezza.scala.scripting { - /** - * Implementation of {@link AbstractFile} on top of a {@link org.osgi.framework.Bundle} - */ - object BundleFS { - - /** - * Create a new {@link AbstractFile} instance representing an - * {@link org.osgi.framework.Bundle} - * @param bundle - */ - def create(bundle: Bundle): AbstractFile = { - require(bundle != null, "bundle must not be null") - - /** - * The superclass of FileEntry and DirEntry - */ - abstract class BundleEntry(url: URL, parent: DirEntry) extends AbstractFile { - require(url != null, "url must not be null") - lazy val (path: String, name: String) = getPathAndName(url) - lazy val fullName: String = (path::name::Nil).filter(!_.isEmpty).mkString("/") - - /** - * @return null - */ - def file: File = null - - //what if this is not a relative file? - def absolute = null - - /** - * @return last modification time or 0 if not known - */ - def lastModified: Long = - try { url.openConnection.getLastModified } - catch { case _: Exception => 0 } - - @throws(classOf[IOException]) - def container: AbstractFile = - valueOrElse(parent) { - throw new IOException("No container") - } - - @throws(classOf[IOException]) - def input: InputStream = url.openStream() - - /** - * Not supported. Always throws an IOException. - * @throws IOException - */ - @throws(classOf[IOException]) - def output = throw new IOException("not supported: output") - - def delete = throw new IOException("not supported: delete") - def create = throw new IOException("not supported: create") - - private def getPathAndName(url: URL): (String, String) = { - val u = url.getPath - var k = u.length - while( (k > 0) && (u(k - 1) == '/') ) - k = k - 1 - - var j = k - while( (j > 0) && (u(j - 1) != '/') ) - j = j - 1 - - (u.substring(if (j > 0) 1 else 0, if (j > 1) j - 1 else j), u.substring(j, k)) - } - - override def toString = fullName - } - - class DirEntry(url: URL, parent: DirEntry) extends BundleEntry(url, parent) { - - /** - * @return true - */ - def isDirectory: Boolean = true - - override def iterator: Iterator[AbstractFile] = { - new Iterator[AbstractFile]() { - val dirs = bundle.getEntryPaths(fullName) - def hasNext = if (dirs != null) { dirs.hasMoreElements} else {false} - def next = { - val entry = dirs.nextElement.asInstanceOf[String] - var entryUrl = bundle.getResource("/" + entry) - - // Bundle.getResource seems to be inconsistent with respect to requiring - // a trailing slash - if (entryUrl == null) - entryUrl = bundle.getResource("/" + removeTralingSlash(entry)) - - if (entryUrl == null) { - entryUrl = new URL(bundle.getResource("/"), entry) - if (entryUrl == null) { - throw new RuntimeException("Could not locate entry: "+entry+" in bundle: "+bundle) - } - } + /** + * Implementation of {@link AbstractFile} on top of a {@link org.osgi.framework.Bundle} + */ + object BundleFS { + + /** + * Create a new {@link AbstractFile} instance representing an + * {@link org.osgi.framework.Bundle} + * @param bundle + */ + def create(bundle: Bundle): AbstractFile = { + require(bundle != null, "bundle must not be null") + + /** + * The superclass of FileEntry and DirEntry + */ + abstract class BundleEntry(url: URL, parent: DirEntry) extends AbstractFile { + require(url != null, "url must not be null") + lazy val (path: String, name: String) = getPathAndName(url) + lazy val fullName: String = (path::name::Nil).filter(!_.isEmpty).mkString("/") + + /** + * @return null + */ + def file: File = null + + //what if this is not a relative file? + def absolute = null + + /** + * @return last modification time or 0 if not known + */ + def lastModified: Long = + try { url.openConnection.getLastModified } + catch { case _: Exception => 0 } + + @throws(classOf[IOException]) + def container: AbstractFile = + valueOrElse(parent) { + throw new IOException("No container") + } + + @throws(classOf[IOException]) + def input: InputStream = url.openStream() + + /** + * Not supported. Always throws an IOException. + * @throws IOException + */ + @throws(classOf[IOException]) + def output = throw new IOException("not supported: output") + + def delete = throw new IOException("not supported: delete") + def create = throw new IOException("not supported: create") + + private def getPathAndName(url: URL): (String, String) = { + val u = url.getPath + var k = u.length + while( (k > 0) && (u(k - 1) == '/') ) + k = k - 1 + + var j = k + while( (j > 0) && (u(j - 1) != '/') ) + j = j - 1 + + (u.substring(if (j > 0) 1 else 0, if (j > 1) j - 1 else j), u.substring(j, k)) + } + + override def toString = fullName + } + + class DirEntry(url: URL, parent: DirEntry) extends BundleEntry(url, parent) { + + /** + * @return true + */ + def isDirectory: Boolean = true + + override def iterator: Iterator[AbstractFile] = { + new Iterator[AbstractFile]() { + val dirs = bundle.getEntryPaths(fullName) + def hasNext = if (dirs != null) { dirs.hasMoreElements} else {false} + def next = { + val entry = dirs.nextElement.asInstanceOf[String] + var entryUrl = bundle.getResource("/" + entry) + + // Bundle.getResource seems to be inconsistent with respect to requiring + // a trailing slash + if (entryUrl == null) + entryUrl = bundle.getResource("/" + removeTralingSlash(entry)) + + if (entryUrl == null) { + entryUrl = new URL(bundle.getResource("/"), entry) + if (entryUrl == null) { + throw new RuntimeException("Could not locate entry: "+entry+" in bundle: "+bundle) + } + } - if (entry.endsWith(".class")) - new FileEntry(entryUrl, DirEntry.this) - else - new DirEntry(entryUrl, DirEntry.this) - } + if (entry.endsWith(".class")) + new FileEntry(entryUrl, DirEntry.this) + else + new DirEntry(entryUrl, DirEntry.this) + } - private def removeTralingSlash(s: String): String = { - if (s == null || s.length == 0) { - s - }else if (s.last == '/') { - removeTralingSlash(s.substring(0, s.length - 1)) - } else { - s - } - } - } - } - - def lookupName(name: String, directory: Boolean): AbstractFile = { - val entry = bundle.getEntry(fullName + "/" + name) - nullOrElse(entry) { entry => - if (directory) - new DirEntry(entry, DirEntry.this) - else - new FileEntry(entry, DirEntry.this) - } - } - - def lookupNameUnchecked(name: String, directory: Boolean): AbstractFile = { - val entry = bundle.getEntry(fullName + "/" + name) - if (entry == null) { - throw new RuntimeException("Not yet implemented: inexistendt file") - } else { - if (directory) - new DirEntry(entry, DirEntry.this) - else - new FileEntry(entry, DirEntry.this) - } - } - - } - - class FileEntry(url: URL, parent: DirEntry) extends BundleEntry(url, parent) { - - /** - * @return false - */ - def isDirectory: Boolean = false - override def sizeOption: Option[Int] = Some(bundle.getEntry(fullName).openConnection().getContentLength()) - override def iterator: Iterator[AbstractFile] = Iterator.empty - def lookupName(name: String, directory: Boolean): AbstractFile = null - def lookupNameUnchecked(name: String, directory: Boolean): AbstractFile = null - } - - new DirEntry(bundle.getResource("/"), null) - } - - } + private def removeTralingSlash(s: String): String = { + if (s == null || s.length == 0) { + s + }else if (s.last == '/') { + removeTralingSlash(s.substring(0, s.length - 1)) + } else { + s + } + } + } + } + + def lookupName(name: String, directory: Boolean): AbstractFile = { + val entry = bundle.getEntry(fullName + "/" + name) + nullOrElse(entry) { entry => + if (directory) + new DirEntry(entry, DirEntry.this) + else + new FileEntry(entry, DirEntry.this) + } + } + + def lookupNameUnchecked(name: String, directory: Boolean): AbstractFile = { + val entry = bundle.getEntry(fullName + "/" + name) + if (entry == null) { + throw new RuntimeException("Not yet implemented: inexistendt file") + } else { + if (directory) + new DirEntry(entry, DirEntry.this) + else + new FileEntry(entry, DirEntry.this) + } + } + + } + + class FileEntry(url: URL, parent: DirEntry) extends BundleEntry(url, parent) { + + /** + * @return false + */ + def isDirectory: Boolean = false + override def sizeOption: Option[Int] = Some(bundle.getEntry(fullName).openConnection().getContentLength()) + override def iterator: Iterator[AbstractFile] = Iterator.empty + def lookupName(name: String, directory: Boolean): AbstractFile = null + def lookupNameUnchecked(name: String, directory: Boolean): AbstractFile = null + } + + new DirEntry(bundle.getResource("/"), null) + } + + } } \ No newline at end of file http://git-wip-us.apache.org/repos/asf/clerezza/blob/35448624/scala-scripting/script-engine/src/main/scala/org/apache/clerezza/scala/scripting/CompilerService.scala ---------------------------------------------------------------------- diff --git a/scala-scripting/script-engine/src/main/scala/org/apache/clerezza/scala/scripting/CompilerService.scala b/scala-scripting/script-engine/src/main/scala/org/apache/clerezza/scala/scripting/CompilerService.scala index d21f7ec..56205b1 100644 --- a/scala-scripting/script-engine/src/main/scala/org/apache/clerezza/scala/scripting/CompilerService.scala +++ b/scala-scripting/script-engine/src/main/scala/org/apache/clerezza/scala/scripting/CompilerService.scala @@ -184,5 +184,5 @@ class CompilerService() extends BundleListener { } } - + } http://git-wip-us.apache.org/repos/asf/clerezza/blob/35448624/scala-scripting/script-engine/src/main/scala/org/apache/clerezza/scala/scripting/InterpreterFactory.scala ---------------------------------------------------------------------- diff --git a/scala-scripting/script-engine/src/main/scala/org/apache/clerezza/scala/scripting/InterpreterFactory.scala b/scala-scripting/script-engine/src/main/scala/org/apache/clerezza/scala/scripting/InterpreterFactory.scala index dda2595..fa1f5ba 100644 --- a/scala-scripting/script-engine/src/main/scala/org/apache/clerezza/scala/scripting/InterpreterFactory.scala +++ b/scala-scripting/script-engine/src/main/scala/org/apache/clerezza/scala/scripting/InterpreterFactory.scala @@ -30,22 +30,22 @@ import java.net._ class InterpreterFactory() { - - protected var bundles: Array[Bundle] = null - protected var bundleContext : BundleContext = null; + + protected var bundles: Array[Bundle] = null + protected var bundleContext : BundleContext = null; - def activate(componentContext: ComponentContext)= { - bundleContext = componentContext.getBundleContext - } + def activate(componentContext: ComponentContext)= { + bundleContext = componentContext.getBundleContext + } - def deactivate(componentContext: ComponentContext) = { - bundleContext = null - } + def deactivate(componentContext: ComponentContext) = { + bundleContext = null + } - def createInterpreter(out: PrintWriter) : IMain = { - val i = new BundleContextScalaInterpreter(bundleContext, out) - i - } + def createInterpreter(out: PrintWriter) : IMain = { + val i = new BundleContextScalaInterpreter(bundleContext, out) + i + } - + }