<?php
/**
 * This file is part of the set of generic classes available for implementations
 * of the DDR Simple API to speed up implementation. It contains a generic
 * implementation of the {@link PropertyRef} interface.
 * 
 * @author Sylvain Lequeux
 * @author Francois Daoust <fd@w3.org>
 * @package AskPythia
 * @subpackage Implementation
 * @version $Revision: 1.9 $
 * @license http://www.w3.org/Consortium/Legal/2002/copyright-software-20021231.html W3C Software Notice and License
 * @copyright Copyright (c) 2009, W3C (MIT, ERCIM, Keio)
 */

/**
 * Include the {@link PropertyRef} interface description.
 */
require_once(dirname(__FILE__).'/../../interface/propertyRef.php');
/**
 * Include the {@link PropertyName} interface description.
 */
require_once(dirname(__FILE__).'/../../interface/propertyName.php');
/**
 * Include the {@link SystemException} class description.
 */
require_once(dirname(__FILE__).'/../../interface/systemException.php');

/**
 * A basic {@link PropertyRef} holds the IRI of the vocabulary associated with
 * a property and an aspect, along with the property's local name and aspect
 * name within that vocabulary. 
 * 
 * @author Sylvain Lequeux
 * @author Francois Daoust <fd@w3.org>
 * @package AskPythia
 * @subpackage Implementation
 * @link http://www.w3.org/TR/DDR-Simple-API/ Device Description Repository Simple API
 * @version $Revision: 1.9 $
 * @license http://www.w3.org/Consortium/Legal/2002/copyright-software-20021231.html W3C Software Notice and License
 * @copyright Copyright (c) 2009, W3C (MIT, ERCIM, Keio)
 */
class BasicPropertyRef implements PropertyRef{
	/**
	 * @var PropertyName The property name (namespace included).
	 */
	private $propertyName;
	/**
	 * @var string the aspect name the property applies to.
	 */
	private $aspectName;
	
	/**
	 * Creates an instance of the BasicPropertyRef class initialized with
	 * the given @{link PropertyName} and aspect name.
	 * 
	 * @param PropertyName $propertyName The underlying property (namespace included)
	 * @param string $aspectName The aspect the property applies to within the property's namespace.
	 * @exception SystemException The arguments are not of the expected type.
	 */
	public function __construct($propertyName, $aspectName){
		if(!isset($propertyName)){
			throw new SystemException(
				'Property name cannot be NULL.',
				SystemException::$ILLEGAL_ARGUMENT);
		}
		if(!isset($aspectName)){
			throw new SystemException(
				'Aspect name cannot be NULL.',
				SystemException::$ILLEGAL_ARGUMENT);
		}
		if(!($propertyName instanceof PropertyName)){
			throw new SystemException(
				'The property name does not implement the PropertyName interface.',
				SystemException::$ILLEGAL_ARGUMENT);
		}
		$this->propertyName = $propertyName;
		$this->aspectName = $aspectName;		
	}
	
	public function getLocalPropertyName(){
		return $this->propertyName->getLocalPropertyName();
	}
	
	public function getAspectName(){
		return $this->aspectName;
	}
	
	public function getNamespace(){
		return $this->propertyName->getNamespace();
	}
}


?>