Class JsonPipelineInput
java.lang.Object
com.northconcepts.datapipeline.foundations.core.Bean
com.northconcepts.datapipeline.foundations.core.FoundationObject
com.northconcepts.datapipeline.foundations.pipeline.PipelineObject
com.northconcepts.datapipeline.foundations.pipeline.PipelineInput
com.northconcepts.datapipeline.foundations.pipeline.input.FileSourcePipelineInput
com.northconcepts.datapipeline.foundations.pipeline.input.XmlPipelineInput
com.northconcepts.datapipeline.foundations.pipeline.input.JsonPipelineInput
- All Implemented Interfaces:
DataExceptionContributor,JsonSerializable,RecordSerializable,XmlSerializable,DataReaderFactory,JavaCodeGenerator,Serializable
Reads a pipeline's source data from a JSON
FileSource using a JsonReader,
which selects fields and record breaks by location path.- See Also:
-
Field Summary
Fields inherited from class com.northconcepts.datapipeline.foundations.core.FoundationObject
internalId, internalName, log, TIMESTAMP_FORMATFields inherited from interface com.northconcepts.datapipeline.core.RecordSerializable
SERIALIZED_CLASS_NAME, TYPEFields inherited from interface com.northconcepts.datapipeline.core.XmlSerializable
XML_SERIALIZED_CLASS_NAME -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionAdds a field read from the nodes matching a location path such as/teachers/teacher/@memberid.Adds a field; withcascadeValuesits last value is carried into later records until the path matches again.Adds a field whose last value is carried into later records until a node matchingcascadeResetLocationPathclears it; a blank reset path turns cascading off.addRecordBreak(String locationPathAsString) Adds a location path, such as/teachers/teacher, whose matching nodes delimit records.protected XmlReaderCreates the reader for the file's stream;XmlPipelineInput.createDataReader()then applies this input's settings.fromRecord(Record source) Loads this instance's state from a record and returnsthis(for fluid API call chaining).fromXmlElement(Element pipelineInputElement) protected voidgenerateJavaCodeImpl(JavaCodeBuilder code, CodeWriter writer) Writes the reader declaration (and any format-specific setters), leaving the writer indented for the common setters.getName()Returns a display name for this input, such as the source's name followed by its format.booleanIndicates if JSON decimal numbers are read asBigDecimalinstead of double (defaults to false).booleanReturns whether to useBigIntegerfor large integer values in JSON.setAutoCloseReader(boolean autoCloseReader) Indicates if the file's stream is closed when the reader is closed (defaults to true).setDebug(boolean debug) Indicates if the reader logs each parsed node to help find field and record break paths; not serialized (defaults to false).setDuplicateFieldPolicy(XmlReader.DuplicateFieldPolicy duplicateFieldPolicy) Sets how a field matched more than once within a record is stored (defaults toXmlReader.DuplicateFieldPolicy.USE_LAST_VALUE).setFileSource(FileSource fileSource) setUseBigDecimal(boolean useBigDecimal) Indicates if JSON decimal numbers are read asBigDecimalinstead of double (defaults to false).setUseBigInteger(boolean useBigInteger) Sets whether to useBigIntegerfor large integer values in JSON.toRecord()Converts this object's state to a record thatRecordSerializable.fromRecord(Record)can load.toXmlElement(Document document) Returns an element, created withdocument, describing this object; the default implementation throws aDataException.Methods inherited from class com.northconcepts.datapipeline.foundations.pipeline.input.XmlPipelineInput
createDataReader, generateJavaCode, getDuplicateFieldPolicy, getFields, getFields, getFileSource, getRecordBreaks, getRecordBreaks, isAutoCloseReader, isDebug, isLineageSupportedMethods inherited from class com.northconcepts.datapipeline.foundations.pipeline.PipelineInput
getNestedPipelineInput, getPipelineInput, getRootPipelineInput, isSaveLineage, setSaveLineageMethods inherited from class com.northconcepts.datapipeline.foundations.core.FoundationObject
addExceptionProperties, assertValid, assertValid, clone, exception, exception, exception, getInternalId, getInternalName, resetInternalIdMethods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface com.northconcepts.datapipeline.core.DataExceptionContributor
addExceptionProperties
-
Constructor Details
-
JsonPipelineInput
public JsonPipelineInput()
-
-
Method Details
-
createDataReaderImpl
Description copied from class:XmlPipelineInputCreates the reader for the file's stream;XmlPipelineInput.createDataReader()then applies this input's settings. Subclasses override it to read other formats.- Overrides:
createDataReaderImplin classXmlPipelineInput
-
setFileSource
- Overrides:
setFileSourcein classXmlPipelineInput
-
getName
Description copied from class:PipelineInputReturns a display name for this input, such as the source's name followed by its format.- Overrides:
getNamein classXmlPipelineInput
-
isUseBigDecimal
public boolean isUseBigDecimal()Indicates if JSON decimal numbers are read asBigDecimalinstead of double (defaults to false). -
setUseBigDecimal
Indicates if JSON decimal numbers are read asBigDecimalinstead of double (defaults to false). -
isUseBigInteger
public boolean isUseBigInteger()Returns whether to useBigIntegerfor large integer values in JSON.When enabled, large integer values that exceed the range of standard Java integer types will be parsed as
BigIntegerinstead of being converted to doubles or longs.- Returns:
trueifBigIntegershould be used for large integers,falseotherwise
-
setUseBigInteger
Sets whether to useBigIntegerfor large integer values in JSON.When enabled, large integer values that exceed the range of standard Java integer types will be parsed as
BigIntegerinstead of being converted to doubles or longs.- Parameters:
useBigInteger-trueto useBigIntegerfor large integers,falseotherwise- Returns:
- this instance for method chaining
-
addField
- Overrides:
addFieldin classXmlPipelineInput
-
addField
Description copied from class:XmlPipelineInputAdds a field read from the nodes matching a location path such as/teachers/teacher/@memberid.- Overrides:
addFieldin classXmlPipelineInput
-
addField
Description copied from class:XmlPipelineInputAdds a field; withcascadeValuesits last value is carried into later records until the path matches again.- Overrides:
addFieldin classXmlPipelineInput
-
addField
public JsonPipelineInput addField(String name, String locationPathAsString, String cascadeResetLocationPath) Description copied from class:XmlPipelineInputAdds a field whose last value is carried into later records until a node matchingcascadeResetLocationPathclears it; a blank reset path turns cascading off.- Overrides:
addFieldin classXmlPipelineInput
-
addRecordBreak
Description copied from class:XmlPipelineInputAdds a location path, such as/teachers/teacher, whose matching nodes delimit records.- Overrides:
addRecordBreakin classXmlPipelineInput
-
setDuplicateFieldPolicy
public JsonPipelineInput setDuplicateFieldPolicy(XmlReader.DuplicateFieldPolicy duplicateFieldPolicy) Description copied from class:XmlPipelineInputSets how a field matched more than once within a record is stored (defaults toXmlReader.DuplicateFieldPolicy.USE_LAST_VALUE).- Overrides:
setDuplicateFieldPolicyin classXmlPipelineInput
-
setAutoCloseReader
Description copied from class:XmlPipelineInputIndicates if the file's stream is closed when the reader is closed (defaults to true).- Overrides:
setAutoCloseReaderin classXmlPipelineInput
-
setDebug
Description copied from class:XmlPipelineInputIndicates if the reader logs each parsed node to help find field and record break paths; not serialized (defaults to false).- Overrides:
setDebugin classXmlPipelineInput
-
generateJavaCodeImpl
Description copied from class:XmlPipelineInputWrites the reader declaration (and any format-specific setters), leaving the writer indented for the common setters.- Overrides:
generateJavaCodeImplin classXmlPipelineInput
-
toRecord
Description copied from interface:RecordSerializableConverts this object's state to a record thatRecordSerializable.fromRecord(Record)can load.- Specified by:
toRecordin interfaceRecordSerializable- Overrides:
toRecordin classXmlPipelineInput
-
fromRecord
Description copied from interface:RecordSerializableLoads this instance's state from a record and returnsthis(for fluid API call chaining). For fluid API call chaining, the overridden method should change the declared return type to its class.- Specified by:
fromRecordin interfaceRecordSerializable- Overrides:
fromRecordin classXmlPipelineInput- Parameters:
source-- Returns:
- this instance.
-
toXmlElement
Description copied from interface:XmlSerializableReturns an element, created withdocument, describing this object; the default implementation throws aDataException.- Specified by:
toXmlElementin interfaceXmlSerializable- Overrides:
toXmlElementin classXmlPipelineInput
-
fromXmlElement
- Specified by:
fromXmlElementin interfaceXmlSerializable- Overrides:
fromXmlElementin classXmlPipelineInput
-