1 5 6 package org.joseki.test; 7 8 import java.util.* ; 9 import org.joseki.server.*; 10 import org.joseki.server.processors.*; 11 import org.joseki.vocabulary.JosekiVocab; 12 13 import com.hp.hpl.jena.rdf.model.*; 14 15 21 22 public class ClearModelProcessor extends ZeroArgProcessor 23 { 24 public ClearModelProcessor() 25 { 26 super("clear", ProcessorCom.WriteOperation, ProcessorCom.MutatesModel) ; 27 } 28 29 public String getInterfaceURI() { return JosekiVocab.getURI()+"OpClear" ; } 30 31 public Model execZeroArg(ModelSource src, Request request) 32 throws RDFException, ExecutionException 33 { 34 if ( super.mutatingOp && src.isImmutable() ) 35 throw new ExecutionException(ExecutionError.rcImmutableModel, "Immutable Model") ; 36 Model target = ((ModelSourceJena)src).getModel() ; 37 38 Set s = new HashSet() ; 40 for ( StmtIterator sIter = target.listStatements() ; sIter.hasNext() ; ) 41 s.add(sIter.next()) ; 42 for ( Iterator iter = s.iterator() ; iter.hasNext() ; ) 43 target.remove((Statement)iter.next()) ; 44 return super.emptyModel ; 45 } 46 } 47 48 74 | Popular Tags |