Anonymous committed 3da9eba

Handle type literals when loading model

Comments (0)

Files changed (1)


     private Binding currentBinding;
     private DefaultHandler delegate = resultsHandler;
-    public ModelBuildingHandler() {
-    }
     public Model getModel() {
         return model;
-    private void handleTypeStart(final String qName) {
+    private void handleTypeStart(final String qName, final Attributes attributes) {
         if ("uri".equals(qName)) {
             delegate = uriHandler;
             delegate = bNodeHandler;
         else if ("literal".equals(qName)) {
+            literalHandler.setDataType(attributes.getValue("datatype"));
             delegate = literalHandler;
         return resource;
-    private void handleLiteralEnd(final String value) {
+    private void handleLiteralEnd(final String value, final String datatype) {
         delegate = bindingHandler;
         switch (currentBinding) {
             case SUBJECT:
                 throw new IllegalStateException("Binding: " + currentBinding);
             case OBJECT:
-                object = ResourceFactory.createPlainLiteral(value);
+                object = model.createTypedLiteral(value, datatype);
         public void startElement(final String uri, final String localName, final String qName, final Attributes attributes) throws SAXException {
-            handleTypeStart(qName);
+            handleTypeStart(qName, attributes);
     private class LiteralHandler extends DefaultHandler {
         private final StringBuilder value = new StringBuilder();
+        private String datatype;
         public void endElement(final String uri, final String localName, final String qName) throws SAXException {
             final String result = value.toString();
-            handleLiteralEnd(result);
+            handleLiteralEnd(result, datatype);
         public void characters(final char[] ch, final int start, final int length) throws SAXException {
             value.append(ch, start, length);
+        public void setDataType(final String datatype) {
+            this.datatype = datatype;
+        }
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.