本文整理汇总了Java中org.openrdf.model.URI类的典型用法代码示例。如果您正苦于以下问题:Java URI类的具体用法?Java URI怎么用?Java URI使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
URI类属于org.openrdf.model包,在下文中一共展示了URI类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: apply
import org.openrdf.model.URI; //导入依赖的package包/类
/**
* Transform a statement pattern according to OWL-2 inverse properties
* axiom.
*
* @param node the node to transform
* @return list of nodes to visit next
*/
@Override
public List<QueryModelNode> apply(StatementPattern node) {
List<QueryModelNode> next = newNextList();
Var s = node.getSubjectVar();
Var p = node.getPredicateVar();
Var o = node.getObjectVar();
Var c = node.getContextVar();
URI uri = (URI) p.getValue();
String op = uri.stringValue();
Var p2;
// check if need to replace with op1 or op2
if (op.equals(op1)) {
p2 = new ConstVar(vf.createURI(op2));
} else {
p2 = new ConstVar(vf.createURI(op1));
}
StatementPattern left = node.clone();
// switch subject and object and replace predicate
StatementPattern right = new StatementPattern(o, p2, s, c);
node.replaceWith(new Union(left, right));
next.add(left);
next.add(right);
return next;
}
示例2: getAnimationInput
import org.openrdf.model.URI; //导入依赖的package包/类
public static Map<URI, URI> getAnimationInput( Frame frame, RetrievingLabelCache rlc,
IEngine engine, Collection<? extends GraphElement> gelements ) {
if ( !hasAnimationCandidates( gelements ) ) {
JOptionPane.showMessageDialog( frame, "No Animation Candidates",
"Nothing to Animate", JOptionPane.INFORMATION_MESSAGE );
return new HashMap<>();
}
MultiMap<URI, URI> modelvals = new MultiMap<>();
for ( GraphElement ge : gelements ) {
List<URI> countables = AbstractGraphElement.getCountablePropertyKeys( ge );
if ( !countables.isEmpty() ) {
modelvals.addAll( ge.getType(), countables );
}
}
String options[] = { "OK", "Cancel" };
GraphAnimationPanel inputs = new GraphAnimationPanel( rlc, engine, modelvals );
int ans = JOptionPane.showOptionDialog( frame, inputs, "Animate On...",
JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE, null, options,
options[0] );
return ( 0 == ans ? inputs.getAnimationInputs() : new HashMap<>() );
}
示例3: edgesFromVertex
import org.openrdf.model.URI; //导入依赖的package包/类
/**
* @see {@link Templates#EDGES_FROM_VERTEX}
*/
String edgesFromVertex(final BlazeVertex src, final Direction dir,
final List<URI> edgeLabels) {
final URI id = src.rdfId();
final StringBuilder vc = buildValuesClause(
new StringBuilder(), "?src", asList(id));
if (!edgeLabels.isEmpty()) {
buildValuesClause(vc, "?label", edgeLabels);
}
final String queryStr;
if (dir == Direction.BOTH) {
queryStr = EDGES_FROM_VERTEX_BOTH.replace(Templates.VALUES, vc.toString());
} else {
final String DIRECTION = dir == Direction.OUT ? FORWARD : REVERSE;
queryStr = EDGES_FROM_VERTEX.replace(Templates.VALUES, vc.toString())
.replace(Templates.DIRECTION, DIRECTION);
}
return queryStr;
}
示例4: refresh
import org.openrdf.model.URI; //导入依赖的package包/类
public void refresh( Collection<V> instances, SemossGraphVisualization vizzy ) {
data.clear();
viz = vizzy;
MultiMap<URI, URI> propmap = new MultiMap<>(); // type -> possible properties
for ( V v : instances ) {
Set<URI> keys = v.getPropertyKeys();
if ( propmap.containsKey( v.getType() ) ) {
keys.addAll( propmap.get( v.getType() ) );
}
propmap.put( v.getType(), new ArrayList<>( keys ) );
}
for ( Map.Entry<URI, List<URI>> en : propmap.entrySet() ) {
data.add( new ControlDataRow( en.getKey(), Constants.ANYNODE ) );
for ( URI prop : en.getValue() ) {
ControlDataRow row = new ControlDataRow( en.getKey(), prop );
data.add( row );
}
}
Collections.sort( data );
fireTableDataChanged();
}
示例5: testPrint
import org.openrdf.model.URI; //导入依赖的package包/类
@Test
public void testPrint() throws Exception {
DirectedGraph<URI, URI> graph = new DirectedSparseGraph<>();
graph.addVertex( YURI );
graph.addVertex( YUGO );
graph.addEdge( YPY, YURI, YUGO, EdgeType.DIRECTED );
Collection<URI> roots = Arrays.asList( YURI );
GraphToTreeConverter.Search search = GraphToTreeConverter.Search.DFS;
Forest<URI, URI> result = GraphToTreeConverter.convert( graph, roots, search );
Logger log = Logger.getLogger( GraphToTreeConverter.class );
StringWriter stringy = new StringWriter();
WriterAppender app = new WriterAppender( new SimpleLayout(), stringy );
log.setLevel( Level.DEBUG );
log.addAppender( app );
GraphToTreeConverter.printForest( result );
String output = stringy.toString().replaceAll( "\\s", "" );
assertEquals( "DEBUG-http://semoss.va.gov/database/T44889381-85ce-43e3-893d-6267fd480660/YuriDEBUG-http://semoss.va.gov/database/T44889381-85ce-43e3-893d-6267fd480660/Yugo", output );
}
示例6: getDatatype
import org.openrdf.model.URI; //导入依赖的package包/类
/**
* Gets the datatype of the given val. If val is null, returns null. It
* returns {@link XMLSchema#ANYURI} for a URI, {@link XMLSchema#ENTITY} for a
* BNode, and {@link Literal#getDatatype()} if it's a literal. If it's not a
* {@link Value}, then it is converted to a Value first, and reprocessed. If
* we have a literal, but a null datatype, returns {@link XMLSchema#STRING}
*
* @param val
* @return
*/
public static URI getDatatype( Object val ) {
if ( null == val ) {
return null;
}
if ( val instanceof URI ) {
return XMLSchema.ANYURI;
}
else if ( val instanceof Literal ) {
Literal l = Literal.class.cast( val );
return ( null == l.getDatatype() ? XMLSchema.STRING : l.getDatatype() );
}
else if ( val instanceof BNode ) {
return XMLSchema.ENTITY;
}
Class<?> theClass = val.getClass();
return REVTYPELOOKUP.getOrDefault( theClass, XMLSchema.STRING );
}
示例7: 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;
}
示例8: validateIds
import org.openrdf.model.URI; //导入依赖的package包/类
/**
* Helper to parse URIs from a list of element ids for lookup of
* vertices or edges.
*
* @see #vertices(Object...)
* @see #edges(Object...)
*/
private List<URI> validateIds(final Object... elementIds) {
ElementHelper.validateMixedElementIds(Element.class, elementIds);
return Stream.of(elementIds)
.map(elementId -> {
if (elementId instanceof String) {
return (String) elementId;
} else if (elementId instanceof Element) {
final Object id = ((Element) elementId).id();
if (id instanceof String) {
return (String) id;
}
}
throw new IllegalArgumentException(
"Unknown element id type: " + elementId +
" ("+ elementId.getClass()+")");
})
.map(vf::elementURI)
.collect(Collectors.toList());
}
示例9: testDfs
import org.openrdf.model.URI; //导入依赖的package包/类
@Test
public void testDfs() throws Exception {
DirectedGraph<URI, URI> graph = new DirectedSparseGraph<>();
graph.addVertex( YURI );
graph.addVertex( YUGO );
graph.addEdge( YPY, YURI, YUGO, EdgeType.DIRECTED );
Collection<URI> roots = Arrays.asList( YURI );
GraphToTreeConverter.Search search = GraphToTreeConverter.Search.DFS;
Forest<URI, URI> result = GraphToTreeConverter.convert( graph, roots, search );
assertEquals( 1, result.getTrees().size() );
Tree<URI, URI> tree = result.getTrees().iterator().next();
assertEquals( YURI, tree.getRoot() );
assertEquals( YUGO, tree.getChildren( YURI ).iterator().next() );
}
示例10: update
import org.openrdf.model.URI; //导入依赖的package包/类
@Override
public void update( User user ) throws Exception {
RepositoryConnection rc = store.getConnection();
try {
Map<URI, DbAccess> accesses = getAccesses( user );
Resource id = getId( user, rc );
if ( null != id ) {
rc.begin();
rc.remove( id, null, null );
rc.add( getCreateStatements( id, user, rc.getValueFactory() ) );
addAccesses( id, accesses, rc );
rc.commit();
}
}
catch ( RepositoryException e ) {
log.error( e, e );
try {
rc.rollback();
}
catch ( Exception x ) {
log.warn( x, x );
}
}
}
示例11: getCopier
import org.openrdf.model.URI; //导入依赖的package包/类
private static RepositoryCopier getCopier( RepositoryConnection conn,
Map<URI, URI> fromto, URI schema, URI data ) {
final UriBuilder owlb = UriBuilder.getBuilder( schema );
final UriBuilder datab = UriBuilder.getBuilder( data );
return new RepositoryCopier( conn ) {
@Override
public void handleStatement( Statement stmt ) throws RDFHandlerException {
URI sub = URI.class.cast( stmt.getSubject() );
URI pred = stmt.getPredicate();
Value obj = stmt.getObject();
sub = upgrade( sub, fromto, owlb, datab );
pred = upgrade( pred, fromto, owlb, datab );
if ( obj instanceof URI ) {
obj = upgrade( URI.class.cast( obj ), fromto, owlb, datab );
}
super.handleStatement( new StatementImpl( sub, pred, obj ) );
}
};
}
示例12: requery
import org.openrdf.model.URI; //导入依赖的package包/类
private void requery( Parameter child ) {
log.debug( "requerying for parameter: " + child );
OneVarListQueryAdapter<URI> onevar
= OneVarListQueryAdapter.getUriList( child.getDefaultQuery() );
for ( Parameter ancestor : ordered.getPredecessors( child ) ) {
if ( !ancestor.equals( ordered.getRoot() ) ) {
UriComboBox cmb = combos.get( ancestor );
onevar.bind( ancestor.getVariable(),
cmb.getItemAt( cmb.getSelectedIndex() ) );
}
}
log.debug( "approximate requery is: " + onevar.bindAndGetSparql() );
List<URI> vals = engine.queryNoEx( onevar );
UriComboBox combo = combos.get( child );
combo.removeItemListener( listener );
Map<URI, String> labels = Utility.getInstanceLabels( vals, engine );
combo.setData( Utility.sortUrisByLabel( labels ) );
//combo.setMaximumSize( new Dimension( 100, 25 ) );
//combo.setPreferredSize( new Dimension( 100, 25 ) );
combo.setMinimumSize( new Dimension( 10, 25 ) );
combo.addItemListener( listener );
}
示例13: select
import org.openrdf.model.URI; //导入依赖的package包/类
public String select( DirectedGraph<QueryNode, QueryEdge> graph,
List<QueryOrder> ordering ) {
List<QueryGraphElement> todo = new ArrayList<>();
todo.addAll( graph.getVertices() );
todo.addAll( graph.getEdges() );
Set<QueryOrder> linkedOrderSet = new LinkedHashSet<>( ordering );
for ( QueryGraphElement v : todo ) {
for ( URI prop : v.getAllValues().keySet() ) {
QueryOrder qo = new QueryOrder( v, prop );
if ( !linkedOrderSet.contains( qo ) ) {
linkedOrderSet.add( qo );
}
}
}
List<QueryOrder> fullOrdering = new ArrayList<>( linkedOrderSet );
return buildSelect( fullOrdering ) + buildWhere( graph, fullOrdering );
}
示例14: getConnections
import org.openrdf.model.URI; //导入依赖的package包/类
/**
* Gets the top-level connections between the give node types
*
* @param subtype
* @param objtype
* @param engine
* @return a collection of connections
*/
public static Collection<URI> getConnections( URI subtype, URI objtype, IEngine engine ) {
String query = "SELECT DISTINCT ?rel {\n"
+ " ?s a ?subtype .\n"
+ " ?o a ?objtype .\n"
+ " ?s ?rel ?o .\n"
+ " ?rel rdfs:subPropertyOf ?semrel .\n"
+ " FILTER( ?rel != ?semrel ) .\n"
+ " FILTER( ?subtype != ?concept && ?subtype != ?skos ) .\n"
+ " FILTER( ?objtype != ?concept && ?objtype != ?skos ) .\n"
+ "}";
ListQueryAdapter<URI> lqa = OneVarListQueryAdapter.getUriList( query );
lqa.bind( "semrel", engine.getSchemaBuilder().getRelationUri().build() );
lqa.bind( "concept", engine.getSchemaBuilder().getConceptUri().build() );
lqa.bind( "skos", SKOS.CONCEPT );
lqa.bind( "subtype", subtype );
lqa.bind( "objtype", objtype );
Set<URI> edges = getTopLevelRelations( engine.queryNoEx( lqa ), engine );
return edges;
}
示例15: create
import org.openrdf.model.URI; //导入依赖的package包/类
/**
* Creates graph nodes from the given data. If the {@code Value[]}s have
* length 1, the values are expected to be nodes ({@link Resource}s. If they
* have length 3, then they are repackaged as Statements, and forwarded on to
* {@link #create(org.openrdf.model.Model, com.ostrichemulators.semtool.rdf.engine.api.IEngine) }.
* Anything else will throw an exception
*
* @param data the data to add are expected to be
* @param headers ignored
* @param engine
* @throws IllegalArgumentException
*
*/
@Override
public void create( List<Value[]> data, List<String> headers, IEngine engine ) {
List<URI> nodes = new ArrayList<>();
Model model = new LinkedHashModel();
for ( Value[] row : data ) {
URI s = URI.class.cast( row[0] );
if ( 1 == row.length ) {
nodes.add( s );
}
else if ( 3 == row.length ) {
URI p = URI.class.cast( row[1] );
Value o = row[2];
model.add( s, p, o );
}
else {
throw new IllegalArgumentException( "Values cannot be converted for graph usage" );
}
}
add( model, nodes, engine );
}