jena-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cla...@apache.org
Subject svn commit: r1536294 - in /jena/trunk: jena-core/src/main/java/com/hp/hpl/jena/rdf/model/ jena-core/src/main/java/com/hp/hpl/jena/rdf/model/impl/ jena-core/src/test/java/com/hp/hpl/jena/rdf/model/test/ jena-security/src/main/java/org/apache/jena/securi...
Date Mon, 28 Oct 2013 09:48:03 GMT
Author: claude
Date: Mon Oct 28 09:48:03 2013
New Revision: 1536294

URL: http://svn.apache.org/r1536294
Log:
JENA-540
Added resetRDFWriterF() and removeWriter()
Updated documentation

Modified:
    jena/trunk/jena-core/src/main/java/com/hp/hpl/jena/rdf/model/RDFWriterF.java
    jena/trunk/jena-core/src/main/java/com/hp/hpl/jena/rdf/model/impl/ModelCom.java
    jena/trunk/jena-core/src/main/java/com/hp/hpl/jena/rdf/model/impl/RDFWriterFImpl.java
    jena/trunk/jena-core/src/test/java/com/hp/hpl/jena/rdf/model/test/TestRDFWriterMap.java
    jena/trunk/jena-security/src/main/java/org/apache/jena/security/model/impl/SecuredModelImpl.java

Modified: jena/trunk/jena-core/src/main/java/com/hp/hpl/jena/rdf/model/RDFWriterF.java
URL: http://svn.apache.org/viewvc/jena/trunk/jena-core/src/main/java/com/hp/hpl/jena/rdf/model/RDFWriterF.java?rev=1536294&r1=1536293&r2=1536294&view=diff
==============================================================================
--- jena/trunk/jena-core/src/main/java/com/hp/hpl/jena/rdf/model/RDFWriterF.java (original)
+++ jena/trunk/jena-core/src/main/java/com/hp/hpl/jena/rdf/model/RDFWriterF.java Mon Oct 28
09:48:03 2013
@@ -51,7 +51,22 @@ public interface RDFWriterF {
 /** set the class name for the RDFWriter for a langauge
  * @param lang the language for which this class should be used
  * @param className the class name for writers for this language
+ * @throws NullPointerException if lang or classname is null.
  * @return the old class name for this language
  */    
     public String setWriterClassName(String lang, String className);
+    
+    /**
+     * Resets the values to the initial condition.
+     */
+    public void resetRDFWriterF();
+    
+    /**
+     * Remove lang from list of writers.
+     * Must be one of the classes that was added using setWriterClassName()
+     * @param lang The lang to remove.
+     * @return the old class name for this language
+     * @throws IllegalArgumentException if lang is one of the initial languages
+     */
+    public String removeWriter( String lang ) throws IllegalArgumentException;
 }

Modified: jena/trunk/jena-core/src/main/java/com/hp/hpl/jena/rdf/model/impl/ModelCom.java
URL: http://svn.apache.org/viewvc/jena/trunk/jena-core/src/main/java/com/hp/hpl/jena/rdf/model/impl/ModelCom.java?rev=1536294&r1=1536293&r2=1536294&view=diff
==============================================================================
--- jena/trunk/jena-core/src/main/java/com/hp/hpl/jena/rdf/model/impl/ModelCom.java (original)
+++ jena/trunk/jena-core/src/main/java/com/hp/hpl/jena/rdf/model/impl/ModelCom.java Mon Oct
28 09:48:03 2013
@@ -300,6 +300,15 @@ implements Model, PrefixMapping, Lock
     }
 
     @Override
