[Mulgara-svn] r1615 - branches/consistency/src/jar/content-rlog/java/org/mulgara/krule/rlog

pag at mulgara.org pag at mulgara.org
Tue Mar 17 19:49:59 UTC 2009


Author: pag
Date: 2009-03-17 12:49:59 -0700 (Tue, 17 Mar 2009)
New Revision: 1615

Modified:
   branches/consistency/src/jar/content-rlog/java/org/mulgara/krule/rlog/Program.java
Log:
Added support for imports

Modified: branches/consistency/src/jar/content-rlog/java/org/mulgara/krule/rlog/Program.java
===================================================================
--- branches/consistency/src/jar/content-rlog/java/org/mulgara/krule/rlog/Program.java	2009-03-17 19:49:12 UTC (rev 1614)
+++ branches/consistency/src/jar/content-rlog/java/org/mulgara/krule/rlog/Program.java	2009-03-17 19:49:59 UTC (rev 1615)
@@ -12,7 +12,8 @@
 
 package org.mulgara.krule.rlog;
 
-import java.net.URL;
+import java.net.URI;
+import java.net.URISyntaxException;
 import java.util.ArrayList;
 import java.util.Iterator;
 import java.util.List;
@@ -43,7 +44,7 @@
   private List<CanonicalStatement> canonicalStatements;
 
   /** The list of imports */
-  private List<URL> imports;
+  private List<URI> imports;
 
   /**
    * Constructs an empty program.
@@ -51,8 +52,10 @@
   public Program() {
     statements = new ArrayList<Statement>();
     canonicalStatements = new ArrayList<CanonicalStatement>();
+    imports = new ArrayList<URI>();
   }
 
+
   /**
    * Retrieve the statements from this program.
    * @return A list of statements in the program.
@@ -61,6 +64,7 @@
     return statements;
   }
 
+
   /**
    * Merges the statements from another program into this one.
    * Note that the parsing context of the foreign statements is maintained.
@@ -71,6 +75,7 @@
     for (Statement s: p.getStatements()) add(s);
   }
 
+
   /**
    * Adds a statement to this program. If the statement is already present it is skipped.
    * @param s The statement to add.
@@ -85,14 +90,30 @@
     }
   }
 
+
   /**
    * Adds an import directive to the program.
    */
-  public void addImport(URL imp) {
-    imports.add(imp);
+  public void addImport(String imp) throws ParseException {
+    try {
+      URI u = new URI(imp);
+      imports.add(u);
+    } catch (URISyntaxException e) {
+      throw new ParseException("Bad URL in import");
+    }
   }
 
+
   /**
+   * Get all the import URIs for the document
+   * @return A List of URIs. These can be absolute or relative.
+   */
+  public List<URI> getImports() {
+    return imports;
+  }
+
+
+  /**
    * Get an iterator for the statements in this program.
    * @return A new iterator that returns statements.
    */




More information about the Mulgara-svn mailing list