Package com.btaz.util

Examples of com.btaz.util.DataUtilException


                           String pageDescription, int tableColumns, int maxRowsPerPage) {
        encoding = "UTF8";

        // validations
        if(outputDirectory == null) {
            throw new DataUtilException("The outputDirectory field can not be a null value");
        }
        if(!outputDirectory.exists()) {
            throw new DataUtilException("The output directory must exist: " + outputDirectory.getAbsolutePath());
        }
        if(filenamePrefix == null) {
            throw new DataUtilException("The filenamePrefix field can not be a null value");
        }
        if(filenamePrefix.length() < 1) {
            throw new DataUtilException("The filenamePrefix field must contain at least one character");
        }
        if(pageTitle == null) {
            pageTitle = "";
        }
        if(tableColumns < 1) {
            throw new DataUtilException("You must have at least one column. Invalid column value: " + tableColumns);
        }

        this.tableColumns = tableColumns;
        this.outputDirectory = outputDirectory;
        this.filenamePrefix = filenamePrefix;
View Full Code Here


     * @param columns columns
     * @throws DataUtilException exception
     */
    public void write(String... columns) throws DataUtilException {
        if(columns.length != tableColumns) {
            throw new DataUtilException("Invalid column count. Expected " + tableColumns + " but found: "
                    + columns.length);
        }
        try {
            if(currentRow == 0) {
                // capture header row
                this.headerRowColumns = columns;
                writeTop();
                writeRow(headerRowColumns);
            } else if(maxRowsPerPage > 1 && currentRow % maxRowsPerPage == 0) {
                writeRow(columns);
                writeBottom(true);
                currentPageNumber = (currentRow/maxRowsPerPage) + 1;
                writeTop();
                writeRow(headerRowColumns);
                writeRow(columns);
            } else {
                writeRow(columns);
            }
            currentRow += 1;
        } catch (Exception e) {
            throw new DataUtilException(e);
        }
    }
View Full Code Here

        try {
            if(writer != null) {
                writeBottom(false);
            }
        } catch (IOException e) {
            throw new DataUtilException("Failed to close the HTML table file", e);
        }
    }
View Full Code Here

     * @return file new file
     * @throws DataUtilException data util exception
     */
    public File createFile(File dir, String filename) throws DataUtilException {
        if(dir == null) {
            throw new DataUtilException("The directory parameter can't be a null value");
        }
        try {
            File file = new File(dir, filename);
            return createFile(file);
        } catch (Exception e) {
            throw new DataUtilException("Invalid file: " + filename);
        }
    }
View Full Code Here

     * @param file new file
     * @return file new file
     */
    public File createFile(File file) throws DataUtilException {
        if(file == null) {
            throw new DataUtilException("File parameter can not be a null value");
        }

        try {
            if(! file.createNewFile()) {
                throw new DataUtilException("Failed to create file. Result of File.createNewFile() was false.");
            }
            trackedFiles.add(file);
        } catch (IOException e) {
            throw new DataUtilException("Failed to create file: " + file.getAbsolutePath(), e);
        }
        return file;
    }
View Full Code Here

     * @param dir new directory
     * @return file new directory
     */
    public File createDir(File dir) throws DataUtilException {
        if(dir == null) {
            throw new DataUtilException("Dir parameter can not be a null value");
        }
        if(dir.exists()) {
            throw new DataUtilException("Directory already exists: " + dir.getAbsolutePath());
        }
        if(! dir.mkdir()) {
            throw new DataUtilException("The result of File.mkDir() was false. Failed to create directory. : "
                    + dir.getAbsolutePath());
        }
        trackedFiles.add(dir);
        return dir;
    }
View Full Code Here

        assert url != null : "Couldn't load : " + resourceName;
        try {
            return new File(url.toURI());
        } catch (URISyntaxException e) {
            throw new DataUtilException("Couldn't load test resource");
        }
    }
View Full Code Here

        Collections.sort(files, filePathComparator);

        for(File file : files) {
            if(file.exists()) {
                if(!file.delete()) {
                    throw new DataUtilException("Couldn't delete a tracked "
                            + (file.isFile()? "file":"directory" + ": ") + file.getAbsolutePath());
                }
            }
        }
View Full Code Here

                // no more data
                writer.flush();
                writer.close();
            }
        } catch (IOException e) {
            throw new DataUtilException(e);
        }
    }
View Full Code Here

            try {
                inputStream = new FileInputStream(file);
                reader = new BufferedReader(new InputStreamReader(inputStream, DataUtilDefaults.charSet));
                hasMoreData = true;
            } catch (FileNotFoundException e) {
                throw new DataUtilException(e);
            } catch (UnsupportedEncodingException e) {
                throw new DataUtilException(e);
            }
        }
View Full Code Here

TOP

Related Classes of com.btaz.util.DataUtilException

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.