+    public void resetRDFWriterF()  {
+    	writerFactory.resetRDFWriterF();
+    }
+    
+    @Override
+    public String removeWriter( String lang ) throws IllegalArgumentException {
+    	return writerFactory.removeWriter( lang );
+    }
+    @Override
     public Model write(Writer writer) 
     {
         getWriter() .write(this, writer, "");

Modified: jena/trunk/jena-core/src/main/java/com/hp/hpl/jena/rdf/model/impl/RDFWriterFImpl.java
URL: http://svn.apache.org/viewvc/jena/trunk/jena-core/src/main/java/com/hp/hpl/jena/rdf/model/impl/RDFWriterFImpl.java?rev=1536294&r1=1536293&r2=1536294&view=diff
==============================================================================
--- jena/trunk/jena-core/src/main/java/com/hp/hpl/jena/rdf/model/impl/RDFWriterFImpl.java
(original)
+++ jena/trunk/jena-core/src/main/java/com/hp/hpl/jena/rdf/model/impl/RDFWriterFImpl.java
Mon Oct 28 09:48:03 2013
@@ -21,6 +21,7 @@ package com.hp.hpl.jena.rdf.model.impl;
 import com.hp.hpl.jena.*;
 import com.hp.hpl.jena.rdf.model.*;
 
+import java.util.Arrays;
 import java.util.Properties;
 import com.hp.hpl.jena.shared.*;
 import com.hp.hpl.jena.n3.N3JenaWriter;
@@ -79,12 +80,26 @@ public class RDFWriterFImpl extends Obje
     protected static final String PROPNAMEBASE = Jena.PATH + ".writer.";
 
     static { // static initializer - set default readers
-        langToClassName = new Properties();
+    	reset();
+    }
+    
+    private static void reset() {
+    	Properties newLangToClassName = new Properties();
         for (int i = 0; i < LANGS.length; i++) {
-            langToClassName.setProperty(
+        	newLangToClassName.setProperty(
                 LANGS[i],
                 JenaRuntime.getSystemProperty(PROPNAMEBASE + LANGS[i], DEFAULTWRITERS[i]));
         }
+        // do the setup all at once.
+        langToClassName = newLangToClassName;  	
+    }
+    
+    private static String remove( String lang) throws IllegalArgumentException {
+    	if (Arrays.asList( LANGS ).contains( lang ))
+    	{
+    		throw new IllegalArgumentException( lang+" is a required language set in initialization");
+    	}
+    	return langToClassName.remove(lang).toString();  	
     }
 
     /** Creates new RDFReaderFImpl */
@@ -128,4 +143,14 @@ public class RDFWriterFImpl extends Obje
         return oldClassName;
     }
 
+	@Override
+	public void resetRDFWriterF() {
+		reset();
+	}
+
+	@Override
+	public String removeWriter(String lang) throws IllegalArgumentException {
+		return remove(lang);
+	}
+
 }

Modified: jena/trunk/jena-core/src/test/java/com/hp/hpl/jena/rdf/model/test/TestRDFWriterMap.java
URL: http://svn.apache.org/viewvc/jena/trunk/jena-core/src/test/java/com/hp/hpl/jena/rdf/model/test/TestRDFWriterMap.java?rev=1536294&r1=1536293&r2=1536294&view=diff
==============================================================================
--- jena/trunk/jena-core/src/test/java/com/hp/hpl/jena/rdf/model/test/TestRDFWriterMap.java
(original)
+++ jena/trunk/jena-core/src/test/java/com/hp/hpl/jena/rdf/model/test/TestRDFWriterMap.java
Mon Oct 28 09:48:03 2013
@@ -125,6 +125,18 @@ public class TestRDFWriterMap extends Je
 				throw new JenaException(e);
 			}
 		}
+
+		@Override
+		public void resetRDFWriterF() {
+			// TODO Auto-generated method stub
+			
+		}
+
+		@Override
+		public String removeWriter(String lang) throws IllegalArgumentException {
+			// TODO Auto-generated method stub
+			return null;
+		}
 	}
 
 	public static final String TURTLE_WRITER_ALT2 = N3JenaWriter.turtleWriterAlt2;

Modified: jena/trunk/jena-security/src/main/java/org/apache/jena/security/model/impl/SecuredModelImpl.java
URL: http://svn.apache.org/viewvc/jena/trunk/jena-security/src/main/java/org/apache/jena/security/model/impl/SecuredModelImpl.java?rev=1536294&r1=1536293&r2=1536294&view=diff
==============================================================================
--- jena/trunk/jena-security/src/main/java/org/apache/jena/security/model/impl/SecuredModelImpl.java
(original)
+++ jena/trunk/jena-security/src/main/java/org/apache/jena/security/model/impl/SecuredModelImpl.java
Mon Oct 28 09:48:03 2013
@@ -93,6 +93,7 @@ import org.apache.jena.security.utils.Co
  */
 public class SecuredModelImpl extends SecuredItemImpl implements SecuredModel
 {
+
 	// a class that implements ModelChangedListener
 	private class SecuredModelChangedListener implements ModelChangedListener
 	{
@@ -1667,6 +1668,16 @@ public class SecuredModelImpl extends Se
 	{
 		return holder.getBaseItem().getWriter(lang);
 	}
+	
+	@Override
+	public void resetRDFWriterF() {
+		holder.getBaseItem().resetRDFWriterF();
+	}
+
+	@Override
+	public String removeWriter(String lang) throws IllegalArgumentException {
+		return holder.getBaseItem().removeWriter(lang);
+	}
 
 	@Override
 	public boolean independent()



Mime
View raw message