本文整理汇总了Java中org.openrdf.model.Resource.stringValue方法的典型用法代码示例。如果您正苦于以下问题:Java Resource.stringValue方法的具体用法?Java Resource.stringValue怎么用?Java Resource.stringValue使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.openrdf.model.Resource
的用法示例。
在下文中一共展示了Resource.stringValue方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: createStatementRegex
import org.openrdf.model.Resource; //导入方法依赖的package包/类
/**
* Creates a Regular Expression to match serialized statements meeting these constraints. A <code>null</code> or empty parameters imply
* no constraint. A <code>null</code> return value implies no constraints.
*
* @param context
* context constraint
* @param subject
* subject constraint
* @param predicates
* list of predicate constraints
* @return a regular expression that can be used to match serialized statements. A <code>null</code> return value implies no
* constraints.
*/
public static String createStatementRegex(StatementConstraints contraints) {
Resource context = contraints.getContext();
Resource subject = contraints.getSubject();
Set<URI> predicates = contraints.getPredicates();
if (context == null && subject == null && (predicates == null || predicates.isEmpty())) {
return null;
}
// match on anything but a separator
String anyReg = "[^" + SEP + "]*";
// if context is empty, match on any context
String contextReg = (context == null) ? anyReg : context.stringValue();
// if subject is empty, match on any subject
String subjectReg = (subject == null) ? anyReg : subject.stringValue();
// if the predicates are empty, match on any predicate. Otherwise, "or" the predicates.
String predicateReg = "";
if (predicates == null || predicates.isEmpty()) {
predicateReg = anyReg;
} else {
predicateReg = "(" + StringUtils.join(predicates, "|") + ")";
}
return "^" + contextReg + SEP + subjectReg + SEP + predicateReg + SEP + ".*";
}
示例2: TypeRequirementVisitor
import org.openrdf.model.Resource; //导入方法依赖的package包/类
public TypeRequirementVisitor(String varName, Resource requiredType) {
final Var typeVar = new Var("-const-" + requiredType.stringValue(), requiredType);
typeVar.setConstant(true);
this.varName = varName;
if (BASE_TYPES.contains(requiredType)) {
this.typeRequirement = null;
}
else {
this.typeRequirement = new StatementPattern(new Var(varName), RDF_TYPE_VAR, typeVar);
}
}
示例3: encodeIdentifier
import org.openrdf.model.Resource; //导入方法依赖的package包/类
private Object encodeIdentifier(final Resource identifier) {
if (identifier instanceof URI) {
try {
final Integer key = this.dictionary.keyFor((URI) identifier, false);
if (key != null) {
return AvroSerializer.newGenericRecord(AvroSchemas.COMPRESSED_IDENTIFIER, key);
}
} catch (final IOException ex) {
throw new IllegalStateException("Cannot access dictionary: " + ex.getMessage(), ex);
}
}
final String id = identifier instanceof BNode ? "_:" + ((BNode) identifier).getID()
: identifier.stringValue();
return AvroSerializer.newGenericRecord(AvroSchemas.PLAIN_IDENTIFIER, id);
}
示例4: encodeIdentifier
import org.openrdf.model.Resource; //导入方法依赖的package包/类
private Object encodeIdentifier(final Resource identifier) {
if (identifier instanceof URI) {
try {
final Integer key = this.dictionary.keyFor((URI) identifier, false);
if (key != null) {
return SerializerAvro.newGenericRecord(Schemas.COMPRESSED_IDENTIFIER, key);
}
} catch (final IOException ex) {
throw new IllegalStateException("Cannot access dictionary: " + ex.getMessage(), ex);
}
}
final String id = identifier instanceof BNode ? "_:" + ((BNode) identifier).getID()
: identifier.stringValue();
return SerializerAvro.newGenericRecord(Schemas.PLAIN_IDENTIFIER, id);
}
示例5: resourceToString
import org.openrdf.model.Resource; //导入方法依赖的package包/类
/**
* Returns the correct syntax for a Resource,
* depending on whether it is a URI or a Blank Node (ie, BNode)
*
* @param uriOrBnode The resource to serialise to a string
* @return The string value of the sesame resource
*/
private static String resourceToString(Resource uriOrBnode)
{
if(uriOrBnode instanceof URI)
{
return uriOrBnode.stringValue();
}
else
{
return "_:" + ((BNode)uriOrBnode).getID();
}
}
示例6: resourceToString
import org.openrdf.model.Resource; //导入方法依赖的package包/类
/**
* Returns the correct syntax for a Resource, depending on whether it is a URI
* or a Blank Node (ie, BNode)
*
* @param uriOrBnode
* The resource to serialise to a string
* @return The string value of the sesame resource
*/
private static String resourceToString(Resource uriOrBnode) {
if (uriOrBnode instanceof URI) {
return uriOrBnode.stringValue();
} else {
return "_:" + ((BNode) uriOrBnode).getID();
}
}