use of org.apache.jena.sparql.util.Symbol in project jena by apache.
the class RDFReaderRIOT method setProperty.
@Override
public Object setProperty(String propName, Object propValue) {
Symbol sym = Symbol.create(basename + propName);
Object oldObj = context.get(sym);
return oldObj;
}
use of org.apache.jena.sparql.util.Symbol in project jena by apache.
the class RDFWriterRIOT method setProperty.
@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
return oldObj;
}
use of org.apache.jena.sparql.util.Symbol in project jena by apache.
the class ContextMBean method getMBeanInfo.
@Override
public MBeanInfo getMBeanInfo() {
/*
* MBeanAttributeInfo(String name, String type, String description, boolean isReadable, boolean isWritable, boolean isIs)
*/
MBeanAttributeInfo[] attrInfo = new MBeanAttributeInfo[context.size()];
int idx = 0;
for (Symbol sk : context.keys()) {
// Not all are settable - only is string, boolean, integer.
Object obj = context.get(sk);
boolean settable = false;
if (obj instanceof String)
settable = true;
if (obj instanceof Boolean)
settable = true;
if (obj instanceof Integer)
settable = true;
MBeanAttributeInfo attr = new MBeanAttributeInfo(sk.getSymbol(), "java.lang.String", sk.getSymbol(), true, settable, false);
attrInfo[idx++] = attr;
}
/*
* String className,
String description,
MBeanAttributeInfo[] attributes,
MBeanConstructorInfo[] constructors,
MBeanOperationInfo[] operations,
MBeanNotificationInfo[] notifications)
throws IllegalArgumentException
*/
MBeanInfo info = new MBeanInfo(this.getClass().getName(), "ARQ global context", attrInfo, // Constructors
null, // Operations
null, // Notifications
null);
return info;
}
use of org.apache.jena.sparql.util.Symbol in project jena by apache.
the class AssemblerUtils method setContext.
/** Look for and set context declarations.
* e.g.
* <pre>
* root ... ;
* ja:context [ ja:cxtName "arq:queryTimeout" ; ja:cxtValue "10000" ] ;
* ...
* </pre>
* Short name forms of context parameters can be used.
* Setting as string "undef" will remove the context setting.
*/
public static void setContext(Resource r, Context context) {
String qs = "PREFIX ja: <" + JA.getURI() + ">\nSELECT * { ?x ja:context [ ja:cxtName ?name ; ja:cxtValue ?value ] }";
QuerySolutionMap qsm = new QuerySolutionMap();
qsm.add("x", r);
QueryExecution qExec = QueryExecutionFactory.create(qs, r.getModel(), qsm);
ResultSet rs = qExec.execSelect();
while (rs.hasNext()) {
QuerySolution soln = rs.next();
String name = soln.getLiteral("name").getLexicalForm();
// Works for numbers as well!
String value = soln.getLiteral("value").getLexicalForm();
name = MappingRegistry.mapPrefixName(name);
Symbol symbol = Symbol.create(name);
if ("undef".equalsIgnoreCase(value))
context.remove(symbol);
else
context.set(symbol, value);
}
}
use of org.apache.jena.sparql.util.Symbol in project jena by apache.
the class SettingAssembler method open.
/*
* :setting [ :name tdbsym:name ; :value "SPO.idx" ]
*/
//@Override
public Object open(Assembler a, Resource root, Mode mode) {
Resource r = getResourceValue(root, pSetting);
String k = getAsStringValue(r, pName);
String v = getAsStringValue(r, pValue);
Symbol symbol = Symbol.create(k);
ARQ.getContext().set(symbol, v);
return r;
}