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 2012/04/12 16:11:13 UTC

svn commit: r1325271 - /incubator/jena/Scratch/AFS/Jena-Dev/trunk/src/dev/Jena175_TDB_prefixes.java

Author: andy
Date: Thu Apr 12 14:11:12 2012
New Revision: 1325271

URL: http://svn.apache.org/viewvc?rev=1325271&view=rev
Log: (empty)

Added:
    incubator/jena/Scratch/AFS/Jena-Dev/trunk/src/dev/Jena175_TDB_prefixes.java

Added: incubator/jena/Scratch/AFS/Jena-Dev/trunk/src/dev/Jena175_TDB_prefixes.java
URL: http://svn.apache.org/viewvc/incubator/jena/Scratch/AFS/Jena-Dev/trunk/src/dev/Jena175_TDB_prefixes.java?rev=1325271&view=auto
==============================================================================
--- incubator/jena/Scratch/AFS/Jena-Dev/trunk/src/dev/Jena175_TDB_prefixes.java (added)
+++ incubator/jena/Scratch/AFS/Jena-Dev/trunk/src/dev/Jena175_TDB_prefixes.java Thu Apr 12 14:11:12 2012
@@ -0,0 +1,77 @@
+/**
+ * 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 dev;
+
+import java.util.Map ;
+
+import org.openjena.atlas.lib.FileOps ;
+import org.openjena.riot.SysRIOT ;
+
+import com.hp.hpl.jena.query.Dataset ;
+import com.hp.hpl.jena.query.ReadWrite ;
+import com.hp.hpl.jena.shared.PrefixMapping ;
+import com.hp.hpl.jena.sparql.core.DatasetPrefixStorage ;
+import com.hp.hpl.jena.tdb.TDBFactory ;
+import com.hp.hpl.jena.tdb.base.file.Location ;
+import com.hp.hpl.jena.tdb.transaction.DatasetGraphTransaction ;
+import com.hp.hpl.jena.util.FileManager ;
+
+public class Jena175_TDB_prefixes
+{
+    public static void main(String ... argv)
+    {
+        SysRIOT.wireIntoJena() ;
+        Location loc = Location.mem("XYZ") ; 
+
+        if ( ! loc.isMem() )
+            FileOps.clearDirectory(loc.getDirectoryPath()) ; 
+        
+        Dataset ds = TDBFactory.createDataset(loc) ;
+        ds.begin(ReadWrite.WRITE) ;
+        FileManager.get().readModel(ds.getDefaultModel(), "D.ttl") ;
+        ds.commit() ;
+        ds.end() ;
+
+        System.out.println("Prefixes (DS):") ;
+        
+        // BlockMgrFactory does not respect named mem locations. -- BlockAccessMem  
+        //DatasetPrefixStorage prefixes = SetupTDB.makePrefixes(loc, new DatasetControlNone()) ;
+        
+        ds.begin(ReadWrite.READ) ;
+        
+        DatasetPrefixStorage prefixes = ((DatasetGraphTransaction)ds.asDatasetGraph()).getDatasetGraphToQuery().getPrefixes() ;
+        
+        for ( String gn : prefixes.graphNames() )
+        {
+            System.out.println("Graph: "+gn) ;
+            PrefixMapping pmap = prefixes.getPrefixMapping(gn) ;
+            Map<String, String> x = pmap.getNsPrefixMap() ;
+            for ( String k : x.keySet() )
+                System.out.printf("  %-10s %s\n", k+":", x.get(k)) ;
+        }
+
+
+        System.out.println("Prefixes (dft model):") ;
+        Map<String, String> mapping = ds.getDefaultModel().getNsPrefixMap() ;
+        System.out.println(mapping) ;
+
+        ds.end() ;
+    }
+}
+