[Batchserver-cvs] batchserver/src/org/jmonks/batchserver/io FileParseException.java, 1.2, 1.3 FileS
Brought to you by:
suresh_pragada
From: Suresh <sur...@us...> - 2006-06-08 02:51:16
|
Update of /cvsroot/batchserver/batchserver/src/org/jmonks/batchserver/io In directory sc8-pr-cvs3.sourceforge.net:/tmp/cvs-serv2188/org/jmonks/batchserver/io Modified Files: FileParseException.java FileSpec.java FileSpecException.java FileType.java Record.java RecordType.java WriterRecord.java Log Message: no message Index: FileSpecException.java =================================================================== RCS file: /cvsroot/batchserver/batchserver/src/org/jmonks/batchserver/io/FileSpecException.java,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** FileSpecException.java 1 Jun 2006 22:11:41 -0000 1.2 --- FileSpecException.java 7 Jun 2006 22:10:41 -0000 1.3 *************** *** 12,15 **** --- 12,19 ---- /** + * <p> + * FileSpecException is a runtime exception thrown when there is a problem creating + * the FileSpec object from the given file contains the file specification. + * </p> * * @author Suresh Pragada *************** *** 19,24 **** public class FileSpecException extends RuntimeException { ! ! /** Creates a new instance of FileSpecException */ public FileSpecException(String message) { --- 23,32 ---- public class FileSpecException extends RuntimeException { ! /** ! * Constructs the FileSpecException by accepting the message describes the ! * problem. ! * ! * @param message Message identifies the problem. ! */ public FileSpecException(String message) { Index: RecordType.java =================================================================== RCS file: /cvsroot/batchserver/batchserver/src/org/jmonks/batchserver/io/RecordType.java,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** RecordType.java 1 Jun 2006 22:11:41 -0000 1.2 --- RecordType.java 7 Jun 2006 22:10:41 -0000 1.3 *************** *** 12,28 **** /** ! * ! * @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 static RecordType toRecordType(String recordType) { --- 12,60 ---- /** ! * <p> ! * RecordType defines the different kind of records can be available in a file. ! * This defines the constants to identify all the records as enums. This record ! * type information should be provided when defining the record spec in file spec. ! * </p> ! * @author Suresh Pragada ! * @version 1.0 ! * @since 1.0 */ ! public class RecordType { + /** + * Holds the string representing the record type. + */ private String type=null; ! /** ! * Private constructor to make sure that RecordType cannot be instantiated from ! * outside of this class. ! * ! * @param type String representing the type of record. ! * ! * @throws IllegalArgumentException Throws if the type is null or the value is in use. ! */ ! protected RecordType(String type) { ! if(type!=null) ! { ! if("HEADER".equalsIgnoreCase(type) || "DETAIL".equalsIgnoreCase(type) || "TRAILOR".equalsIgnoreCase(type)) ! throw new IllegalArgumentException("Record type value " + type + " is in use."); ! else ! this.type=type; ! } ! else ! throw new IllegalArgumentException("Record type cannot be null."); } ! ! /** ! * Utility method returns the RecordType object matches to the given value. ! * ! * @param type String representing the type of record. ! * ! * @return Returns the RecordType references matches to the given value, null ! * if it cannot match the given value to any of the available record types. ! */ public static RecordType toRecordType(String recordType) { *************** *** 37,47 **** } ! 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"); } --- 69,95 ---- } ! /** ! * Returns the string representation of the RecordType which can be used to ! * define the record spec in file spec. ! */ ! public final String toString() { return type; } ! ! /** ! * Represents the header record and the value to be used in the record ! * spec is "HEADER". ! */ public static final RecordType HEADER = new RecordType("HEADER"); + /** + * Represents the detailed record and the value to be used in the record + * spec is "DETAIL". + */ public static final RecordType DETAIL = new RecordType("DETAIL"); + /** + * Represents the header record and the value to be used in the record + * spec is "TRAILOR". + */ public static final RecordType TRAILOR = new RecordType("TRAILOR"); } Index: Record.java =================================================================== RCS file: /cvsroot/batchserver/batchserver/src/org/jmonks/batchserver/io/Record.java,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** Record.java 2 Jun 2006 21:02:06 -0000 1.2 --- Record.java 7 Jun 2006 22:10:41 -0000 1.3 *************** *** 11,16 **** package org.jmonks.batchserver.io; ! import java.util.HashMap; ! import java.util.Map; --- 11,15 ---- package org.jmonks.batchserver.io; ! Index: FileParseException.java =================================================================== RCS file: /cvsroot/batchserver/batchserver/src/org/jmonks/batchserver/io/FileParseException.java,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** FileParseException.java 2 Jun 2006 21:02:06 -0000 1.2 --- FileParseException.java 7 Jun 2006 22:10:41 -0000 1.3 *************** *** 12,26 **** /** * ! * @author Suresh Pragada */ public class FileParseException extends RuntimeException { ! ! /** Creates a new instance of FileParseException */ public FileParseException(String message) { super(message); ! } ! } --- 12,35 ---- /** + * <p> + * FileParseException is a runtime exception thrown when there is a problem reading + * the records from the file or writing the records into the file. + * </p> * ! * @author Suresh Pragada ! * @version 1.0 ! * @since 1.0 */ public class FileParseException extends RuntimeException { ! /** ! * Constructs the FileParseException by accepting the message describes ! * the problem. ! * ! * @param message Messages describes the problem. ! */ public FileParseException(String message) { super(message); ! } } Index: WriterRecord.java =================================================================== RCS file: /cvsroot/batchserver/batchserver/src/org/jmonks/batchserver/io/WriterRecord.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** WriterRecord.java 2 Jun 2006 21:02:06 -0000 1.1 --- WriterRecord.java 7 Jun 2006 22:10:41 -0000 1.2 *************** *** 11,15 **** package org.jmonks.batchserver.io; ! import org.apache.xml.resolver.apps.resolver; /** --- 11,15 ---- package org.jmonks.batchserver.io; ! /** Index: FileSpec.java =================================================================== RCS file: /cvsroot/batchserver/batchserver/src/org/jmonks/batchserver/io/FileSpec.java,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** FileSpec.java 3 Jun 2006 13:14:41 -0000 1.5 --- FileSpec.java 7 Jun 2006 22:10:41 -0000 1.6 *************** *** 29,32 **** --- 29,38 ---- /** + * <p> + * 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. + * </p> * * @author Suresh Pragada *************** *** 36,47 **** public abstract class FileSpec { protected String fileSpecPath=null; ! protected FileType fileType=null; ! protected List recordSpecList=null; ! public static final String FILE_SPEC_TAG_NAME = "file-spec"; ! public static final String FILE_TYPE_ATTRIB_NAME = "file-type"; --- 42,64 ---- public abstract class FileSpec { + /** + * Holds the path of the file contains the spec of any file to read/write. + */ protected String fileSpecPath=null; ! /** ! * Holds the type of the file this spec is representing. ! */ protected FileType fileType=null; ! /** ! * Holds the list of record specs. ! */ protected List recordSpecList=null; ! /** ! * Constant defines the file spec tage name. ! */ public static final String FILE_SPEC_TAG_NAME = "file-spec"; ! /** ! * Constant defines the attribute name file type should contain. ! */ public static final String FILE_TYPE_ATTRIB_NAME = "file-type"; *************** *** 49,53 **** /** ! * Creates a new instance of FileSpec */ protected FileSpec(String fileSpecPath,FileType fileType) --- 66,74 ---- /** ! * Constructs the FileSpec object by accepting the path of the file contains ! * the file specification and file type. ! * ! * @param fileSpecPath Path of a file contains the spec. ! * @param fileType Type of the file this spec is representing. */ protected FileSpec(String fileSpecPath,FileType fileType) *************** *** 59,76 **** /** ! * Adds the record spec object to the record spec list. * ! * @param recordSpec Record spec. * * @return Returns true, if record spec is added, false otherwise. */ protected boolean addRecordSpec(RecordSpec recordSpec) { ! this.recordSpecList.add(recordSpec); ! return true; } /** ! * Gets the record spec's as a list. * * @return Returns record spec's as a list. --- 80,101 ---- /** ! * Adds the record spec to the file spec. * ! * @param recordSpec Record spec to be added to the file spec. * * @return Returns true, if record spec is added, false otherwise. + * + * @throws IllegalArgumentException If recordSpec is null. */ protected boolean addRecordSpec(RecordSpec recordSpec) { ! if(recordSpec==null) ! throw new IllegalArgumentException("RecordSpec cannot be null to add to the file spec."); ! else ! return this.recordSpecList.add(recordSpec); } /** ! * Gets all the record spec's in this file spec as a list. * * @return Returns record spec's as a list. *************** *** 80,83 **** --- 105,126 ---- return this.recordSpecList; } + + /** + * + * @throws IllegalArgumentException If recordType is null. + */ + public RecordSpec getRecordSpec(RecordType recordType) + { + if(recordType==null) + throw new IllegalArgumentException("RecordType cannot be null to get the record spec from file spec."); + else + { + for(Iterator iterator=this.recordSpecList.iterator();iterator.hasNext();) + { + RecordSpec recordSpec=(RecordSpec)iterator.next(); + if(recordType.toString().equ) + } + } + } /** *************** *** 119,132 **** return XMLFileSpec.createXMLFileSpec(fileSpecPath,fileSpecElement); else ! throw new FileSpecException("Configured file type in the file spec is not recognizable."); } else ! throw new FileSpecException("File spec root element doenst match the expected " + FileSpec.FILE_SPEC_TAG_NAME + " value."); } catch(FileNotFoundException exception) { exception.printStackTrace(); ! logger.fatal("Couldnt find the file spec in the given file path = " + fileSpecPath,exception); ! throw new FileSpecException("Cannot find the file = " + fileSpecPath + " Message = " + exception.getMessage()); } catch(ParserConfigurationException exception) --- 162,175 ---- return XMLFileSpec.createXMLFileSpec(fileSpecPath,fileSpecElement); else ! throw new FileSpecException("Configured file type " + fileType + " in the file spec is not recognizable. File spec location = " + fileSpecPath); } else ! throw new FileSpecException("File spec root element doesnt match the expected " + FileSpec.FILE_SPEC_TAG_NAME + " value in the file spec located at = " + fileSpecPath); } catch(FileNotFoundException exception) { exception.printStackTrace(); ! logger.fatal("Cannot find the file in the given path = " + fileSpecPath,exception); ! throw new FileSpecException("Cannot find the file contains the spec in given location = ." + fileSpecPath + " Message = " + exception.getMessage()); } catch(ParserConfigurationException exception) *************** *** 140,144 **** exception.printStackTrace(); logger.fatal("Parsing exception while parsing the file spec = " + fileSpecPath,exception); ! throw new FileSpecException("Parsing exception while parsing the file spec = " + fileSpecPath + " Message = " + exception.getMessage()); } catch(IOException exception) --- 183,187 ---- exception.printStackTrace(); logger.fatal("Parsing exception while parsing the file spec = " + fileSpecPath,exception); ! throw new FileSpecException("Parsing exception while parsing the file spec in given location = " + fileSpecPath + " Message = " + exception.getMessage()); } catch(IOException exception) *************** *** 146,150 **** exception.printStackTrace(); logger.fatal("IO exception while parsing the file spec = " + fileSpecPath,exception); ! throw new FileSpecException("IO exception while parsing the file spec = " + fileSpecPath + " Message = " + exception.getMessage()); } } --- 189,193 ---- exception.printStackTrace(); logger.fatal("IO exception while parsing the file spec = " + fileSpecPath,exception); ! throw new FileSpecException("IO exception while parsing the file spec in given location=" + fileSpecPath + " Message = " + exception.getMessage()); } } Index: FileType.java =================================================================== RCS file: /cvsroot/batchserver/batchserver/src/org/jmonks/batchserver/io/FileType.java,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** FileType.java 3 Jun 2006 04:20:15 -0000 1.3 --- FileType.java 7 Jun 2006 22:10:41 -0000 1.4 *************** *** 12,34 **** /** * ! * @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 static FileType toFileType(String fileType) { ! if(FileType.FIXED_WIDTH_FLAT_FILE.toString().equalsIgnoreCase(fileType)) return FileType.FIXED_WIDTH_FLAT_FILE; ! else if(FileType.DELIMITED_FLAT_FILE.toString().equalsIgnoreCase(fileType)) return FileType.DELIMITED_FLAT_FILE; ! else if(FileType.XML_FILE.toString().equalsIgnoreCase(fileType)) return FileType.XML_FILE; else --- 12,59 ---- /** + * <p> + * FileType defines different kinds of file formats this package supports for + * reading and writing. This defines the constants to identify those file formats + * that it supports as enums. The file type information should be provided when + * defining the file spec to identify the kind of file this spec is going to represent. + * </p> * ! * @author Suresh Pragada ! * @version 1.0 ! * @since 1.0 */ public final class FileType { ! /** ! * Holds the string representing the file type. ! */ ! private String type=null; ! ! /** ! * Private constructor to make sure that FileType cannot be instantiated from ! * outside of this class. ! * ! * @param type String representing the type of file. ! */ ! private FileType(String type) { ! this.type=type; } ! /** ! * Utility method returns the FileType object matches to the given value. ! * ! * @param type String representing the type of file. ! * ! * @return Returns the FileType references matches to the given values, null ! * if it cannot match to the available file types. ! */ ! public static FileType toFileType(String type) { ! if(FileType.FIXED_WIDTH_FLAT_FILE.toString().equalsIgnoreCase(type)) return FileType.FIXED_WIDTH_FLAT_FILE; ! else if(FileType.DELIMITED_FLAT_FILE.toString().equalsIgnoreCase(type)) return FileType.DELIMITED_FLAT_FILE; ! else if(FileType.XML_FILE.toString().equalsIgnoreCase(type)) return FileType.XML_FILE; else *************** *** 36,46 **** } 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"); ! public static final FileType XML_FILE = new FileType("xml"); } --- 61,87 ---- } + /** + * Returns the string representation of the FileType which can be used to + * defines the file spec. + */ public String toString() { ! return type; } ! ! /** ! * Represents the fixed width flat files. The value to be used in the file ! * spec for this kind of file types is "fixed-width-flat". ! */ public static final FileType FIXED_WIDTH_FLAT_FILE = new FileType("fixed-width-flat"); + /** + * Represents the delimited flat files. The value to be used in the file + * spec for this kind of file types is "delimited-flat". + */ public static final FileType DELIMITED_FLAT_FILE = new FileType("delimited-flat"); ! /** ! * Represents the xml files. The value to be used in the file ! * spec for this kind of file types is "xml". ! */ ! public static final FileType XML_FILE = new FileType("xml"); } |