You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@jena.apache.org by an...@apache.org on 2015/03/08 18:31:39 UTC
[1/3] jena git commit: JENA-886 : Add datatypes from XSD 1.1
Repository: jena
Updated Branches:
refs/heads/master d72568333 -> ec5b5dad8
JENA-886 : Add datatypes from XSD 1.1
xsd:dateTimeStamp, xsd:yearMonthDuration, xsd:dayTimeDuration
Project: http://git-wip-us.apache.org/repos/asf/jena/repo
Commit: http://git-wip-us.apache.org/repos/asf/jena/commit/03dc77f4
Tree: http://git-wip-us.apache.org/repos/asf/jena/tree/03dc77f4
Diff: http://git-wip-us.apache.org/repos/asf/jena/diff/03dc77f4
Branch: refs/heads/master
Commit: 03dc77f49562d96d658a02886fd3ea285b8bf980
Parents: d725683
Author: Andy Seaborne <an...@apache.org>
Authored: Sun Mar 8 17:13:19 2015 +0000
Committer: Andy Seaborne <an...@apache.org>
Committed: Sun Mar 8 17:13:19 2015 +0000
----------------------------------------------------------------------
.../hp/hpl/jena/datatypes/xsd/XSDDatatype.java | 12 ++
.../xsd/impl/XSDDateTimeStampType.java | 57 +++++++
.../xsd/impl/XSDDayTimeDurationType.java | 60 +++++++
.../xsd/impl/XSDYearMonthDurationType.java | 37 +++++
.../java/com/hp/hpl/jena/vocabulary/XSD.java | 12 ++
.../hp/hpl/jena/datatypes/TestDatatypes.java | 160 +++++++++++++++++++
.../com/hp/hpl/jena/datatypes/TestPackage.java | 40 +++++
.../java/com/hp/hpl/jena/test/TestPackage.java | 1 +
8 files changed, 379 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/jena/blob/03dc77f4/jena-core/src/main/java/com/hp/hpl/jena/datatypes/xsd/XSDDatatype.java
----------------------------------------------------------------------
diff --git a/jena-core/src/main/java/com/hp/hpl/jena/datatypes/xsd/XSDDatatype.java b/jena-core/src/main/java/com/hp/hpl/jena/datatypes/xsd/XSDDatatype.java
index aee2bcf..e4f2d72 100644
--- a/jena-core/src/main/java/com/hp/hpl/jena/datatypes/xsd/XSDDatatype.java
+++ b/jena-core/src/main/java/com/hp/hpl/jena/datatypes/xsd/XSDDatatype.java
@@ -176,9 +176,18 @@ public class XSDDatatype extends BaseDatatype {
/** Datatype representing xsd:dateTime */
public static final XSDDatatype XSDdateTime = new XSDDateTimeType("dateTime");
+ /** Datatype representing xsd:dateTime */
+ public static final XSDDatatype XSDdateTimeStamp = new XSDDateTimeStampType("dateTimeStamp");
+
/** Datatype representing xsd:duration */
public static final XSDDatatype XSDduration = new XSDDurationType();
+ /** Datatype representing xsd:dayTimeDration */
+ public static final XSDDatatype XSDdayTimeDuration = new XSDDayTimeDurationType();
+
+ /** Datatype representing xsd:yearMonthDuration */
+ public static final XSDDatatype XSDyearMonthDuration = new XSDYearMonthDurationType();
+
/** Datatype representing xsd:gDay */
public static final XSDDatatype XSDgDay = new XSDDayType("gDay");
@@ -570,7 +579,10 @@ public class XSDDatatype extends BaseDatatype {
tm.registerDatatype(XSDdate);
tm.registerDatatype(XSDtime);
tm.registerDatatype(XSDdateTime);
+ tm.registerDatatype(XSDdateTimeStamp);
tm.registerDatatype(XSDduration);
+ tm.registerDatatype(XSDyearMonthDuration);
+ tm.registerDatatype(XSDdayTimeDuration) ;
tm.registerDatatype(XSDgYearMonth);
tm.registerDatatype(XSDgMonthDay);
tm.registerDatatype(XSDgMonth);
http://git-wip-us.apache.org/repos/asf/jena/blob/03dc77f4/jena-core/src/main/java/com/hp/hpl/jena/datatypes/xsd/impl/XSDDateTimeStampType.java
----------------------------------------------------------------------
diff --git a/jena-core/src/main/java/com/hp/hpl/jena/datatypes/xsd/impl/XSDDateTimeStampType.java b/jena-core/src/main/java/com/hp/hpl/jena/datatypes/xsd/impl/XSDDateTimeStampType.java
new file mode 100644
index 0000000..7040697
--- /dev/null
+++ b/jena-core/src/main/java/com/hp/hpl/jena/datatypes/xsd/impl/XSDDateTimeStampType.java
@@ -0,0 +1,57 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.hp.hpl.jena.datatypes.xsd.impl;
+
+import com.hp.hpl.jena.datatypes.DatatypeFormatException ;
+import com.hp.hpl.jena.datatypes.xsd.impl.XSDDateTimeType ;
+
+public class XSDDateTimeStampType extends XSDDateTimeType {
+ public XSDDateTimeStampType(String name) {
+ // Pretend to to be dateTime then tweak the uri.
+ super("dateTime") ;
+ super.javaClass = null ;
+ super.uri = XSD + "#"+name ;
+ }
+
+ @Override
+ public Object parse(String lex) {
+ Object obj = super.parse(lex) ;
+ // At this point it is OK as an xsd:dateTime - check it has a timezone.
+ // timezoneFrag ::= 'Z' | ('+' | '-') (('0' digit | '1' [0-3]) ':' minuteFrag | '14:00')
+ if ( lex.indexOf('Z') != -1 )
+ return obj ;
+ // Check a legal xsd:dateTime ends with timezoneFrag
+ // Z or a +/- at length-6
+
+ // Avoid regex!
+ int n = lex.length() ;
+ char z = lex.charAt(n-6) ;
+ if ( z != '+' && z != '-' )
+ throw new DatatypeFormatException("Not valid as xsd:dateTimeStamp: "+lex) ;
+// || ! RiotChars.isDigit(lex.charAt(n-5))
+// || ! RiotChars.isDigit(lex.charAt(n-4))
+// || lex.charAt(n-3) != ':'
+// || ! RiotChars.isDigit(lex.charAt(n-2))
+// || ! RiotChars.isDigit(lex.charAt(n-1)) )
+ return obj ;
+ // Alternative:
+ //static Pattern p = Pattern.compile("\\d\\d:\\d\\d$") ;
+ //return p.matcher(x).find() ;
+ }
+ }
http://git-wip-us.apache.org/repos/asf/jena/blob/03dc77f4/jena-core/src/main/java/com/hp/hpl/jena/datatypes/xsd/impl/XSDDayTimeDurationType.java
----------------------------------------------------------------------
diff --git a/jena-core/src/main/java/com/hp/hpl/jena/datatypes/xsd/impl/XSDDayTimeDurationType.java b/jena-core/src/main/java/com/hp/hpl/jena/datatypes/xsd/impl/XSDDayTimeDurationType.java
new file mode 100644
index 0000000..4166a7c
--- /dev/null
+++ b/jena-core/src/main/java/com/hp/hpl/jena/datatypes/xsd/impl/XSDDayTimeDurationType.java
@@ -0,0 +1,60 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.hp.hpl.jena.datatypes.xsd.impl;
+
+import com.hp.hpl.jena.datatypes.DatatypeFormatException ;
+import com.hp.hpl.jena.datatypes.xsd.impl.XSDAbstractDateTimeType ;
+
+// Xerces 2.11.0 does not have xsd:dayTimeDuration.
+// Treat as duration with checking.
+public class XSDDayTimeDurationType extends XSDAbstractDateTimeType {
+ public XSDDayTimeDurationType() {
+ super("duration") ;
+ super.uri = XSD + "#dayTimeDuration" ;
+ }
+
+ @Override
+ public Object parse(String lex) {
+ Object obj = super.parse(lex) ;
+ // Must not have Y
+ if ( lex.indexOf('Y') != -1 )
+ // has year.
+ throw new DatatypeFormatException("Not valid as xsd:dayTimeDuration: "+lex) ;
+
+ int idx_T = lex.indexOf('T') ;
+ int idx_M = lex.indexOf('M') ;
+
+ if ( idx_T == -1 ) {
+ // There is no T ; must have D and no M.
+ if ( lex.indexOf('D') == -1 )
+ throw new DatatypeFormatException("Not valid as xsd:dayTimeDuration: "+lex) ;
+ if ( idx_M != -1 )
+ // M, no T -> month
+ throw new DatatypeFormatException("Not valid as xsd:dayTimeDuration: "+lex) ;
+ return obj ;
+ }
+
+ // Has T
+ // Must not have a M before T
+ if ( idx_M != -1 && idx_M < idx_T )
+ // M before T => month.
+ throw new DatatypeFormatException("Not valid as xsd:dayTimeDuration: "+lex) ;
+ return obj ;
+ }
+}
http://git-wip-us.apache.org/repos/asf/jena/blob/03dc77f4/jena-core/src/main/java/com/hp/hpl/jena/datatypes/xsd/impl/XSDYearMonthDurationType.java
----------------------------------------------------------------------
diff --git a/jena-core/src/main/java/com/hp/hpl/jena/datatypes/xsd/impl/XSDYearMonthDurationType.java b/jena-core/src/main/java/com/hp/hpl/jena/datatypes/xsd/impl/XSDYearMonthDurationType.java
new file mode 100644
index 0000000..bd58b94
--- /dev/null
+++ b/jena-core/src/main/java/com/hp/hpl/jena/datatypes/xsd/impl/XSDYearMonthDurationType.java
@@ -0,0 +1,37 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.hp.hpl.jena.datatypes.xsd.impl;
+
+import com.hp.hpl.jena.datatypes.DatatypeFormatException ;
+import com.hp.hpl.jena.datatypes.xsd.impl.XSDAbstractDateTimeType ;
+
+public class XSDYearMonthDurationType extends XSDAbstractDateTimeType {
+ public XSDYearMonthDurationType() {
+ super("duration") ;
+ super.uri = XSD + "#yearMonthDuration" ;
+ }
+
+ @Override
+ public Object parse(String lex) {
+ Object obj = super.parse(lex) ;
+ if ( lex.indexOf('D') != -1 || lex.indexOf('T') != -1 )
+ throw new DatatypeFormatException("Not valid as xsd:yearMonthDuration: "+lex) ;
+ return obj ;
+ }
+}
http://git-wip-us.apache.org/repos/asf/jena/blob/03dc77f4/jena-core/src/main/java/com/hp/hpl/jena/vocabulary/XSD.java
----------------------------------------------------------------------
diff --git a/jena-core/src/main/java/com/hp/hpl/jena/vocabulary/XSD.java b/jena-core/src/main/java/com/hp/hpl/jena/vocabulary/XSD.java
index c31d9b3..c141a25 100644
--- a/jena-core/src/main/java/com/hp/hpl/jena/vocabulary/XSD.java
+++ b/jena-core/src/main/java/com/hp/hpl/jena/vocabulary/XSD.java
@@ -147,9 +147,18 @@ public class XSD {
/** Resource URI for xsd:dateTime */
public static Resource dateTime;
+ /** Resource URI for xsd:dateTimeStamp */
+ public static Resource dateTimeStamp;
+
/** Resource URI for xsd:duration */
public static Resource duration;
+ /** Resource URI for xsd:yearMonthDuration */
+ public static Resource yearMonthDuration;
+
+ /** Resource URI for xsd:dayTimeDuration */
+ public static Resource dayTimeDuration;
+
/** Resource URI for xsd:gDay */
public static Resource gDay;
@@ -202,7 +211,10 @@ public class XSD {
date = ResourceFactory.createResource(XSDDatatype.XSDdate.getURI());
time = ResourceFactory.createResource(XSDDatatype.XSDtime.getURI());
dateTime = ResourceFactory.createResource(XSDDatatype.XSDdateTime.getURI());
+ dateTimeStamp = ResourceFactory.createResource(XSDDatatype.XSDdateTimeStamp.getURI());
duration = ResourceFactory.createResource(XSDDatatype.XSDduration.getURI());
+ yearMonthDuration = ResourceFactory.createResource(XSDDatatype.XSDyearMonthDuration.getURI());
+ dayTimeDuration = ResourceFactory.createResource(XSDDatatype.XSDdayTimeDuration.getURI());
gDay = ResourceFactory.createResource(XSDDatatype.XSDgDay.getURI());
gMonth = ResourceFactory.createResource(XSDDatatype.XSDgMonth.getURI());
gYear = ResourceFactory.createResource(XSDDatatype.XSDgYear.getURI());
http://git-wip-us.apache.org/repos/asf/jena/blob/03dc77f4/jena-core/src/test/java/com/hp/hpl/jena/datatypes/TestDatatypes.java
----------------------------------------------------------------------
diff --git a/jena-core/src/test/java/com/hp/hpl/jena/datatypes/TestDatatypes.java b/jena-core/src/test/java/com/hp/hpl/jena/datatypes/TestDatatypes.java
new file mode 100644
index 0000000..389be78
--- /dev/null
+++ b/jena-core/src/test/java/com/hp/hpl/jena/datatypes/TestDatatypes.java
@@ -0,0 +1,160 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.hp.hpl.jena.datatypes;
+
+import static org.junit.Assert.assertEquals ;
+import static org.junit.Assert.assertFalse ;
+import static org.junit.Assert.assertNotNull ;
+import static org.junit.Assert.assertTrue ;
+import org.junit.Test ;
+
+import com.hp.hpl.jena.datatypes.xsd.XSDDatatype ;
+import com.hp.hpl.jena.graph.NodeFactory ;
+import com.hp.hpl.jena.rdf.model.Resource ;
+import com.hp.hpl.jena.vocabulary.XSD ;
+
+public class TestDatatypes {
+
+ public XSDDatatype xsdDateTime = XSDDatatype.XSDdateTime ;
+ public XSDDatatype xsdDateTimeStamp = XSDDatatype.XSDdateTimeStamp ;
+ public XSDDatatype xsdDuration = XSDDatatype.XSDduration ;
+ public XSDDatatype xsdYearMonthDuration = XSDDatatype.XSDyearMonthDuration ;
+ public XSDDatatype xsdDayTimeDuration = XSDDatatype.XSDdayTimeDuration ;
+
+ @Test public void registration_01() { checkRegistration1("dateTime", XSD.dateTime); }
+ @Test public void registration_02() { checkRegistration1("dateTimeStamp", XSD.dateTimeStamp); }
+ @Test public void registration_03() { checkRegistration1("duration", XSD.duration); }
+ @Test public void registration_04() { checkRegistration1("yearMonthDuration", XSD.yearMonthDuration); }
+ @Test public void registration_05() { checkRegistration1("dayTimeDuration", XSD.dayTimeDuration); }
+
+ // xsd:dateTimeStamp
+
+ @Test public void dateTimeStamp_01() {
+ valid(xsdDateTime, "2015-02-23T15:21:18Z") ;
+ valid(xsdDateTimeStamp, "2015-02-23T15:21:18Z") ;
+ }
+
+ @Test public void dateTimeStamp_02() {
+ valid(xsdDateTime, "2015-02-23T15:21:18") ;
+ invalid(xsdDateTimeStamp, "2015-02-23T15:21:18") ;
+ }
+
+ @Test public void dateTimeStamp_03() {
+ invalid(xsdDateTime, "2015-02-23Z") ;
+ invalid(xsdDateTimeStamp, "2015-02-23Z") ;
+ }
+
+ @Test public void dateTimeStamp_04() {
+ valid(xsdDateTime, "2015-02-23T15:21:18.665Z") ;
+ valid(xsdDateTimeStamp, "2015-02-23T15:21:18.665Z") ;
+ }
+
+ @Test public void dateTimeStamp_05() {
+ valid(xsdDateTime, "2015-02-23T15:21:18.665+00:00") ;
+ valid(xsdDateTimeStamp, "2015-02-23T15:21:18.665+00:00") ;
+ }
+
+ @Test public void dateTimeStamp_06() {
+ invalid(xsdDateTime, "2015-02-23T15:21:18.665+15:00") ;
+ invalid(xsdDateTimeStamp, "2015-02-23T15:21:18.665+15:00") ;
+ }
+
+ // xsd:yearMonthDuration
+ @Test public void yearMonthDuration_01() {
+ valid(xsdDuration, "P1Y") ;
+ valid(xsdYearMonthDuration, "P1Y") ;
+ }
+
+ @Test public void yearMonthDuration_02() {
+ valid(xsdDuration, "-P1M") ;
+ valid(xsdYearMonthDuration, "-P1M") ;
+ }
+
+ @Test public void yearMonthDuration_03() {
+ valid(xsdYearMonthDuration, "P9Y10M") ;
+ valid(xsdYearMonthDuration, "P9Y10M") ;
+ }
+
+ @Test public void yearMonthDuration_04() {
+ valid(xsdDuration, "P1Y1D") ;
+ invalid(xsdYearMonthDuration, "P1Y1D") ;
+ }
+
+ @Test public void yearMonthDuration_05() {
+ valid(xsdDuration, "P1YT1M") ;
+ invalid(xsdYearMonthDuration, "P1YT1M") ;
+ }
+
+ @Test public void yearMonthDuration_06() {
+ valid(xsdDuration, "P1D") ;
+ invalid(xsdYearMonthDuration, "P1D") ;
+ }
+
+ // xsd:dayTimeDuration
+ @Test public void dayTimeDuration_01() {
+ valid(xsdDuration, "PT0S") ;
+ valid(xsdDayTimeDuration, "PT0S") ;
+ }
+
+ @Test public void dayTimeDuration_02() {
+ invalid(xsdDuration, "PT") ;
+ invalid(xsdDayTimeDuration, "PT") ;
+ }
+
+ @Test public void dayTimeDuration_03() {
+ valid(xsdDuration, "P1D") ;
+ valid(xsdDayTimeDuration, "P1D") ;
+ }
+
+ @Test public void dayTimeDuration_04() {
+ valid(xsdDuration, "PT1M") ;
+ valid(xsdDayTimeDuration, "PT1M") ;
+ }
+
+ @Test public void dayTimeDuration_05() {
+ valid(xsdDuration, "PT1S") ;
+ valid(xsdDayTimeDuration, "PT1S") ;
+ }
+
+ @Test public void dayTimeDuration_06() {
+ valid(xsdDuration, "PT1M") ;
+ invalid(xsdDayTimeDuration, "P1M") ;
+ }
+
+ @Test public void dayTimeDuration_07() {
+ invalid(xsdDuration, "P1DT") ;
+ invalid(xsdDayTimeDuration, "P1DT") ;
+ }
+
+ private void valid(XSDDatatype xsddatatype, String string) {
+ assertTrue("Expected valid: "+string, xsddatatype.isValid(string)) ;
+ }
+
+ private void invalid(XSDDatatype xsddatatype, String string) {
+ assertFalse("Expected invalid: "+string, xsddatatype.isValid(string)) ;
+ }
+
+ private void checkRegistration1(String localName, Resource r) {
+ XSDDatatype _xsd = (XSDDatatype)NodeFactory.getType(XSD.getURI() + localName) ;
+ assertNotNull(_xsd) ;
+ assertEquals(r.getURI(), _xsd.getURI()) ;
+ }
+
+}
+
http://git-wip-us.apache.org/repos/asf/jena/blob/03dc77f4/jena-core/src/test/java/com/hp/hpl/jena/datatypes/TestPackage.java
----------------------------------------------------------------------
diff --git a/jena-core/src/test/java/com/hp/hpl/jena/datatypes/TestPackage.java b/jena-core/src/test/java/com/hp/hpl/jena/datatypes/TestPackage.java
new file mode 100644
index 0000000..b470fc4
--- /dev/null
+++ b/jena-core/src/test/java/com/hp/hpl/jena/datatypes/TestPackage.java
@@ -0,0 +1,40 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.hp.hpl.jena.datatypes;
+
+import junit.framework.JUnit4TestAdapter ;
+import junit.framework.TestSuite ;
+
+/**
+ Collected test suite for the .datatype package.
+ (many other tests are elsewhere)
+*/
+
+public class TestPackage extends TestSuite {
+
+ static public TestSuite suite() {
+ return new TestPackage();
+ }
+
+ /** Creates new TestPackage */
+ private TestPackage() {
+ super("datatypes");
+ addTest(new JUnit4TestAdapter(TestDatatypes.class)) ;
+ }
+}
http://git-wip-us.apache.org/repos/asf/jena/blob/03dc77f4/jena-core/src/test/java/com/hp/hpl/jena/test/TestPackage.java
----------------------------------------------------------------------
diff --git a/jena-core/src/test/java/com/hp/hpl/jena/test/TestPackage.java b/jena-core/src/test/java/com/hp/hpl/jena/test/TestPackage.java
index b75da5b..7008367 100644
--- a/jena-core/src/test/java/com/hp/hpl/jena/test/TestPackage.java
+++ b/jena-core/src/test/java/com/hp/hpl/jena/test/TestPackage.java
@@ -41,6 +41,7 @@ public class TestPackage extends TestCase {
ts.setName("Jena") ;
addTest(ts, "System setup", TestSystemSetup.suite());
addTest(ts, "Enhanced", com.hp.hpl.jena.enhanced.test.TestPackage.suite());
+ addTest(ts, "Datatypes", com.hp.hpl.jena.datatypes.TestPackage.suite()) ;
addTest(ts, "Graph", com.hp.hpl.jena.graph.test.TestPackage.suite());
addTest(ts, "Mem", com.hp.hpl.jena.mem.test.TestMemPackage.suite() );
addTest(ts, "Mem2", com.hp.hpl.jena.mem.test.TestGraphMemPackage.suite() );
[2/3] jena git commit: Revise name/description for Fuseki POMs
Posted by an...@apache.org.
Revise name/description for Fuseki POMs
Project: http://git-wip-us.apache.org/repos/asf/jena/repo
Commit: http://git-wip-us.apache.org/repos/asf/jena/commit/7663226f
Tree: http://git-wip-us.apache.org/repos/asf/jena/tree/7663226f
Diff: http://git-wip-us.apache.org/repos/asf/jena/diff/7663226f
Branch: refs/heads/master
Commit: 7663226f03b76b4f2d8ea38358fb489b03ca2884
Parents: 03dc77f
Author: Andy Seaborne <an...@apache.org>
Authored: Sun Mar 8 17:13:57 2015 +0000
Committer: Andy Seaborne <an...@apache.org>
Committed: Sun Mar 8 17:13:57 2015 +0000
----------------------------------------------------------------------
jena-fuseki1/pom.xml | 4 ++--
jena-fuseki2/pom.xml | 7 +++++--
2 files changed, 7 insertions(+), 4 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/jena/blob/7663226f/jena-fuseki1/pom.xml
----------------------------------------------------------------------
diff --git a/jena-fuseki1/pom.xml b/jena-fuseki1/pom.xml
index 20aff08..18ceac2 100644
--- a/jena-fuseki1/pom.xml
+++ b/jena-fuseki1/pom.xml
@@ -20,9 +20,9 @@
<modelVersion>4.0.0</modelVersion>
<artifactId>jena-fuseki1</artifactId>
<packaging>jar</packaging>
- <name>Apache Jena - Fuseki1 (SPARQL 1.1 Server)</name>
+ <name>Apache Jena - Fuseki1</name>
<version>1.1.3-SNAPSHOT</version>
- <description>Fuseki is a SPARQL 1.1 Server which provides query, update and graph store protocol endpoints that can be used to expose triple store(s) over HTTP</description>
+ <description>Fuseki is a SPARQL 1.1 Server</description>
<url>http://jena.apache.org/</url>
<parent>
http://git-wip-us.apache.org/repos/asf/jena/blob/7663226f/jena-fuseki2/pom.xml
----------------------------------------------------------------------
diff --git a/jena-fuseki2/pom.xml b/jena-fuseki2/pom.xml
index 7f9b15c..7d91e7d 100644
--- a/jena-fuseki2/pom.xml
+++ b/jena-fuseki2/pom.xml
@@ -25,11 +25,14 @@
<relativePath>../jena-parent</relativePath>
</parent>
- <name>Apache Jena - Fuseki</name>
+ <name>Apache Jena - Fuseki - A SPARQL 1.1 Server</name>
<artifactId>jena-fuseki</artifactId>
<version>2.0.1-SNAPSHOT</version>
- <description>Apache Jena Fuseki</description>
+ <description>Fuseki is a SPARQL 1.1 Server which provides the SPARQL query,
+ SPARQL update and SPARQL graph store protocols.
+ </description>
+
<packaging>pom</packaging>
<url>http://jena.apache.org/</url>
[3/3] jena git commit: JENA-886 : Use datatypes from Jena datatypes.
Posted by an...@apache.org.
JENA-886 : Use datatypes from Jena datatypes.
xsd:dateTimeStamp, xsd:yearMonthDuration, xsd:dayTimeDuration
Project: http://git-wip-us.apache.org/repos/asf/jena/repo
Commit: http://git-wip-us.apache.org/repos/asf/jena/commit/ec5b5dad
Tree: http://git-wip-us.apache.org/repos/asf/jena/tree/ec5b5dad
Diff: http://git-wip-us.apache.org/repos/asf/jena/diff/ec5b5dad
Branch: refs/heads/master
Commit: ec5b5dad8a6d4da444b2525c6af061ee5196bbcd
Parents: 7663226
Author: Andy Seaborne <an...@apache.org>
Authored: Sun Mar 8 17:31:19 2015 +0000
Committer: Andy Seaborne <an...@apache.org>
Committed: Sun Mar 8 17:31:19 2015 +0000
----------------------------------------------------------------------
.../com/hp/hpl/jena/sparql/expr/NodeValue.java | 89 ++++++++------------
1 file changed, 33 insertions(+), 56 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/jena/blob/ec5b5dad/jena-arq/src/main/java/com/hp/hpl/jena/sparql/expr/NodeValue.java
----------------------------------------------------------------------
diff --git a/jena-arq/src/main/java/com/hp/hpl/jena/sparql/expr/NodeValue.java b/jena-arq/src/main/java/com/hp/hpl/jena/sparql/expr/NodeValue.java
index 1a16596..d08818f 100644
--- a/jena-arq/src/main/java/com/hp/hpl/jena/sparql/expr/NodeValue.java
+++ b/jena-arq/src/main/java/com/hp/hpl/jena/sparql/expr/NodeValue.java
@@ -31,7 +31,7 @@ import static com.hp.hpl.jena.datatypes.xsd.XSDDatatype.XSDgMonth ;
import static com.hp.hpl.jena.datatypes.xsd.XSDDatatype.XSDgMonthDay ;
import static com.hp.hpl.jena.datatypes.xsd.XSDDatatype.XSDgYear ;
import static com.hp.hpl.jena.datatypes.xsd.XSDDatatype.XSDgYearMonth ;
-import static com.hp.hpl.jena.datatypes.xsd.XSDDatatype.XSDinteger ;
+import static com.hp.hpl.jena.datatypes.xsd.XSDDatatype.* ;
import static com.hp.hpl.jena.datatypes.xsd.XSDDatatype.XSDstring ;
import static com.hp.hpl.jena.datatypes.xsd.XSDDatatype.XSDtime ;
import static com.hp.hpl.jena.sparql.expr.ValueSpaceClassification.VSPACE_BOOLEAN ;
@@ -1035,16 +1035,11 @@ public abstract class NodeValue extends ExprNode
}
// Jena code does not have these types (yet)
- private static final String dtXSDdateTimeStamp = XSD+"#dateTimeStamp" ;
- private static final String dtXSDdayTimeDuration = XSD+"#dayTimeDuration" ;
- private static final String dtXSDyearMonthDuration = XSD+"#yearMonthDuration" ;
private static final String dtXSDprecisionDecimal = XSD+"#precisionDecimal" ;
// Returns null for unrecognized literal.
- private static NodeValue _setByValue(Node node)
- {
+ private static NodeValue _setByValue(Node node) {
if ( NodeUtils.hasLang(node) )
- // Check for RDF 1.1!
return null ;
LiteralLabel lit = node.getLiteral() ;
String lex = lit.getLexicalForm() ;
@@ -1054,8 +1049,7 @@ public abstract class NodeValue extends ExprNode
// Only XSD supported.
// And (for testing) roman numerals.
String datatypeURI = datatype.getURI() ;
- if ( ! datatypeURI.startsWith(xsdNamespace) && ! SystemARQ.EnableRomanNumerals )
- {
+ if ( !datatypeURI.startsWith(xsdNamespace) && !SystemARQ.EnableRomanNumerals ) {
// Not XSD.
return null ;
}
@@ -1076,8 +1070,7 @@ public abstract class NodeValue extends ExprNode
// Order here is promotion order integer-decimal-float-double
- if ( ! datatype.equals(XSDdecimal) )
- {
+ if ( ! datatype.equals(XSDdecimal) ) {
// XSD integer and derived types
if ( XSDinteger.isValidLiteral(lit) )
{
@@ -1092,93 +1085,77 @@ public abstract class NodeValue extends ExprNode
}
}
- if ( datatype.equals(XSDdecimal) && XSDdecimal.isValidLiteral(lit) )
- {
+ if ( datatype.equals(XSDdecimal) && XSDdecimal.isValidLiteral(lit) ) {
BigDecimal decimal = new BigDecimal(lit.getLexicalForm()) ;
return new NodeValueDecimal(decimal, node) ;
}
-
- if ( datatype.equals(XSDfloat) && XSDfloat.isValidLiteral(lit) )
- {
+
+ if ( datatype.equals(XSDfloat) && XSDfloat.isValidLiteral(lit) ) {
// NB If needed, call to floatValue, then assign to double.
// Gets 1.3f != 1.3d right
float f = ((Number)lit.getValue()).floatValue() ;
return new NodeValueFloat(f, node) ;
}
- if ( datatype.equals(XSDdouble) && XSDdouble.isValidLiteral(lit) )
- {
+ if ( datatype.equals(XSDdouble) && XSDdouble.isValidLiteral(lit) ) {
double d = ((Number)lit.getValue()).doubleValue() ;
return new NodeValueDouble(d, node) ;
}
- // XXX Pending Jena update ...
- if ( ( datatype.equals(XSDdateTime) || dtXSDdateTimeStamp.equals(datatypeURI) ) &&
- XSDdateTime.isValid(lex) )
- {
+ if ( (datatype.equals(XSDdateTime) || datatype.equals(XSDdateTimeStamp)) && XSDdateTime.isValid(lex) ) {
XSDDateTime dateTime = (XSDDateTime)lit.getValue() ;
return new NodeValueDT(lex, node) ;
}
-
- if ( datatype.equals(XSDdate) && XSDdate.isValidLiteral(lit) )
- {
- // Jena datatype support works on masked dataTimes.
+
+ if ( datatype.equals(XSDdate) && XSDdate.isValidLiteral(lit) ) {
+ // Jena datatype support works on masked dataTimes.
XSDDateTime dateTime = (XSDDateTime)lit.getValue() ;
return new NodeValueDT(lex, node) ;
}
-
- if ( datatype.equals(XSDtime) && XSDtime.isValidLiteral(lit) )
- {
- // Jena datatype support works on masked dataTimes.
+
+ if ( datatype.equals(XSDtime) && XSDtime.isValidLiteral(lit) ) {
+ // Jena datatype support works on masked dataTimes.
XSDDateTime time = (XSDDateTime)lit.getValue() ;
return new NodeValueDT(lex, node) ;
}
-
- if ( datatype.equals(XSDgYear) && XSDgYear.isValidLiteral(lit) )
- {
+
+ if ( datatype.equals(XSDgYear) && XSDgYear.isValidLiteral(lit) ) {
XSDDateTime time = (XSDDateTime)lit.getValue() ;
return new NodeValueDT(lex, node) ;
}
- if ( datatype.equals(XSDgYearMonth) && XSDgYearMonth.isValidLiteral(lit) )
- {
+ if ( datatype.equals(XSDgYearMonth) && XSDgYearMonth.isValidLiteral(lit) ) {
XSDDateTime time = (XSDDateTime)lit.getValue() ;
return new NodeValueDT(lex, node) ;
}
- if ( datatype.equals(XSDgMonth) && XSDgMonth.isValidLiteral(lit) )
- {
+ if ( datatype.equals(XSDgMonth) && XSDgMonth.isValidLiteral(lit) ) {
XSDDateTime time = (XSDDateTime)lit.getValue() ;
return new NodeValueDT(lex, node) ;
}
-
- if ( datatype.equals(XSDgMonthDay) && XSDgMonthDay.isValidLiteral(lit) )
- {
+
+ if ( datatype.equals(XSDgMonthDay) && XSDgMonthDay.isValidLiteral(lit) ) {
XSDDateTime time = (XSDDateTime)lit.getValue() ;
return new NodeValueDT(lex, node) ;
}
- if ( datatype.equals(XSDgDay) && XSDgDay.isValidLiteral(lit) )
- {
+ if ( datatype.equals(XSDgDay) && XSDgDay.isValidLiteral(lit) ) {
XSDDateTime time = (XSDDateTime)lit.getValue() ;
return new NodeValueDT(lex, node) ;
}
+
+ if ( datatype.equals(XSDduration) && XSDduration.isValid(lex) ) {
+ Duration duration = xmlDatatypeFactory.newDuration(lex) ;
+ return new NodeValueDuration(duration, node) ;
+ }
- // XXX Pending Jena update ...
- if ( ( datatype.equals(XSDduration) ||
- dtXSDdayTimeDuration.equals(datatypeURI) ||
- dtXSDyearMonthDuration.equals(datatypeURI) ) &&
- XSDduration.isValid(lex) ) // use lex
- {
+ if ( datatype.equals(XSDyearMonthDuration) && XSDyearMonthDuration.isValid(lex) ) {
+ Duration duration = xmlDatatypeFactory.newDuration(lex) ;
+ return new NodeValueDuration(duration, node) ;
+ }
+ if ( datatype.equals(XSDdayTimeDuration) && XSDdayTimeDuration.isValid(lex) ) {
Duration duration = xmlDatatypeFactory.newDuration(lex) ;
-
- if ( dtXSDdayTimeDuration.equals(datatypeURI) && ! XSDFuncOp.isDayTime(duration) )
- return null ;
- if ( dtXSDyearMonthDuration.equals(datatypeURI) && ! XSDFuncOp.isYearMonth(duration) )
- return null ;
-
return new NodeValueDuration(duration, node) ;
}
- if ( datatype.equals(XSDboolean) && XSDboolean.isValidLiteral(lit) )
- {
+ if ( datatype.equals(XSDboolean) && XSDboolean.isValidLiteral(lit) ) {
boolean b = (Boolean) lit.getValue();
return new NodeValueBoolean(b, node) ;
}