
/** vc_id = "$Id: ListingAttribute.cfm 10847 2007-09-11 21:24:35Z jgiven $" */
/**
 * This class's intention is to allow simple Yes/No data on particular attributes
 * of a Listing to be set and consolidated into a data structure suitable for 
 * transmitting across a bandwidth-expensive data stream such as a computer network.
 * @author Devin Canterberry
 * @created 2007-08-23 12:00 PM -08:00
 */
var ListingAttribute = function( flags )
{

	var OPEN_HOUSE      = 0x01;
	var PREMIER_LISTING = 0x02;
	var PHOTO_GALLERY   = 0x04;

	var m_Flags = flags ? flags : 0;

	/**
	 * @return true if the Open House attribute is set, false otherwise.
	 */
	this.hasOpenHouse = function() { return (m_Flags & OPEN_HOUSE) > 0; };

	/**
	 * @return true if the Premier Listing attribute is set, false otherwise.
	 */
	this.isPremierListing = function() { return (m_Flags & PREMIER_LISTING) > 0; };

	/**
	 * @return true if the Photo Gallery attribute is set, false otherwise.
	 */
	this.hasPhotoGallery = function() { return (m_Flags & PHOTO_GALLERY) > 0; };

	/**
	 * Set the attribute for Open House to the specified value.
	 * @param value The Open House attribute will be set to this value.
	 */
	this.setOpenHouse = function( value ) { m_Flags = value ? m_Flags | OPEN_HOUSE : m_Flags & ~OPEN_HOUSE; };

	/**
	 * Set the attribute for Premier Listing to the specified value.
	 * @param value The Premier Listing attribute will be set to this value.
	 */
	this.setPremierListing = function( value ) { m_Flags = value ? m_Flags | PREMIER_LISTING : m_Flags & ~PREMIER_LISTING; };

	/**
	 * Set the attribute for Photo Gallery to the specified value.
	 * @param value The Photo Gallery attribute will be set to this value.
	 */
	this.setPhotoGallery = function( value ) { m_Flags = value ? m_Flags | PHOTO_GALLERY : m_Flags & ~PHOTO_GALLERY; };

	/**
	 * This method satisfies all Object.hashCode() rules as defined in the JDK 6 documentation.
	 * @return The smallest possible data structure to uniquely identify the information
	 * represented by this object.
	 */
	this.hashCode = function() { return m_Flags; };

};


