org.jmonks.batch.io
Class RecordSpec

java.lang.Object
  extended byorg.jmonks.batch.io.RecordSpec
Direct Known Subclasses:
DelimitedFlatFileRecordSpec, FixedWidthFlatFileRecordSpec, XMLRecordSpec

public abstract class RecordSpec
extends java.lang.Object

RecordSpec represents the <record-spec> element in file spec. Record spec specifies the format of the record in the form of multiple field specs and contains the attribute helps in identifying the type of record and so. Each record spec contains zero or more field specs based on the file type.

Every record-spec element contains record-type attribute specifies the kind of record it is. Most of these values will be defined in RecordType class and additional values can be added by extending the RecordType. The record-type values should be unique across one file spec. Here is a sample record-spec configuration.

      <record-spec record-type="DETAIL">
          <field-spec field-name="consumer-id">
          </field-spec>
      </record-spec>
  

Since:
1.0
Version:
1.0
Author:
Suresh Pragada

Field Summary
protected  java.util.List fieldSpecList
          Holds all the field spec objects.
static java.lang.String RECORD_SPEC_TAG_NAME
          Constant defines the record spec tag name.
static java.lang.String RECORD_TYPE_ATTRIB_NAME
          Constant defines the record type attribute name.
protected  RecordType recordType
          Holds the type of the record this spec is representing.
 
Constructor Summary
protected RecordSpec(RecordType recordType)
          Constructs the RecordSpec object by accepting the RecordType.
 
Method Summary
protected  boolean addFieldSpec(FieldSpec fieldSpec)
          Adds the given field spec object to the record spec.
 java.util.List getFieldSpecs()
          Gets the field spec objects as a list.
 RecordType getRecordType()
          Returns the record type of this record spec.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

recordType

protected RecordType recordType
Holds the type of the record this spec is representing.


fieldSpecList

protected java.util.List fieldSpecList
Holds all the field spec objects.


RECORD_SPEC_TAG_NAME

public static final java.lang.String RECORD_SPEC_TAG_NAME
Constant defines the record spec tag name.

See Also:
Constant Field Values

RECORD_TYPE_ATTRIB_NAME

public static final java.lang.String RECORD_TYPE_ATTRIB_NAME
Constant defines the record type attribute name.

See Also:
Constant Field Values
Constructor Detail

RecordSpec

protected RecordSpec(RecordType recordType)
Constructs the RecordSpec object by accepting the RecordType.

Parameters:
recordType - Type of the record.
Method Detail

addFieldSpec

protected boolean addFieldSpec(FieldSpec fieldSpec)
Adds the given field spec object to the record spec.

Parameters:
fieldSpec - Field spec object to be added.
Returns:
Returns true if field spec has been added successfully, flase otherwise.
Throws:
java.lang.IllegalArgumentException - If given field spec is null.
FileSpecException - If multiple field specs configured with same field name.

getFieldSpecs

public java.util.List getFieldSpecs()
Gets the field spec objects as a list.


getRecordType

public RecordType getRecordType()
Returns the record type of this record spec.