/*
 * Profile.java
 *
 * Copyright (c) 2007  Vreixo Formoso
 *
 * This library is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 * See COPYING file for details.
 */

package org.pykix.libburnia.libburn;

import java.util.EnumSet;

/**
 * MMC profile of the loaded media.
 * 
 * @author Vreixo Formoso
 * @since 0.1
 */
public enum Profile {

	NONE((short)0, "No profile"),         
	NON_REMOVABLE_DISC((short)0x01, "Non-removable disc"),
	REMOVABLE_DISC((short)0x02, "Removable disc"),
	MO_ERASABLE((short)0x03, "MO Erasable"),
	OPTICAL_WRITE_ONCE((short)0x04, "Optical Write Once"),
	AS_MO((short)0x05, "AS-MO"),
	CD_ROM((short)0x08, "CD-ROM"),
	CD_R((short)0x09, "CD-R"),
	CD_RW((short)0x0A, "CD-RW"),
	DVD_ROM((short)0x10, "DVD-ROM"),
	DVD_R_SEQUENCIAL((short)0x11, "DVD-R Sequential Recording"),
	DVD_RAM((short)0x12, "DVD-RAM"),
	DVD_RW_RESTRICTED_OVERWITE((short)0x13, "DVD-RW Restricted Overwrite"),
	DVD_RW_SEQUENCIAL((short)0x14, "DVD-RW Sequential recording"),
	DVD_R_DL_SEQUENCIAL((short)0x15, "DVD-R Dual Layer Sequential Recording"),
	DVD_R_DL_JUMP((short)0x16, "DVD-R Dual Layer Jump Recording"),
	DVD_PLUS_RW((short)0x1A, "DVD+RW"),
	DVD_PLUS_R((short)0x1B, "DVD+R"),
	DVD_PLUS_RW_DL((short)0x2A, "DVD+RW Dual Layer"),
	DVD_PLUS_R_DL((short)0x2B, "DVD+R Dual Layer"),
	BD_ROM((short)0x40, "BD-ROM"),
	BD_R_SRM((short)0x41, "BD-R SRM"),
	BD_R_RRM((short)0x42, "BD-R RRM"),
	HD_DVD_ROM((short)0x50, "HD DVD-ROM"),
	HD_DVD_R((short)0x51, "HD DVD-R"),
	HD_DVD_RAM((short)0x52, "HD DVD-RAM"),
	UNKNOWN((short)0xFFFF, "Unknown Profile");               
	
	private final short code;
	private final String name;
	
	private Profile(final short code, final String name) {
		this.code = code;
		this.name = name;
	}

	/**
	 * Get the Profile Number as of mmc5r03c.pdf, table 89.
	 * 
	 * @return
	 * 		The profile number.
	 */
	public short getCode() {
		return code;
	}
	
	/**
	 * Get the Profile Name (e.g "CD-RW").
	 * 
	 * @return
	 * 		the profile name
	 */
	public String getName() {
		return name;
	}
	
	static Profile get(short code) {
		EnumSet<Profile> set = EnumSet.allOf(Profile.class);
		for ( Profile prof : set ) {
			if ( prof.getCode() == code) {
				return prof;
			}
		}
		return UNKNOWN;
	}
	
}
