|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectinfo.sswap.impl.empire.io.ClosureBuilder
public class ClosureBuilder
Builds a closure of statements that are contained in a particular model by recursively following the URIs of Resources (until a certain depth is reached, a time/byte limit is reached, or no new statements could be added by this method). TODO: Add a note about reusing this object
Nested Class Summary | |
---|---|
private class |
ClosureBuilder.DereferenceTask
A dereference task that is executed in the separate thread. |
Field Summary | |
---|---|
private long |
bytesRead
The counter of bytes read by this closure builder. |
private int |
connectTimeout
|
private static java.util.Set<com.hp.hpl.jena.rdf.model.Resource> |
DEREFERENCED_TYPES
A set of types of that are dereferenced during the closure computation. |
private java.util.List<java.lang.String> |
dereferenceQueue
The current list of URIs to be dereferenced for the current depth. |
private ExpressivityChecker |
expressivityChecker
|
private static java.util.Set<com.hp.hpl.jena.rdf.model.Property> |
HIERARCHY_PROPERTIES
|
private java.util.List<java.lang.String> |
ignoredNamespaces
|
private static org.apache.log4j.Logger |
LOGGER
|
private java.util.Set<java.lang.String> |
markedURIs
The set of URIs that were marked during closure computation. |
private long |
maxBytes
The maximum number of bytes transferred over the network this builder should not exceed while computing the closure Please note: the byte limits from separate threads are synchronized at the beginning and the end of each dereference operation. |
private int |
maxThreads
Maximum amount of concurrent threads (in addition to the caller's thread) for concurrent downloads. |
private long |
maxTime
The maximum amount of time this builder is allowed to spend while computing the closure. |
private ModelCache |
modelCache
|
private int |
readTimeout
|
private long |
startTime
|
Constructor Summary | |
---|---|
ClosureBuilder(long maxBytes,
long maxTime,
int maxThreads,
ModelCache modelCache,
java.util.List<java.lang.String> ignoredNamespaces)
Creates a new closure builder. |
Method Summary | |
---|---|
private void |
addStatements(com.hp.hpl.jena.rdf.model.Model destModel,
com.hp.hpl.jena.rdf.model.Model sourceModel)
Adds all statements from a source model to the destination model. |
private void |
addTypeStatements(java.lang.String url,
com.hp.hpl.jena.rdf.model.Model dest,
com.hp.hpl.jena.rdf.model.Model source)
Adds only type statements from the source model that describe the specified resource. |
private boolean |
belongsToDereferencedProperty(com.hp.hpl.jena.rdf.model.Model model,
com.hp.hpl.jena.rdf.model.Resource resource)
Attempts to guess whether a resource is a property mentioning (in a position other than predicate position) that should be dereferenced (as opposed to an individual). |
private boolean |
belongsToDereferencedType(com.hp.hpl.jena.rdf.model.Model model,
com.hp.hpl.jena.rdf.model.Resource resource)
Attempts to guess whether a resource is a type definition that should be dereferenced (as opposed to an individual). |
Closure |
build(com.hp.hpl.jena.rdf.model.Model baseModel,
java.lang.String modelURI)
Build closure for the given model using default values for max closure parameters. |
Closure |
build(com.hp.hpl.jena.rdf.model.Model baseModel,
java.lang.String modelURI,
int degree)
Build closure for the given model |
Closure |
build(com.hp.hpl.jena.rdf.model.Model baseModel,
java.lang.String modelURI,
int degree,
int hierarchyDegree)
|
private com.hp.hpl.jena.rdf.model.Model |
dereferenceURL(java.lang.String urlString)
Retrieves a document at the specified URL and parses it into the Jena model. |
private com.hp.hpl.jena.rdf.model.Model |
doClosure(com.hp.hpl.jena.rdf.model.Model sourceModel,
boolean typeStatementsOnly)
Computes one degree of closure on the passed model |
private com.hp.hpl.jena.rdf.model.Model |
doTypeRetrievingStep(com.hp.hpl.jena.rdf.model.Model baseModel,
com.hp.hpl.jena.rdf.model.Model sourceModel)
|
private void |
enqueueHierarchyURIs(com.hp.hpl.jena.rdf.model.Model model)
|
private void |
enqueueURI(java.lang.String uri)
Add a URI to the dereference queue, unless the URI has been already processed (i.e., has either been dereferenced or is awaiting dereference). |
private void |
enqueueURIs(com.hp.hpl.jena.rdf.model.Model model)
Add URIs of all resources to a dereference queue (unless they have already been processed). |
private long |
getBytesRemaining()
Gets the amount of bytes that can still be transferred before the limit is reached |
int |
getConnectTimeout()
Gets the connect timeout for a single HTTP connection |
int |
getReadTimeout()
Gets the read timeout for a single HTTP connection |
private java.util.Collection<java.lang.String> |
getResourceURIs(com.hp.hpl.jena.rdf.model.Model model)
Extract URIs of all resources that are non-anonymous resources and do not belong to standard ontologies (e.g., OWL, RDF etc.) |
private long |
getTimeRemaining()
Gets the amount of milliseconds that can still be used for closure computation before the time limit is reached. |
private long |
getTimeUsed()
Gets the amount of milliseconds that were already used while computing the closure |
private java.util.Collection<java.lang.String> |
getUpHierarchyResourceURIs(com.hp.hpl.jena.rdf.model.Model model)
|
private boolean |
isIgnoredNamespace(java.lang.String uri)
Checks whether a concept belongs to an ignored namespace. |
private boolean |
isOWLDL(com.hp.hpl.jena.rdf.model.Model baseModel,
com.hp.hpl.jena.rdf.model.Model model,
int currentDegree)
|
private boolean |
isOWLMembersListOfType(com.hp.hpl.jena.rdf.model.Model model,
com.hp.hpl.jena.rdf.model.Resource listResource,
com.hp.hpl.jena.rdf.model.Resource typeResource)
|
private boolean |
modelContainsPattern(com.hp.hpl.jena.rdf.model.Model m,
com.hp.hpl.jena.rdf.model.Resource s,
com.hp.hpl.jena.rdf.model.Property p,
com.hp.hpl.jena.rdf.model.RDFNode o)
|
void |
setConnectTimeout(int connectTimeout)
Sets the connect timeout for a single HTTP connection |
void |
setReadTimeout(int readTimeout)
Sets the read timeout for a single HTTP connection |
private boolean |
shouldBeEnqueued(com.hp.hpl.jena.rdf.model.Model model,
com.hp.hpl.jena.rdf.model.RDFNode node,
boolean property)
Checks whether the URI of an RDFNode from the Jena model should be enqueued for retrieval. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
private static final org.apache.log4j.Logger LOGGER
private static java.util.Set<com.hp.hpl.jena.rdf.model.Resource> DEREFERENCED_TYPES
private static java.util.Set<com.hp.hpl.jena.rdf.model.Property> HIERARCHY_PROPERTIES
private long maxBytes
private long maxTime
private int maxThreads
private long bytesRead
private long startTime
private java.util.Set<java.lang.String> markedURIs
private java.util.List<java.lang.String> dereferenceQueue
private ModelCache modelCache
private ExpressivityChecker expressivityChecker
private int connectTimeout
private int readTimeout
private java.util.List<java.lang.String> ignoredNamespaces
Constructor Detail |
---|
ClosureBuilder(long maxBytes, long maxTime, int maxThreads, ModelCache modelCache, java.util.List<java.lang.String> ignoredNamespaces)
maxBytes
- the maximum amount of bytes this closure builder may transfer while computing the closure (soft limit)maxTime
- the maximum amount of time this closure builder can spend computing the closuremaxThreads
- the maximum amount of concurrent threads (for concurrent downloads)Method Detail |
---|
public int getConnectTimeout()
public void setConnectTimeout(int connectTimeout)
connectTimeout
- the connect timeout in millisecondspublic int getReadTimeout()
public void setReadTimeout(int readTimeout)
readTimeout
- the read timeout in millisecondspublic Closure build(com.hp.hpl.jena.rdf.model.Model baseModel, java.lang.String modelURI)
baseModel
- the model whose closure should be computed (may be null, in such a case the model will be first
dereferenced from the given URI)modelURI
- the URI of the model (may be null). If the passed model is null, this URI will be used to dereference
the initial model. In all other cases, this URI will just prevent an unnecessary re-download of the
initial contents of the model
public Closure build(com.hp.hpl.jena.rdf.model.Model baseModel, java.lang.String modelURI, int degree)
baseModel
- the model whose closure should be computed (may be null, in such a case the model will be first
dereferenced from the given URI)modelURI
- the URI of the model (may be null). If the passed model is null, this URI will be used to dereference
the initial model. In all other cases, this URI will just prevent an unnecessary re-download of the
initial contents of the modeldegree
- the maximum degree for the closure
public Closure build(com.hp.hpl.jena.rdf.model.Model baseModel, java.lang.String modelURI, int degree, int hierarchyDegree)
private com.hp.hpl.jena.rdf.model.Model doTypeRetrievingStep(com.hp.hpl.jena.rdf.model.Model baseModel, com.hp.hpl.jena.rdf.model.Model sourceModel)
private boolean isOWLDL(com.hp.hpl.jena.rdf.model.Model baseModel, com.hp.hpl.jena.rdf.model.Model model, int currentDegree)
private com.hp.hpl.jena.rdf.model.Model doClosure(com.hp.hpl.jena.rdf.model.Model sourceModel, boolean typeStatementsOnly)
sourceModel
- the model whose closure (one level) should be computed
private long getBytesRemaining()
private long getTimeUsed()
private long getTimeRemaining()
private com.hp.hpl.jena.rdf.model.Model dereferenceURL(java.lang.String urlString) throws java.io.IOException, DataAccessException
urlString
- the string containing the URL to be retrieved
ByteLimitExceededException
- if the byte limit has been exceeded during the dereferencing.
java.io.IOException
- if a generic I/O error should occur
DataAccessException
private void enqueueURI(java.lang.String uri)
uri
- the URI to be enqueuedprivate void enqueueURIs(com.hp.hpl.jena.rdf.model.Model model)
model
- the model whose URIs should be addedprivate void enqueueHierarchyURIs(com.hp.hpl.jena.rdf.model.Model model)
private boolean modelContainsPattern(com.hp.hpl.jena.rdf.model.Model m, com.hp.hpl.jena.rdf.model.Resource s, com.hp.hpl.jena.rdf.model.Property p, com.hp.hpl.jena.rdf.model.RDFNode o)
private boolean isOWLMembersListOfType(com.hp.hpl.jena.rdf.model.Model model, com.hp.hpl.jena.rdf.model.Resource listResource, com.hp.hpl.jena.rdf.model.Resource typeResource)
private boolean belongsToDereferencedType(com.hp.hpl.jena.rdf.model.Model model, com.hp.hpl.jena.rdf.model.Resource resource)
model
- the model where the Resource is mentionedresource
- the resource that should be checked
private boolean belongsToDereferencedProperty(com.hp.hpl.jena.rdf.model.Model model, com.hp.hpl.jena.rdf.model.Resource resource)
model
- the model where the Resource is mentionedresource
- the resource that should be checked
private boolean shouldBeEnqueued(com.hp.hpl.jena.rdf.model.Model model, com.hp.hpl.jena.rdf.model.RDFNode node, boolean property)
node
- the node that should be checked
private java.util.Collection<java.lang.String> getResourceURIs(com.hp.hpl.jena.rdf.model.Model model)
model
- the model from which the URIs should be extracted
private java.util.Collection<java.lang.String> getUpHierarchyResourceURIs(com.hp.hpl.jena.rdf.model.Model model)
private void addStatements(com.hp.hpl.jena.rdf.model.Model destModel, com.hp.hpl.jena.rdf.model.Model sourceModel)
destModel
- the destination modelsourceModel
- the source modelprivate void addTypeStatements(java.lang.String url, com.hp.hpl.jena.rdf.model.Model dest, com.hp.hpl.jena.rdf.model.Model source)
url
- the URL of the concept in destination model whose type should be completed with information from the
source modeldest
- the destination modelsource
- the source model for the type informationprivate boolean isIgnoredNamespace(java.lang.String uri)
uri
- the URI to be checked
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |