rdftemplate

Library for generating XML documents from RDF data using templates
git clone https://code.djc.id.au/git/rdftemplate/
commit 2d2d6aaf99d4ba3def2fc2f1fa478b62ca6f0866
parent 27c21cec0e8271e4c56b5746d8a04ca644ab8f78
Author: Dan Callaghan <djc@djc.id.au>
Date:   Wed, 30 Sep 2009 22:04:59 +1000

servlet which renders journal HTML using rdftemplate

Diffstat:
Mpom.xml | 5+++++
Msrc/main/java/au/com/miskinhill/rdftemplate/datatype/DateDataType.java | 13+++++++++----
Msrc/test/java/au/com/miskinhill/rdftemplate/TemplateInterpolatorUnitTest.java | 2+-
Msrc/test/java/au/com/miskinhill/rdftemplate/selector/SelectorEvaluationUnitTest.java | 2+-
4 files changed, 16 insertions(+), 6 deletions(-)
diff --git a/pom.xml b/pom.xml
@@ -71,6 +71,11 @@
         	<artifactId>joda-time</artifactId>
         	<version>1.6</version>
         </dependency>
+        <dependency>
+        	<groupId>org.springframework</groupId>
+        	<artifactId>spring-context</artifactId>
+        	<version>2.5.6</version>
+        </dependency>
     </dependencies>
     
 </project>
diff --git a/src/main/java/au/com/miskinhill/rdftemplate/datatype/DateDataType.java b/src/main/java/au/com/miskinhill/rdftemplate/datatype/DateDataType.java
@@ -3,6 +3,8 @@ package au.com.miskinhill.rdftemplate.datatype;
 import java.util.Arrays;
 import java.util.List;
 
+import org.springframework.stereotype.Component;
+
 import com.hp.hpl.jena.datatypes.DatatypeFormatException;
 import com.hp.hpl.jena.datatypes.RDFDatatype;
 import com.hp.hpl.jena.datatypes.TypeMapper;
@@ -11,13 +13,15 @@ import org.joda.time.LocalDate;
 import org.joda.time.format.DateTimeFormat;
 import org.joda.time.format.DateTimeFormatter;
 
+@Component
 public class DateDataType implements RDFDatatype {
     
     public static final String URI = "http://www.w3.org/TR/xmlschema-2/#date";
     
-    public static final DateDataType instance = new DateDataType();
-    public static void register() {
-        TypeMapper.getInstance().registerDatatype(instance);
+    @SuppressWarnings("unused")
+    private static DateDataType instance;
+    public static void registerStaticInstance() {
+        instance = new DateDataType();
     }
     
     private final List<DateTimeFormatter> parsers = Arrays.asList(
@@ -25,7 +29,8 @@ public class DateDataType implements RDFDatatype {
             DateTimeFormat.forPattern("yyyy-mm"),
             DateTimeFormat.forPattern("yyyy-mm-dd"));
 
-    private DateDataType() {
+    public DateDataType() {
+        TypeMapper.getInstance().registerDatatype(this);
     }
 
     @Override
diff --git a/src/test/java/au/com/miskinhill/rdftemplate/TemplateInterpolatorUnitTest.java b/src/test/java/au/com/miskinhill/rdftemplate/TemplateInterpolatorUnitTest.java
@@ -27,7 +27,7 @@ public class TemplateInterpolatorUnitTest {
     
     @BeforeClass
     public static void ensureDatatypesRegistered() {
-        DateDataType.register();
+        DateDataType.registerStaticInstance();
     }
     
     private Model model;
diff --git a/src/test/java/au/com/miskinhill/rdftemplate/selector/SelectorEvaluationUnitTest.java b/src/test/java/au/com/miskinhill/rdftemplate/selector/SelectorEvaluationUnitTest.java
@@ -26,7 +26,7 @@ public class SelectorEvaluationUnitTest {
     
     @BeforeClass
     public static void ensureDatatypesRegistered() {
-        DateDataType.register();
+        DateDataType.registerStaticInstance();
     }
     
     @Before