當前位置: 首頁>>代碼示例>>Java>>正文


Java Resource.toString方法代碼示例

本文整理匯總了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;
}
 
開發者ID:apache,項目名稱:incubator-rya,代碼行數:26,代碼來源:StatementSerializer.java

示例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;
        }
    }
}
 
開發者ID:apache,項目名稱:incubator-rya,代碼行數:52,代碼來源:IntersectionOfVisitor.java

示例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;
}
 
開發者ID:UCDenver-ccp,項目名稱:datasource,代碼行數:21,代碼來源:RdfRecordWriterImpl.java


注:本文中的org.openrdf.model.Resource.toString方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。