protected final ValueSet loadSet(final Object file, final Object components) { final File inputFile; if (file instanceof File) { inputFile = (File) file; } else { inputFile = new File(file.toString()); } final String pattern = components.toString(); return new ValueSet(createHashSet(pattern, inputFile)); }
@Override public void handleStatement(final Statement statement) throws RDFHandlerException { this.threadScript.get().doHandle(statement); }
private HandlerScript newHandlerScript(final String name, final RDFHandler handler) { try { final HandlerScript script = (HandlerScript) GroovyProcessor.this.scriptClass .newInstance(); script.doInit(name, handler, GroovyProcessor.this.scriptArgs); return script; } catch (final Throwable ex) { throw new Error("Could not instantiate script class", ex); } }
@Override protected HandlerScript initialValue() { synchronized (PooledHandler.this) { final HandlerScript script = newHandlerScript("script" + PooledHandler.this.allScripts.size(), handler); try { script.doStart(PooledHandler.this.pass); } catch (final RDFHandlerException ex) { throw new RuntimeException(ex); } PooledHandler.this.allScripts.add(script); return script; } }
final void doHandle(final Statement statement) throws RDFHandlerException { this.statement = normalize(statement); if (this.handleEnabled) { if (tryInvokeMethod("handle", this.statement)) { return; } this.handleEnabled = false; LOGGER.debug("Using script body for " + this.name + " (no handle() method)"); } this.insideRun = true; try { this.run(); } finally { this.insideRun = false; } }
@Override public void startRDF() throws RDFHandlerException { super.startRDF(); for (final HandlerScript script : this.allScripts) { script.doStart(this.pass); } }
protected final boolean emitIfNot(@Nullable final Object condition) throws RDFHandlerException { if (condition == Boolean.FALSE) { emit(); return true; } return false; }
@Override public synchronized void handleStatement(final Statement statement) throws RDFHandlerException { this.script.doHandle(statement); }
private boolean tryInvokeMethod(final String method, final Object arg) throws RDFHandlerException { try { invokeMethod(method, arg); return true; } catch (final MissingMethodException ex) { return false; } }
@Override public synchronized void startRDF() throws RDFHandlerException { super.startRDF(); this.script.doStart(this.pass); }
@Override public synchronized void endRDF() throws RDFHandlerException { this.script.doEnd(this.pass++); super.endRDF(); }
public Object getProperty(final RDFHandler handler, final String name) { if (!(handler instanceof SingletonHandler)) { return null; } final SingletonHandler h = (SingletonHandler) handler; return h.getScript().getProperty(name); }
@Override public void endRDF() throws RDFHandlerException { for (final HandlerScript script : this.allScripts) { script.doEnd(this.pass); } ++this.pass; super.endRDF(); }
public Object setProperty(final RDFHandler handler, final String name, final Object value) { if (!(handler instanceof SingletonHandler)) { return null; } final SingletonHandler h = (SingletonHandler) handler; final Object oldValue = h.getScript().getProperty(name); h.getScript().setProperty(name, value); return oldValue; }
protected final boolean emitIf(@Nullable final Object condition) throws RDFHandlerException { if (condition == Boolean.TRUE) { emit(); return true; } return false; }