public final class RDFHandlers extends Object
RDFHandler
s.Modifier and Type | Field and Description |
---|---|
static int |
METHOD_CLOSE
The
int value for method AutoCloseable.close() . |
static int |
METHOD_END_RDF
The
int value for method RDFHandler.endRDF() . |
static int |
METHOD_HANDLE_COMMENT
The
int value for method RDFHandler.handleComment(String) . |
static int |
METHOD_HANDLE_NAMESPACE
The
int value for method RDFHandler.handleNamespace(String, String) . |
static int |
METHOD_HANDLE_STATEMENT
The
int value for method RDFHandler.handleStatement(Statement) . |
static int |
METHOD_START_RDF
The
int value for method RDFHandler.startRDF() . |
static AbstractRDFHandler |
NIL
The null
RDFHandler that does nothing. |
Modifier and Type | Method and Description |
---|---|
static org.openrdf.rio.RDFHandler[] |
collect(org.openrdf.rio.RDFHandler handler,
int count,
SetOperator operation)
Returns an
RDFHandler that collects multiple streams of RDF data, merging them by
means in a unique stream using a SetOperator . |
static org.openrdf.rio.RDFHandler |
decouple(org.openrdf.rio.RDFHandler handler)
Wraps the supplied
RDFHandler (if necessary) so to buffer incoming statements and
use additional threads for their processing. |
static org.openrdf.rio.RDFHandler |
decouple(org.openrdf.rio.RDFHandler handler,
int numConsumerThreads)
Wraps the supplied
RDFHandelr (if necessary) using a queue to decouple threads
submitting statements from threads consuming them. |
static org.openrdf.rio.RDFHandler |
dispatchAll(org.openrdf.rio.RDFHandler... handlers)
Returns an
RDFHandler that dispatches calls to all the RDFHandler s
supplied. |
static org.openrdf.rio.RDFHandler |
dispatchAll(org.openrdf.rio.RDFHandler[] handlers,
int[] extraPasses)
Returns an
RDFHandler that dispatches calls to all the RDFHandler s
supplied, optionally performing more passes on selected handlers. |
static org.openrdf.rio.RDFHandler |
dispatchRoundRobin(int chunkSize,
org.openrdf.rio.RDFHandler... handlers)
Returns an
RDFHandler that dispatches calls to one of RDFHandler s supplied
chosen in a round robin fashion. |
static org.openrdf.rio.RDFHandler |
ignoreMethods(org.openrdf.rio.RDFHandler handler,
int ignoredMethods)
Wraps the supplied
RDFHandler ignoring calls to the methods specified by the given
bitmap. |
static org.openrdf.rio.RDFHandler |
ignorePasses(org.openrdf.rio.RDFHandler handler,
int maxPasses)
Wraps the supplied
RDFHandler discarding any method call after the specified number
of passes has been performed. |
static org.openrdf.rio.RDFHandler |
synchronize(org.openrdf.rio.RDFHandler handler)
Wraps the supplied
RDFHandler (if necessary) so that handleXXX() calls are
invoked in a mutually exclusive way. |
static org.openrdf.rio.RDFHandler |
update(String endpointURL)
Returns an
RDFHandler that uploads data to a SPARQL endpoint via SPARQL Update
INSERT DATA calls. |
static org.openrdf.rio.RDFHandler |
wrap(Collection<? super org.openrdf.model.Statement> statements)
Returns an
RDFHandler that populates the supplied statement collection. |
static org.openrdf.rio.RDFHandler |
wrap(Collection<? super org.openrdf.model.Statement> statements,
Collection<? super org.openrdf.model.Namespace> namespaces)
Returns an
RDFHandler that populates the supplied statement and namespace
collections. |
static org.openrdf.rio.RDFHandler |
wrap(Collection<? super org.openrdf.model.Statement> statements,
Map<? super String,? super String> namespaces)
Returns an
RDFHandler that populates the supplied statement collection and
prefix-to-namespace-uri map. |
static org.openrdf.rio.RDFHandler |
write(org.openrdf.rio.WriterConfig config,
int chunkSize,
String... locations)
Returns an
RDFHandler that writes data to the files at the locations specified. |
public static final int METHOD_START_RDF
int
value for method RDFHandler.startRDF()
.public static final int METHOD_HANDLE_COMMENT
int
value for method RDFHandler.handleComment(String)
.public static final int METHOD_HANDLE_NAMESPACE
int
value for method RDFHandler.handleNamespace(String, String)
.public static final int METHOD_HANDLE_STATEMENT
int
value for method RDFHandler.handleStatement(Statement)
.public static final int METHOD_END_RDF
int
value for method RDFHandler.endRDF()
.public static final int METHOD_CLOSE
int
value for method AutoCloseable.close()
.public static final AbstractRDFHandler NIL
RDFHandler
that does nothing.public static org.openrdf.rio.RDFHandler wrap(Collection<? super org.openrdf.model.Statement> statements)
RDFHandler
that populates the supplied statement collection. If the
collection is a Model
or a QuadModel
, it is also populated with namespaces.
If you don't want to populate namespaces, use wrap(Collection, Collection)
passing
null as second argument. Note that access to the collection is not synchronized, so it must
be thread-safe.statements
- the statement collection to populate, not nullRDFHandler
public static org.openrdf.rio.RDFHandler wrap(Collection<? super org.openrdf.model.Statement> statements, @Nullable Collection<? super org.openrdf.model.Namespace> namespaces)
RDFHandler
that populates the supplied statement and namespace
collections. Access to the two collections is not synchronized, so they MUST be thread safe
(may use Collections.synchronizedCollection(Collection)
).statements
- the statement collection to populate, not nullnamespaces
- the namespace collection to populate, or null to discard namespacesRDFHandler
public static org.openrdf.rio.RDFHandler wrap(Collection<? super org.openrdf.model.Statement> statements, @Nullable Map<? super String,? super String> namespaces)
RDFHandler
that populates the supplied statement collection and
prefix-to-namespace-uri map. Access to the collection and map is not synchronized, so they
MUST be thread-safe (may use Collections.synchronizedCollection(Collection)
and
Collections.synchronizedMap(Map)
).statements
- the statement collection to populate, not nullnamespaces
- the prefix-to-namespace-uri map to populate, or null to discard namespacesRDFHandler
public static org.openrdf.rio.RDFHandler write(@Nullable org.openrdf.rio.WriterConfig config, int chunkSize, String... locations)
RDFHandler
that writes data to the files at the locations specified.
Each location is either a file path or a full URL, possibly prefixed with an .ext:
fragment that overrides the file extension used to detect RDF format and compression.
Currently, URL different from file://
are not supported, i.e., only local files can
be written. If more locations are specified, statements are divided among them evenly (in
chunks of configurable size). If no locations are given, the NIL
handler is
returned. Note that data is written at each pass, so you may consider filtering out
multiple passes to avoid writing the same data again.config
- the optional WriterConfig
for fine tuning the writing process; if null,
a default configuration enabling pretty printing will be usedchunkSize
- the number of consecutive statements to write as a block to a single location
(at least 1)locations
- the locations of the files to writeRDFHandler
public static org.openrdf.rio.RDFHandler update(String endpointURL)
RDFHandler
that uploads data to a SPARQL endpoint via SPARQL Update
INSERT DATA calls. Note that data is written at each pass, so you may consider filtering
out multiple passes to avoid writing the same data again.endpointURL
- the URL of the SPARQL Update endpoint, not nullRDFHandler
public static org.openrdf.rio.RDFHandler ignoreMethods(org.openrdf.rio.RDFHandler handler, int ignoredMethods)
RDFHandler
ignoring calls to the methods specified by the given
bitmap. Calling an ignored method on the returned RDFHandler
produces no effect,
while calls to other method are forwarded to the wrapped handler
. Use constants
METHOD_XXX
in this class (OR-ed together) to define which methods to ignore.handler
- the handler to wrap, not nullignoredMethods
- a bitmap specifying which methods to ignoreRDFHandler
wrapperpublic static org.openrdf.rio.RDFHandler ignorePasses(org.openrdf.rio.RDFHandler handler, int maxPasses)
RDFHandler
discarding any method call after the specified number
of passes has been performed. Calls to close()
are always propagated, however.handler
- the handler to wrap, not nullmaxPasses
- the maximum number of passes to perform; additional passes will be ignoredRDFHandler
wrapperpublic static org.openrdf.rio.RDFHandler dispatchAll(org.openrdf.rio.RDFHandler... handlers)
RDFHandler
that dispatches calls to all the RDFHandler
s
supplied. If no RDFHandler
is supplied, NIL
is returned.handlers
- the RDFHandler
s to forward calls toRDFHandler
dispatcherpublic static org.openrdf.rio.RDFHandler dispatchAll(org.openrdf.rio.RDFHandler[] handlers, int[] extraPasses)
RDFHandler
that dispatches calls to all the RDFHandler
s
supplied, optionally performing more passes on selected handlers. Argument
extraPasses
controls how many passes a supplied handler should perform w.r.t. other
handlers. Operatively, if N is the maximum number in extraPasses
, at pass I < N
the dispatcher will forward calls only to handles whose extra passes value is greater than
N - I; in passes I >= N all handlers will be called. This mechanism allows for selected
handlers to receive the additional passes they need for their initialization, without
performing these passes also on other handlers that do not need them. Note that if no
RDFHandler
is supplied, NIL
is returned.handlers
- the RDFHandler
s to forward calls toextraPasses
- the number of extra passes for each supplied handlerRDFHandler
dispatcherpublic static org.openrdf.rio.RDFHandler dispatchRoundRobin(int chunkSize, org.openrdf.rio.RDFHandler... handlers)
RDFHandler
that dispatches calls to one of RDFHandler
s supplied
chosen in a round robin fashion. More precisely, calls to methods
RDFHandler.handleStatement(Statement)
and RDFHandler.handleComment(String)
are forwarded in a round robin fashion, with each chunk of chunkSize >= 1
consecutive calls dispatched to a certain handler. Other methods are always forwarded to
all the handlers. If no RDFHandler
is supplied, NIL
is returned.chunkSize
- the chunk size, greater than or equal to 1; you may use this parameter to keep
triples that are received consecutively together (as far as possible) when
propagated to wrapped handlers, e.g., because in this way they compress better
when written to a file (assuming input triples are somehow sorted)handlers
- the RDFHandler
s to forward calls to, in a round robin fashionRDFHandler
dispatcherpublic static org.openrdf.rio.RDFHandler[] collect(org.openrdf.rio.RDFHandler handler, int count, SetOperator operation)
RDFHandler
that collects multiple streams of RDF data, merging them by
means in a unique stream using a SetOperator
. This method accepts as arguments the
sink where to forward the merged RDF stream, the SetOperator
to apply and the
number of input streams to collect. The method returns an array of RDFHandler
, one
for each input stream to be collected, that can be used by the method caller to provide the
data to be merged.handler
- the handler to decompose, not nullcount
- the number of streams to collect and consequently the number of
RDFHandler
s to return (at least 1)operation
- the set operation to apply to merge input RDF streamsRDFHandler
spublic static org.openrdf.rio.RDFHandler decouple(org.openrdf.rio.RDFHandler handler)
RDFHandler
(if necessary) so to buffer incoming statements and
use additional threads for their processing. An RDFHandler
that has already been
decoupled is not wrapped again.handler
- the handler to wrappublic static org.openrdf.rio.RDFHandler decouple(org.openrdf.rio.RDFHandler handler, int numConsumerThreads)
RDFHandelr
(if necessary) using a queue to decouple threads
submitting statements from threads consuming them. A positive number of consumer threads
should be specified. Wrapping does not occur if the handler is already decoupled using a
queue.handler
- the handler to wrapnumConsumerThreads
- the number of consumer threads, positivepublic static org.openrdf.rio.RDFHandler synchronize(org.openrdf.rio.RDFHandler handler)
RDFHandler
(if necessary) so that handleXXX()
calls are
invoked in a mutually exclusive way. This method can be used with RDFHandler
s that
are not thread-safe.handler
- the handler to wrapCopyright © 2015–2016 FBK-irst. All rights reserved.