1 5 6 package com.hp.hpl.jena.rdf.arp; 7 8 import org.xml.sax.ErrorHandler ; 9 10 17 public class ARPHandlers implements Cloneable { 18 private ErrorHandler errorHandler = new DefaultErrorHandler(); 19 private ExtendedHandler scopeHandler = nullScopeHandler; 20 private StatementHandler statementHandler = new StatementHandler() { 21 public void statement(AResource s, AResource p, AResource o) { 22 } 23 public void statement(AResource s, AResource p, ALiteral o) { 24 } 25 }; 26 private NamespaceHandler nameHandler = new NamespaceHandler() { 27 28 public void startPrefixMapping(String prefix, String uri) { 29 30 } 31 32 public void endPrefixMapping(String prefix) { 33 34 } 35 }; 36 37 ARPHandlers copy() { 38 try { 39 return (ARPHandlers)clone(); 40 } 41 catch (CloneNotSupportedException e){ 42 throw new java.lang.RuntimeException (e); 43 } 44 } 45 46 54 public ExtendedHandler setExtendedHandler(ExtendedHandler sh) { 55 ExtendedHandler old = scopeHandler; 56 scopeHandler = sh; 57 return old; 58 } 59 60 65 public NamespaceHandler setNamespaceHandler(NamespaceHandler sh) { 66 NamespaceHandler old = nameHandler; 67 nameHandler = sh; 68 return old; 69 } 70 71 76 public StatementHandler setStatementHandler(StatementHandler sh) { 77 StatementHandler old = statementHandler; 78 statementHandler = sh; 79 return old; 80 } 81 82 final static ExtendedHandler nullScopeHandler = new ExtendedHandler() { 83 84 public void endBNodeScope(AResource bnode) { 85 } 86 87 public void startRDF() { 88 } 89 90 public void endRDF() { 91 } 92 93 public boolean discardNodesWithNodeID() { 94 return true; 95 } 96 }; 97 98 126 public ErrorHandler setErrorHandler(ErrorHandler eh) { 127 ErrorHandler old = errorHandler; 128 errorHandler = eh; 129 return old; 130 } 131 132 135 ErrorHandler getErrorHandler() { 136 return errorHandler; 137 } 138 141 NamespaceHandler getNamespaceHandler() { 142 return nameHandler; 143 } 144 147 ExtendedHandler getExtendedHandler() { 148 return scopeHandler; 149 } 150 153 StatementHandler getStatementHandler() { 154 return statementHandler; 155 } 156 157 158 } 159 160 161 187 188 | Popular Tags |