Class AbstractPathProcessor
- java.lang.Object
-
- io.wcm.caravan.io.jsontransform.processor.AbstractBufferingProcessor
-
- io.wcm.caravan.io.jsontransform.processor.AbstractPathProcessor
-
- All Implemented Interfaces:
Processor
,Source
,Closeable
,AutoCloseable
,Iterator<JsonElement>
- Direct Known Subclasses:
ArrayProcessor
@ConsumerType public abstract class AbstractPathProcessor extends AbstractBufferingProcessor
Helping abstract class recording the bread crumb of passed JSON stream elements
-
-
Field Summary
-
Fields inherited from class io.wcm.caravan.io.jsontransform.processor.AbstractBufferingProcessor
outputBuffer, source
-
-
Constructor Summary
Constructors Constructor Description AbstractPathProcessor(Source source)
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected JsonPath
getCurrentJsonPath()
protected abstract boolean
isProcessable(JsonPath path, JsonElement element)
protected void
process(JsonElement element)
Has to process the incoming JSON stream element.protected abstract void
process(JsonPath path, JsonElement element)
Processes the current JSON stream elementprotected JsonElement
processToPath(String path)
Requests the next JSON stream elements from the source until the bread crumb matches the given JSON path.protected JsonElement
seekToNext()
Requests the next JSON stream element.protected JsonElement
seekToNext(int steps)
Request x times the next JSON stream element defined by thesteps
parameter.protected JsonElement
seekToPath(String path)
Requests the next JSON stream elements from the source until the bread crumb matches the given JSON path.-
Methods inherited from class io.wcm.caravan.io.jsontransform.processor.AbstractBufferingProcessor
close, hasNext, next
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface java.util.Iterator
forEachRemaining, remove
-
-
-
-
Constructor Detail
-
AbstractPathProcessor
public AbstractPathProcessor(Source source)
- Parameters:
source
- The JSON stream source to process
-
-
Method Detail
-
isProcessable
protected abstract boolean isProcessable(JsonPath path, JsonElement element)
- Parameters:
path
- The current JSON pathelement
- The current JSON stream element- Returns:
- True if process with the given parameter should get called
-
process
protected abstract void process(JsonPath path, JsonElement element)
Processes the current JSON stream element- Parameters:
path
- The current JSON pathelement
- The current JSON stream element
-
process
protected void process(JsonElement element)
Description copied from class:AbstractBufferingProcessor
Has to process the incoming JSON stream element.- Specified by:
process
in classAbstractBufferingProcessor
- Parameters:
element
- Current JSON element
-
seekToPath
protected JsonElement seekToPath(String path)
Requests the next JSON stream elements from the source until the bread crumb matches the given JSON path. Passed elements don't get processed or stored in the output buffer. They get lost! Calls thecontains
function to evaluate the query.- Parameters:
path
- JSON path query- Returns:
- The JSON stream element matching the query
-
seekToNext
protected JsonElement seekToNext()
Requests the next JSON stream element.- Returns:
- The next JSON stream element
-
seekToNext
protected JsonElement seekToNext(int steps)
Request x times the next JSON stream element defined by thesteps
parameter. Passed elements don't get processed or stored in the output buffer. They get lost!- Parameters:
steps
- Number of steps to execute next; must be larger then zero- Returns:
- Null if source has no more elements
-
processToPath
protected JsonElement processToPath(String path)
Requests the next JSON stream elements from the source until the bread crumb matches the given JSON path. Passed elements don't get processed but stored in the output buffer. Calls thecontains
function to evaluate the query.- Parameters:
path
- JSON path query- Returns:
- The JSON stream element matching the query
-
getCurrentJsonPath
protected JsonPath getCurrentJsonPath()
- Returns:
- The current JSON path
-
-