|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.jmonks.batch.io.FileSpec
FileSpec represents the file contains specification (spec for short) of any file to read or write using this package. This provides the factory method to create the FileSpec object from a file contains the spec and necessary methods to access the record spec objects.
File spec defines the file type and possible records could exists in the file. Every file spec will contains one or more record specs. Element file-spec should contain one attribute file-type defines the type of the file this spec is going to represent. Based on the file type, there could be other attributes in file-spec element along with file-type attribute. These attributes can be found from the javadoc of the particular file type file specs. Here is a sample file-spec configuration.
<file-spec file-type="fixed-width-flat"> <record-spec record-type="DETAIL"> </record-spec> </file-spec>
Field Summary | |
static java.lang.String |
FILE_SPEC_TAG_NAME
Constant defines the file spec tage name. |
static java.lang.String |
FILE_TYPE_ATTRIB_NAME
Constant defines the attribute name file type should contain. |
protected FileType |
fileType
Holds the type of the file this spec is representing. |
protected java.util.Map |
recordSpecMap
Map holds the record specs with their record types as keys. |
Constructor Summary | |
protected |
FileSpec(FileType fileType)
Constructs the FileSpec object by accepting file type. |
Method Summary | |
protected boolean |
addRecordSpec(RecordSpec recordSpec)
Adds the record spec to the file spec. |
static FileSpec |
createFileSpec(java.io.InputStream fileSpecInputStream)
Creates the file spec object from the file contains the spec. |
FileType |
getFileType()
Gets the file type. |
RecordSpec |
getRecordSpec(RecordType recordType)
Gets the record spec associated with the given record type. |
java.util.Collection |
getRecordSpecs()
Gets all the record spec's in this file spec as a list. |
boolean |
isValidRecordType(RecordType recordType)
Tells whether a record spec is exists with the given record type in the file spec. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
protected FileType fileType
protected java.util.Map recordSpecMap
public static final java.lang.String FILE_SPEC_TAG_NAME
public static final java.lang.String FILE_TYPE_ATTRIB_NAME
Constructor Detail |
protected FileSpec(FileType fileType)
fileType
- Type of the file this spec is representing.Method Detail |
protected boolean addRecordSpec(RecordSpec recordSpec)
recordSpec
- Record spec to be added to the file spec.
java.lang.IllegalArgumentException
- If recordSpec is null.
FileSpecException
- If multiple record specs configured with same record type.public java.util.Collection getRecordSpecs()
Gets all the record spec's in this file spec as a list. TODO :: There is chance that client might misuse this list. Based on the performance create a new list and return it.
public RecordSpec getRecordSpec(RecordType recordType)
recordType
- Record types associated with the record spec.
java.lang.IllegalArgumentException
- If recordType is null.public boolean isValidRecordType(RecordType recordType)
recordType
- Type of the record to check in the file spec.
public FileType getFileType()
public static FileSpec createFileSpec(java.io.InputStream fileSpecInputStream)
Creates the file spec object from the file contains the spec. This looks for the file-type attribute in file-spec element and creates the appropriate file spec object.
fileSpecInputStream
- Input stream represents the file spec.
FileSpecException
- If file-type attribute
is missing or doesnt consists of the type available FileType class
or given file cannot be found or cannot parse the file.
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |