public class AGValueFactory extends SimpleValueFactory
Modifier and Type | Field and Description |
---|---|
String |
PREFIX_FOR_EXTERNAL_BNODES |
Constructor and Description |
---|
AGValueFactory(AGRepository repository) |
AGValueFactory(AGRepository repository,
AGRepositoryConnection conn) |
Modifier and Type | Method and Description |
---|---|
Resource |
asResource(Node node) |
IRI |
asURI(Node node) |
Value |
asValue(Node node)
Creates an OpenRDF Value from a concrete Jena Node.
|
BNode |
createBNode()
Returns a new blank node.
|
BNode |
createBNode(String nodeID)
Returns a new blank node with the given id.
|
IRI |
generateURI(String registeredEncodableNamespace)
Returns a unique URI within the specified encodable namespace.
|
IRI[] |
generateURIs(String namespace,
int amount)
Returns unique URIs within the specified encodable namespace.
|
String[] |
getBlankNodeIds()
Returns the array of fetched blank node ids
|
int |
getBlankNodesPerRequest()
Gets the number of blank nodes fetched per request.
|
AGHTTPClient |
getHTTPClient() |
AGRepository |
getRepository() |
boolean |
isAGBlankNodeId(String id)
Returns true iff id looks like an AG blank node id.
|
boolean |
isURIForExternalBlankNode(Value v) |
void |
setBlankNodesPerRequest(int amount)
Sets the number of blank nodes to fetch per request.
|
getInstance
createIRI, createIRI, createLiteral, createLiteral, createLiteral, createLiteral, createLiteral, createLiteral, createLiteral, createLiteral, createLiteral, createLiteral, createLiteral, createLiteral, createLiteral, createLiteral, createStatement, createStatement
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
createLiteral, createStatement, createStatement, createURI, createURI
public String PREFIX_FOR_EXTERNAL_BNODES
public AGValueFactory(AGRepository repository)
public AGValueFactory(AGRepository repository, AGRepositoryConnection conn)
public AGRepository getRepository()
public AGHTTPClient getHTTPClient()
public int getBlankNodesPerRequest()
public void setBlankNodesPerRequest(int amount)
This can be used to control the number and frequency of HTTP requests made when automatically obtaining new sets of blank node ids from the server.
Defaults to the value of System property com.franz.agraph.repository.blankNodesPerRequest or to 100 if that property has not been set.
amount
- a positive integerpublic String[] getBlankNodeIds()
Primarily for testing purposes, not for use in apps.
public BNode createBNode(String nodeID)
Consider using createBNode() instead to get an AG-allocated id, it is safer (avoids unintended blank node conflicts) and can be stored more efficiently.
If id is null or empty, returns a unique BNode with AG-allocated id; otherwise, returns a BNode with the given (a.k.a. "external") id (careful to avoid blank node conflicts). See the javadoc for allowing external blank nodes for more discussion.
createBNode
in interface ValueFactory
createBNode
in class AbstractValueFactory
AGHttpRepoClient.setAllowExternalBlankNodeIds(boolean)
,
AGRepositoryConnection.prepareHttpRepoClient()
public BNode createBNode()
If this value factory is for an AGRepository, returns a new BNode with an AG-allocated id; otherwise, returns a new BNode with an "external" id (using ValueFactoryImpl). See also the javadoc for allowing external blank nodes for more discussion.
createBNode
in interface ValueFactory
createBNode
in class AbstractValueFactory
AGHttpRepoClient.setAllowExternalBlankNodeIds(boolean)
,
AGRepositoryConnection.prepareHttpRepoClient()
public Value asValue(Node node)
node
- a concrete Jena nodepublic boolean isAGBlankNodeId(String id)
AG blank node ids currently have the following form:
b[store ID in hex]x[blank node number].
There is nothing sacrosanct about this but it is unlikely to change.
id
- the string to be testedpublic boolean isURIForExternalBlankNode(Value v)
public IRI[] generateURIs(String namespace, int amount) throws RepositoryException
The generated URIs will conform to the format that was specified when the encodable namespace was registered, and are guaranteed to be unique for this namespace generator. Note that this does not prevent other parties from independently using URIs that involve this namespace, however.
If amount cannot be generated, up to amount URIs will be returned, or an exception will be thrown if none are available.
namespace
- encodable namespace from which the URIs will be generatedamount
- the number of URIs to generateRepositoryException
- if there is an error with this requestAGRepositoryConnection.registerEncodableNamespace(String, String)
,
generateURI(String)
public IRI generateURI(String registeredEncodableNamespace) throws RepositoryException
The generated URI will conform to the format that was specified when the encodable namespace was registered, and is guaranteed to be unique for this namespace generator. Note that this does not prevent other parties from independently using URIs that involve this namespace, however.
registeredEncodableNamespace
- encodable namespace from which the URI will be generatedRepositoryException
- if there is an error with this requestAGRepositoryConnection.registerEncodableNamespace(String, String)
,
generateURIs(String, int)
Copyright © 2024 Franz Inc.. All rights reserved.