Class XmlField

java.lang.Object
com.northconcepts.datapipeline.xml.XmlField
All Implemented Interfaces:
JsonSerializable, RecordSerializable, XmlSerializable

public class XmlField extends Object implements RecordSerializable, XmlSerializable
Maps the values found at a location path to a named record field for XmlReader, optionally cascading the last value into later records.
  • Constructor Details

    • XmlField

      public XmlField()
    • XmlField

      public XmlField(String name, String locationPathAsString, boolean cascadeValues)
      Creates a field read from the location path; with cascadeValues, its last value carries over to later records until a new match replaces it.
    • XmlField

      public XmlField(String name, String locationPathAsString, String cascadeResetLocationPath)
      Creates a cascading field whose carried-over value is cleared by elements matching cascadeResetLocationPath; a null or empty reset path turns cascading off.
  • Method Details

    • getName

      public String getName()
    • setName

      public XmlField setName(String name)
    • getLocationPath

      public LocationPath getLocationPath()
    • isCascadeValues

      public boolean isCascadeValues()
      Indicates if this field's last value carries over to later records until a new match replaces it (default is false).
    • setCascadeValues

      public XmlField setCascadeValues(boolean cascadeValues)
      Indicates if this field's last value carries over to later records until a new match replaces it (default is false).
    • getCascadeResetLocationPath

      public LocationPath getCascadeResetLocationPath()
      Returns the location path whose matching elements clear the cascaded value, or null if none is set.
    • setCascadeResetLocationPath

      public XmlField setCascadeResetLocationPath(LocationPath cascadeResetLocationPath)
      Sets the location path whose matching elements clear the cascaded value; unlike the String overload, it leaves isCascadeValues() unchanged.
    • getValues

      protected LinkedList<<any>> getValues()
      Returns the values recorded for this field, each paired with the sequence number of the node it came from.
    • addValue

      protected XmlField addValue(long sequence, Object value)
      Records a value matched at the node with the given sequence number.
    • removeValues

      protected XmlField removeValues(long sequence)
      Removes the most recently recorded values whose node sequence number is at least sequence.
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • 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
    • fromRecord

      public XmlField 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
      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
    • fromXmlElement

      public XmlField fromXmlElement(Element xmlFieldElement)
      Specified by:
      fromXmlElement in interface XmlSerializable