Package org.smooks.io.payload
Class JavaSource
- java.lang.Object
-
- org.smooks.io.payload.FilterSource
-
- org.smooks.io.payload.JavaSource
-
- All Implemented Interfaces:
Source
- Direct Known Subclasses:
JavaSourceWithoutEventStream
public class JavaSource extends FilterSource
Java Filtration/TransformationSource
.Controlling Event Stream Generation
The Java Objects used to create this source can be used to generate a stream of SAX events, which can then be analysed by Smooks in the normal manner. Generation of the SAX event stream can also be turned off via thesetEventStreamRequired(boolean)
method, or by configuring the 'http://www.smooks.org/sax/features/generate-java-event-stream' feature on the reader in the Smoooks configuration as follows:<reader> <features> <setOff feature="http://www.smooks.org/sax/features/generate-java-event-stream" /> </features> </reader>
Turning off event stream generation can make sense in many situations. In some use cases event stream generation may add no value and may just reduces performance e.g. where you simply wish to apply a template to the supplied Java Object(s).
Smooks must generate at least 1 event to which configured resources can be targeted (e.g. a templating resource). When event stream generation is turned off, Smooks simply generates what we call a "Null Source" document event. In XML, it could be represented as "<nullsource-document/>". So when event stream generation is turned off, simply target resources at "nullsource-document" or "#document".- Author:
- tom.fennelly@gmail.com
-
-
Field Summary
Fields Modifier and Type Field Description static String
FEATURE_GENERATE_EVENT_STREAM
-
Fields inherited from class org.smooks.io.payload.FilterSource
SOURCE_TYPED_KEY
-
-
Constructor Summary
Constructors Constructor Description JavaSource(Object sourceObject)
Construct a JavaSource from the supplied source object.JavaSource(String objectName, Object sourceObject)
Construct a JavaSource from the supplied source object.JavaSource(List<Object> sourceObjects)
Construct a JavaSource from the supplied source object.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Map<String,Object>
getBeans()
Get the input bean map for the transform.List<Object>
getSourceObjects()
Get the source object list.boolean
isEventStreamRequired()
Is SAX event stream generation required for the processing of this JavaSource.void
setBeans(Map<String,Object> beans)
Set the input bean map for the transform.void
setEventStreamRequired(boolean eventStreamRequired)
Turn on/off SAX event stream generation for the processing of this JavaSource.-
Methods inherited from class org.smooks.io.payload.FilterSource
getSource, getSystemId, setSource, setSystemId
-
-
-
-
Field Detail
-
FEATURE_GENERATE_EVENT_STREAM
public static final String FEATURE_GENERATE_EVENT_STREAM
- See Also:
- Constant Field Values
-
-
Constructor Detail
-
JavaSource
public JavaSource(Object sourceObject)
Construct a JavaSource from the supplied source object.- Parameters:
sourceObject
- The source object.
-
JavaSource
public JavaSource(String objectName, Object sourceObject)
Construct a JavaSource from the supplied source object.- Parameters:
objectName
- The object name the sourceObject is known undersourceObject
- The source object.
-
-
Method Detail
-
isEventStreamRequired
public boolean isEventStreamRequired()
Is SAX event stream generation required for the processing of this JavaSource. Default istrue
.- Returns:
- True if SAX event stream generation is required, otherwise false.
-
setEventStreamRequired
public void setEventStreamRequired(boolean eventStreamRequired)
Turn on/off SAX event stream generation for the processing of this JavaSource.- Parameters:
eventStreamRequired
- True if SAX event stream generation is required, otherwise false.
-
getSourceObjects
public List<Object> getSourceObjects()
Get the source object list.- Returns:
- The source object list.
-
getBeans
public Map<String,Object> getBeans()
Get the input bean map for the transform.- Returns:
- The bean map.
-
-