本文整理汇总了Java中org.openrdf.model.URI.equals方法的典型用法代码示例。如果您正苦于以下问题:Java URI.equals方法的具体用法?Java URI.equals怎么用?Java URI.equals使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.openrdf.model.URI
的用法示例。
在下文中一共展示了URI.equals方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: fromLiteral
import org.openrdf.model.URI; //导入方法依赖的package包/类
/**
* Create a blueprints property value from a datatyped literal.
* <p>
* Return a graph property from a datatyped literal using its
* XSD datatype.
* <p>
* Supports: Float, Double, Integer, Long, Boolean, Short, Byte, and String.
*/
default Object fromLiteral(final Literal l) {
final URI datatype = l.getDatatype();
if (datatype == null) {
return l.getLabel();
} else if (datatype.equals(XSD.FLOAT)) {
return l.floatValue();
} else if (datatype.equals(XSD.DOUBLE)) {
return l.doubleValue();
} else if (datatype.equals(XSD.INT)) {
return l.intValue();
} else if (datatype.equals(XSD.LONG)) {
return l.longValue();
} else if (datatype.equals(XSD.BOOLEAN)) {
return l.booleanValue();
} else if (datatype.equals(XSD.SHORT)) {
return l.shortValue();
} else if (datatype.equals(XSD.BYTE)) {
return l.byteValue();
} else {
return l.getLabel();
}
}
示例2: fallbackResolve
import org.openrdf.model.URI; //导入方法依赖的package包/类
/**
* Resolves terms that could not be resolved with the lucene approach. This
* brute-force function is significantly slower, but always works
*
* @param needles the URIs that produced errors in lucene
* @param possibles the set of all possible solutions
* @param hits populate this multimap with matches
* @param levy the string distance object to use to measure hits
* @param minDistance the minimum similarity measure
*/
private void fallbackResolve( Collection<URI> needles, Map<URI, String> possibles,
MultiMap<URI, Hit> hits, StringDistance levy, float minDistance ) {
log.debug( "falling back to resolve " + needles.size() + " items" );
for ( URI needle : needles ) {
String needlelabel = labels.get( needle );
for ( Map.Entry<URI, String> en : possibles.entrySet() ) {
URI match = en.getKey();
String matchlabel = en.getValue();
float distance = levy.getDistance( needlelabel, matchlabel );
if ( distance >= minDistance && !match.equals( needle ) ) {
hits.add( needle,
new Hit( match, matchlabel, uriToTypeLkp.get( match ), distance ) );
}
}
}
}
示例3: getPredicatesBetweenQA
import org.openrdf.model.URI; //导入方法依赖的package包/类
/**
* Derives a query adapter capable of pulling out the predicates that connect
* all subject nodes of a given type and all object nodes of a given type. The
* results will contain *all* types, so they will generally be run through {@link
* #getTopLevelRelations(java.util.Collection,
* com.ostrichemulators.semtool.rdf.engine.api.IEngine) } to get only the
* top-level relationships
*
* @param subjectNodeType The type (in URI form) of the subject node
* @param objectNodeType The type (in URI form) of the object node
* @param engine
* @return A proper query adapter capable of querying a knowledgebase for the
* desired predicates
*/
public static ListQueryAdapter<URI> getPredicatesBetweenQA( URI subjectNodeType,
URI objectNodeType, IEngine engine ) {
String q
= "SELECT DISTINCT ?relationship WHERE {\n"
+ " ?in a ?stype . \n"
+ " ?out a ?otype . \n"
+ " ?in ?relationship ?out .\n"
+ " FILTER( ?relationship != ?semrel )\n"
+ "}";
OneVarListQueryAdapter<URI> varq = OneVarListQueryAdapter.getUriList( q );
varq.useInferred( false );
varq.bind( "semrel", engine.getSchemaBuilder().getRelationUri().build() );
varq.bind( "stype", subjectNodeType );
if ( !objectNodeType.equals( Constants.ANYNODE ) ) {
varq.bind( "otype", objectNodeType );
}
log.debug( varq.bindAndGetSparql() );
return varq;
}
示例4: hasProperty
import org.openrdf.model.URI; //导入方法依赖的package包/类
public boolean hasProperty( URI needle, Map<String, String> namespaces ) {
ValueFactory vf = new ValueFactoryImpl();
for ( String head : keySet() ) {
if ( head.contains( ":" ) ) {
int idx = head.indexOf( ":" );
String headns = head.substring( 0, idx );
String localname = head.substring( idx + 1 );
if ( namespaces.containsKey( headns ) ) {
URI uri = vf.createURI( namespaces.get( headns ), localname );
if ( uri.equals( needle ) ) {
return true;
}
}
}
}
return false;
}
示例5: getEdge
import org.openrdf.model.URI; //导入方法依赖的package包/类
/**
* Gets nodes that have both in- and out- edges and are of the given type
*
* @param graph the graph to inspect
* @param type the node type that has the edges
* @param endpoint
* @return
*/
public static MultiMap<SEMOSSVertex, CondenserTuple>
findNodesToCondense( DirectedGraph<SEMOSSVertex, SEMOSSEdge> graph,
URI type, URI endpoint ) {
MultiMap<SEMOSSVertex, CondenserTuple> removers = new MultiMap<>();
for ( SEMOSSVertex middle : graph.getVertices() ) {
if ( type.equals( middle.getType() ) ) {
SEMOSSEdge upstream = getEdge( endpoint, middle, graph, true );
SEMOSSEdge downstream = getEdge( endpoint, middle, graph, false );
// FIXME: we might have multiple pairs of
// endpoints through our middle, so loop
//while ( !( null == upstream || null == downstream ) ) {
if ( !( null == upstream || null == downstream ) ) {
removers.add( middle, new CondenserTuple( upstream, downstream ) );
}
// upstream = getVertex( endpoint, middle, graph, true );
//downstream = getVertex( endpoint, middle, graph, false );
//}
}
}
return removers;
}
示例6: compare
import org.openrdf.model.URI; //导入方法依赖的package包/类
/**
* Compares two properties. Checks whether they are equal to the name of a
* node, type of node, name of an edge, type of an edge, or URI based on the
* constants class. Returns -1 if first string equals one of the listed
* constants and 1 if the second string equals one of the listed constants.
*
* @param str1 String First property to be compared.
* @param str2 String Second property to be compared.
*
* @return int Returns -1, 0, or 1
*/
@Override
public int compare( URI str1, URI str2 ) {
// first, check if we're dealing with one of our specified order elements
for ( URI prop : ordered ) {
if ( str1.equals( prop ) ) {
return -1;
}
else if ( str2.equals( prop ) ) {
return 1;
}
}
// nope, so do a string comparison
return str1.stringValue().compareToIgnoreCase( str2.stringValue() );
}
示例7: isUnselectionEvent
import org.openrdf.model.URI; //导入方法依赖的package包/类
private boolean isUnselectionEvent( URI selectedValue ) {
if ( selectedValue == null ) {
//i don't think this should happen, but just in case
lastSelectedValue = null;
return true;
}
if ( selectedValue.equals( lastSelectedValue ) ) {
lastSelectedValue = null;
return true;
}
lastSelectedValue = selectedValue;
return false;
}
示例8: getText
import org.openrdf.model.URI; //导入方法依赖的package包/类
/**
* Method transform. Transforms the label on a node vertex in the graph
*
* @param vertex DBCMVertex - the vertex to be transformed
*
* @return String - the property name of the vertex
*/
@Override
public String getText( QueryGraphElement vertex ) {
Map<URI, Set<Value>> properties = new HashMap<>( vertex.getAllValues() );
properties.remove( RDF.SUBJECT );
if ( properties.isEmpty() ) {
return "";
}
// make sure we display the sparql id
properties.put( RDF.SUBJECT,
new HashSet<>( Arrays.asList( new LiteralImpl( vertex.getQueryId() ) ) ) );
updateLabels( properties );
StringBuilder html = new StringBuilder();
html.append( "<html><!--" ).append( vertex.getURI() ).append( "-->" );
boolean first = true;
List<URI> orderedProps = new ArrayList<>( properties.keySet() );
Collections.sort( orderedProps, comparator );
for ( URI property : orderedProps ) {
Set<Value> values = properties.get( property );
for ( Value value : values ) {
String propval = ( null == value ? "" : value.stringValue() );
if ( null == propval || propval.isEmpty() ) {
propval = "<Any>";
}
if ( value instanceof URI ) {
propval = labels.get( URI.class.cast( value ) );
}
if ( !first ) {
html.append( "<font size='1'><br></font>" );
}
if ( vertex.hasProperty( property ) || RDF.SUBJECT.equals( property ) ) {
if ( vertex.isSelected( property ) ) {
html.append( "<b>" );
}
if ( property.equals( RDF.SUBJECT ) ) {
// special handling for the query name...italics and no label part
html.append( "<i>" ).append( chop( propval, 50 ) ).append( "</i>" );
}
else {
html.append( labels.get( property ) ).append( ": " ).
append( chop( propval, 50 ) );
}
if ( vertex.isSelected( property ) ) {
html.append( "</b>" );
}
}
}
first = false;
}
// html.append( " lev: " ).append( vertex.getLevel() );
html.append( "</html>" );
return html.toString();
}