本文整理了Java中com.hp.hpl.jena.rdf.model.Resource.getId
方法的一些代码示例,展示了Resource.getId
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Resource.getId
方法的具体详情如下:
包路径:com.hp.hpl.jena.rdf.model.Resource
类名称:Resource
方法名:getId
[英]Returns an a unique identifier for anonymous resources.
The id is unique within the scope of a particular implementation. All models within an implementation will use the same id for the same anonymous resource.
This method is undefined if called on resources which are not anonymous and may raise an exception.
[中]返回匿名资源的唯一标识符。
id在特定实现的范围内是唯一的。一个实现中的所有模型都将对同一匿名资源使用相同的id。
如果在非匿名资源上调用此方法,则此方法未定义,并且可能引发异常。
代码示例来源:origin: org.apache.clerezza.ext/org.apache.jena.jena-core
private String shortAnonId(Resource r) {
String result = anonMap.get(r.getId());
if (result == null) {
result = "A" + Integer.toString(anonCount++);
anonMap.put(r.getId(), result);
}
return result;
}
代码示例来源:origin: epimorphics/elda
private boolean seenbNode(Resource r) {
return bNodes.containsKey( r.getId() );
}
代码示例来源:origin: epimorphics/elda
private int bNodeIdFor(Resource r) {
AnonId id = r.getId();
Integer shortId = bNodes.get( id );
if (shortId == null) {
shortId = bnodeCount++;
bNodes.put(id, shortId);
}
return shortId;
}
代码示例来源:origin: epimorphics/elda
private String idFor( Element e, Resource x ) {
String id = idMap.get(x.getId());
if (id == null) idMap.put(x.getId(), id = newId(e.getTagName()) );
return id;
}
代码示例来源:origin: org.apache.clerezza.ext/org.apache.jena.jena-core
protected static void writeResource(Resource r, PrintWriter writer)
{
if (r.isAnon()) {
writer.print(anonName(r.getId()));
} else {
writer.print("<");
writeURIString(r.getURI(), writer);
writer.print(">");
}
}
static private boolean okURIChars[] = new boolean[128];
代码示例来源: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: org.apache.clerezza.ext/org.apache.jena.jena-core
private String longAnonId(Resource r) {
String rid = r.getId().toString();
return XMLChar.isValidNCName( rid ) ? rid : escapedId( rid );
}
代码示例来源:origin: org.smartdeveloperhub.curator/sdh-curator-connector
@Override
protected void consumeResource(FilterBuilder builder, Resource resource) {
builder.withVariable(ProtocolFactory.newVariable(resource.getId().getLabelString()));
}
}
代码示例来源: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: org.smartdeveloperhub.curator/sdh-curator-connector
private NamedValue createNamedValue(Resource resource) {
NamedValue result=null;
if(resource.isAnon()) {
result=ProtocolFactory.newVariable(resource.getId().getLabelString());
} else { // MUST BE RESOURCE
result=ProtocolFactory.newResource(resource.getURI());
}
return result;
}
代码示例来源: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: epimorphics/elda
protected String spelling( RDFNode n ) {
if (n.isURIResource()) return resourceSpelling( (Resource) n );
if (n.isLiteral()) return ((Literal) n).getLexicalForm();
String id = ((Resource) n).getId().toString();
return id;
}
代码示例来源: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: 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: anno4j/anno4j
/**
* Convert the given Jena Resource into a Sesame Resource
* @param theRes the jena resource to convert
* @return the jena resource as a sesame resource
*/
public static org.openrdf.model.Resource asSesameResource(Resource theRes) {
if (theRes == null) {
return null;
}
else if (theRes.canAs(Property.class)) {
return asSesameURI(theRes.as(Property.class));
}
else {
return FACTORY.createURI("urn:anno4j:" + theRes.getId().getLabelString());
}
}
代码示例来源:origin: Quetzal-RDF/quetzal
private static void closureNoTest(Resource r, Model closureBlob,
Collection<Resource> visited, ClosureTest test, Collection<String> resources) {
visited.add(r);
String gid = ((DB2Graph) r.getModel().getGraph()).getGraphID();
String key = null;
if (r.isAnon()) {
key = gid + ":" + r.getId();
} else {
key = gid + ":" + r.getURI();
}
if (resources.contains(key)) {
return;
}
resources.add(key);
StmtIterator sIter = r.listProperties();
for (; sIter.hasNext();) {
Statement stmt = sIter.nextStatement();
closure(stmt, closureBlob, visited, test, resources);
}
}
代码示例来源: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: org.apache.clerezza.ext/org.apache.jena.jena-arq
label = resource.getId().getLabelString() ;
else
代码示例来源:origin: org.ow2.weblab.core.helpers/rdf-helper-jena
/**
* @param rs
* The reified statement to look for object.
* @param type
* The type of the object.
* @return The object (literal value, id or uri) or null if an error occurs
*/
protected String getReifiedStatementObject(final ReifiedStatement rs, final RDFNodeTypes type) {
String toRet = null;
final RDFNode obj = rs.getStatement().getObject();
if (type.equals(RDFNodeTypes.ANON_R) && obj.isAnon()) {
toRet = ((Resource) obj).getId().getLabelString();
} else if (type.equals(RDFNodeTypes.LITERAL) && obj.isLiteral()) {
toRet = ((Literal) obj).getLexicalForm();
} else if (type.equals(RDFNodeTypes.NAMED_R) && obj.isURIResource()) {
toRet = ((Resource) obj).getURI();
}
return toRet;
}
代码示例来源:origin: org.smartdeveloperhub.curator/sdh-curator-connector
private void populateBindingValue(BindingBuilder builder, RDFNode node) {
LOGGER.trace("- Value {}",node);
if(node.isLiteral()) {
Literal literal=node.asLiteral();
builder.
withValue(
ProtocolFactory.
newLiteral().
withLexicalForm(literal.getLexicalForm()).
withDatatype(literal.getDatatypeURI()).
withLanguage(literal.getLanguage()));
} else if(node.isURIResource()) {
builder.withValue(ProtocolFactory.newResource(node.asResource().getURI()));
} else {
builder.withValue(ProtocolFactory.newVariable(node.asResource().getId().getLabelString()));
}
}
内容来源于网络,如有侵权,请联系作者删除!