FileDocCategorySizeDatePackage
CDDiscImportExport.javaAPI DocExample1648Thu May 05 05:27:58 BST 2005com.samscdrental.importexport

CDDiscImportExport

public class CDDiscImportExport extends Object

Fields Summary
private static final String
ERROR_CDDISC_TOKEN_COUNT
private static final String
ERROR_CDRELEASE_NOT_FOUND
Constructors Summary
Methods Summary
public static CDDiscparseLine(java.lang.String line)
parseLine

param
aString String

		// The line is expected to be in <PhysicalID> <UPCCode of CDRelease> format
		String[] tokens = line.split( "\\|" );
		if ( tokens.length < 2 )
		{
			throw new ParseLineDeviation( ERROR_CDDISC_TOKEN_COUNT +
										  tokens.length );
		}

		String cdDiscPhysicalIDString = tokens[0];
		String cdDiscReleaseUPCCodeString = tokens[1];
		try
		{
			PhysicalID aPhysicalID = PhysicalID.parseString(
				cdDiscPhysicalIDString );
			UPCCode aUPCCode = UPCCode.parseString( cdDiscReleaseUPCCodeString );

			StoreDataAccess collections = StoreDataAccess.getInstance();
			CDRelease aCDRelease = collections.theCDReleaseDataAccess.
				findByUPCCode( aUPCCode );
			if ( aCDRelease == null )
			{
				throw new ParseLineDeviation( ERROR_CDRELEASE_NOT_FOUND +
											  aUPCCode );
			}
			return new CDDisc( aCDRelease, aPhysicalID );
		}
		catch ( PhysicalIDFormatDeviation e )
		{
			throw new ParseLineDeviation( e.getMessage() );
		}
		catch ( UPCCodeFormatDeviation e )
		{
			throw new ParseLineDeviation( e.getMessage() );
		}