All Implemented Interfaces:
DataExceptionContributor, JsonSerializable, RecordSerializable, XmlSerializable, DataReaderFactory, JavaCodeGenerator, Serializable
Direct Known Subclasses:
JsonPipelineInput

public class XmlPipelineInput extends FileSourcePipelineInput
Reads a pipeline's source data from an XML FileSource using an XmlReader, which selects fields and record breaks by location path (a subset of XPath).
See Also:
  • Constructor Details

    • XmlPipelineInput

      public XmlPipelineInput()
  • Method Details

    • createDataReader

      public DataReader createDataReader()
    • createDataReaderImpl

      protected XmlReader createDataReaderImpl(InputStream in)
      Creates the reader for the file's stream; createDataReader() then applies this input's settings. Subclasses override it to read other formats.
    • getFileSource

      public FileSource getFileSource()
      Specified by:
      getFileSource in class FileSourcePipelineInput
    • setFileSource

      public XmlPipelineInput setFileSource(FileSource fileSource)
      Specified by:
      setFileSource in class FileSourcePipelineInput
    • getName

      public String getName()
      Description copied from class: PipelineInput
      Returns a display name for this input, such as the source's name followed by its format.
      Overrides:
      getName in class FileSourcePipelineInput
    • getFields

      public List<XmlField> getFields()
      Returns the fields to read; null or empty if none were added.
    • getFields

      public List<XmlField> getFields(boolean create)
      Returns the fields to read, first creating an empty list if create is true and there is none.
    • addField

      public XmlPipelineInput addField(XmlField xmlField)
    • addField

      public XmlPipelineInput addField(String name, String locationPathAsString)
      Adds a field read from the nodes matching a location path such as /teachers/teacher/@memberid.
    • addField

      public XmlPipelineInput addField(String name, String locationPathAsString, boolean cascadeValues)
      Adds a field; with cascadeValues its last value is carried into later records until the path matches again.
    • addField

      public XmlPipelineInput addField(String name, String locationPathAsString, String cascadeResetLocationPath)
      Adds a field whose last value is carried into later records until a node matching cascadeResetLocationPath clears it; a blank reset path turns cascading off.
    • getRecordBreaks

      public List<String> getRecordBreaks()
      Returns the location paths that delimit records or null if none were added.
    • getRecordBreaks

      public List<String> getRecordBreaks(boolean create)
      Returns the record break paths, first creating an empty list if create is true and there is none.
    • addRecordBreak

      public XmlPipelineInput addRecordBreak(String locationPathAsString)
      Adds a location path, such as /teachers/teacher, whose matching nodes delimit records.
    • getDuplicateFieldPolicy

      public XmlReader.DuplicateFieldPolicy getDuplicateFieldPolicy()
      Returns how a field matched more than once within a record is stored (defaults to XmlReader.DuplicateFieldPolicy.USE_LAST_VALUE).
    • setDuplicateFieldPolicy

      public XmlPipelineInput setDuplicateFieldPolicy(XmlReader.DuplicateFieldPolicy duplicateFieldPolicy)
      Sets how a field matched more than once within a record is stored (defaults to XmlReader.DuplicateFieldPolicy.USE_LAST_VALUE).
    • isDebug

      public boolean isDebug()
      Indicates if the reader logs each parsed node to help find field and record break paths; not serialized (defaults to false).
    • setDebug

      public XmlPipelineInput setDebug(boolean debug)
      Indicates if the reader logs each parsed node to help find field and record break paths; not serialized (defaults to false).
    • isAutoCloseReader

      public boolean isAutoCloseReader()
      Indicates if the file's stream is closed when the reader is closed (defaults to true).
    • setAutoCloseReader

      public XmlPipelineInput setAutoCloseReader(boolean autoCloseReader)
      Indicates if the file's stream is closed when the reader is closed (defaults to true).
    • isLineageSupported

      public boolean isLineageSupported()
      Description copied from class: PipelineInput
      Indicates if this input can save data lineage on the records it reads (false unless a subclass overrides it).
      Overrides:
      isLineageSupported in class PipelineInput
    • generateJavaCode

      public void generateJavaCode(JavaCodeBuilder code)
      Description copied from interface: JavaCodeGenerator
      Appends Java source code representing this object to the given builder.
    • generateJavaCodeImpl

      protected void generateJavaCodeImpl(JavaCodeBuilder code, CodeWriter writer)
      Writes the reader declaration (and any format-specific setters), leaving the writer indented for the common setters.
    • toRecord

      public Record toRecord()
      Description copied from interface: RecordSerializable
      Converts this object's state to a record that RecordSerializable.fromRecord(Record) can load.
      Specified by:
      toRecord in interface RecordSerializable
      Overrides:
      toRecord in class PipelineInput
    • fromRecord

      public XmlPipelineInput fromRecord(Record source)
      Description copied from interface: RecordSerializable
      Loads this instance's state from a record and returns this (for fluid API call chaining). For fluid API call chaining, the overridden method should change the declared return type to its class.
      Specified by:
      fromRecord in interface RecordSerializable
      Overrides:
      fromRecord in class PipelineInput
      Parameters:
      source -
      Returns:
      this instance.
    • toXmlElement

      public Element toXmlElement(Document document)
      Description copied from interface: XmlSerializable
      Returns an element, created with document, describing this object; the default implementation throws a DataException.
      Specified by:
      toXmlElement in interface XmlSerializable
      Overrides:
      toXmlElement in class PipelineInput
    • fromXmlElement

      public XmlPipelineInput fromXmlElement(Element pipelineInputElement)
      Specified by:
      fromXmlElement in interface XmlSerializable
      Overrides:
      fromXmlElement in class PipelineInput