[Batchserver-cvs] batchserver/src/org/jmonks/batchserver/io FieldSpec.java,NONE,1.1 FileIO.java,NONE
Brought to you by:
suresh_pragada
From: Suresh <sur...@us...> - 2006-05-26 22:22:30
|
Update of /cvsroot/batchserver/batchserver/src/org/jmonks/batchserver/io In directory sc8-pr-cvs3.sourceforge.net:/tmp/cvs-serv23292 Added Files: FieldSpec.java FileIO.java FileReader.java FileSpec.java FileType.java FixedWidthFieldSpec.java FixedWidthFlatFileReader.java payment-file-spec.xml payment.pmt Record.java RecordSpec.java RecordType.java Log Message: no message --- NEW FILE: FixedWidthFieldSpec.java --- /* * FixedWidthFieldSpec.java * * Created on May 26, 2006, 2:43 PM * * To change this template, choose Tools | Options and locate the template under * the Source Creation and Management node. Right-click the template and choose * Open. You can then make changes to the template in the Source Editor. */ package org.jmonks.batchserver.io; /** * * @author Suresh Pragada */ public class FixedWidthFieldSpec { private int startPosition=0; private int endPosition=0; /** Creates a new instance of FixedWidthFieldSpec */ public FixedWidthFieldSpec() { } } --- NEW FILE: RecordType.java --- /* * RecordType.java * * Created on May 26, 2006, 11:14 AM * * To change this template, choose Tools | Options and locate the template under * the Source Creation and Management node. Right-click the template and choose * Open. You can then make changes to the template in the Source Editor. */ package org.jmonks.batchserver.io; /** * * @author Suresh Pragada */ public final class RecordType { private String type=null; /** Creates a new instance of RecordType */ private RecordType(String type) { this.type=type; } public String toString() { return type; } public static final RecordType HEADER = new RecordType("HEADER"); public static final RecordType DETAIL = new RecordType("DETAIL"); public static final RecordType TRAILOR = new RecordType("TRAILOR"); } --- NEW FILE: Record.java --- /* * Record.java * * Created on May 26, 2006, 11:04 AM * * To change this template, choose Tools | Options and locate the template under * the Source Creation and Management node. Right-click the template and choose * Open. You can then make changes to the template in the Source Editor. */ package org.jmonks.batchserver.io; import java.util.HashMap; import java.util.Map; /** * * @author Suresh Pragada * @version 1.0 * @since 1.0 */ public class Record { private RecordType recordType=null; private Map fieldMap=null; /** Creates a new instance of Record */ public Record(RecordType recordType) { this.recordType=recordType; fieldMap=new HashMap(); } public RecordType getRecordType() { return this.recordType; } public void setField(String fieldName,String fieldValue) { this.fieldMap.put(fieldName,fieldValue); } public Object getField(String fieldName) { return this.fieldMap.get(fieldName); } } --- NEW FILE: FixedWidthFlatFileReader.java --- /* * FixedWidthFlatFileReader.java * * Created on May 26, 2006, 2:15 PM * * To change this template, choose Tools | Options and locate the template under * the Source Creation and Management node. Right-click the template and choose * Open. You can then make changes to the template in the Source Editor. */ package org.jmonks.batchserver.io; /** * * @author Suresh Pragada */ public class FixedWidthFlatFileReader extends FileReader { public Record getNextRecord() { if() return null; } } --- NEW FILE: RecordSpec.java --- /* * RecordSpec.java * * Created on May 26, 2006, 2:21 PM * * To change this template, choose Tools | Options and locate the template under * the Source Creation and Management node. Right-click the template and choose * Open. You can then make changes to the template in the Source Editor. */ package org.jmonks.batchserver.io; import java.util.ArrayList; import java.util.List; /** * * @author Suresh Pragada */ public class RecordSpec { private RecordType recordType=null; private List fieldSpecList=null; /** Creates a new instance of RecordSpec */ public RecordSpec(RecordType recordType) { this.recordType=recordType; fieldSpecList=new ArrayList(); } public boolean addFieldSpec(FieldSpec fieldSpec) { this.fieldSpecList.add(fieldSpec); return true; } public List getFieldSpecs() { return fieldSpecList; } } --- NEW FILE: payment.pmt --- 120060526 512345678910000012.0034343434347878787878 512345678920000013.0034343434347878787878 512345678930000014.0034343434347878787878 512345678940000015.0034343434347878787878 512345678950000016.0034343434347878787878 60000000.00 --- NEW FILE: FileSpec.java --- /* * FileSpec.java * * Created on May 26, 2006, 2:18 PM * * To change this template, choose Tools | Options and locate the template under * the Source Creation and Management node. Right-click the template and choose * Open. You can then make changes to the template in the Source Editor. */ package org.jmonks.batchserver.io; import java.util.ArrayList; import java.util.List; /** * * @author Suresh Pragada */ public class FileSpec { private String fileSpecPath=null; private FileType fileType=null; private List recordSpecList=null; /** Creates a new instance of FileSpec */ protected FileSpec() { recordSpecList=new ArrayList(); } public boolean addRecordSpec(RecordSpec recordSpec) { this.recordSpecList.add(recordSpec); return true; } public List getRecordSpec() { return this.recordSpecList; } public FileType getFileType() { return this.fileType; } public static FileSpec createFileSpec(String fileSpecPath) { return null; } } --- NEW FILE: FileIO.java --- /* * FileIO.java * * Created on May 26, 2006, 9:33 AM * * To change this template, choose Tools | Options and locate the template under * the Source Creation and Management node. Right-click the template and choose * Open. You can then make changes to the template in the Source Editor. */ package org.jmonks.batchserver.io; /** * * @author Suresh Pragada */ public final class FileIO { private FileIO() { } public static FileReader readFile(String filePath,String fileSpecPath) { return FileReader.getFileReader(filePath,fileSpecPath); } } --- NEW FILE: FileType.java --- /* * FileType.java * * Created on May 26, 2006, 3:01 PM * * To change this template, choose Tools | Options and locate the template under * the Source Creation and Management node. Right-click the template and choose * Open. You can then make changes to the template in the Source Editor. */ package org.jmonks.batchserver.io; /** * * @author Suresh Pragada */ public final class FileType { private String fileType=null; /** Creates a new instance of FileType */ private FileType(String fileType) { this.fileType=fileType; } public String toString() { return fileType; } public static final FileType FIXED_WIDTH_FLAT_FILE = new FileType("fixed-width-flat"); public static final FileType DELIMITED_FLAT_FILE = new FileType("delimited-flat"); } --- NEW FILE: FieldSpec.java --- /* * FieldSpec.java * * Created on May 26, 2006, 2:25 PM * * To change this template, choose Tools | Options and locate the template under * the Source Creation and Management node. Right-click the template and choose * Open. You can then make changes to the template in the Source Editor. */ package org.jmonks.batchserver.io; /** * * @author Suresh Pragada */ public class FieldSpec { private String fieldName=null; private Class fieldType=null; /** Creates a new instance of FieldSpec */ public FieldSpec(String fieldName,Class fieldType) { this.fieldName=fieldName; this.fieldType=fieldType; } public String getFieldName() { return this.fieldName; } public Class getFieldType() { return this.fieldType; } } --- NEW FILE: FileReader.java --- /* * FileReader.java * * Created on May 26, 2006, 9:37 AM * * To change this template, choose Tools | Options and locate the template under * the Source Creation and Management node. Right-click the template and choose * Open. You can then make changes to the template in the Source Editor. */ package org.jmonks.batchserver.io; /** * * @author Suresh Pragada */ public abstract class FileReader { protected String filePath=null; protected FileSpec fileSpec=null; public static FileReader getFileReader(String filePath,String fileSpecPath) { FileReader fileReader=null; /** * Create the fileSpec. */ FileSpec fileSpec=FileSpec.createFileSpec(fileSpecPath); if(fileSpec.getFileType()==FileType.FIXED_WIDTH_FLAT_FILE) { fileReader=new FixedWidthFlatFileReader(); fileReader.filePath=filePath; fileReader.fileSpec=fileSpec; } else if(fileSpec.getFileType()==FileType.DELIMITED_FLAT_FILE) { fileReader=null; // Create Demlited Flat file reader. fileReader.filePath=filePath; fileReader.fileSpec=fileSpec; } else { // Throw an exception. } return fileReader; } protected abstract void initialize(); public abstract Record getNextRecord(); } --- NEW FILE: payment-file-spec.xml --- <?xml version="1.0" encoding="UTF-8"?> <file-spec file-type="fixed-width-flat"> <record-spec record-type="header" start-with="1"> <field-spec field-name="timestamp" field-type="java.lang.String" start-pos="2" end-pos="9"/> </record-spec> <record-spec record-type="detail" starts-with="5"> <field-spec field-name="pmtId" field-type="java.lang.Long" start-pos="2" end-pos="11"/> <field-spec field-name="pmtAmt" field-type="java.lang.Double" start-pos="12" end-pos="21"/> <field-spec field-name="mpaId" field-type="java.lang.Long" start-pos="22" end-pos="31"/> <field-spec field-name="pmId" field-type="java.lang.Long" start-pos="32" end-pos="41"/> </record-spec> <record-spec record-type="trailor" start-with="6"> <field-spec field-name="grandAmount" field-type="java.lang.Double" start-pos="2" end-pos="9"/> </record-spec> <!-- <record-spec record-type="detail" delimiter="|"> <field-spec field-name="pmtId" field-type="java.lang.Long" index="1"/> </record-spec> --> </file-spec> |