Package sg.edu.nus.iss.se07.common.io

Examples of sg.edu.nus.iss.se07.common.io.CSVFormat


                return errorList;
        }

        public ErrorList update(Member newCategory, Member oldCategory) {
                ErrorList errorList = new ErrorList();
                return errorList;
        }
View Full Code Here


                ErrorList errorList = new ErrorList();
                return errorList;
        }

        public ErrorList delete(Member member) throws AppException {
                ErrorList errorList = new ErrorList();
                return errorList;
        }
View Full Code Here

                ErrorList errorList = new ErrorList();
                return errorList;
        }

        public ErrorList delete(String memberID) throws AppException {
                ErrorList errorList = new ErrorList();
                return errorList;
        }
View Full Code Here

                        String data = category.toCSVFormat(format);
                        bw = FileUtil.getBufferedWriter(fileName, append);
                        if (bw != null) {
                                FileUtil.writeContents(bw, data);
                        } else {
                                throw new AppException("[CategoryDA::writeData]Failed to create filename " + fileName, "[CategoryDA::writeData]",null);
                        }
                } catch (IOException ex) {
                        throw new AppException(ex.getMessage(), "[CategoryDA::writeData]", ex);
                } finally {
                        try {
                                if (bw != null) {
                                        bw.close();
                                }
View Full Code Here

                                        Category category = new Category(categoryCode, categoryName);
                                        String data = category.toCSVFormat(format);
                                        FileUtil.writeContents(bw, data);
                                }
                        } else {
                                throw new AppException("Failed to create filename " + fileName, "[CategoryDA::writeDataSet]", null);
                        }
                } catch (IOException ex) {
                        throw new AppException(ex.getMessage(), "[CategoryDA::writeDataSet]", ex);
                } finally {
                        try {
                                if (bw != null) {
                                        bw.close();
                                }
View Full Code Here

                                if (contents == null) {
                                        return null;
                                }
                                String[] lines = StringUtil.parse(contents, format.getEndOfLineSymbols());
                                if (lines == null) {
                                        throw new AppException("Record not found.", "[CategoryDA::readData]", null);
                                } else {

                                        if (lines.length < 1) {
                                                throw new AppException("Record not found.", "[CategoryDA::readData]", null);
                                        }

                                        for (int i = 0; i < lines.length; i++) {
                                                String record = lines[i];
                                                String[] fields = StringUtil.parse(record, String.valueOf((char) format.getDelimiterChar()));
                                                if (fields == null) {
                                                        throw new AppException("Unable to read record no " + (String.valueOf(i + 1)), "[CategoryDA::readData]", null);
                                                } else {
                                                        if (fields.length != 2) {
                                                                Logger.getLogger(CategoryDA.class.getName()).log(Level.SEVERE, "[CategoryDA::readData]Record no " + (String.valueOf(i + 1)) + " is corrupted");
                                                        } else {
                                                                String catCode = fields[0];
                                                                String catName = fields[1];
                                                                if (catCode == null) {
                                                                        catCode = "";
                                                                }

                                                                if (catName == null) {
                                                                        catName = "";
                                                                }

                                                                if (categoryCode.equalsIgnoreCase(catCode)) {
                                                                        dataObject = new Category();
                                                                        dataObject.setCategoryCode(catCode);
                                                                        dataObject.setCategoryName(catName);
                                                                        i = lines.length;
                                                                }
                                                        }
                                                }
                                        }
                                }
                        } else {
                                throw new AppException("File not found.", "[CategoryDA::readData]", null);
                        }
                } catch (IOException ex) {
                        throw new AppException(ex.getMessage(), "[CategoryDA::readData]", ex);
                } finally {
                        if (br != null) {
                                try {
                                        br.close();
                                } catch (IOException ex) {
View Full Code Here

                                if (contents == null) {
                                        return null;
                                }
                                String[] lines = StringUtil.parse(contents, format.getEndOfLineSymbols());
                                if (lines == null) {
                                        throw new AppException("Record not found.", "[CategoryDA::readDataSet]", null);
                                } else {

                                        if (lines.length < 1) {
                                                throw new AppException("Record not found.", "[CategoryDA::readDataSet]", null);
                                        }

                                        dataObjectSet = new ArrayList<Tuple2<NameValue<String>, NameValue<String>>>();
                                        for (int i = 0; i < lines.length; i++) {
                                                String record = lines[i];
                                                String[] fields = StringUtil.parse(record, String.valueOf((char) format.getDelimiterChar()));
                                                if (fields == null) {
                                                        throw new AppException("Unable to read record no " + (String.valueOf(i + 1)), "[CategoryDA::readDataSet]", null);
                                                } else {
                                                        if (fields.length != 2) {
                                                                Logger.getLogger(CategoryDA.class.getName()).log(Level.SEVERE, "[CategoryDA::readData]Record no " + (String.valueOf(i + 1)) + " is corrupted");
                                                        } else {

                                                                //get the value from file and verify it
                                                                String catCode = fields[0];
                                                                String catName = fields[1];
                                                                if (catCode == null) {
                                                                        catCode = "";
                                                                }

                                                                if (catName == null) {
                                                                        catName = "";
                                                                }

                                                                //valid row
                                                                if (!"".equalsIgnoreCase(catCode) && !"".equalsIgnoreCase(catName)) {
                                                                        NameValue<String> categoryCode = new NameValue<String>("CategoryCode", catCode);
                                                                        NameValue<String> categoryName = new NameValue<String>("CategoryName", catName);
                                                                        dataObjectSet.add(new Tuple2<NameValue<String>, NameValue<String>>(categoryCode, categoryName));
                                                                }

                                                        }
                                                }
                                        }
                                }
                        } else {
                                throw new AppException("File not found.", "[CategoryDA::readDataSet]", null);
                        }
                } catch (IOException ex) {
                        throw new AppException(ex.getMessage(), "[CategoryDA::readDataSet]", ex);
                } finally {
                        if (br != null) {
                                try {
                                        br.close();
                                } catch (IOException ex) {
View Full Code Here

                if (!dir.endsWith("\\")) {
                        dir = dir + "\\";
                }
                dir = dir + SystemSetting.getProperty("report.folder");
                String fileOutputName = dir + "\\" + MEMBER_REPORT_PREFIX + "-" + System.currentTimeMillis() + MEMBER_REPORT_SUFFIX;
                CSVFormat fileInputFormat = CSVFormat.STANDARD_FORMAT;
                String fileInputName = MemberDA.DEFAULT_MEMBER_FILENAME;
                String reportTitle = "MEMBER REPORT";

                setReportTitle(reportTitle);
                setFileInputFormat(fileInputFormat);
View Full Code Here

                if (!dir.endsWith("\\")) {
                        dir = dir + "\\";
                }
                dir = dir + SystemSetting.getProperty("report.folder");
                String fileOutputName = dir + "\\" + PRODUCT_REPORT_PREFIX + "-" + System.currentTimeMillis() + PRODUCT_REPORT_SUFFIX;
                CSVFormat fileInputFormat = CSVFormat.STANDARD_FORMAT;
                String fileInputName = ProductDA.DEFAULT_PRODUCT_FILENAME;
                String reportTitle = "PRODUCT REPORT";

                setReportTitle(reportTitle);
                setFileInputFormat(fileInputFormat);
View Full Code Here

                if (!dir.endsWith("\\")) {
                        dir = dir + "\\";
                }
                dir = dir + SystemSetting.getProperty("report.folder");
                String fileOutputName = dir + "\\" + TRANSACTION_REPORT_PREFIX + "-" + System.currentTimeMillis() + TRANSACTION_REPORT_SUFFIX;
                CSVFormat fileInputFormat = CSVFormat.STANDARD_FORMAT;
                String fileInputName = TransactionDA.DEFAULT_TRANSACTION_FILENAME;
                String reportTitle = "TRANSACTION REPORT";

                setReportTitle(reportTitle);
                setFileInputFormat(fileInputFormat);
View Full Code Here

TOP

Related Classes of sg.edu.nus.iss.se07.common.io.CSVFormat

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.