Location: PHPKode > projects > PhpiCalLib > parameterfactory.php
<?php
/**
 * parameterfactory.php produces the right kind of parameter derived class for a parameter
 * 
 * This program 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.
 * 
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 * 
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
 *
 * @copyright Copyright (C) 2008 Nigel Swinson, hide@address.com 
 * @author  Nigel Swinson
 * @package PhpiCalLib
 * @version 1.0
 */

require_once 'parameters.php';

/**
 * The factory class for creating the right kind of {@link PhpiCalLib_Parameter} objects. 
 * 
 * Derived from Parameter, this factory class is able to create the right specialization of 
 * {@link PhpiCalLib_Parameter} when you call {@link PhpiCalLib_Parameter::Create()}
 */
class PhpiCalLib_ParameterFactory extends PhpiCalLib_Parameter {
	/**
	 * Overridden, to create the right kind of PhpiCalLib_ContentLine
	 */
	protected function CreateParameter($Name) {
		// Get the type of the property
		$Type = self::ToParameterType($Name);

		// Build the right type of object
		switch ($Type) {
			case PHPICALLIB_PARAMETER_ALTREP:
			case PHPICALLIB_PARAMETER_CN:
			case PHPICALLIB_PARAMETER_CUTYPE:
			case PHPICALLIB_PARAMETER_DELEGATED_FROM:
			case PHPICALLIB_PARAMETER_DELEGATED_TO:
			case PHPICALLIB_PARAMETER_DIR:
			case PHPICALLIB_PARAMETER_ENCODING:
			case PHPICALLIB_PARAMETER_FMTTYPE:
			case PHPICALLIB_PARAMETER_FBTYPE:
			case PHPICALLIB_PARAMETER_LANGUAGE:
			case PHPICALLIB_PARAMETER_MEMBER:
			case PHPICALLIB_PARAMETER_PARTSTAT:
			case PHPICALLIB_PARAMETER_RANGE:
			case PHPICALLIB_PARAMETER_RELATED:
			case PHPICALLIB_PARAMETER_RELTYPE:
			case PHPICALLIB_PARAMETER_ROLE:
			case PHPICALLIB_PARAMETER_RSVP:
			case PHPICALLIB_PARAMETER_SENT_BY:
			case PHPICALLIB_PARAMETER_TZID:
				break;
			case PHPICALLIB_PARAMETER_VALUE:
				return new PhpiCalLib_Parameters_Value();
			//http://tools.ietf.org/html/draft-ietf-calsify-rfc2445bis-08#section-3.2
			//       3.2.  Property Parameters
			case PHPICALLIB_PARAMETER_IANAPARAM:
			case PHPICALLIB_PARAMETER_XPARAM:
				// Very deliberatly the default
				$Result = new PhpiCalLib_Parameter();
				$Result->SetName($Name);
				return $Result;
		}
		
		// By default, return a generic Parameter
		$Result = new PhpiCalLib_Parameter();
		// We can call SetType(), as we have filtered off IanaParam and XParam
		$Result->SetType($Type);
		return $Result;
	}	
}

?>
Return current item: PhpiCalLib