本文整理汇总了Java中org.openrdf.model.Namespace类的典型用法代码示例。如果您正苦于以下问题:Java Namespace类的具体用法?Java Namespace怎么用?Java Namespace使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Namespace类属于org.openrdf.model包,在下文中一共展示了Namespace类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testGetNamespaces
import org.openrdf.model.Namespace; //导入依赖的package包/类
public void testGetNamespaces() throws Exception {
String namespace = "urn:testNamespace#";
String prefix = "pfx";
connection.setNamespace(prefix, namespace);
namespace = "urn:testNamespace2#";
prefix = "pfx2";
connection.setNamespace(prefix, namespace);
RepositoryResult<Namespace> result = connection.getNamespaces();
int count = 0;
while (result.hasNext()) {
result.next();
count++;
}
assertEquals(2, count);
}
示例2: getNamespaces
import org.openrdf.model.Namespace; //导入依赖的package包/类
@Override
public Map<String,String> getNamespaces() {
assertModel();
Map<String,String> nsMap = new HashMap<String,String>();
try {
RepositoryResult<Namespace> openrdfMap = this.connection.getNamespaces();
openrdfMap.enableDuplicateFilter();
List<Namespace> openrdfList = Iterations.asList(openrdfMap);
for(Namespace openrdfNamespace : openrdfList) {
nsMap.put(openrdfNamespace.getPrefix(), openrdfNamespace.getName());
}
return nsMap;
} catch(RepositoryException e) {
throw new ModelRuntimeException(e);
}
}
示例3: getNamespaces
import org.openrdf.model.Namespace; //导入依赖的package包/类
@Override
public Map<String,String> getNamespaces() {
this.assertModel();
Map<String,String> nsMap = new HashMap<String,String>();
try {
RepositoryResult<Namespace> openrdfMap = this.connection.getNamespaces();
openrdfMap.enableDuplicateFilter();
while (openrdfMap.hasNext()) {
Namespace openrdfNamespace = openrdfMap.next();
nsMap.put(openrdfNamespace.getPrefix(), openrdfNamespace.getName());
}
return nsMap;
} catch(RepositoryException e) {
throw new ModelRuntimeException(e);
}
}
示例4: getNamespaces
import org.openrdf.model.Namespace; //导入依赖的package包/类
@Override
public CloseableIteration<? extends Namespace, SailException> getNamespaces()
throws SailException {
return new CloseableIteratorIteration<Namespace, SailException>() {
private Iterator<Namespace> namespaces = Arrays.asList(
new Namespace[] {
new NamespaceImpl(OWL.PREFIX, OWL.NAMESPACE)
//TODO list all supported namespaces from the file
})
.iterator();
@Override
public boolean hasNext() throws SailException {
return namespaces.hasNext();
}
@Override
public Namespace next() throws SailException {
return namespaces.next();
};
};
}
示例5: getNamespaces
import org.openrdf.model.Namespace; //导入依赖的package包/类
@Override
public CloseableIteration<? extends Namespace, SailException> getNamespaces()
throws SailException {
return new CloseableIteratorIteration<Namespace, SailException>() {
private Iterator<Namespace> namespaces = Arrays.asList(
new Namespace[] {
new SimpleNamespace(FALDO.PREFIX, FALDO.NAMESPACE),
new SimpleNamespace(BED.PREFIX, BED.NAMESPACE) })
.iterator();
@Override
public boolean hasNext() throws SailException {
return namespaces.hasNext();
}
@Override
public Namespace next() throws SailException {
return namespaces.next();
};
};
}
示例6: getNamespaces
import org.openrdf.model.Namespace; //导入依赖的package包/类
@Override
public Map<String, String> getNamespaces() {
Map<String, String> ret = new HashMap<>();
try {
RepositoryConnection rc = getRawConnection();
for ( Namespace ns : Iterations.asList( rc.getNamespaces() ) ) {
ret.put( ns.getPrefix(), ns.getName() );
}
}
catch ( RepositoryException re ) {
log.warn( "could not retrieve namespaces", re );
}
return ret;
}
示例7: iterateNamespace
import org.openrdf.model.Namespace; //导入依赖的package包/类
public CloseableIteration<? extends Namespace, SailException> iterateNamespace() {
try {
//for this one we will go directly to the store
final CloseableIteration<? extends Namespace, RdfDAOException> iteration = namespaceManager.iterateNamespace();
return new CloseableIteration<Namespace, SailException>() {
@Override
public void close() throws SailException {
iteration.close();
}
@Override
public boolean hasNext() throws SailException {
return iteration.hasNext();
}
@Override
public Namespace next() throws SailException {
return iteration.next();
}
@Override
public void remove() throws SailException {
iteration.remove();
}
};
} catch (Exception e) {
throw new RuntimeException(e);
}
}
示例8: iterateNamespace
import org.openrdf.model.Namespace; //导入依赖的package包/类
@SuppressWarnings({ "unchecked", "rawtypes" })
@Override
public CloseableIteration<Namespace, RyaDAOException> iterateNamespace() throws RyaDAOException {
try {
final Scanner scanner = connector.createScanner(tableLayoutStrategy.getNs(),
ALL_AUTHORIZATIONS);
scanner.fetchColumnFamily(INFO_NAMESPACE_TXT);
final Iterator<Map.Entry<Key, Value>> result = scanner.iterator();
return new AccumuloNamespaceTableIterator(result);
} catch (final Exception e) {
throw new RyaDAOException(e);
}
}
示例9: next
import org.openrdf.model.Namespace; //导入依赖的package包/类
@Override
public Namespace next() throws RdfDAOException {
if (hasNext()) {
return getNamespace(result);
}
return null;
}
示例10: getNamespace
import org.openrdf.model.Namespace; //导入依赖的package包/类
public static Namespace getNamespace(final Iterator<Entry<Key, Value>> rowResults) {
for (; rowResults.hasNext(); ) {
final Entry<Key, Value> next = rowResults.next();
final Key key = next.getKey();
final Value val = next.getValue();
final String cf = key.getColumnFamily().toString();
final String cq = key.getColumnQualifier().toString();
return new NamespaceImpl(key.getRow().toString(),
new String(val.get(), StandardCharsets.UTF_8));
}
return null;
}
示例11: compareTo
import org.openrdf.model.Namespace; //导入依赖的package包/类
@Override
public int compareTo(final Namespace o) {
if (!namespace.equalsIgnoreCase(o.getName())) {
return namespace.compareTo(o.getName());
}
if (!prefix.equalsIgnoreCase(o.getPrefix())) {
return prefix.compareTo(o.getPrefix());
}
return 0;
}
示例12: next
import org.openrdf.model.Namespace; //导入依赖的package包/类
@Override
public Namespace next() throws RyaDAOException {
final DBObject ns = cursor.next();
final Map values = ns.toMap();
final String namespace = (String) values.get(NAMESPACE);
final String prefix = (String) values.get(PREFIX);
final Namespace temp = new NamespaceImplementation(namespace, prefix);
return temp;
}
示例13: iterateNamespace
import org.openrdf.model.Namespace; //导入依赖的package包/类
@Override
public CloseableIteration<? extends Namespace, RyaDAOException> iterateNamespace()
throws RyaDAOException {
final DBObject query = new BasicDBObject();
final DBCursor cursor = nsColl.find(query);
return new MongoCursorIteration(cursor);
}
示例14: testAddNamespaces
import org.openrdf.model.Namespace; //导入依赖的package包/类
public static void testAddNamespaces(final SailRepositoryConnection conn) throws MalformedQueryException, RepositoryException,
UpdateExecutionException, QueryEvaluationException, TupleQueryResultHandlerException {
conn.setNamespace("rya", "http://rya.com");
final RepositoryResult<Namespace> results = conn.getNamespaces();
for (final Namespace space : Iterations.asList(results)){
System.out.println(space.getName() + ", " + space.getPrefix());
}
}
示例15: startRDF
import org.openrdf.model.Namespace; //导入依赖的package包/类
@Override
public synchronized void startRDF() throws RDFHandlerException {
// Accept nested startRDF/endRDF calls
if (this.depth++ > 0) {
return;
}
// Initialize queue and exception holder
this.queue = new ArrayBlockingQueue<Object>(this.queueSize);
this.exception = new AtomicReference<Throwable>(null);
// Run a background task to move comments, namespaces and statements off the queue and
// forward it to the wrapped handler
this.future = Data.getExecutor().submit(new Runnable() {
@Override
public void run() {
Object object;
try {
DecouplingHandler.this.handler.startRDF();
while ((object = DecouplingHandler.this.queue.take()) != EOF) {
if (object instanceof Statement) {
DecouplingHandler.this.handler.handleStatement((Statement) object);
} else if (object instanceof Namespace) {
final Namespace ns = (Namespace) object;
DecouplingHandler.this.handler.handleNamespace(ns.getPrefix(),
ns.getName());
} else if (object instanceof String) {
DecouplingHandler.this.handler.handleComment((String) object);
}
}
DecouplingHandler.this.handler.endRDF();
} catch (final Throwable ex) {
DecouplingHandler.this.exception.set(ex);
}
}
});
}