Documentation is available at TopicMapSystemFactory.abstract.php
- <?php
- /**
- * @package org.phptmapi.core
- */
- require_once('FactoryConfigurationException.exception.php');
- /**
- * abstract class TopicMapSystemFactory: This factory class provides access to a topic map system. A new TopicMapSystemInterface instance is created by invoking the newTopicMapSystem() method. Configuration properties for the new TopicMapSystemInterface instance can be set by calling the setFeature() and/or setProperty() methods prior to invoking newTopicMapSystem().
- *
- * @author Johannes Schmidt - t8d <kontakt@t8d.de>
- */
- abstract class TopicMapSystemFactory{
- /**
- * Constructor
- * @access public
- * @return void
- */
- abstract function __construct();
- /**
- * newInstance: This static method creates a new factory instance.
- * @access public
- * @return object TopicMapSystemFactory
- * @throws FactoryConfigurationException
- */
- public static function newInstance(){
- try{
- $class = self::getClassFromFile();
- if($class instanceof TopicMapSystemFactory){
- $instance = $class->newInstance();
- return $instance;
- }
- else throw new FactoryConfigurationException('Exception in '.__method__.': Cannot instantiate an implementation of TopicMapSystemFactory!');
- }
- catch(FactoryConfigurationException $e){
- $exception = $e->getCause();
- echo $exception->getMessage();
- }
- }
- /**
- * newTopicMapSystem: Creates a new TopicMapSystemInterface instance using the currently configured factory parameters.
- * @access public
- * @return object TopicMapSystemInterface
- * @throws TMAPIException if a topic map system cannot be created which satisfies the requested configuration.
- * <code>
- * public function newTopicMapSystem(){
- * throw new TMAPIException('Exception in '.__method__);
- * }
- * </code>
- */
- abstract function newTopicMapSystem();
- /**
- * setFeature: Sets a particular feature in the underlying implementation of TopicMapSystemInterface. A list of the core features can be found at http://tmapi.org/features/.
- * @param string $featureName The name of the feature to be set.
- * @param boolean $value True to enable the feature, false to disable it.
- * @access public
- * @return void
- * @throws FeatureNotRecognizedException if the underlying implementation does not recognize the named feature.
- * @throws FeatureNotSupportedException if the underlying implementation recognizes the named feature but does not support enabling or disabling it (as specified by the value parameter).
- * <code>
- * public function setFeature($featureName, $value){
- * throw new FeatureNotRecognizedException('Exception in '.__method__);
- * throw new FeatureNotSupportedException('Exception in '.__method__);
- * }
- * </code>
- */
- abstract function setFeature($featureName, $value);
- /**
- * Returns the particular feature requested for in the underlying implementation of TopicMapSystemInterface.
- * @param string $featureName The name of the feature to check.
- * @access public
- * @return boolean true if the named feature is enabled for TopicMapSystemInterface instances created by this factory; false if the named feature is disabled for TopicMapSystemInterface instances created by this factory.
- * @throws FeatureNotRecognizedException if the underlying implementation does not recognize the named feature.
- * <code>
- * public function getFeature($featureName){
- * throw new FeatureNotRecognizedException('Exception in '.__method__);
- * }
- * </code>
- */
- abstract function getFeature($featureName);
- /**
- * Returns if the particular feature is supported by the TopicMapSystemInterface. Opposite to getFeature() this method returns if the requested feature is generally available/supported by the underlying TopicMapSystemInterface and does not return the state (enabled/disabled) of the feature.
- * @param string $featureName The name of the feature to check.
- * @access public
- * @return boolean true if the requested feature is supported, otherwise false.
- */
- abstract function hasFeature($featureName);
- /**
- * Sets the properties in the underlying implementation of TopicMapSystemInterface.
- * @param array $props The properties to be used to initialise the system.
- * @access public
- * @return void
- * @see setProperty()
- */
- abstract function setProperties($props);
- /**
- * Sets a property in the underlying implementation of TopicMapSystemInterface. A list of the core properties defined by TMAPI can be found at http://tmapi.org/properties/. An implementation is free to support properties other than the core ones.
- * @param string $propertyName The name of the property to be set
- * @param string $value The value to be set of this property or null to remove the property from the current factory configuration.
- * @access public
- * @return void
- */
- abstract function setProperty($propertyName, $value);
- /**
- * Gets the value of a property in the underlying implementation of TopicMapSystemInterface.
- * A list of the core properties defined by TMAPI can be found at http://tmapi.org/properties/. An implementation is free to support properties other than the core ones.
- * @param string $propertyName The name of the property to retrieve.
- * @access public
- * @return string The value set for this property or null if no value is currently set for the property.
- */
- abstract function getProperty($propertyName);
- /**
- * getClassFromFile: Returns the TopicMapSystemFactory implementation using the discovery file.
- * @access private
- * @return object TopicMapSystemFactory
- * @throws FactoryConfigurationException
- */
- private static function getClassFromFile(){
- try{
- $dir = '../META/factory/';
- if($dh = opendir($dir)){
- while(($tempfile = readdir($dh)) !== false) {
- $file = $tempfile;
- }
- closedir($dh);
- if($pathToClass = file_get_contents($dir.$file)){
- require_once $pathToClass;
- $class = $file;
- $class = new $class;
- return $class;
- }
- else throw new FactoryConfigurationException('Exception in '.__method__.': Cannot read discovery file for the implementation of TopicMapSystemFactory!');
- }
- else throw new FactoryConfigurationException('Exception in '.__method__.': Cannot open directory that includes discovery file for the implementation of TopicMapSystemFactory!');
- }
- catch(FactoryConfigurationException $e){
- $exception = $e->getCause();
- echo $exception->getMessage();
- }
- }
- }
- ?>
Documentation generated on Fri, 30 Jun 2006 13:07:11 +0200 by phpDocumentor 1.3.0RC4