edu.uci.ics.inf111.dvdvendor.app
Class Utils

java.lang.Object
  extended by edu.uci.ics.inf111.dvdvendor.app.Utils

public class Utils
extends java.lang.Object

This class contains constants, enums, and static methods that are commonly used in the DVD Vendor System.


Nested Class Summary
static class Utils.genre
          Enumeration that represents the different genres the DVD can belong to.
 
Field Summary
static double lateFee
          The double representation for the late fee to be charged per DVD.
 
Constructor Summary
Utils()
           
 
Method Summary
static java.lang.String getBarCodeFromDescription(java.lang.String description)
          This utility method returns the String that represents the BarCode from a String that has both the BarCode and the Title of the DVD.
static java.lang.String[] getBarCodesAndTitlesFromProductDB()
          This utility method returns an array of String with the Bar Codes and Titles from the Product Database
static java.lang.String getFieldBeforeSymbol(java.lang.String line, java.lang.String symbol)
          This utility method returns the String that represents the field between the beginning of the line and the symbol.
static java.lang.String getLineAfterSymbol(java.lang.String line, java.lang.String symbol)
          This utility method returns the String that represents the line after the indicated symbol.
static long getSecondsDifference(java.lang.String start, java.lang.String end)
          A utility method which calculates the difference in seconds between two date times
static boolean isNumber(java.lang.String str)
          This utility method returns true if the characters in the String are all numbers, else it returns false
static void printDB(java.util.Hashtable<java.lang.String,Product> itemsInDB)
          A utility method which prints the contents of the ProductDB to System.out
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

lateFee

public static double lateFee
The double representation for the late fee to be charged per DVD.

Constructor Detail

Utils

public Utils()
Method Detail

printDB

public static void printDB(java.util.Hashtable<java.lang.String,Product> itemsInDB)
A utility method which prints the contents of the ProductDB to System.out

Parameters:
itemsInDB - The DB Hashtable, which should be accessed using productDB.listAll()

getBarCodesAndTitlesFromProductDB

public static java.lang.String[] getBarCodesAndTitlesFromProductDB()
                                                            throws java.lang.Exception
This utility method returns an array of String with the Bar Codes and Titles from the Product Database

Throws:
java.lang.Exception - if there is any problem instantiating the ProductDB

isNumber

public static boolean isNumber(java.lang.String str)
This utility method returns true if the characters in the String are all numbers, else it returns false


getBarCodeFromDescription

public static java.lang.String getBarCodeFromDescription(java.lang.String description)
This utility method returns the String that represents the BarCode from a String that has both the BarCode and the Title of the DVD. This method is used to extract the bar code from the ComboBox in the Graphical User Interface

Parameters:
description - String showed in the ComboBox in the format barcode - title

getFieldBeforeSymbol

public static java.lang.String getFieldBeforeSymbol(java.lang.String line,
                                                    java.lang.String symbol)
This utility method returns the String that represents the field between the beginning of the line and the symbol. It is used to get the values of a Transaction read from the Transaction file

Parameters:
line - String that represents a line in the Transaction file
symbol - Stop symbol used to delimit fields in the Transaction file

getLineAfterSymbol

public static java.lang.String getLineAfterSymbol(java.lang.String line,
                                                  java.lang.String symbol)
This utility method returns the String that represents the line after the indicated symbol. It will delete a read field, so that the next one could be read. These fields correspond to fields in the Transaction file.

Parameters:
line - String that represents a line in the Transaction file
symbol - Stop symbol used to delimit fields in the Transaction file

getSecondsDifference

public static long getSecondsDifference(java.lang.String start,
                                        java.lang.String end)
                                 throws java.text.ParseException
A utility method which calculates the difference in seconds between two date times

Parameters:
start - The start date and time
end - The end date and time
Throws:
java.text.ParseException