本文整理汇总了Java中org.openrdf.model.Resource.toString方法的典型用法代码示例。如果您正苦于以下问题:Java Resource.toString方法的具体用法?Java Resource.toString怎么用?Java Resource.toString使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.openrdf.model.Resource
的用法示例。
在下文中一共展示了Resource.toString方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: writeStatement
import org.openrdf.model.Resource; //导入方法依赖的package包/类
/**
* Write a {@link Statement} to a {@link String}
*
* @param statement
* the {@link Statement} to write
* @return a {@link String} representation of the statement
*/
public static String writeStatement(Statement statement) {
Resource subject = statement.getSubject();
Resource context = statement.getContext();
URI predicate = statement.getPredicate();
Value object = statement.getObject();
Validate.notNull(subject);
Validate.notNull(predicate);
Validate.notNull(object);
String s = "";
if (context == null) {
s = SEP + subject.toString() + SEP + predicate.toString() + SEP + object.toString();
} else {
s = context.toString() + SEP + subject.toString() + SEP + predicate.toString() + SEP + object.toString();
}
return s;
}
示例2: createJoinTree
import org.openrdf.model.Resource; //导入方法依赖的package包/类
/**
* Recursively creates a {@link TupleExpr} tree comprised of
* {@link InferJoin}s and {@link StatementPattern}s. The left arg is a
* {@link StatementPattern} and the right arg is either a
* {@link StatementPattern} if it's the final element or a nested
* {@link InferJoin}.<p>
* A list of {@code [:A, :B, :C, :D, :E]} with type {@code ?x} returns:
* <pre>
* InferJoin(
* StatementPattern(?x, rdf:type, :A),
* InferJoin(
* StatementPattern(?x, rdf:type, :B),
* InferJoin(
* StatementPattern(?x, rdf:type, :C),
* InferJoin(
* StatementPattern(?x, rdf:type, :D),
* StatementPattern(?x, rdf:type, :E)
* )
* )
* )
* )
* </pre>
* @param intersection a {@link List} of {@link Resource}s.
* @param typeVar the type {@link Var} to use as the subject for the
* {@link StatementPattern}.
* @param conVar the {@link Var} to use as the context for the
* {@link StatementPattern}.
* @return the {@link TupleExpr} tree. Returns {@code null} if
* {@code intersection} is empty. Returns a {@link StatementPattern} if
* {@code intersection}'s size is 1. Otherwise, returns an
* {@link InferJoin} which may contain more nested {@link InferJoin}s.
*/
private static TupleExpr createJoinTree(final List<Resource> intersection, final Var typeVar, final Var conVar) {
if (intersection.isEmpty()) {
return null;
} else {
final Var predVar = new Var(RDF.TYPE.toString(), RDF.TYPE);
final Resource resource = intersection.get(0);
final Var valueVar = new Var(resource.toString(), resource);
final StatementPattern left = new StatementPattern(typeVar, predVar, valueVar, conVar);
if (intersection.size() == 1) {
return left;
} else {
final List<Resource> subList = intersection.subList(1, intersection.size());
final TupleExpr right = createJoinTree(subList, typeVar, conVar);
final InferJoin join = new InferJoin(left, right);
join.getProperties().put(InferConstants.INFERRED, InferConstants.TRUE);
return join;
}
}
}
示例3: needToCheckFilter
import org.openrdf.model.Resource; //导入方法依赖的package包/类
/**
* if the input subject matches one of the prefixes for a primary key field then we do not need
* to check the filter b/c there is no way that field has been previously observed. Aside from
* saving time, this will also save on memory b/c there's no point in caching this field since
* it should not be observed again given its "primary key" status
*
* @param subject
* @param primaryKeyFieldValues
* will contain things like: F_SparseUniProtDatFileRecord_accession_
* @return true if the filter should be checked, false otherwise
*/
private boolean needToCheckFilter(Resource subject) {
String sub = subject.toString();
for (String key : primaryKeyFieldNames) {
if (sub.contains(key)) {
return false;
}
}
return true;
}