本文整理汇总了Java中org.apache.jena.util.ResourceUtils类的典型用法代码示例。如果您正苦于以下问题:Java ResourceUtils类的具体用法?Java ResourceUtils怎么用?Java ResourceUtils使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
ResourceUtils类属于org.apache.jena.util包,在下文中一共展示了ResourceUtils类的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: representation
import org.apache.jena.util.ResourceUtils; //导入依赖的package包/类
@Override
public InputStream representation() {
final ByteArrayOutputStream out = new ByteArrayOutputStream();
final RDFWriter writer = doc.getWriter(lang.getName());
// To allow relative URIs in XML, if desired
writer.setProperty("allowBadURIs", "true");
if (useRelativeURIs && Lang.NTRIPLES.equals(lang)) {
final URI uri = URI.create(resourceURI);
final String serviceDocURI = routing.serviceDocFor(uri).toString();
doc.listSubjects()
.andThen(
doc.listObjects()
.filterKeep(RDFNode::isURIResource)
.mapWith(RDFNode::asResource))
.filterKeep(Resource::isURIResource)
.filterKeep(u -> u.getURI().startsWith("#") || u.getURI().equals("")).toSet()
.forEach(r -> ResourceUtils.renameResource(r,
serviceDocURI + r.getURI()));
}
writer.write(doc, out, base);
return new ByteArrayInputStream(out.toByteArray());
}
示例2: replaceVar
import org.apache.jena.util.ResourceUtils; //导入依赖的package包/类
public QueryBuilder replaceVar(String varName, String uri)
{
if (varName == null) throw new IllegalArgumentException("Variable name cannot be null");
if (uri == null) throw new IllegalArgumentException("URI value cannot be null");
if (log.isTraceEnabled()) log.trace("Replacing variable ?{} with URI: {}", varName, uri);
Resource var = getVarByName(varName);
var.removeAll(SP.varName);
ResourceUtils.renameResource(var, uri);
return this;
}
示例3: isWhereVariable
import org.apache.jena.util.ResourceUtils; //导入依赖的package包/类
protected boolean isWhereVariable(Variable var)
{
ResIterator it = ResourceUtils.reachableClosure(getWhere()).
listSubjectsWithProperty(SP.varName, var.getName());
try
{
return it.hasNext();
}
finally
{
it.close();
}
}
示例4: build
import org.apache.jena.util.ResourceUtils; //导入依赖的package包/类
public Model build(Model model)
{
if (model == null) throw new IllegalArgumentException("Model cannot be null");
Map<Resource, String> resourceURIMap = new HashMap<>();
ResIterator resIt = model.listSubjects();
try
{
while (resIt.hasNext())
{
Resource resource = resIt.next();
if (resource.isAnon())
{
URI uri = build(resource);
if (uri != null) resourceURIMap.put(resource, uri.toString());
}
}
}
finally
{
resIt.close();
}
Iterator<Map.Entry<Resource, String>> entryIt = resourceURIMap.entrySet().iterator();
while (entryIt.hasNext())
{
Map.Entry<Resource, String> entry = entryIt.next();
ResourceUtils.renameResource(entry.getKey(), entry.getValue());
}
return model;
}
示例5: flatten
import org.apache.jena.util.ResourceUtils; //导入依赖的package包/类
/**
* Merges the version information onto a root VersionedThing.
*/
public static void flatten(Resource root, Resource version) {
ResourceUtils.renameResource(version, root.getURI());
root.removeAll(Version.currentVersion);
root.removeAll(Version.interval);
root.removeAll(DCTerms.isVersionOf);
root.removeAll(DCTerms.replaces);
}
示例6: skolemize
import org.apache.jena.util.ResourceUtils; //导入依赖的package包/类
/**
* If the entity is a bNode then skolemize it
*/
public void skolemize() {
if (entity != null && entity.isAnon()) {
String skolemURI = Registry.get().baseURI + "/.well-known/skolem/" + entity.getId();
ResourceUtils.renameResource(entity, skolemURI);
entity = entity.getModel().createResource( skolemURI );
}
}
示例7: relocate
import org.apache.jena.util.ResourceUtils; //导入依赖的package包/类
private void relocate() {
String uri = makeItemURI(parentURI, getNotation());
if ( ! uri.equals(root.getURI()) ) {
ResourceUtils.renameResource(root, uri);
}
root = root.getModel().createResource(uri);
}
示例8: relocateEntity
import org.apache.jena.util.ResourceUtils; //导入依赖的package包/类
private void relocateEntity(Resource srcEntity) {
String uri = entityURI(srcEntity);
if ( ! uri.equals(srcEntity.getURI()) ) {
ResourceUtils.renameResource(srcEntity, uri);
entity = srcEntity.getModel().createResource(uri);
} else {
entity = srcEntity;
}
}
示例9: normalizeRoot
import org.apache.jena.util.ResourceUtils; //导入依赖的package包/类
/**
* The query argument order of the root resouce can vary depending on execution
* environment, normalize it
*/
protected void normalizeRoot(Model m, String base, String arg) {
List<String> args = new ArrayList<>();
for (String a : arg.split("&")) args.add(a);
Set<String> perms = new HashSet<>();
permute(args, 0, perms);
for (String perm : perms) {
Resource r = m.getResource(base + "?" + perm);
if (r.listProperties().hasNext()) {
ResourceUtils.renameResource(r, base + "?" + arg);
}
}
}