public void setHandlersWith(ARPHandlers newHh) { handlers = ARPHandlers.createNewHandlers() ; handlers.setErrorHandler(newHh.getErrorHandler()); handlers.setExtendedHandler(newHh.getExtendedHandler()); handlers.setNamespaceHandler(newHh.getNamespaceHandler()); handlers.setStatementHandler(newHh.getStatementHandler()); }
/** Internal use only */ public static ARPHandlers createNewHandlers() { return new ARPHandlers() ; }
public void useWith( ARPHandlers h ) { h.setStatementHandler( this ); h.setErrorHandler( this ); h.setNamespaceHandler( this ); }
arp.getHandlers().setErrorHandler(new ErrorHandler(){ @Override public void fatalError(SAXParseException e){ arp.getHandlers().setStatementHandler(new StatementHandler(){ @Override public void statement(AResource a, AResource b, ALiteral l){
arp = new ARP(); ARPHandlers handlers = arp.getHandlers(); handlers.setStatementHandler(getSH(true)); handlers.setNamespaceHandler(ap); handlers.setExtendedHandler(ap); handlers.setErrorHandler(eh);
/** * Parses the RDF/XML at the given URL into the given StatementHandler. */ public static void parseRDFXML(URL url, StatementHandler handler) throws IOException { ARP parser = new ARP(); parser.getHandlers().setStatementHandler(handler); URLConnection conn = url.openConnection(); String encoding = conn.getContentEncoding(); InputStream in = null; try { in = conn.getInputStream(); if (encoding == null) parser.load(in, url.toString()); else parser.load(new InputStreamReader(in, encoding), url.toString()); in.close(); } catch (org.xml.sax.SAXException e) { throw new OntopiaRuntimeException(e); } finally { if (in != null) in.close(); } }
final StringBuffer buf = new StringBuffer(); ARP arp = new ARP(); arp.getHandlers().setErrorHandler(new ErrorHandler() {
void endBnodeScope() { if (handlers.getExtendedHandler() != nullScopeHandler) { for ( String nodeId : nodeIdUserData.keySet() ) { ARPResource bn = new ARPResource( this, nodeId ); handlers.getExtendedHandler().endBNodeScope( bn ); } } }
void warning(Taint taintMe, int id, SAXParseException e) throws SAXParseException { try { switch (options.getErrorMode(id)) { case EM_IGNORE: break; case EM_WARNING: handlers.getErrorHandler().warning(e); break; case EM_ERROR: if (taintMe != null) taintMe.taint(); handlers.getErrorHandler().error(e); break; case EM_FATAL: handlers.getErrorHandler().fatalError(e); break; } } catch (SAXParseException xx) { throw xx; } catch (SAXException ee) { throw new WrappedException(ee); } if (e instanceof ParseException && ((ParseException) e).isPromoted()) throw e; if (options.getErrorMode(id) == EM_FATAL) { // If we get here, we shouldn't go on // throw an error into Jena. throw new FatalParsingErrorException(); } }
arp.getHandlers().setErrorHandler(new ErrorHandler(){ @Override public void fatalError(SAXParseException e){ arp.getHandlers().setStatementHandler(new StatementHandler(){ @Override public void statement(AResource a, AResource b, ALiteral l){
public void useWith( ARPHandlers h ) { h.setStatementHandler( this ); h.setErrorHandler( this ); h.setNamespaceHandler( this ); }
arp = new ARP(); ARPHandlers handlers = arp.getHandlers(); handlers.setStatementHandler(getSH(true)); handlers.setNamespaceHandler(ap); handlers.setExtendedHandler(ap); handlers.setErrorHandler(eh);
/** * Parses the RDF/XML at the given InputStream into the given StatementHandler. */ public static void parseRDFXML(InputStream in, StatementHandler handler) throws IOException { ARP parser = new ARP(); parser.getHandlers().setStatementHandler(handler); try { parser.load(in); } catch (org.xml.sax.SAXException e) { throw new OntopiaRuntimeException(e); } finally { if (in != null) in.close(); } } }
final StringBuffer buf = new StringBuffer(); ARP arp = new ARP(); arp.getHandlers().setErrorHandler(new ErrorHandler() {
void endBnodeScope() { if (handlers.getExtendedHandler() != nullScopeHandler) { for ( String nodeId : nodeIdUserData.keySet() ) { ARPResource bn = new ARPResource( this, nodeId ); handlers.getExtendedHandler().endBNodeScope( bn ); } } }
void warning(Taint taintMe, int id, SAXParseException e) throws SAXParseException { try { switch (options.getErrorMode(id)) { case EM_IGNORE: break; case EM_WARNING: handlers.getErrorHandler().warning(e); break; case EM_ERROR: if (taintMe != null) taintMe.taint(); handlers.getErrorHandler().error(e); break; case EM_FATAL: handlers.getErrorHandler().fatalError(e); break; } } catch (SAXParseException xx) { throw xx; } catch (SAXException ee) { throw new WrappedException(ee); } if (e instanceof ParseException && ((ParseException) e).isPromoted()) throw e; if (options.getErrorMode(id) == EM_FATAL) { // If we get here, we shouldn't go on // throw an error into Jena. throw new FatalParsingErrorException(); } }
public void setHandlersWith(ARPHandlers newHh) { handlers = ARPHandlers.createNewHandlers() ; handlers.setErrorHandler(newHh.getErrorHandler()); handlers.setExtendedHandler(newHh.getExtendedHandler()); handlers.setNamespaceHandler(newHh.getNamespaceHandler()); handlers.setStatementHandler(newHh.getStatementHandler()); }
public void testInterrupt() throws SAXException, IOException { ARP a = new ARP(); try ( InputStream in = new FileInputStream("testing/wg/miscellaneous/consistent001.rdf") ) { a.getHandlers().setStatementHandler(new StatementHandler() { int countDown = 10; a.getHandlers().setErrorHandler(new ErrorHandler(){ @Override public void error(SAXParseException exception) throws SAXException {
arp.getHandlers().setStatementHandler(rslt) ; arp.getHandlers().setErrorHandler(rslt) ; arp.getHandlers().setNamespaceHandler(rslt) ;
public void testDOMwithARP() throws SAXException, IOException { InputStream in = new FileInputStream("testing/wg/Class/conclusions001.rdf"); Document document = domParser .parse(in,"http://www.example.org/"); DOM2Model d2m = DOM2Model.createD2M("http://www.example.org/",null); d2m.getHandlers().setStatementHandler(this); try { d2m.load(document); } finally { d2m.close(); } assertEquals("Incorrect number of triples",3,count); }