3 namespace Org\Mxchange\CoreFramework\Handler;
5 // Import framework stuff
6 use Org\Mxchange\CoreFramework\Criteria\Storing\StoreableCriteria;
7 use Org\Mxchange\CoreFramework\Generic\FrameworkInterface;
8 use Org\Mxchange\CoreFramework\Handler\DataSet\HandleableDataSet;
9 use Org\Mxchange\CoreFramework\Object\BaseFrameworkSystem;
12 use \InvalidArgumentException;
17 * @author Roland Haeder <webmaster@shipsimu.org>
19 * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2023 Core Developer Team
20 * @license GNU GPL 3.0 or any newer version
21 * @link http://www.shipsimu.org
23 * This program is free software: you can redistribute it and/or modify
24 * it under the terms of the GNU General Public License as published by
25 * the Free Software Foundation, either version 3 of the License, or
26 * (at your option) any later version.
28 * This program is distributed in the hope that it will be useful,
29 * but WITHOUT ANY WARRANTY; without even the implied warranty of
30 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
31 * GNU General Public License for more details.
33 * You should have received a copy of the GNU General Public License
34 * along with this program. If not, see <http://www.gnu.org/licenses/>.
36 abstract class BaseHandler extends BaseFrameworkSystem implements HandleableDataSet {
40 private $handlerName = 'invalid';
43 * Protected constructor
45 * @param $className Name of the class
48 protected function __construct (string $className) {
49 // Call parent constructor
50 //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('BASE-HANDLER: className=%s - CONSTRUCTED!', $className));
51 parent::__construct($className);
54 //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage('BASE-HANDLER: EXIT!');
58 * Getter for handler name
60 * @return $handlerName Name of this handler
62 public final function getHandlerName () {
63 return $this->handlerName;
67 * Setter for handler name
69 * @param $handlerName Name of this handler
72 protected final function setHandlerName (string $handlerName) {
73 $this->handlerName = $handlerName;
77 * Adds all required elements from given array into data set instance
79 * @param $dataSetInstance An instance of a StoreableCriteria class
80 * @param $messageData An array with all message data
82 * @todo Rewrite this to use DHT
84 public function addArrayToDataSet (StoreableCriteria $dataSetInstance, array $messageData) {
86 //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('BASE-HANDLER: dataSetInstance=%s,messageData()=%d - CALLED!', $dataSetInstance->__toString(), count($messageData)));
87 if (count($messageData) == 0) {
89 throw new InvalidArgumentException('Parameter "messageData" is an empty array', FrameworkInterface::EXCEPTION_INVALID_ARGUMENT);
93 //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage('BASE-HANDLER: EXIT!');