use of org.apache.jena.query.text.TextIndexException in project jena by apache.
the class Params method getParamSpecs.
protected static List<ParamSpec> getParamSpecs(Resource list) {
List<ParamSpec> result = new ArrayList<>();
Resource current = list;
while (current != null && !current.equals(RDF.nil)) {
Statement firstStmt = current.getProperty(RDF.first);
if (firstStmt == null) {
throw new TextIndexException("parameter list not well formed: " + current);
}
RDFNode first = firstStmt.getObject();
if (!first.isResource()) {
throw new TextIndexException("parameter specification must be an anon resource : " + first);
}
result.add(getParamSpec((Resource) first));
Statement restStmt = current.getProperty(RDF.rest);
if (restStmt == null) {
throw new TextIndexException("parameter list not terminated by rdf:nil");
}
RDFNode rest = restStmt.getObject();
if (!rest.isResource()) {
throw new TextIndexException("parameter list node is not a resource : " + rest);
}
current = (Resource) rest;
}
return result;
}
use of org.apache.jena.query.text.TextIndexException in project jena by apache.
the class Params method getType.
private static String getType(Resource node) {
Statement typeStmt = node.getProperty(TextVocab.pParamType);
Statement valueStmt = node.getProperty(TextVocab.pParamValue);
String type = null;
if (typeStmt == null) {
if (valueStmt == null) {
throw new TextIndexException("Parameter specification must have a text:paramValue: " + node);
}
RDFNode obj = valueStmt != null ? valueStmt.getObject() : null;
Literal lit = obj.asLiteral();
RDFDatatype rdfType = lit.getDatatype();
Class<?> clazz = rdfType.getJavaClass();
if (clazz == java.lang.Boolean.class) {
type = TYPE_BOOL;
} else if (clazz == java.math.BigInteger.class) {
type = TYPE_INT;
} else if (clazz == java.lang.String.class) {
type = TYPE_STRING;
}
} else {
Resource typeRes = typeStmt.getResource();
type = typeRes.getLocalName();
}
return type;
}
Aggregations