private Value castValue(Object val) throws RepositoryException {
if (val == null)
return null;
if (val instanceof ExtendedString) {
ExtendedString ves = (ExtendedString) val;
String valueString = ves.toString();
if (ves.getIriType() == ExtendedString.IRI && (ves.getStrType() & 0x01)==0x01) {
if (valueString.startsWith("_:")) {
valueString = valueString.substring(2);
return getRepository().getValueFactory().createBNode(valueString);
}
try {
if (valueString.indexOf(':') < 0)
return getRepository().getValueFactory().createURI(":" + valueString);
else
return getRepository().getValueFactory().createURI(valueString);
}
catch (IllegalArgumentException iaex) {
throw new RepositoryException("VirtuosoRepositoryConnection().castValue() Invalid value from Virtuoso: \"" + valueString + "\"", iaex);
}
}
else if (ves.getIriType() == ExtendedString.BNODE) {
try {
valueString = valueString.substring(9); // "nodeID://"
return getRepository().getValueFactory().createBNode(valueString);
}
catch (IllegalArgumentException iaex) {
throw new RepositoryException("VirtuosoRepositoryConnection().castValue() Invalid value from Virtuoso: \"" + valueString + "\"", iaex);
}
}
else {
try {
return getRepository().getValueFactory().createLiteral(valueString);
}
catch (IllegalArgumentException iaex) {
throw new RepositoryException("VirtuosoRepositoryConnection().castValue() Invalid value from Virtuoso: \"" + valueString + "\", STRTYPE = " + ves.getIriType(), iaex);
}
}
}
else if (val instanceof RdfBox) {
RdfBox rb = (RdfBox) val;