public static StageGenerator getGenerator(Context context) { if ( context == null ) return null ; return (StageGenerator)context.get(ARQ.stageGenerator) ; }
public static PropertyFunctionRegistry get(Context context) { if ( context == null ) return null ; return (PropertyFunctionRegistry)context.get(ARQConstants.registryPropertyFunctions) ; }
public static FunctionRegistry get(Context context) { if ( context == null ) return null ; return (FunctionRegistry)context.get(ARQConstants.registryFunctions) ; }
@Override public void start(Model accumulateResultModel, Context cxt) { acc = accumulateResultModel ; this.dataset = (Dataset)cxt.get(ARQConstants.sysCurrentDataset) ; }
private boolean isTrue(Symbol property, boolean dft) { Object x = get(property) ; if ( x == null ) return dft ; if ( x instanceof String ) { String s = (String)x ; if ( s.equalsIgnoreCase("true") ) return true ; } return x.equals(Boolean.TRUE) ; }
private boolean isFalse(Symbol property, boolean dft) { Object x = get(property) ; if ( x == null ) return dft ; if ( x instanceof String ) { String s = (String)x ; if ( s.equalsIgnoreCase("false") ) return true ; } return x.equals(Boolean.FALSE) ; }
@Override public Object setProperty(String propName, Object propValue) { Symbol sym = Symbol.create(basename + propName) ; Object oldObj = context.get(sym) ; return oldObj ; }
@Override public String toString() { String x = "" ; String sep = "" ; for ( Symbol s : keys() ) { Object value = get(s) ; x = x + sep + s + " = " + value ; sep = "\n" ; } return x ; }
static private JsonLdOptions getJsonLdOptions(String baseURI, Context jenaContext) { JsonLdOptions opts = null; if (jenaContext != null) { opts = (JsonLdOptions) jenaContext.get(JSONLD_OPTIONS); } if (opts == null) { opts = defaultJsonLdOptions(baseURI); } return opts; }
/** * Convenience method to get the {@link HttpContext} * * @return HttpContext */ public HttpContext getHttpContext() { return (HttpContext) getContext().get(HTTP_CONTEXT); }
static private Rewrite decideOptimizer(Context context) { RewriteFactory f = (RewriteFactory)context.get(ARQConstants.sysOptimizerFactory) ; if ( f == null ) f = factory ; if ( f == null ) f = stdOptimizationFactory ; // Only if default 'factory' gets lost. return f.create(context) ; }
public static Predicate<Tuple<NodeId>> getFilter(Context context) { Object x = context.get(SystemTDB.symTupleFilter) ; try { @SuppressWarnings("unchecked") Predicate<Tuple<NodeId>> f = (Predicate<Tuple<NodeId>>)x ; return f ; } catch (ClassCastException ex) { throw new TDBException("Not a Filter<Tuple<NodeId>>:"+x, ex) ; } }
@Override public Object setProperty(String propName, Object propValue) { Symbol sym = Symbol.create(basename + "#" + propName); Object oldObj = context.get(sym); context.set(sym, propValue); properties.put(propName, propValue) ; // These are added to any Jena RDFWriter (old-style, e.g. RDF/XML) in AdapterRDFWriter return oldObj; }
/** Get the {@link AuthorizationService} for an action/query/dataset */ static AuthorizationService getAuthorizationService(HttpAction action, DatasetGraph dsg) { if ( dsg instanceof DatasetGraphAccessControl ) return ((DatasetGraphAccessControl)dsg).getAuthService(); return dsg.getContext().get(DataAccessCtl.symAuthorizationService); }
private static void destroy(Dataset spatialDataset){ SpatialIndex index = (SpatialIndex)spatialDataset.getContext().get(SpatialQuery.spatialIndex); if (index instanceof SpatialIndexLucene){ deleteOldFiles(LUCENE_INDEX_DIR); deleteOldFiles(LUCENE_TDB_DIR); } } private static void emptyAndDeleteDirectory(File dir) {
@Override public NodeValue eval(NodeValue v, FunctionEnv env) { String baseIRI = null ; if ( env.getContext() != null ) { Query query = (Query)env.getContext().get(ARQConstants.sysCurrentQuery) ; if ( query != null ) baseIRI = query.getBaseURI() ; } return NodeFunctions.iri(v, baseIRI) ; }
@Override public void write(OutputStream outStream, boolean result, Context context) { XMLOutputASK out = new XMLOutputASK(outStream); if ( context != null && context.isDefined(xmlInstruction) ) out.xmlInst = context.isTrue(xmlInstruction); if ( context != null && context.isDefined(xmlStylesheet) ) out.stylesheetURL = (String)(context.get(xmlStylesheet)); out.exec(result); }
public static NodeValue get(Symbol symbol, FunctionEnv env) { Object obj = env.getContext().get(symbol); if ( obj == null ) throw new ExprEvalException("null for symbol: " + symbol); if ( !(obj instanceof Node) ) throw new ExprEvalException("Not a Node: " + Lib.className(obj)); Node n = (Node)obj; NodeValue nv = NodeValue.makeNode(n); return nv; } }
@Test public void testCxt3() { Context cxt = new Context() ; cxt.set(p1, "v") ; cxt.setIfUndef(p1, "w") ; Object v = cxt.get(p1) ; assertSame("Not as first set", "v", v) ; }
@Test public void testCxt2() { Context cxt = new Context() ; assertTrue("Defined in empty context", !cxt.isDefined(p1)) ; cxt.set(p1, "v") ; assertTrue("Not defined after .set", cxt.isDefined(p1)) ; Object v = cxt.get(p1) ; assertSame("Not the same", "v", v) ; }