org.jmonks.batch.io.flat
Class FixedWidthFlatFileRecordSpec

java.lang.Object
  extended byorg.jmonks.batch.io.RecordSpec
      extended byorg.jmonks.batch.io.flat.FixedWidthFlatFileRecordSpec

public class FixedWidthFlatFileRecordSpec
extends RecordSpec

FixedWidthFlatFileRecordSpec represents record-spec element in the file spec belongs to the fixed width flat file type. Along with the record-type attribute it looks for the starts-with and record-length attributes in the record-spec element to identify the record. starts-with tells the value that the record starts with and record-length tells the length of the record. Record type and starts-with attribute values should be unique across the file-spec. Here is a sample spec snippet...

      <file-spec file-type="fixed-width-flat">
          <record-spec record-type="detail" starts-with="5" record-length="42">
              <!-- field specs will follow here -->
          </record-spec>
      </file-spec>
  

Since:
1.0
Version:
1.0
Author:
Suresh Pragada

Field Summary
static java.lang.String RECORD_LENGTH_ATTRIB_NAME
          Constant defines the record length attribute name.
protected  int recordLength
          Holds the length of the record.
static java.lang.String STARTS_WITH_ATTRIB_NAME
          Constant defines the starts with attribute name.
protected  java.lang.String startsWith
          Holds the record specs starts with attribute value.
 
Fields inherited from class org.jmonks.batch.io.RecordSpec
fieldSpecList, RECORD_SPEC_TAG_NAME, RECORD_TYPE_ATTRIB_NAME, recordType
 
Constructor Summary
protected FixedWidthFlatFileRecordSpec(RecordType recordType)
          Constructs the record spec by accepting the record type.
 
Method Summary
static FixedWidthFlatFileRecordSpec createFixedWidthFlatFileRecordSpec(org.w3c.dom.Element recordSpecElement)
          Factory method to create the fixed width flat record spec from the given DOM Element representing the record-spec element in the file spec.
 int getRecordLength()
          Gets the length of the record.
 java.lang.String getStartsWith()
          Gets the starts-with value of this record.
 boolean isMatch(java.lang.String recordString)
          Tells whether the given record matches with the record spec.
 java.lang.String toString()
           
 
Methods inherited from class org.jmonks.batch.io.RecordSpec
addFieldSpec, getFieldSpecs, getRecordType
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

startsWith

protected java.lang.String startsWith
Holds the record specs starts with attribute value.


recordLength

protected int recordLength
Holds the length of the record.


STARTS_WITH_ATTRIB_NAME

public static final java.lang.String STARTS_WITH_ATTRIB_NAME
Constant defines the starts with attribute name.

See Also:
Constant Field Values

RECORD_LENGTH_ATTRIB_NAME

public static final java.lang.String RECORD_LENGTH_ATTRIB_NAME
Constant defines the record length attribute name.

See Also:
Constant Field Values
Constructor Detail

FixedWidthFlatFileRecordSpec

protected FixedWidthFlatFileRecordSpec(RecordType recordType)
Constructs the record spec by accepting the record type.

Method Detail

getStartsWith

public java.lang.String getStartsWith()
Gets the starts-with value of this record.


getRecordLength

public int getRecordLength()
Gets the length of the record. This will be obtained from the record-legnth attribute in the record-spec. This will be used while writing/generating the record using file writer and while reading the record to identify the record type.


isMatch

public boolean isMatch(java.lang.String recordString)
Tells whether the given record matches with the record spec. It checks whether this record string starts with the starts-with value and the length is equals to the record length.

Parameters:
recordString - Record read from the file.
Returns:
Returns true if the recordString matches this recrd spec, false otherwise.

createFixedWidthFlatFileRecordSpec

public static FixedWidthFlatFileRecordSpec createFixedWidthFlatFileRecordSpec(org.w3c.dom.Element recordSpecElement)
Factory method to create the fixed width flat record spec from the given DOM Element representing the record-spec element in the file spec.

Parameters:
recordSpecElement - DOM Element representing the record spec.
Returns:
Returns the fixed width flat file record spec.
Throws:
FileSpecException - If record-spec doesnt have the starts-with or record-type attribute.

toString

public java.lang.String toString()
See Also:
Object.toString()