本文整理了Java中com.hp.hpl.jena.rdf.model.Resource.isURIResource
方法的一些代码示例,展示了Resource.isURIResource
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Resource.isURIResource
方法的具体详情如下:
包路径:com.hp.hpl.jena.rdf.model.Resource
类名称:Resource
方法名:isURIResource
暂无
代码示例来源:origin: epimorphics/elda
private String getId(Resource r) {
if (r.isURIResource()) return r.getURI();
String id = bnodes.get(r);
if (id == null) bnodes.put(r, id = "_:B" + bnodes.size());
return id;
}
代码示例来源:origin: DSpace/DSpace
protected String parseResourceGenerator(Resource resourceGenerator,
String value, String dsoIRI) {
if (resourceGenerator.isURIResource()
&& resourceGenerator.equals(DMRM.DSpaceObjectIRI)) {
return dsoIRI;
}
return parseValueProcessor(resourceGenerator, value);
}
代码示例来源:origin: epimorphics/elda
private void addIdentification( Trail t, Element e, Resource x ) {
if (x.isURIResource())
e.setAttribute( "href", x.getURI() );
else if (t.hasSeen( x )) {
e.setAttribute( "ref", idFor( e, x ) );
} else {
e.setAttribute( "id", idFor( e, x ) );
}
}
代码示例来源:origin: epimorphics/elda
/**
* Find a name to give a resource
*/
public static String getNameFor(Resource r) {
String label = getStringValue(r, RDFS.label);
if (label != null) return label;
if (r.isURIResource()) {
String uri = r.getURI();
int split = uri.lastIndexOf('#');
if (split == -1) split = uri.lastIndexOf('/');
return uri.substring(split + 1);
} else {
return r.getId().toString();
}
}
代码示例来源:origin: uk.ac.open.kmi.iserve/iserve-semantic-discovery
/**
* Given a query result from a SPARQL query, obtain the given variable value
* as a URL
*
* @param resultRow the result from a SPARQL query
* @param variableName the name of the variable to obtain
* @return the value or null if it could not be obtained
*/
private static URL getUrlValueFromRow(QuerySolution resultRow, String variableName) {
// Check the input and exit immediately if null
if (resultRow == null) {
return null;
}
URL result = null;
Resource res = resultRow.getResource(variableName);
// Ignore and track services that are blank nodes
if (res.isAnon()) {
log.warn("Blank node found and ignored " + res.toString());
} else if (res.isURIResource()) {
try {
result = new URL(res.getURI());
} catch (MalformedURLException e) {
log.error("Malformed URL for node", e);
} catch (ClassCastException e) {
log.error("The node is not a URI", e);
}
}
return result;
}
代码示例来源:origin: org.ow2.weblab.core.helpers/rdf-helper-jena
if (pred.equals(stat.getPredicate())) {
final Resource subj = stat.getSubject();
if (resType.equals(ResourceTypes.NAMED) && subj.isURIResource()) {
subjs.add(subj.getURI());
} else if (resType.equals(ResourceTypes.ANON) && subj.isAnon()) {
代码示例来源:origin: org.ow2.weblab.core.helpers/rdf-helper-jena
/**
* @param resType
* The type of the resources to retrieve, i.e. named or anonymous one.
* @return A <code>Set</code> of URIs or internal IDs resources that are subjects of statements in this model.
*/
protected Set<String> getSubjects(final ResourceTypes resType) {
final List<Statement> stats = this.listStatements();
final HashSet<String> subjs = new HashSet<String>();
for (final Statement stat : stats) {
final Resource subj = stat.getSubject();
if (resType.equals(ResourceTypes.NAMED) && subj.isURIResource()) {
subjs.add(subj.getURI());
} else if (resType.equals(ResourceTypes.ANON) && subj.isAnon()) {
subjs.add(subj.getId().getLabelString());
}
}
return subjs;
}
代码示例来源:origin: org.apache.clerezza.ext/org.apache.jena.jena-arq
private static Resource otherModel(Resource r, Model model)
{
if ( r.isURIResource() )
return model.createResource(r.getURI()) ;
if ( r.isAnon() )
return model.createResource(r.getId()) ;
// Literals do not need converting.
return r ;
}
代码示例来源:origin: com.hp.hpl.jena/arq
private static Resource otherModel(Resource r, Model model)
{
if ( r.isURIResource() )
return model.createResource(r.getURI()) ;
if ( r.isAnon() )
return model.createResource(r.getId()) ;
// Literals do not need converting.
return r ;
}
代码示例来源:origin: net.sf.taverna.t2.activities/sadi-activity
/**
* Fakes a de-reference operation, returning a byte stream over the node.
*/
public InputStream openStream(ReferenceContext context) {
try {
String result = "";
if (node == null) {
result = "";
} else if (node.isLiteral()) {
result = ((Literal) node).getLexicalForm();
} else if (node.isResource()) {
Resource resource = (Resource) node;
if (resource.isURIResource()) {
result = resource.getURI();
} else {
Model model = ResourceUtils.reachableClosure(resource);
StringWriter stringWriter = new StringWriter();
model.write(stringWriter, "RDF/XML-ABBREV");
result = stringWriter.toString();
}
}
return new ByteArrayInputStream(result.getBytes(getCharset()));
} catch (UnsupportedEncodingException e) {
throw new DereferenceException(e);
}
}
代码示例来源:origin: AskNowQA/AutoSPARQL
public Set<NamedClass> getAllClasses() {
Set<NamedClass> classes = new TreeSet<NamedClass>();
String query = "PREFIX owl: <http://www.w3.org/2002/07/owl#> SELECT ?c WHERE {?c a owl:Class} LIMIT 1000";
ResultSet q = queryable.query(query);
while (q.hasNext()) {
QuerySolution qs = q.next();
if(qs.getResource("c").isURIResource()){
classes.add(new NamedClass(qs.getResource("c").getURI()));
}
}
//remove trivial classes
classes.remove(new NamedClass(OWL.Nothing.toStringID()));
classes.remove(new NamedClass(OWL.Thing.toStringID()));
return classes;
}
代码示例来源:origin: Quetzal-RDF/quetzal
private static Resource otherModel(Resource r, Model model) {
if (r.isURIResource())
return model.createResource(r.getURI());
if (r.isAnon())
return model.createResource(r.getId());
return r;
}
}
代码示例来源:origin: org.apache.clerezza.ext/org.apache.jena.jena-core
/**
Answer the default OntModelSpec for this root, which will be
<code>DEFAULT</code> unless <code>root</code> has the JA
namespace and a local name which is the name of an OntModelSpec
constant (in OntModelSpec), in which case it's that constant's value.
*/
private OntModelSpec getDefault( Resource root )
{
if (root.isURIResource() && root.getNameSpace().equals( JA.uri ))
{
OntModelSpec oms = getOntModelSpecField( root.getLocalName() );
return oms == null ? DEFAULT : oms;
}
else
{
Resource like = getUniqueResource( root, JA.likeBuiltinSpec );
return like == null ? DEFAULT : getRequiredOntModelSpecField( like.getLocalName() );
}
}
代码示例来源:origin: uk.ac.open.kmi.iserve/iserve-semantic-discovery
destination = soln.getResource(MATCH_VAR + index);
if (origin != null && origin.isURIResource() && destination != null && destination.isURIResource()) {
originUri = new URI(origin.getURI());
matchUri = new URI(destination.getURI());
代码示例来源:origin: epimorphics/elda
public static MapLookup createMapLookup(Resource root, final Source ds) {
final Map<String, SPARQLMapLookup.Element> maps = new HashMap<String, SPARQLMapLookup.Element>();
//
List<Resource> mapSpecs = root.getModel().listSubjectsWithProperty(RDF.type, ELDA_API.SPARQLMap).toList();
for (Resource mapSpec: mapSpecs) {
String mapName = mapSpec.isURIResource()
? mapSpec.getURI()
: getResourceValue(mapSpec, ELDA_API.mapName).getURI()
;
String inName = getStringValue(mapSpec, ELDA_API.mapIn, "input");
String outName = getStringValue(mapSpec, ELDA_API.mapOut, "result");
String queryString = getStringValue(mapSpec,ELDA_API.mapQuery);
maps.put(mapName, new Element(inName, queryString, outName));
}
return new SPARQLMapLookup(ds, maps);
}
代码示例来源:origin: org.apache.clerezza.ext/org.apache.jena.jena-core
protected static void addSubclassesFrom( Model result, Model schema )
{
for (StmtIterator it = schema.listStatements( ANY, RDFS.subClassOf, ANY ); it.hasNext();)
{
Statement s = it.nextStatement();
if (s.getSubject().isURIResource() && s.getObject().isURIResource()) result.add( s );
}
}
代码示例来源:origin: DSpace/DSpace
protected Literal parseLiteralGenerator(Model m, Resource literalGenerator,
String value, String lang) {
if (literalGenerator.isURIResource()
&& literalGenerator.equals(DMRM.DSpaceValue)) {
return m.createLiteral(value);
代码示例来源:origin: de.unibonn.iai.eis/luzzu-semantics
public static String toSPARQL(Resource n){
if (n != null && (n.isResource() || n.isLiteral())){
if (n.isURIResource())
return "<" + n.getURI() + ">";
else if (n.isLiteral()) {
String sparql = "'''" + sparqlEncode(n.asLiteral().toString()) + "'''";
//does it have a Datatype Literal?
if (n.asLiteral().getDatatypeURI() != null){
sparql = sparql + "'''^^<" + n.asLiteral().getDatatypeURI().toString() + ">";
}
if (n.asLiteral().getLanguage() != ""){
sparql = sparql + "'''@" + n.asLiteral().getLanguage();
}
return sparql;
}
else return null; //TODO: throws exception
} else
return null; //TODO: throws exception
}
代码示例来源:origin: org.ow2.weblab.core.helpers/rdf-helper-jena
/**
* @param rs
* The reified statement to look for subject.
* @param type
* The type of the subject.
* @return The subject (uri or id) or null if an error occurs
*/
protected String getReifiedStatementSubject(final ReifiedStatement rs, final ResourceTypes type) {
String toRet = null;
final Resource subj = rs.getStatement().getSubject();
if (type.equals(ResourceTypes.ANON) && subj.isAnon()) {
toRet = subj.getId().getLabelString();
} else if (type.equals(ResourceTypes.NAMED) && subj.isURIResource()) {
toRet = subj.getURI();
}
return toRet;
}
代码示例来源:origin: usc-isi-i2/Web-Karma
if (!r.isURIResource())
continue;
内容来源于网络,如有侵权,请联系作者删除!