]> git.mxchange.org Git - core.git/blob - inc/classes/main/class_BaseFrameworkSystem.php
Added setter/getter for a Minable instance (interface still in 'hub' project).
[core.git] / inc / classes / main / class_BaseFrameworkSystem.php
1 <?php
2 /**
3  * The simulator system class is the super class of all other classes. This
4  * class handles saving of games etc.
5  *
6  * @author              Roland Haeder <webmaster@shipsimu.org>
7  * @version             0.0.0
8  * @copyright   Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2013 Core Developer Team
9  * @license             GNU GPL 3.0 or any newer version
10  * @link                http://www.shipsimu.org
11  *
12  * This program is free software: you can redistribute it and/or modify
13  * it under the terms of the GNU General Public License as published by
14  * the Free Software Foundation, either version 3 of the License, or
15  * (at your option) any later version.
16  *
17  * This program is distributed in the hope that it will be useful,
18  * but WITHOUT ANY WARRANTY; without even the implied warranty of
19  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
20  * GNU General Public License for more details.
21  *
22  * You should have received a copy of the GNU General Public License
23  * along with this program. If not, see <http://www.gnu.org/licenses/>.
24  */
25 class BaseFrameworkSystem extends stdClass implements FrameworkInterface {
26         /**
27          * Length of output from hash()
28          */
29         private static $hashLength = NULL;
30
31         /**
32          * The real class name
33          */
34         private $realClass = 'BaseFrameworkSystem';
35
36         /**
37          * Instance of a request class
38          */
39         private $requestInstance = NULL;
40
41         /**
42          * Instance of a response class
43          */
44         private $responseInstance = NULL;
45
46         /**
47          * Search criteria instance
48          */
49         private $searchInstance = NULL;
50
51         /**
52          * Update criteria instance
53          */
54         private $updateInstance = NULL;
55
56         /**
57          * The file I/O instance for the template loader
58          */
59         private $fileIoInstance = NULL;
60
61         /**
62          * Resolver instance
63          */
64         private $resolverInstance = NULL;
65
66         /**
67          * Template engine instance
68          */
69         private $templateInstance = NULL;
70
71         /**
72          * Database result instance
73          */
74         private $resultInstance = NULL;
75
76         /**
77          * Instance for user class
78          */
79         private $userInstance = NULL;
80
81         /**
82          * A controller instance
83          */
84         private $controllerInstance = NULL;
85
86         /**
87          * Instance of a RNG
88          */
89         private $rngInstance = NULL;
90
91         /**
92          * Instance of a crypto helper
93          */
94         private $cryptoInstance = NULL;
95
96         /**
97          * Instance of an Iterator class
98          */
99         private $iteratorInstance = NULL;
100
101         /**
102          * Instance of the list
103          */
104         private $listInstance = NULL;
105
106         /**
107          * Instance of a menu
108          */
109         private $menuInstance = NULL;
110
111         /**
112          * Instance of the image
113          */
114         private $imageInstance = NULL;
115
116         /**
117          * Instance of the stacker
118          */
119         private $stackInstance = NULL;
120
121         /**
122          * A Compressor instance
123          */
124         private $compressorInstance = NULL;
125
126         /**
127          * A Parseable instance
128          */
129         private $parserInstance = NULL;
130
131         /**
132          * A ProtocolHandler instance
133          */
134         private $protocolInstance = NULL;
135
136         /**
137          * A database wrapper instance
138          */
139         private $databaseInstance = NULL;
140
141         /**
142          * A helper instance for the form
143          */
144         private $helperInstance = NULL;
145
146         /**
147          * An instance of a Sourceable class
148          */
149         private $sourceInstance = NULL;
150
151         /**
152          * An instance of a InputStream class
153          */
154         private $inputStreamInstance = NULL;
155
156         /**
157          * An instance of a OutputStream class
158          */
159         private $outputStreamInstance = NULL;
160
161         /**
162          * Networkable handler instance
163          */
164         private $handlerInstance = NULL;
165
166         /**
167          * Visitor handler instance
168          */
169         private $visitorInstance = NULL;
170
171         /**
172          * DHT instance
173          */
174         private $dhtInstance = NULL;
175
176         /**
177          * An instance of a database wrapper class
178          */
179         private $wrapperInstance = NULL;
180
181         /**
182          * An instance of a file I/O pointer class (not handler)
183          */
184         private $pointerInstance = NULL;
185
186         /**
187          * An instance of an Indexable class
188          */
189         private $indexInstance = NULL;
190
191         /**
192          * An instance of a Block class
193          */
194         private $blockInstance = NULL;
195
196         /**
197          * A Minable instance
198          */
199         private $minableInstance = NULL;
200
201         /**
202          * Thousands separator
203          */
204         private $thousands = '.'; // German
205
206         /**
207          * Decimal separator
208          */
209         private $decimals  = ','; // German
210
211         /**
212          * Socket resource
213          */
214         private $socketResource = FALSE;
215
216         /**
217          * Package data
218          */
219         private $packageData = array();
220
221         /**
222          * Generic array
223          */
224         private $genericArray = array();
225
226         /***********************
227          * Exception codes.... *
228          ***********************/
229
230         // @todo Try to clean these constants up
231         const EXCEPTION_IS_NULL_POINTER              = 0x001;
232         const EXCEPTION_IS_NO_OBJECT                 = 0x002;
233         const EXCEPTION_IS_NO_ARRAY                  = 0x003;
234         const EXCEPTION_MISSING_METHOD               = 0x004;
235         const EXCEPTION_CLASSES_NOT_MATCHING         = 0x005;
236         const EXCEPTION_INDEX_OUT_OF_BOUNDS          = 0x006;
237         const EXCEPTION_DIMENSION_ARRAY_INVALID      = 0x007;
238         const EXCEPTION_ITEM_NOT_TRADEABLE           = 0x008;
239         const EXCEPTION_ITEM_NOT_IN_PRICE_LIST       = 0x009;
240         const EXCEPTION_GENDER_IS_WRONG              = 0x00a;
241         const EXCEPTION_BIRTH_DATE_IS_INVALID        = 0x00b;
242         const EXCEPTION_EMPTY_STRUCTURES_ARRAY       = 0x00c;
243         const EXCEPTION_HAS_ALREADY_PERSONELL_LIST   = 0x00d;
244         const EXCEPTION_NOT_ENOUGTH_UNEMPLOYEES      = 0x00e;
245         const EXCEPTION_TOTAL_PRICE_NOT_CALCULATED   = 0x00f;
246         const EXCEPTION_HARBOR_HAS_NO_SHIPYARDS      = 0x010;
247         const EXCEPTION_CONTRACT_PARTNER_INVALID     = 0x011;
248         const EXCEPTION_CONTRACT_PARTNER_MISMATCH    = 0x012;
249         const EXCEPTION_CONTRACT_ALREADY_SIGNED      = 0x013;
250         const EXCEPTION_UNEXPECTED_EMPTY_STRING      = 0x014;
251         const EXCEPTION_PATH_NOT_FOUND               = 0x015;
252         const EXCEPTION_INVALID_PATH_NAME            = 0x016;
253         const EXCEPTION_READ_PROTECED_PATH           = 0x017;
254         const EXCEPTION_WRITE_PROTECED_PATH          = 0x018;
255         const EXCEPTION_DIR_POINTER_INVALID          = 0x019;
256         const EXCEPTION_FILE_POINTER_INVALID         = 0x01a;
257         const EXCEPTION_INVALID_RESOURCE             = 0x01b;
258         const EXCEPTION_UNEXPECTED_OBJECT            = 0x01c;
259         const EXCEPTION_LIMIT_ELEMENT_IS_UNSUPPORTED = 0x01d;
260         const EXCEPTION_GETTER_IS_MISSING            = 0x01e;
261         const EXCEPTION_ARRAY_EXPECTED               = 0x01f;
262         const EXCEPTION_ARRAY_HAS_INVALID_COUNT      = 0x020;
263         const EXCEPTION_ID_IS_INVALID_FORMAT         = 0x021;
264         const EXCEPTION_MD5_CHECKSUMS_MISMATCH       = 0x022;
265         const EXCEPTION_UNEXPECTED_STRING_SIZE       = 0x023;
266         const EXCEPTION_SIMULATOR_ID_INVALID         = 0x024;
267         const EXCEPTION_MISMATCHING_COMPRESSORS      = 0x025;
268         const EXCEPTION_CONTAINER_ITEM_IS_NULL       = 0x026;
269         const EXCEPTION_ITEM_IS_NO_ARRAY             = 0x027;
270         const EXCEPTION_CONTAINER_MAYBE_DAMAGED      = 0x028;
271         const EXCEPTION_INVALID_STRING               = 0x029;
272         const EXCEPTION_VARIABLE_NOT_SET             = 0x02a;
273         const EXCEPTION_ATTRIBUTES_ARE_MISSING       = 0x02b;
274         const EXCEPTION_ARRAY_ELEMENTS_MISSING       = 0x02c;
275         const EXCEPTION_TEMPLATE_ENGINE_UNSUPPORTED  = 0x02d;
276         const EXCEPTION_UNSPPORTED_OPERATION         = 0x02e;
277         const EXCEPTION_FACTORY_REQUIRE_PARAMETER    = 0x02f;
278         const EXCEPTION_MISSING_ELEMENT              = 0x030;
279         const EXCEPTION_HEADERS_ALREADY_SENT         = 0x031;
280         const EXCEPTION_DEFAULT_CONTROLLER_GONE      = 0x032;
281         const EXCEPTION_CLASS_NOT_FOUND              = 0x033;
282         const EXCEPTION_REQUIRED_INTERFACE_MISSING   = 0x034;
283         const EXCEPTION_FATAL_ERROR                  = 0x035;
284         const EXCEPTION_FILE_NOT_FOUND               = 0x036;
285         const EXCEPTION_ASSERTION_FAILED             = 0x037;
286         const EXCEPTION_FILE_CANNOT_BE_READ          = 0x038;
287         const EXCEPTION_DATABASE_UPDATED_NOT_ALLOWED = 0x039;
288         const EXCEPTION_FILTER_CHAIN_INTERCEPTED     = 0x03a;
289
290         /**
291          * Hexadecimal->Decimal translation array
292          */
293         private static $hexdec = array(
294                 '0' => 0,
295                 '1' => 1,
296                 '2' => 2,
297                 '3' => 3,
298                 '4' => 4,
299                 '5' => 5,
300                 '6' => 6,
301                 '7' => 7,
302                 '8' => 8,
303                 '9' => 9,
304                 'a' => 10,
305                 'b' => 11,
306                 'c' => 12,
307                 'd' => 13,
308                 'e' => 14,
309                 'f' => 15
310         );
311
312         /**
313          * Decimal->hexadecimal translation array
314          */
315         private static $dechex = array(
316                  0 => '0',
317                  1 => '1',
318                  2 => '2',
319                  3 => '3',
320                  4 => '4',
321                  5 => '5',
322                  6 => '6',
323                  7 => '7',
324                  8 => '8',
325                  9 => '9',
326                 10 => 'a',
327                 11 => 'b',
328                 12 => 'c',
329                 13 => 'd',
330                 14 => 'e',
331                 15 => 'f'
332         );
333
334         /**
335          * Startup time in miliseconds
336          */
337         private static $startupTime = 0;
338
339         /**
340          * Protected super constructor
341          *
342          * @param       $className      Name of the class
343          * @return      void
344          */
345         protected function __construct ($className) {
346                 // Set real class
347                 $this->setRealClass($className);
348
349                 // Set configuration instance if no registry ...
350                 if (!$this instanceof Register) {
351                         // ... because registries doesn't need to be configured
352                         $this->setConfigInstance(FrameworkConfiguration::getSelfInstance());
353                 } // END - if
354
355                 // Is the startup time set? (0 cannot be TRUE anymore)
356                 if (self::$startupTime == 0) {
357                         // Then set it
358                         self::$startupTime = microtime(TRUE);
359                 } // END - if
360         }
361
362         /**
363          * Destructor for all classes
364          *
365          * @return      void
366          */
367         public function __destruct () {
368                 // Flush any updated entries to the database
369                 $this->flushPendingUpdates();
370
371                 // Is this object already destroyed?
372                 if ($this->__toString() != 'DestructedObject') {
373                         // Destroy all informations about this class but keep some text about it alive
374                         $this->setRealClass('DestructedObject');
375                 } elseif ((defined('DEBUG_DESTRUCTOR')) && (is_object($this->getDebugInstance()))) {
376                         // Already destructed object
377                         self::createDebugInstance(__CLASS__)->debugOutput(sprintf('[%s:] The object <span class="object_name">%s</span> is already destroyed.',
378                                 __CLASS__,
379                                 $this->__toString()
380                         ));
381                 } else {
382                         // Do not call this twice
383                         trigger_error(__METHOD__ . ': Called twice.');
384                         exit;
385                 }
386         }
387
388         /**
389          * The __call() method where all non-implemented methods end up
390          *
391          * @param       $methodName             Name of the missing method
392          * @args        $args                   Arguments passed to the method
393          * @return      void
394          */
395         public final function __call ($methodName, $args) {
396                 return self::__callStatic($methodName, $args);
397         }
398
399         /**
400          * The __callStatic() method where all non-implemented static methods end up
401          *
402          * @param       $methodName             Name of the missing method
403          * @args        $args                   Arguments passed to the method
404          * @return      void
405          */
406         public static final function __callStatic ($methodName, $args) {
407                 // Init argument string
408                 $argsString = '';
409
410                 // Is it empty or an array?
411                 if (empty($args)) {
412                         // No arguments
413                         $argsString = 'NULL';
414                 } elseif (is_array($args)) {
415                         // Some arguments are there
416                         foreach ($args as $arg) {
417                                 // Add the value itself if not array. This prevents 'array to string conversion' message
418                                 if (is_array($arg)) {
419                                         $argsString .= 'Array';
420                                 } else {
421                                         $argsString .= $arg;
422                                 }
423
424                                 // Add data about the argument
425                                 $argsString .= ' (' . gettype($arg);
426
427                                 if (is_string($arg)) {
428                                         // Add length for strings
429                                         $argsString .= ', ' . strlen($arg);
430                                 } elseif (is_array($arg)) {
431                                         // .. or size if array
432                                         $argsString .= ', ' . count($arg);
433                                 } elseif ($arg === TRUE) {
434                                         // ... is boolean 'TRUE'
435                                         $argsString .= ', TRUE';
436                                 } elseif ($arg === FALSE) {
437                                         // ... is boolean 'FALSE'
438                                         $argsString .= ', FALSE';
439                                 }
440
441                                 // Closing bracket
442                                 $argsString .= '), ';
443                         } // END - foreach
444
445                         // Remove last comma
446                         if (substr($argsString, -2, 1) == ',') {
447                                 $argsString = substr($argsString, 0, -2);
448                         } // END - if
449                 } else {
450                         // Invalid arguments!
451                         $argsString = '!INVALID:' . gettype($args) . '!';
452                 }
453
454                 // Output stub message
455                 // @TODO __CLASS__ does always return BaseFrameworkSystem but not the extending (=child) class
456                 self::createDebugInstance(__CLASS__)->debugOutput(sprintf('[unknown::%s:] Stub! Args: %s',
457                         $methodName,
458                         $argsString
459                 ));
460
461                 // Return nothing
462                 return NULL;
463         }
464
465         /**
466          * Getter for $realClass
467          *
468          * @return      $realClass The name of the real class (not BaseFrameworkSystem)
469          */
470         public function __toString () {
471                 return $this->realClass;
472         }
473
474         /**
475          * Magic function to catch setting of missing but set class fields/attributes
476          *
477          * @param       $name   Name of the field/attribute
478          * @param       $value  Value to store
479          * @return      void
480          */
481         public final function __set ($name, $value) {
482                 $this->debugBackTrace(sprintf('Tried to set a missing field. name=%s, value[%s]=%s',
483                         $name,
484                         gettype($value),
485                         print_r($value, TRUE)
486                 ));
487         }
488
489         /**
490          * Magic function to catch getting of missing fields/attributes
491          *
492          * @param       $name   Name of the field/attribute
493          * @return      void
494          */
495         public final function __get ($name) {
496                 $this->debugBackTrace(sprintf('Tried to get a missing field. name=%s',
497                         $name
498                 ));
499         }
500
501         /**
502          * Magic function to catch unsetting of missing fields/attributes
503          *
504          * @param       $name   Name of the field/attribute
505          * @return      void
506          */
507         public final function __unset ($name) {
508                 $this->debugBackTrace(sprintf('Tried to unset a missing field. name=%s',
509                         $name
510                 ));
511         }
512
513         /**
514          * Setter for the real class name
515          *
516          * @param       $realClass      Class name (string)
517          * @return      void
518          */
519         public final function setRealClass ($realClass) {
520                 // Set real class
521                 $this->realClass = (string) $realClass;
522         }
523
524         /**
525          * Setter for database result instance
526          *
527          * @param       $resultInstance         An instance of a database result class
528          * @return      void
529          * @todo        SearchableResult and UpdateableResult shall have a super interface to use here
530          */
531         protected final function setResultInstance (SearchableResult $resultInstance) {
532                 $this->resultInstance =  $resultInstance;
533         }
534
535         /**
536          * Getter for database result instance
537          *
538          * @return      $resultInstance         An instance of a database result class
539          */
540         public final function getResultInstance () {
541                 return $this->resultInstance;
542         }
543
544         /**
545          * Setter for template engine instances
546          *
547          * @param       $templateInstance       An instance of a template engine class
548          * @return      void
549          */
550         protected final function setTemplateInstance (CompileableTemplate $templateInstance) {
551                 $this->templateInstance = $templateInstance;
552         }
553
554         /**
555          * Getter for template engine instances
556          *
557          * @return      $templateInstance       An instance of a template engine class
558          */
559         protected final function getTemplateInstance () {
560                 return $this->templateInstance;
561         }
562
563         /**
564          * Setter for search instance
565          *
566          * @param       $searchInstance         Searchable criteria instance
567          * @return      void
568          */
569         public final function setSearchInstance (LocalSearchCriteria $searchInstance) {
570                 $this->searchInstance = $searchInstance;
571         }
572
573         /**
574          * Getter for search instance
575          *
576          * @return      $searchInstance         Searchable criteria instance
577          */
578         public final function getSearchInstance () {
579                 return $this->searchInstance;
580         }
581
582         /**
583          * Setter for update instance
584          *
585          * @param       $updateInstance         Searchable criteria instance
586          * @return      void
587          */
588         public final function setUpdateInstance (LocalUpdateCriteria $updateInstance) {
589                 $this->updateInstance = $updateInstance;
590         }
591
592         /**
593          * Getter for update instance
594          *
595          * @return      $updateInstance         Updateable criteria instance
596          */
597         public final function getUpdateInstance () {
598                 return $this->updateInstance;
599         }
600
601         /**
602          * Setter for resolver instance
603          *
604          * @param       $resolverInstance       Instance of a command resolver class
605          * @return      void
606          */
607         public final function setResolverInstance (Resolver $resolverInstance) {
608                 $this->resolverInstance = $resolverInstance;
609         }
610
611         /**
612          * Getter for resolver instance
613          *
614          * @return      $resolverInstance       Instance of a command resolver class
615          */
616         public final function getResolverInstance () {
617                 return $this->resolverInstance;
618         }
619
620         /**
621          * Setter for language instance
622          *
623          * @param       $configInstance         The configuration instance which shall
624          *                                                              be FrameworkConfiguration
625          * @return      void
626          */
627         public final function setConfigInstance (FrameworkConfiguration $configInstance) {
628                 Registry::getRegistry()->addInstance('config', $configInstance);
629         }
630
631         /**
632          * Getter for configuration instance
633          *
634          * @return      $configInstance         Configuration instance
635          */
636         public final function getConfigInstance () {
637                 $configInstance = Registry::getRegistry()->getInstance('config');
638                 return $configInstance;
639         }
640
641         /**
642          * Setter for debug instance
643          *
644          * @param       $debugInstance  The instance for debug output class
645          * @return      void
646          */
647         public final function setDebugInstance (DebugMiddleware $debugInstance) {
648                 Registry::getRegistry()->addInstance('debug', $debugInstance);
649         }
650
651         /**
652          * Getter for debug instance
653          *
654          * @return      $debugInstance  Instance to class DebugConsoleOutput or DebugWebOutput
655          */
656         public final function getDebugInstance () {
657                 // Get debug instance
658                 $debugInstance = Registry::getRegistry()->getInstance('debug');
659
660                 // Return it
661                 return $debugInstance;
662         }
663
664         /**
665          * Setter for web output instance
666          *
667          * @param       $webInstance    The instance for web output class
668          * @return      void
669          */
670         public final function setWebOutputInstance (OutputStreamer $webInstance) {
671                 Registry::getRegistry()->addInstance('web_output', $webInstance);
672         }
673
674         /**
675          * Getter for web output instance
676          *
677          * @return      $webOutputInstance - Instance to class WebOutput
678          */
679         public final function getWebOutputInstance () {
680                 $webOutputInstance = Registry::getRegistry()->getInstance('web_output');
681                 return $webOutputInstance;
682         }
683
684         /**
685          * Setter for database instance
686          *
687          * @param       $databaseInstance       The instance for the database connection (forced DatabaseConnection)
688          * @return      void
689          */
690         public final function setDatabaseInstance (DatabaseConnection $databaseInstance) {
691                 Registry::getRegistry()->addInstance('db_instance', $databaseInstance);
692         }
693
694         /**
695          * Getter for database layer
696          *
697          * @return      $databaseInstance       The database layer instance
698          */
699         public final function getDatabaseInstance () {
700                 // Get instance
701                 $databaseInstance = Registry::getRegistry()->getInstance('db_instance');
702
703                 // Return instance
704                 return $databaseInstance;
705         }
706
707         /**
708          * Setter for compressor channel
709          *
710          * @param       $compressorInstance             An instance of CompressorChannel
711          * @return      void
712          */
713         public final function setCompressorChannel (CompressorChannel $compressorInstance) {
714                 Registry::getRegistry()->addInstance('compressor', $compressorInstance);
715         }
716
717         /**
718          * Getter for compressor channel
719          *
720          * @return      $compressorInstance             The compressor channel
721          */
722         public final function getCompressorChannel () {
723                 $compressorInstance = Registry::getRegistry()->getInstance('compressor');
724                 return $compressorInstance;
725         }
726
727         /**
728          * Protected getter for a manageable application helper class
729          *
730          * @return      $applicationInstance    An instance of a manageable application helper class
731          */
732         protected final function getApplicationInstance () {
733                 $applicationInstance = Registry::getRegistry()->getInstance('application');
734                 return $applicationInstance;
735         }
736
737         /**
738          * Setter for a manageable application helper class
739          *
740          * @param       $applicationInstance    An instance of a manageable application helper class
741          * @return      void
742          */
743         public final function setApplicationInstance (ManageableApplication $applicationInstance) {
744                 Registry::getRegistry()->addInstance('application', $applicationInstance);
745         }
746
747         /**
748          * Setter for request instance
749          *
750          * @param       $requestInstance        An instance of a Requestable class
751          * @return      void
752          */
753         public final function setRequestInstance (Requestable $requestInstance) {
754                 $this->requestInstance = $requestInstance;
755         }
756
757         /**
758          * Getter for request instance
759          *
760          * @return      $requestInstance        An instance of a Requestable class
761          */
762         public final function getRequestInstance () {
763                 return $this->requestInstance;
764         }
765
766         /**
767          * Setter for response instance
768          *
769          * @param       $responseInstance       An instance of a Responseable class
770          * @return      void
771          */
772         public final function setResponseInstance (Responseable $responseInstance) {
773                 $this->responseInstance = $responseInstance;
774         }
775
776         /**
777          * Getter for response instance
778          *
779          * @return      $responseInstance       An instance of a Responseable class
780          */
781         public final function getResponseInstance () {
782                 return $this->responseInstance;
783         }
784
785         /**
786          * Private getter for language instance
787          *
788          * @return      $langInstance   An instance to the language sub-system
789          */
790         protected final function getLanguageInstance () {
791                 $langInstance = Registry::getRegistry()->getInstance('language');
792                 return $langInstance;
793         }
794
795         /**
796          * Setter for language instance
797          *
798          * @param       $langInstance   An instance to the language sub-system
799          * @return      void
800          * @see         LanguageSystem
801          */
802         public final function setLanguageInstance (ManageableLanguage $langInstance) {
803                 Registry::getRegistry()->addInstance('language', $langInstance);
804         }
805
806         /**
807          * Private getter for file IO instance
808          *
809          * @return      $fileIoInstance         An instance to the file I/O sub-system
810          */
811         protected final function getFileIoInstance () {
812                 return $this->fileIoInstance;
813         }
814
815         /**
816          * Setter for file I/O instance
817          *
818          * @param       $fileIoInstance         An instance to the file I/O sub-system
819          * @return      void
820          */
821         public final function setFileIoInstance (IoHandler $fileIoInstance) {
822                 $this->fileIoInstance = $fileIoInstance;
823         }
824
825         /**
826          * Protected setter for user instance
827          *
828          * @param       $userInstance   An instance of a user class
829          * @return      void
830          */
831         protected final function setUserInstance (ManageableAccount $userInstance) {
832                 $this->userInstance = $userInstance;
833         }
834
835         /**
836          * Getter for user instance
837          *
838          * @return      $userInstance   An instance of a user class
839          */
840         public final function getUserInstance () {
841                 return $this->userInstance;
842         }
843
844         /**
845          * Setter for controller instance (this surely breaks a bit the MVC patterm)
846          *
847          * @param       $controllerInstance             An instance of the controller
848          * @return      void
849          */
850         public final function setControllerInstance (Controller $controllerInstance) {
851                 $this->controllerInstance = $controllerInstance;
852         }
853
854         /**
855          * Getter for controller instance (this surely breaks a bit the MVC patterm)
856          *
857          * @return      $controllerInstance             An instance of the controller
858          */
859         public final function getControllerInstance () {
860                 return $this->controllerInstance;
861         }
862
863         /**
864          * Setter for RNG instance
865          *
866          * @param       $rngInstance    An instance of a random number generator (RNG)
867          * @return      void
868          */
869         protected final function setRngInstance (RandomNumberGenerator $rngInstance) {
870                 $this->rngInstance = $rngInstance;
871         }
872
873         /**
874          * Getter for RNG instance
875          *
876          * @return      $rngInstance    An instance of a random number generator (RNG)
877          */
878         public final function getRngInstance () {
879                 return $this->rngInstance;
880         }
881
882         /**
883          * Setter for Cryptable instance
884          *
885          * @param       $cryptoInstance An instance of a Cryptable class
886          * @return      void
887          */
888         protected final function setCryptoInstance (Cryptable $cryptoInstance) {
889                 $this->cryptoInstance = $cryptoInstance;
890         }
891
892         /**
893          * Getter for Cryptable instance
894          *
895          * @return      $cryptoInstance An instance of a Cryptable class
896          */
897         public final function getCryptoInstance () {
898                 return $this->cryptoInstance;
899         }
900
901         /**
902          * Setter for the list instance
903          *
904          * @param       $listInstance   A list of Listable
905          * @return      void
906          */
907         protected final function setListInstance (Listable $listInstance) {
908                 $this->listInstance = $listInstance;
909         }
910
911         /**
912          * Getter for the list instance
913          *
914          * @return      $listInstance   A list of Listable
915          */
916         protected final function getListInstance () {
917                 return $this->listInstance;
918         }
919
920         /**
921          * Setter for the menu instance
922          *
923          * @param       $menuInstance   A RenderableMenu instance
924          * @return      void
925          */
926         protected final function setMenuInstance (RenderableMenu $menuInstance) {
927                 $this->menuInstance = $menuInstance;
928         }
929
930         /**
931          * Getter for the menu instance
932          *
933          * @return      $menuInstance   A RenderableMenu instance
934          */
935         protected final function getMenuInstance () {
936                 return $this->menuInstance;
937         }
938
939         /**
940          * Setter for image instance
941          *
942          * @param       $imageInstance  An instance of an image
943          * @return      void
944          */
945         public final function setImageInstance (BaseImage $imageInstance) {
946                 $this->imageInstance = $imageInstance;
947         }
948
949         /**
950          * Getter for image instance
951          *
952          * @return      $imageInstance  An instance of an image
953          */
954         public final function getImageInstance () {
955                 return $this->imageInstance;
956         }
957
958         /**
959          * Setter for stacker instance
960          *
961          * @param       $stackInstance  An instance of an stacker
962          * @return      void
963          */
964         public final function setStackInstance (Stackable $stackInstance) {
965                 $this->stackInstance = $stackInstance;
966         }
967
968         /**
969          * Getter for stacker instance
970          *
971          * @return      $stackInstance  An instance of an stacker
972          */
973         public final function getStackInstance () {
974                 return $this->stackInstance;
975         }
976
977         /**
978          * Setter for compressor instance
979          *
980          * @param       $compressorInstance     An instance of an compressor
981          * @return      void
982          */
983         public final function setCompressorInstance (Compressor $compressorInstance) {
984                 $this->compressorInstance = $compressorInstance;
985         }
986
987         /**
988          * Getter for compressor instance
989          *
990          * @return      $compressorInstance     An instance of an compressor
991          */
992         public final function getCompressorInstance () {
993                 return $this->compressorInstance;
994         }
995
996         /**
997          * Setter for Parseable instance
998          *
999          * @param       $parserInstance An instance of an Parseable
1000          * @return      void
1001          */
1002         public final function setParserInstance (Parseable $parserInstance) {
1003                 $this->parserInstance = $parserInstance;
1004         }
1005
1006         /**
1007          * Getter for Parseable instance
1008          *
1009          * @return      $parserInstance An instance of an Parseable
1010          */
1011         public final function getParserInstance () {
1012                 return $this->parserInstance;
1013         }
1014
1015         /**
1016          * Setter for ProtocolHandler instance
1017          *
1018          * @param       $protocolInstance       An instance of an ProtocolHandler
1019          * @return      void
1020          */
1021         public final function setProtocolInstance (ProtocolHandler $protocolInstance = NULL) {
1022                 $this->protocolInstance = $protocolInstance;
1023         }
1024
1025         /**
1026          * Getter for ProtocolHandler instance
1027          *
1028          * @return      $protocolInstance       An instance of an ProtocolHandler
1029          */
1030         public final function getProtocolInstance () {
1031                 return $this->protocolInstance;
1032         }
1033
1034         /**
1035          * Setter for DatabaseWrapper instance
1036          *
1037          * @param       $wrapperInstance        An instance of an DatabaseWrapper
1038          * @return      void
1039          */
1040         public final function setWrapperInstance (DatabaseWrapper $wrapperInstance) {
1041                 $this->wrapperInstance = $wrapperInstance;
1042         }
1043
1044         /**
1045          * Getter for DatabaseWrapper instance
1046          *
1047          * @return      $wrapperInstance        An instance of an DatabaseWrapper
1048          */
1049         public final function getWrapperInstance () {
1050                 return $this->wrapperInstance;
1051         }
1052
1053         /**
1054          * Setter for socket resource
1055          *
1056          * @param       $socketResource         A valid socket resource
1057          * @return      void
1058          */
1059         public final function setSocketResource ($socketResource) {
1060                 //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput($this->__toString() . '::' . __FUNCTION__ . ': socketResource=' . $socketResource . ',previous[' . gettype($this->socketResource) . ']=' . $this->socketResource);
1061                 $this->socketResource = $socketResource;
1062         }
1063
1064         /**
1065          * Getter for socket resource
1066          *
1067          * @return      $socketResource         A valid socket resource
1068          */
1069         public final function getSocketResource () {
1070                 //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput($this->__toString() . '::' . __FUNCTION__ . ': socketResource[' . gettype($this->socketResource) . ']=' . $this->socketResource);
1071                 return $this->socketResource;
1072         }
1073
1074         /**
1075          * Setter for helper instance
1076          *
1077          * @param       $helperInstance         An instance of a helper class
1078          * @return      void
1079          */
1080         protected final function setHelperInstance (Helper $helperInstance) {
1081                 $this->helperInstance = $helperInstance;
1082         }
1083
1084         /**
1085          * Getter for helper instance
1086          *
1087          * @return      $helperInstance         An instance of a helper class
1088          */
1089         public final function getHelperInstance () {
1090                 return $this->helperInstance;
1091         }
1092
1093         /**
1094          * Setter for a Sourceable instance
1095          *
1096          * @param       $sourceInstance The Sourceable instance
1097          * @return      void
1098          */
1099         protected final function setSourceInstance (Sourceable $sourceInstance) {
1100                 $this->sourceInstance = $sourceInstance;
1101         }
1102
1103         /**
1104          * Getter for a Sourceable instance
1105          *
1106          * @return      $sourceInstance The Sourceable instance
1107          */
1108         protected final function getSourceInstance () {
1109                 return $this->sourceInstance;
1110         }
1111
1112         /**
1113          * Getter for a InputStream instance
1114          *
1115          * @param       $inputStreamInstance    The InputStream instance
1116          */
1117         protected final function getInputStreamInstance () {
1118                 return $this->inputStreamInstance;
1119         }
1120
1121         /**
1122          * Setter for a InputStream instance
1123          *
1124          * @param       $inputStreamInstance    The InputStream instance
1125          * @return      void
1126          */
1127         protected final function setInputStreamInstance (InputStream $inputStreamInstance) {
1128                 $this->inputStreamInstance = $inputStreamInstance;
1129         }
1130
1131         /**
1132          * Getter for a OutputStream instance
1133          *
1134          * @param       $outputStreamInstance   The OutputStream instance
1135          */
1136         protected final function getOutputStreamInstance () {
1137                 return $this->outputStreamInstance;
1138         }
1139
1140         /**
1141          * Setter for a OutputStream instance
1142          *
1143          * @param       $outputStreamInstance   The OutputStream instance
1144          * @return      void
1145          */
1146         protected final function setOutputStreamInstance (OutputStream $outputStreamInstance) {
1147                 $this->outputStreamInstance = $outputStreamInstance;
1148         }
1149
1150         /**
1151          * Setter for handler instance
1152          *
1153          * @param       $handlerInstance        An instance of a Handleable class
1154          * @return      void
1155          */
1156         protected final function setHandlerInstance (Handleable $handlerInstance) {
1157                 $this->handlerInstance = $handlerInstance;
1158         }
1159
1160         /**
1161          * Getter for handler instance
1162          *
1163          * @return      $handlerInstance        A Networkable instance
1164          */
1165         protected final function getHandlerInstance () {
1166                 return $this->handlerInstance;
1167         }
1168
1169         /**
1170          * Setter for visitor instance
1171          *
1172          * @param       $visitorInstance        A Visitor instance
1173          * @return      void
1174          */
1175         protected final function setVisitorInstance (Visitor $visitorInstance) {
1176                 $this->visitorInstance = $visitorInstance;
1177         }
1178
1179         /**
1180          * Getter for visitor instance
1181          *
1182          * @return      $visitorInstance        A Visitor instance
1183          */
1184         protected final function getVisitorInstance () {
1185                 return $this->visitorInstance;
1186         }
1187
1188         /**
1189          * Setter for DHT instance
1190          *
1191          * @param       $dhtInstance    A Distributable instance
1192          * @return      void
1193          */
1194         protected final function setDhtInstance (Distributable $dhtInstance) {
1195                 $this->dhtInstance = $dhtInstance;
1196         }
1197
1198         /**
1199          * Getter for DHT instance
1200          *
1201          * @return      $dhtInstance    A Distributable instance
1202          */
1203         protected final function getDhtInstance () {
1204                 return $this->dhtInstance;
1205         }
1206
1207         /**
1208          * Setter for raw package Data
1209          *
1210          * @param       $packageData    Raw package Data
1211          * @return      void
1212          */
1213         public final function setPackageData (array $packageData) {
1214                 $this->packageData = $packageData;
1215         }
1216
1217         /**
1218          * Getter for raw package Data
1219          *
1220          * @return      $packageData    Raw package Data
1221          */
1222         public function getPackageData () {
1223                 return $this->packageData;
1224         }
1225
1226
1227         /**
1228          * Setter for Iterator instance
1229          *
1230          * @param       $iteratorInstance       An instance of an Iterator
1231          * @return      void
1232          */
1233         protected final function setIteratorInstance (Iterator $iteratorInstance) {
1234                 $this->iteratorInstance = $iteratorInstance;
1235         }
1236
1237         /**
1238          * Getter for Iterator instance
1239          *
1240          * @return      $iteratorInstance       An instance of an Iterator
1241          */
1242         public final function getIteratorInstance () {
1243                 return $this->iteratorInstance;
1244         }
1245
1246         /**
1247          * Setter for InputOutputPointer instance
1248          *
1249          * @param       $pointerInstance        An instance of an InputOutputPointer class
1250          * @return      void
1251          */
1252         protected final function setPointerInstance (InputOutputPointer $pointerInstance) {
1253                 $this->pointerInstance = $pointerInstance;
1254         }
1255
1256         /**
1257          * Getter for InputOutputPointer instance
1258          *
1259          * @return      $pointerInstance        An instance of an InputOutputPointer class
1260          */
1261         public final function getPointerInstance () {
1262                 return $this->pointerInstance;
1263         }
1264
1265         /**
1266          * Setter for Indexable instance
1267          *
1268          * @param       $indexInstance  An instance of an Indexable class
1269          * @return      void
1270          */
1271         protected final function setIndexInstance (Indexable $indexInstance) {
1272                 $this->indexInstance = $indexInstance;
1273         }
1274
1275         /**
1276          * Getter for Indexable instance
1277          *
1278          * @return      $indexInstance  An instance of an Indexable class
1279          */
1280         public final function getIndexInstance () {
1281                 return $this->indexInstance;
1282         }
1283
1284         /**
1285          * Setter for Block instance
1286          *
1287          * @param       $blockInstance  An instance of an Block class
1288          * @return      void
1289          */
1290         protected final function setBlockInstance (Block $blockInstance) {
1291                 $this->blockInstance = $blockInstance;
1292         }
1293
1294         /**
1295          * Getter for Block instance
1296          *
1297          * @return      $blockInstance  An instance of an Block class
1298          */
1299         public final function getBlockInstance () {
1300                 return $this->blockInstance;
1301         }
1302
1303         /**
1304          * Setter for Minable instance
1305          *
1306          * @param       $minableInstance        A Minable instance
1307          * @return      void
1308          */
1309         protected final function setMinableInstance (Minable $minableInstance) {
1310                 $this->minableInstance = $minableInstance;
1311         }
1312
1313         /**
1314          * Getter for minable instance
1315          *
1316          * @return      $minableInstance        A Minable instance
1317          */
1318         protected final function getMinableInstance () {
1319                 return $this->minableInstance;
1320         }
1321
1322         /**
1323          * Checks whether an object equals this object. You should overwrite this
1324          * method to implement own equality checks
1325          *
1326          * @param       $objectInstance         An instance of a FrameworkInterface object
1327          * @return      $equals                         Whether both objects equals
1328          */
1329         public function equals (FrameworkInterface $objectInstance) {
1330                 // Now test it
1331                 $equals = ((
1332                         $this->__toString() == $objectInstance->__toString()
1333                 ) && (
1334                         $this->hashCode() == $objectInstance->hashCode()
1335                 ));
1336
1337                 // Return the result
1338                 return $equals;
1339         }
1340
1341         /**
1342          * Generates a generic hash code of this class. You should really overwrite
1343          * this method with your own hash code generator code. But keep KISS in mind.
1344          *
1345          * @return      $hashCode       A generic hash code respresenting this whole class
1346          */
1347         public function hashCode () {
1348                 // Simple hash code
1349                 return crc32($this->__toString());
1350         }
1351
1352         /**
1353          * Formats computer generated price values into human-understandable formats
1354          * with thousand and decimal separators.
1355          *
1356          * @param       $value          The in computer format value for a price
1357          * @param       $currency       The currency symbol (use HTML-valid characters!)
1358          * @param       $decNum         Number of decimals after commata
1359          * @return      $price          The for the current language formated price string
1360          * @throws      MissingDecimalsThousandsSeparatorException      If decimals or
1361          *                                                                                              thousands separator
1362          *                                                                                              is missing
1363          */
1364         public function formatCurrency ($value, $currency = '&euro;', $decNum = 2) {
1365                 // Are all required attriutes set?
1366                 if ((!isset($this->decimals)) || (!isset($this->thousands))) {
1367                         // Throw an exception
1368                         throw new MissingDecimalsThousandsSeparatorException($this, self::EXCEPTION_ATTRIBUTES_ARE_MISSING);
1369                 } // END - if
1370
1371                 // Cast the number
1372                 $value = (float) $value;
1373
1374                 // Reformat the US number
1375                 $price = number_format($value, $decNum, $this->decimals, $this->thousands) . $currency;
1376
1377                 // Return as string...
1378                 return $price;
1379         }
1380
1381         /**
1382          * Appends a trailing slash to a string
1383          *
1384          * @param       $str    A string (maybe) without trailing slash
1385          * @return      $str    A string with an auto-appended trailing slash
1386          */
1387         public final function addMissingTrailingSlash ($str) {
1388                 // Is there a trailing slash?
1389                 if (substr($str, -1, 1) != '/') {
1390                         $str .= '/';
1391                 } // END - if
1392
1393                 // Return string with trailing slash
1394                 return $str;
1395         }
1396
1397         /**
1398          * Prepare the template engine (WebTemplateEngine by default) for a given
1399          * application helper instance (ApplicationHelper by default).
1400          *
1401          * @param               $applicationInstance    An application helper instance or
1402          *                                                                              null if we shall use the default
1403          * @return              $templateInstance               The template engine instance
1404          * @throws              NullPointerException    If the discovered application
1405          *                                                                              instance is still null
1406          */
1407         protected function prepareTemplateInstance (ManageableApplication $applicationInstance = NULL) {
1408                 // Is the application instance set?
1409                 if (is_null($applicationInstance)) {
1410                         // Get the current instance
1411                         $applicationInstance = $this->getApplicationInstance();
1412
1413                         // Still null?
1414                         if (is_null($applicationInstance)) {
1415                                 // Thrown an exception
1416                                 throw new NullPointerException($this, self::EXCEPTION_IS_NULL_POINTER);
1417                         } // END - if
1418                 } // END - if
1419
1420                 // Initialize the template engine
1421                 $templateInstance = ObjectFactory::createObjectByConfiguredName('web_template_class');
1422
1423                 // Return the prepared instance
1424                 return $templateInstance;
1425         }
1426
1427         /**
1428          * Debugs this instance by putting out it's full content
1429          *
1430          * @param       $message        Optional message to show in debug output
1431          * @return      void
1432          */
1433         public final function debugInstance ($message = '') {
1434                 // Restore the error handler to avoid trouble with missing array elements or undeclared variables
1435                 restore_error_handler();
1436
1437                 // Init content
1438                 $content = '';
1439
1440                 // Is a message set?
1441                 if (!empty($message)) {
1442                         // Construct message
1443                         $content = sprintf('<div class="debug_message">Message: %s</div>' . PHP_EOL, $message);
1444                 } // END - if
1445
1446                 // Generate the output
1447                 $content .= sprintf('<pre>%s</pre>',
1448                         trim(
1449                                 htmlentities(
1450                                         print_r($this, TRUE)
1451                                 )
1452                         )
1453                 );
1454
1455                 // Output it
1456                 ApplicationEntryPoint::app_exit(sprintf('<div class="debug_header">%s debug output:</div><div class="debug_content">%s</div>Loaded includes: <div class="debug_include_list">%s</div>',
1457                         $this->__toString(),
1458                         $content,
1459                         ClassLoader::getSelfInstance()->getPrintableIncludeList()
1460                 ));
1461         }
1462
1463         /**
1464          * Replaces control characters with printable output
1465          *
1466          * @param       $str    String with control characters
1467          * @return      $str    Replaced string
1468          */
1469         protected function replaceControlCharacters ($str) {
1470                 // Replace them
1471                 $str = str_replace(
1472                         chr(13), '[r]', str_replace(
1473                         chr(10), '[n]', str_replace(
1474                         chr(9) , '[t]',
1475                         $str
1476                 )));
1477
1478                 // Return it
1479                 return $str;
1480         }
1481
1482         /**
1483          * Output a partial stub message for the caller method
1484          *
1485          * @param       $message        An optional message to display
1486          * @return      void
1487          */
1488         protected function partialStub ($message = '') {
1489                 // Get the backtrace
1490                 $backtrace = debug_backtrace();
1491
1492                 // Generate the class::method string
1493                 $methodName = 'UnknownClass-&gt;unknownMethod';
1494                 if ((isset($backtrace[1]['class'])) && (isset($backtrace[1]['function']))) {
1495                         $methodName = $backtrace[1]['class'] . '-&gt;' . $backtrace[1]['function'];
1496                 } // END - if
1497
1498                 // Construct the full message
1499                 $stubMessage = sprintf('[%s:] Partial stub!',
1500                         $methodName
1501                 );
1502
1503                 // Is the extra message given?
1504                 if (!empty($message)) {
1505                         // Then add it as well
1506                         $stubMessage .= ' Message: ' . $message;
1507                 } // END - if
1508
1509                 // Debug instance is there?
1510                 if (!is_null($this->getDebugInstance())) {
1511                         // Output stub message
1512                         self::createDebugInstance(__CLASS__)->debugOutput($stubMessage);
1513                 } else {
1514                         // Trigger an error
1515                         trigger_error($stubMessage);
1516                         exit;
1517                 }
1518         }
1519
1520         /**
1521          * Outputs a debug backtrace and stops further script execution
1522          *
1523          * @param       $message        An optional message to output
1524          * @param       $doExit         Whether exit the program (TRUE is default)
1525          * @return      void
1526          */
1527         public function debugBackTrace ($message = '', $doExit = TRUE) {
1528                 // Sorry, there is no other way getting this nice backtrace
1529                 if (!empty($message)) {
1530                         // Output message
1531                         printf('Message: %s<br />' . chr(10), $message);
1532                 } // END - if
1533
1534                 print('<pre>');
1535                 debug_print_backtrace();
1536                 print('</pre>');
1537
1538                 // Exit program?
1539                 if ($doExit === TRUE) {
1540                         exit();
1541                 } // END - if
1542         }
1543
1544         /**
1545          * Creates an instance of a debugger instance
1546          *
1547          * @param       $className              Name of the class (currently unsupported)
1548          * @return      $debugInstance  An instance of a debugger class
1549          */
1550         public final static function createDebugInstance ($className) {
1551                 // Is the instance set?
1552                 if (!Registry::getRegistry()->instanceExists('debug')) {
1553                         // Init debug instance
1554                         $debugInstance = NULL;
1555
1556                         // Try it
1557                         try {
1558                                 // Get a debugger instance
1559                                 $debugInstance = DebugMiddleware::createDebugMiddleware(FrameworkConfiguration::getSelfInstance()->getConfigEntry('debug_class'));
1560                         } catch (NullPointerException $e) {
1561                                 // Didn't work, no instance there
1562                                 exit('Cannot create debugInstance! Exception=' . $e->__toString() . ', message=' . $e->getMessage());
1563                         }
1564
1565                         // Empty string should be ignored and used for testing the middleware
1566                         DebugMiddleware::getSelfInstance()->output('');
1567
1568                         // Set it in its own class. This will set it in the registry
1569                         $debugInstance->setDebugInstance($debugInstance);
1570                 } else {
1571                         // Get instance from registry
1572                         $debugInstance = Registry::getRegistry()->getDebugInstance();
1573                 }
1574
1575                 // Return it
1576                 return $debugInstance;
1577         }
1578
1579         /**
1580          * Simple output of a message with line-break
1581          *
1582          * @param       $message        Message to output
1583          * @return      void
1584          */
1585         public function outputLine ($message) {
1586                 // Simply output it
1587                 print($message . PHP_EOL);
1588         }
1589
1590         /**
1591          * Outputs a debug message whether to debug instance (should be set!) or
1592          * dies with or ptints the message. Do NEVER EVER rewrite the exit() call to
1593          * ApplicationEntryPoint::app_exit(), this would cause an endless loop.
1594          *
1595          * @param       $message        Message we shall send out...
1596          * @param       $doPrint        Whether print or die here (default: print)
1597          * @paran       $stripTags      Whether to strip tags (default: FALSE)
1598          * @return      void
1599          */
1600         public function debugOutput ($message, $doPrint = TRUE, $stripTags = FALSE) {
1601                 // Set debug instance to NULL
1602                 $debugInstance = NULL;
1603
1604                 // Try it:
1605                 try {
1606                         // Get debug instance
1607                         $debugInstance = $this->getDebugInstance();
1608                 } catch (NullPointerException $e) {
1609                         // The debug instance is not set (yet)
1610                 }
1611
1612                 // Is the debug instance there?
1613                 if (is_object($debugInstance)) {
1614                         // Use debug output handler
1615                         $debugInstance->output($message, $stripTags);
1616
1617                         if ($doPrint === FALSE) {
1618                                 // Die here if not printed
1619                                 exit();
1620                         } // END - if
1621                 } else {
1622                         // Are debug times enabled?
1623                         if ($this->getConfigInstance()->getConfigEntry('debug_output_timings') == 'Y') {
1624                                 // Prepent it
1625                                 $message = $this->getPrintableExecutionTime() . $message;
1626                         } // END - if
1627
1628                         // Put directly out
1629                         if ($doPrint === TRUE) {
1630                                 // Print message
1631                                 $this->outputLine($message);
1632                         } else {
1633                                 // Die here
1634                                 exit($message);
1635                         }
1636                 }
1637         }
1638
1639         /**
1640          * Converts e.g. a command from URL to a valid class by keeping out bad characters
1641          *
1642          * @param       $str            The string, what ever it is needs to be converted
1643          * @return      $className      Generated class name
1644          */
1645         public function convertToClassName ($str) {
1646                 // Init class name
1647                 $className = '';
1648
1649                 // Convert all dashes in underscores
1650                 $str = $this->convertDashesToUnderscores($str);
1651
1652                 // Now use that underscores to get classname parts for hungarian style
1653                 foreach (explode('_', $str) as $strPart) {
1654                         // Make the class name part lower case and first upper case
1655                         $className .= ucfirst(strtolower($strPart));
1656                 } // END - foreach
1657
1658                 // Return class name
1659                 return $className;
1660         }
1661
1662         /**
1663          * Converts dashes to underscores, e.g. useable for configuration entries
1664          *
1665          * @param       $str    The string with maybe dashes inside
1666          * @return      $str    The converted string with no dashed, but underscores
1667          */
1668         public final function convertDashesToUnderscores ($str) {
1669                 // Convert them all
1670                 $str = str_replace('-', '_', $str);
1671
1672                 // Return converted string
1673                 return $str;
1674         }
1675
1676         /**
1677          * Marks up the code by adding e.g. line numbers
1678          *
1679          * @param       $phpCode                Unmarked PHP code
1680          * @return      $markedCode             Marked PHP code
1681          */
1682         public function markupCode ($phpCode) {
1683                 // Init marked code
1684                 $markedCode = '';
1685
1686                 // Get last error
1687                 $errorArray = error_get_last();
1688
1689                 // Init the code with error message
1690                 if (is_array($errorArray)) {
1691                         // Get error infos
1692                         $markedCode = sprintf('<div id="error_header">File: <span id="error_data">%s</span>, Line: <span id="error_data">%s</span>, Message: <span id="error_data">%s</span>, Type: <span id="error_data">%s</span></div>',
1693                                 basename($errorArray['file']),
1694                                 $errorArray['line'],
1695                                 $errorArray['message'],
1696                                 $errorArray['type']
1697                         );
1698                 } // END - if
1699
1700                 // Add line number to the code
1701                 foreach (explode(chr(10), $phpCode) as $lineNo => $code) {
1702                         // Add line numbers
1703                         $markedCode .= sprintf('<span id="code_line">%s</span>: %s' . chr(10),
1704                                 ($lineNo + 1),
1705                                 htmlentities($code, ENT_QUOTES)
1706                         );
1707                 } // END - foreach
1708
1709                 // Return the code
1710                 return $markedCode;
1711         }
1712
1713         /**
1714          * Filter a given GMT timestamp (non Uni* stamp!) to make it look more
1715          * beatiful for web-based front-ends. If null is given a message id
1716          * null_timestamp will be resolved and returned.
1717          *
1718          * @param       $timestamp      Timestamp to prepare (filter) for display
1719          * @return      $readable       A readable timestamp
1720          */
1721         public function doFilterFormatTimestamp ($timestamp) {
1722                 // Default value to return
1723                 $readable = '???';
1724
1725                 // Is the timestamp null?
1726                 if (is_null($timestamp)) {
1727                         // Get a message string
1728                         $readable = $this->getLanguageInstance()->getMessage('null_timestamp');
1729                 } else {
1730                         switch ($this->getLanguageInstance()->getLanguageCode()) {
1731                                 case 'de': // German format is a bit different to default
1732                                         // Split the GMT stamp up
1733                                         $dateTime  = explode(' ', $timestamp  );
1734                                         $dateArray = explode('-', $dateTime[0]);
1735                                         $timeArray = explode(':', $dateTime[1]);
1736
1737                                         // Construct the timestamp
1738                                         $readable = sprintf($this->getConfigInstance()->getConfigEntry('german_date_time'),
1739                                                 $dateArray[0],
1740                                                 $dateArray[1],
1741                                                 $dateArray[2],
1742                                                 $timeArray[0],
1743                                                 $timeArray[1],
1744                                                 $timeArray[2]
1745                                         );
1746                                         break;
1747
1748                                 default: // Default is pass-through
1749                                         $readable = $timestamp;
1750                                         break;
1751                         } // END - switch
1752                 }
1753
1754                 // Return the stamp
1755                 return $readable;
1756         }
1757
1758         /**
1759          * Filter a given number into a localized number
1760          *
1761          * @param       $value          The raw value from e.g. database
1762          * @return      $localized      Localized value
1763          */
1764         public function doFilterFormatNumber ($value) {
1765                 // Generate it from config and localize dependencies
1766                 switch ($this->getLanguageInstance()->getLanguageCode()) {
1767                         case 'de': // German format is a bit different to default
1768                                 $localized = number_format($value, $this->getConfigInstance()->getConfigEntry('decimals'), ',', '.');
1769                                 break;
1770
1771                         default: // US, etc.
1772                                 $localized = number_format($value, $this->getConfigInstance()->getConfigEntry('decimals'), '.', ',');
1773                                 break;
1774                 } // END - switch
1775
1776                 // Return it
1777                 return $localized;
1778         }
1779
1780         /**
1781          * "Getter" for databse entry
1782          *
1783          * @return      $entry  An array with database entries
1784          * @throws      NullPointerException    If the database result is not found
1785          * @throws      InvalidDatabaseResultException  If the database result is invalid
1786          */
1787         protected final function getDatabaseEntry () {
1788                 // Is there an instance?
1789                 if (is_null($this->getResultInstance())) {
1790                         // Throw an exception here
1791                         throw new NullPointerException($this, self::EXCEPTION_IS_NULL_POINTER);
1792                 } // END - if
1793
1794                 // Rewind it
1795                 $this->getResultInstance()->rewind();
1796
1797                 // Do we have an entry?
1798                 if ($this->getResultInstance()->valid() === FALSE) {
1799                         throw new InvalidDatabaseResultException(array($this, $this->getResultInstance()), DatabaseResult::EXCEPTION_INVALID_DATABASE_RESULT);
1800                 } // END - if
1801
1802                 // Get next entry
1803                 $this->getResultInstance()->next();
1804
1805                 // Fetch it
1806                 $entry = $this->getResultInstance()->current();
1807
1808                 // And return it
1809                 return $entry;
1810         }
1811
1812         /**
1813          * Getter for field name
1814          *
1815          * @param       $fieldName              Field name which we shall get
1816          * @return      $fieldValue             Field value from the user
1817          * @throws      NullPointerException    If the result instance is null
1818          */
1819         public final function getField ($fieldName) {
1820                 // Default field value
1821                 $fieldValue = NULL;
1822
1823                 // Get result instance
1824                 $resultInstance = $this->getResultInstance();
1825
1826                 // Is this instance null?
1827                 if (is_null($resultInstance)) {
1828                         // Then the user instance is no longer valid (expired cookies?)
1829                         throw new NullPointerException($this, self::EXCEPTION_IS_NULL_POINTER);
1830                 } // END - if
1831
1832                 // Get current array
1833                 $fieldArray = $resultInstance->current();
1834                 //* DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput($fieldName.':<pre>'.print_r($fieldArray, TRUE).'</pre>');
1835
1836                 // Convert dashes to underscore
1837                 $fieldName = $this->convertDashesToUnderscores($fieldName);
1838
1839                 // Does the field exist?
1840                 if (isset($fieldArray[$fieldName])) {
1841                         // Get it
1842                         $fieldValue = $fieldArray[$fieldName];
1843                 } else {
1844                         // Missing field entry, may require debugging
1845                         self::createDebugInstance(__CLASS__)->debugOutput($this->__toString() . ':fieldname=' . $fieldName . ' not found!');
1846                 }
1847
1848                 // Return it
1849                 return $fieldValue;
1850         }
1851
1852         /**
1853          * Flushs all pending updates to the database layer
1854          *
1855          * @return      void
1856          */
1857         public function flushPendingUpdates () {
1858                 // Get result instance
1859                 $resultInstance = $this->getResultInstance();
1860
1861                 // Do we have data to update?
1862                 if ((is_object($resultInstance)) && ($resultInstance->ifDataNeedsFlush())) {
1863                         // Get wrapper class name config entry
1864                         $configEntry = $resultInstance->getUpdateInstance()->getWrapperConfigEntry();
1865
1866                         // Create object instance
1867                         $wrapperInstance = ObjectFactory::createObjectByConfiguredName($configEntry);
1868
1869                         // Yes, then send the whole result to the database layer
1870                         $wrapperInstance->doUpdateByResult($this->getResultInstance());
1871                 } // END - if
1872         }
1873
1874         /**
1875          * Outputs a deprecation warning to the developer.
1876          *
1877          * @param       $message        The message we shall output to the developer
1878          * @return      void
1879          * @todo        Write a logging mechanism for productive mode
1880          */
1881         public function deprecationWarning ($message) {
1882                 // Is developer mode active?
1883                 if (defined('DEVELOPER')) {
1884                         // Debug instance is there?
1885                         if (!is_null($this->getDebugInstance())) {
1886                                 // Output stub message
1887                                 self::createDebugInstance(__CLASS__)->debugOutput($message);
1888                         } else {
1889                                 // Trigger an error
1890                                 trigger_error($message . "<br />\n");
1891                                 exit;
1892                         }
1893                 } else {
1894                         // @TODO Finish this part!
1895                         $this->partialStub('Developer mode inactive. Message:' . $message);
1896                 }
1897         }
1898
1899         /**
1900          * Checks whether the given PHP extension is loaded
1901          *
1902          * @param       $phpExtension   The PHP extension we shall check
1903          * @return      $isLoaded       Whether the PHP extension is loaded
1904          */
1905         public final function isPhpExtensionLoaded ($phpExtension) {
1906                 // Is it loaded?
1907                 $isLoaded = in_array($phpExtension, get_loaded_extensions());
1908
1909                 // Return result
1910                 return $isLoaded;
1911         }
1912
1913         /**
1914          * "Getter" as a time() replacement but with milliseconds. You should use this
1915          * method instead of the encapsulated getimeofday() function.
1916          *
1917          * @return      $milliTime      Timestamp with milliseconds
1918          */
1919         public function getMilliTime () {
1920                 // Get the time of day as float
1921                 $milliTime = gettimeofday(TRUE);
1922
1923                 // Return it
1924                 return $milliTime;
1925         }
1926
1927         /**
1928          * Idles (sleeps) for given milliseconds
1929          *
1930          * @return      $hasSlept       Whether it goes fine
1931          */
1932         public function idle ($milliSeconds) {
1933                 // Sleep is fine by default
1934                 $hasSlept = TRUE;
1935
1936                 // Idle so long with found function
1937                 if (function_exists('time_sleep_until')) {
1938                         // Get current time and add idle time
1939                         $sleepUntil = $this->getMilliTime() + abs($milliSeconds) / 1000;
1940
1941                         // New PHP 5.1.0 function found, ignore errors
1942                         $hasSlept = @time_sleep_until($sleepUntil);
1943                 } else {
1944                         /*
1945                          * My Sun station doesn't have that function even with latest PHP
1946                          * package. :(
1947                          */
1948                         usleep($milliSeconds * 1000);
1949                 }
1950
1951                 // Return result
1952                 return $hasSlept;
1953         }
1954         /**
1955          * Converts a hexadecimal string, even with negative sign as first string to
1956          * a decimal number using BC functions.
1957          *
1958          * This work is based on comment #86673 on php.net documentation page at:
1959          * <http://de.php.net/manual/en/function.dechex.php#86673>
1960          *
1961          * @param       $hex    Hexadecimal string
1962          * @return      $dec    Decimal number
1963          */
1964         protected function hex2dec ($hex) {
1965                 // Convert to all lower-case
1966                 $hex = strtolower($hex);
1967
1968                 // Detect sign (negative/positive numbers)
1969                 $sign = '';
1970                 if (substr($hex, 0, 1) == '-') {
1971                         $sign = '-';
1972                         $hex = substr($hex, 1);
1973                 } // END - if
1974
1975                 // Decode the hexadecimal string into a decimal number
1976                 $dec = 0;
1977                 for ($i = strlen($hex) - 1, $e = 1; $i >= 0; $i--, $e = bcmul($e, 16)) {
1978                         $factor = self::$hexdec[substr($hex, $i, 1)];
1979                         $dec = bcadd($dec, bcmul($factor, $e));
1980                 } // END - for
1981
1982                 // Return the decimal number
1983                 return $sign . $dec;
1984         }
1985
1986         /**
1987          * Converts even very large decimal numbers, also signed, to a hexadecimal
1988          * string.
1989          *
1990          * This work is based on comment #97756 on php.net documentation page at:
1991          * <http://de.php.net/manual/en/function.hexdec.php#97756>
1992          *
1993          * @param       $dec            Decimal number, even with negative sign
1994          * @param       $maxLength      Optional maximum length of the string
1995          * @return      $hex    Hexadecimal string
1996          */
1997         protected function dec2hex ($dec, $maxLength = 0) {
1998                 // maxLength can be zero or devideable by 2
1999                 assert(($maxLength == 0) || (($maxLength % 2) == 0));
2000
2001                 // Detect sign (negative/positive numbers)
2002                 $sign = '';
2003                 if ($dec < 0) {
2004                         $sign = '-';
2005                         $dec = abs($dec);
2006                 } // END - if
2007
2008                 // Encode the decimal number into a hexadecimal string
2009                 $hex = '';
2010                 do {
2011                         $hex = self::$dechex[($dec % (2 ^ 4))] . $hex;
2012                         $dec /= (2 ^ 4);
2013                 } while ($dec >= 1);
2014
2015                 /*
2016                  * Leading zeros are required for hex-decimal "numbers". In some
2017                  * situations more leading zeros are wanted, so check for both
2018                  * conditions.
2019                  */
2020                 if ($maxLength > 0) {
2021                         // Prepend more zeros
2022                         $hex = str_pad($hex, $maxLength, '0', STR_PAD_LEFT);
2023                 } elseif ((strlen($hex) % 2) != 0) {
2024                         // Only make string's length dividable by 2
2025                         $hex = '0' . $hex;
2026                 }
2027
2028                 // Return the hexadecimal string
2029                 return $sign . $hex;
2030         }
2031
2032         /**
2033          * Converts a ASCII string (0 to 255) into a decimal number.
2034          *
2035          * @param       $asc    The ASCII string to be converted
2036          * @return      $dec    Decimal number
2037          */
2038         protected function asc2dec ($asc) {
2039                 // Convert it into a hexadecimal number
2040                 $hex = bin2hex($asc);
2041
2042                 // And back into a decimal number
2043                 $dec = $this->hex2dec($hex);
2044
2045                 // Return it
2046                 return $dec;
2047         }
2048
2049         /**
2050          * Converts a decimal number into an ASCII string.
2051          *
2052          * @param       $dec            Decimal number
2053          * @return      $asc    An ASCII string
2054          */
2055         protected function dec2asc ($dec) {
2056                 // First convert the number into a hexadecimal string
2057                 $hex = $this->dec2hex($dec);
2058
2059                 // Then convert it into the ASCII string
2060                 $asc = $this->hex2asc($hex);
2061
2062                 // Return it
2063                 return $asc;
2064         }
2065
2066         /**
2067          * Converts a hexadecimal number into an ASCII string. Negative numbers
2068          * are not allowed.
2069          *
2070          * @param       $hex    Hexadecimal string
2071          * @return      $asc    An ASCII string
2072          */
2073         protected function hex2asc ($hex) {
2074                 // Check for length, it must be devideable by 2
2075                 //* DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('hex='.$hex);
2076                 assert((strlen($hex) % 2) == 0);
2077
2078                 // Walk the string
2079                 $asc = '';
2080                 for ($idx = 0; $idx < strlen($hex); $idx+=2) {
2081                         // Get the decimal number of the chunk
2082                         $part = hexdec(substr($hex, $idx, 2));
2083
2084                         // Add it to the final string
2085                         $asc .= chr($part);
2086                 } // END - for
2087
2088                 // Return the final string
2089                 return $asc;
2090         }
2091
2092         /**
2093          * Checks whether the given encoded data was encoded with Base64
2094          *
2095          * @param       $encodedData    Encoded data we shall check
2096          * @return      $isBase64               Whether the encoded data is Base64
2097          */
2098         protected function isBase64Encoded ($encodedData) {
2099                 // Determine it
2100                 $isBase64 = (@base64_decode($encodedData, TRUE) !== FALSE);
2101
2102                 // Return it
2103                 return $isBase64;
2104         }
2105
2106         /**
2107          * "Getter" to get response/request type from analysis of the system.
2108          *
2109          * @return      $responseType   Analyzed response type
2110          */
2111         protected function getResponseTypeFromSystem () {
2112                 // Default is console
2113                 $responseType = 'console';
2114
2115                 // Is 'HTTP_HOST' set?
2116                 if (isset($_SERVER['HTTP_HOST'])) {
2117                         // Then it is a HTTP response/request
2118                         $responseType = 'http';
2119                 } // END - if
2120
2121                 // Return it
2122                 return $responseType;
2123         }
2124
2125         /**
2126          * Gets a cache key from Criteria instance
2127          *
2128          * @param       $criteriaInstance       An instance of a Criteria class
2129          * @param       $onlyKeys                       Only use these keys for a cache key
2130          * @return      $cacheKey                       A cache key suitable for lookup/storage purposes
2131          */
2132         protected function getCacheKeyByCriteria (Criteria $criteriaInstance, array $onlyKeys = array()) {
2133                 // Generate it
2134                 $cacheKey = sprintf('%s@%s',
2135                         $this->__toString(),
2136                         $criteriaInstance->getCacheKey($onlyKeys)
2137                 );
2138
2139                 // And return it
2140                 //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput($this->__toString() . ': cacheKey=' . $cacheKey);
2141                 return $cacheKey;
2142         }
2143
2144         /**
2145          * Getter for startup time in miliseconds
2146          *
2147          * @return      $startupTime    Startup time in miliseconds
2148          */
2149         protected function getStartupTime () {
2150                 return self::$startupTime;
2151         }
2152
2153         /**
2154          * "Getter" for a printable currently execution time in nice braces
2155          *
2156          * @return      $executionTime  Current execution time in nice braces
2157          */
2158         protected function getPrintableExecutionTime () {
2159                 // Caculate the execution time
2160                 $executionTime = microtime(TRUE) - $this->getStartupTime();
2161
2162                 // Pack it in nice braces
2163                 $executionTime = sprintf('[ %01.5f ] ', $executionTime);
2164
2165                 // And return it
2166                 return $executionTime;
2167         }
2168
2169         /**
2170          * Hashes a given string with a simple but stronger hash function (no salt)
2171          * and hex-encode it.
2172          *
2173          * @param       $str    The string to be hashed
2174          * @return      $hash   The hash from string $str
2175          */
2176         public static final function hash ($str) {
2177                 // Hash given string with (better secure) hasher
2178                 $hash = bin2hex(mhash(MHASH_SHA256, $str));
2179
2180                 // Return it
2181                 return $hash;
2182         }
2183
2184         /**
2185          * "Getter" for length of hash() output. This will be "cached" to speed up
2186          * things.
2187          *
2188          * @return      $length         Length of hash() output
2189          */
2190         public static final function getHashLength () {
2191                 // Is it cashed?
2192                 if (is_null(self::$hashLength)) {
2193                         // No, then hash a string and save its length.
2194                         self::$hashLength = strlen(self::hash('abc123'));
2195                 } // END - if
2196
2197                 // Return it
2198                 return self::$hashLength;
2199         }
2200
2201         /**
2202          * Checks whether the given number is really a number (only chars 0-9).
2203          *
2204          * @param       $num            A string consisting only chars between 0 and 9
2205          * @param       $castValue      Whether to cast the value to double. Do only use this to secure numbers from Requestable classes.
2206          * @param       $assertMismatch         Whether to assert mismatches
2207          * @return      $ret            The (hopefully) secured numbered value
2208          */
2209         public function bigintval ($num, $castValue = TRUE, $assertMismatch = FALSE) {
2210                 // Filter all numbers out
2211                 $ret = preg_replace('/[^0123456789]/', '', $num);
2212
2213                 // Shall we cast?
2214                 if ($castValue === TRUE) {
2215                         // Cast to biggest numeric type
2216                         $ret = (double) $ret;
2217                 } // END - if
2218
2219                 // Assert only if requested
2220                 if ($assertMismatch === TRUE) {
2221                         // Has the whole value changed?
2222                         assert(('' . $ret . '' != '' . $num . '') && (!is_null($num)));
2223                 } // END - if
2224
2225                 // Return result
2226                 return $ret;
2227         }
2228
2229         /**
2230          * Checks whether the given hexadecimal number is really a hex-number (only chars 0-9,a-f).
2231          *
2232          * @param       $num    A string consisting only chars between 0 and 9
2233          * @param       $assertMismatch         Whether to assert mismatches
2234          * @return      $ret    The (hopefully) secured hext-numbered value
2235          */
2236         public function hexval ($num, $assertMismatch = FALSE) {
2237                 // Filter all numbers out
2238                 $ret = preg_replace('/[^0123456789abcdefABCDEF]/', '', $num);
2239
2240                 // Assert only if requested
2241                 if ($assertMismatch === TRUE) {
2242                         // Has the whole value changed?
2243                         assert(('' . $ret . '' != '' . $num . '') && (!is_null($num)));
2244                 } // END - if
2245
2246                 // Return result
2247                 return $ret;
2248         }
2249
2250         /**
2251          * Checks whether start/end marker are set
2252          *
2253          * @param       $data   Data to be checked
2254          * @return      $isset  Whether start/end marker are set
2255          */
2256         public final function ifStartEndMarkersSet ($data) {
2257                 // Determine it
2258                 $isset = ((substr($data, 0, strlen(BaseRawDataHandler::STREAM_START_MARKER)) == BaseRawDataHandler::STREAM_START_MARKER) && (substr($data, -1 * strlen(BaseRawDataHandler::STREAM_END_MARKER), strlen(BaseRawDataHandler::STREAM_END_MARKER)) == BaseRawDataHandler::STREAM_END_MARKER));
2259
2260                 // ... and return it
2261                 return $isset;
2262         }
2263
2264         /**
2265          * Determines if an element is set in the generic array
2266          *
2267          * @param       $keyGroup       Main group for the key
2268          * @param       $subGroup       Sub group for the key
2269          * @param       $key            Key to check
2270          * @param       $element        Element to check
2271          * @return      $isset          Whether the given key is set
2272          */
2273         protected final function isGenericArrayElementSet ($keyGroup, $subGroup, $key, $element) {
2274                 // Debug message
2275                 //* NOISY-DEBUG: */ $this->outputLine('[' . __METHOD__ . ':' . __LINE__ . '] keyGroup=' . $keyGroup . ',subGroup=' . $subGroup . ',key=' . $key . ',element=' . $element);
2276
2277                 // Is it there?
2278                 $isset = isset($this->genericArray[$keyGroup][$subGroup][$key][$element]);
2279
2280                 // Return it
2281                 return $isset;
2282         }
2283         /**
2284          * Determines if a key is set in the generic array
2285          *
2286          * @param       $keyGroup       Main group for the key
2287          * @param       $subGroup       Sub group for the key
2288          * @param       $key            Key to check
2289          * @return      $isset          Whether the given key is set
2290          */
2291         protected final function isGenericArrayKeySet ($keyGroup, $subGroup, $key) {
2292                 // Debug message
2293                 //* NOISY-DEBUG: */ $this->outputLine('[' . __METHOD__ . ':' . __LINE__ . '] keyGroup=' . $keyGroup . ',subGroup=' . $subGroup . ',key=' . $key);
2294
2295                 // Is it there?
2296                 $isset = isset($this->genericArray[$keyGroup][$subGroup][$key]);
2297
2298                 // Return it
2299                 return $isset;
2300         }
2301
2302
2303         /**
2304          * Determines if a group is set in the generic array
2305          *
2306          * @param       $keyGroup       Main group
2307          * @param       $subGroup       Sub group
2308          * @return      $isset          Whether the given group is set
2309          */
2310         protected final function isGenericArrayGroupSet ($keyGroup, $subGroup) {
2311                 // Debug message
2312                 //* NOISY-DEBUG: */ $this->outputLine('[' . __METHOD__ . ':' . __LINE__ . '] keyGroup=' . $keyGroup . ',subGroup=' . $subGroup);
2313
2314                 // Is it there?
2315                 $isset = isset($this->genericArray[$keyGroup][$subGroup]);
2316
2317                 // Return it
2318                 return $isset;
2319         }
2320
2321         /**
2322          * Getter for sub key group
2323          *
2324          * @param       $keyGroup       Main key group
2325          * @param       $subGroup       Sub key group
2326          * @return      $array          An array with all array elements
2327          */
2328         protected final function getGenericSubArray ($keyGroup, $subGroup) {
2329                 // Is it there?
2330                 if (!$this->isGenericArrayGroupSet($keyGroup, $subGroup)) {
2331                         // No, then abort here
2332                         trigger_error(__METHOD__ . ': keyGroup=' . $keyGroup . ',subGroup=' . $subGroup . ' not found.');
2333                         exit;
2334                 } // END - if
2335
2336                 // Debug message
2337                 //* NOISY-DEBUG: */ $this->outputLine('[' . __METHOD__ . ':' . __LINE__ . '] keyGroup=' . $keyGroup . ',subGroup=' . $subGroup . ',value=' . print_r($this->genericArray[$keyGroup][$subGroup], TRUE));
2338
2339                 // Return it
2340                 return $this->genericArray[$keyGroup][$subGroup];
2341         }
2342
2343         /**
2344          * Unsets a given key in generic array
2345          *
2346          * @param       $keyGroup       Main group for the key
2347          * @param       $subGroup       Sub group for the key
2348          * @param       $key            Key to unset
2349          * @return      void
2350          */
2351         protected final function unsetGenericArrayKey ($keyGroup, $subGroup, $key) {
2352                 // Debug message
2353                 //* NOISY-DEBUG: */ $this->outputLine('[' . __METHOD__ . ':' . __LINE__ . '] keyGroup=' . $keyGroup . ',subGroup=' . $subGroup . ',key=' . $key);
2354
2355                 // Remove it
2356                 unset($this->genericArray[$keyGroup][$subGroup][$key]);
2357         }
2358
2359         /**
2360          * Unsets a given element in generic array
2361          *
2362          * @param       $keyGroup       Main group for the key
2363          * @param       $subGroup       Sub group for the key
2364          * @param       $key            Key to unset
2365          * @param       $element        Element to unset
2366          * @return      void
2367          */
2368         protected final function unsetGenericArrayElement ($keyGroup, $subGroup, $key, $element) {
2369                 // Debug message
2370                 //* NOISY-DEBUG: */ $this->outputLine('[' . __METHOD__ . ':' . __LINE__ . '] keyGroup=' . $keyGroup . ',subGroup=' . $subGroup . ',key=' . $key . ',element=' . $element);
2371
2372                 // Remove it
2373                 unset($this->genericArray[$keyGroup][$subGroup][$key][$element]);
2374         }
2375
2376         /**
2377          * Append a string to a given generic array key
2378          *
2379          * @param       $keyGroup       Main group for the key
2380          * @param       $subGroup       Sub group for the key
2381          * @param       $key            Key to unset
2382          * @param       $value          Value to add/append
2383          * @return      void
2384          */
2385         protected final function appendStringToGenericArrayKey ($keyGroup, $subGroup, $key, $value, $appendGlue = '') {
2386                 // Debug message
2387                 //* NOISY-DEBUG: */ if (!is_object($value)) $this->outputLine('[' . __METHOD__ . ':' . __LINE__ . '] keyGroup=' . $keyGroup . ',subGroup=' . $subGroup . ',key=' . $key . ',value[' . gettype($value) . ']=' . print_r($value, TRUE) . ',appendGlue=' . $appendGlue);
2388
2389                 // Is it already there?
2390                 if ($this->isGenericArrayKeySet($keyGroup, $subGroup, $key)) {
2391                         // Append it
2392                         $this->genericArray[$keyGroup][$subGroup][$key] .= $appendGlue . (string) $value;
2393                 } else {
2394                         // Add it
2395                         $this->genericArray[$keyGroup][$subGroup][$key] = (string) $value;
2396                 }
2397         }
2398
2399         /**
2400          * Append a string to a given generic array element
2401          *
2402          * @param       $keyGroup       Main group for the key
2403          * @param       $subGroup       Sub group for the key
2404          * @param       $key            Key to unset
2405          * @param       $element        Element to check
2406          * @param       $value          Value to add/append
2407          * @return      void
2408          */
2409         protected final function appendStringToGenericArrayElement ($keyGroup, $subGroup, $key, $element, $value, $appendGlue = '') {
2410                 // Debug message
2411                 //* NOISY-DEBUG: */ if (!is_object($value)) $this->outputLine('[' . __METHOD__ . ':' . __LINE__ . '] keyGroup=' . $keyGroup . ',subGroup=' . $subGroup . ',key=' . $key . ',element=' . $element . ',value[' . gettype($value) . ']=' . print_r($value, TRUE) . ',appendGlue=' . $appendGlue);
2412
2413                 // Is it already there?
2414                 if ($this->isGenericArrayElementSet($keyGroup, $subGroup, $key, $element)) {
2415                         // Append it
2416                         $this->genericArray[$keyGroup][$subGroup][$key][$element] .= $appendGlue . (string) $value;
2417                 } else {
2418                         // Add it
2419                         $this->genericArray[$keyGroup][$subGroup][$key][$element] = (string) $value;
2420                 }
2421         }
2422
2423         /**
2424          * Initializes given generic array group
2425          *
2426          * @param       $keyGroup       Main group for the key
2427          * @param       $subGroup       Sub group for the key
2428          * @param       $key            Key to use
2429          * @param       $forceInit      Optionally force initialization
2430          * @return      void
2431          */
2432         protected final function initGenericArrayGroup ($keyGroup, $subGroup, $forceInit = FALSE) {
2433                 // Debug message
2434                 //* NOISY-DEBUG: */ $this->outputLine('[' . __METHOD__ . ':' . __LINE__ . '] keyGroup=' . $keyGroup . ',subGroup=' . $subGroup . ',forceInit=' . intval($forceInit));
2435
2436                 // Is it already set?
2437                 if (($forceInit === FALSE) && ($this->isGenericArrayGroupSet($keyGroup, $subGroup))) {
2438                         // Already initialized
2439                         trigger_error(__METHOD__ . ':keyGroup=' . $keyGroup . ',subGroup=' . $subGroup . ' already initialized.');
2440                         exit;
2441                 } // END - if
2442
2443                 // Initialize it
2444                 $this->genericArray[$keyGroup][$subGroup] = array();
2445         }
2446
2447         /**
2448          * Initializes given generic array key
2449          *
2450          * @param       $keyGroup       Main group for the key
2451          * @param       $subGroup       Sub group for the key
2452          * @param       $key            Key to use
2453          * @param       $forceInit      Optionally force initialization
2454          * @return      void
2455          */
2456         protected final function initGenericArrayKey ($keyGroup, $subGroup, $key, $forceInit = FALSE) {
2457                 // Debug message
2458                 //* NOISY-DEBUG: */ $this->outputLine('[' . __METHOD__ . ':' . __LINE__ . '] keyGroup=' . $keyGroup . ',subGroup=' . $subGroup . ',key=' . $key . ',forceInit=' . intval($forceInit));
2459
2460                 // Is it already set?
2461                 if (($forceInit === FALSE) && ($this->isGenericArrayKeySet($keyGroup, $subGroup, $key))) {
2462                         // Already initialized
2463                         trigger_error(__METHOD__ . ':keyGroup=' . $keyGroup . ',subGroup=' . $subGroup . ',key=' . $key . ' already initialized.');
2464                         exit;
2465                 } // END - if
2466
2467                 // Initialize it
2468                 $this->genericArray[$keyGroup][$subGroup][$key] = array();
2469         }
2470
2471         /**
2472          * Initializes given generic array element
2473          *
2474          * @param       $keyGroup       Main group for the key
2475          * @param       $subGroup       Sub group for the key
2476          * @param       $key            Key to use
2477          * @param       $element        Element to use
2478          * @param       $forceInit      Optionally force initialization
2479          * @return      void
2480          */
2481         protected final function initGenericArrayElement ($keyGroup, $subGroup, $key, $element, $forceInit = FALSE) {
2482                 // Debug message
2483                 //* NOISY-DEBUG: */ $this->outputLine('[' . __METHOD__ . ':' . __LINE__ . '] keyGroup=' . $keyGroup . ',subGroup=' . $subGroup . ',key=' . $key . ',element=' . $element . ',forceInit=' . intval($forceInit));
2484
2485                 // Is it already set?
2486                 if (($forceInit === FALSE) && ($this->isGenericArrayElementSet($keyGroup, $subGroup, $key, $element))) {
2487                         // Already initialized
2488                         trigger_error(__METHOD__ . ':keyGroup=' . $keyGroup . ',subGroup=' . $subGroup . ',key=' . $key . ',element=' . $element . ' already initialized.');
2489                         exit;
2490                 } // END - if
2491
2492                 // Initialize it
2493                 $this->genericArray[$keyGroup][$subGroup][$key][$element] = array();
2494         }
2495
2496         /**
2497          * Pushes an element to a generic key
2498          *
2499          * @param       $keyGroup       Main group for the key
2500          * @param       $subGroup       Sub group for the key
2501          * @param       $key            Key to use
2502          * @param       $value          Value to add/append
2503          * @return      $count          Number of array elements
2504          */
2505         protected final function pushValueToGenericArrayKey ($keyGroup, $subGroup, $key, $value) {
2506                 // Debug message
2507                 //* NOISY-DEBUG: */ if (!is_object($value)) $this->outputLine('[' . __METHOD__ . ':' . __LINE__ . '] keyGroup=' . $keyGroup . ',subGroup=' . $subGroup . ',key=' . $key . ',value[' . gettype($value) . ']=' . print_r($value, TRUE));
2508
2509                 // Is it set?
2510                 if (!$this->isGenericArrayKeySet($keyGroup, $subGroup, $key)) {
2511                         // Initialize array
2512                         $this->initGenericArrayKey($keyGroup, $subGroup, $key);
2513                 } // END - if
2514
2515                 // Then push it
2516                 $count = array_push($this->genericArray[$keyGroup][$subGroup][$key], $value);
2517
2518                 // Return count
2519                 //* DEBUG: */ print(__METHOD__ . ': genericArray=' . print_r($this->genericArray[$keyGroup][$subGroup][$key], TRUE));
2520                 //* DEBUG: */ print(__METHOD__ . ': count=' . $count . PHP_EOL);
2521                 return $count;
2522         }
2523
2524         /**
2525          * Pushes an element to a generic array element
2526          *
2527          * @param       $keyGroup       Main group for the key
2528          * @param       $subGroup       Sub group for the key
2529          * @param       $key            Key to use
2530          * @param       $element        Element to check
2531          * @param       $value          Value to add/append
2532          * @return      $count          Number of array elements
2533          */
2534         protected final function pushValueToGenericArrayElement ($keyGroup, $subGroup, $key, $element, $value) {
2535                 // Debug message
2536                 //* NOISY-DEBUG: */ if (!is_object($value)) $this->outputLine('[' . __METHOD__ . ':' . __LINE__ . '] keyGroup=' . $keyGroup . ',subGroup=' . $subGroup . ',key=' . $key . ',element=' . $element . ',value[' . gettype($value) . ']=' . print_r($value, TRUE));
2537
2538                 // Is it set?
2539                 if (!$this->isGenericArrayElementSet($keyGroup, $subGroup, $key, $element)) {
2540                         // Initialize array
2541                         $this->initGenericArrayElement($keyGroup, $subGroup, $key, $element);
2542                 } // END - if
2543
2544                 // Then push it
2545                 $count = array_push($this->genericArray[$keyGroup][$subGroup][$key][$element], $value);
2546
2547                 // Return count
2548                 //* DEBUG: */ print(__METHOD__ . ': genericArray=' . print_r($this->genericArray[$keyGroup][$subGroup][$key], TRUE));
2549                 //* DEBUG: */ print(__METHOD__ . ': count=' . $count . PHP_EOL);
2550                 return $count;
2551         }
2552
2553         /**
2554          * Pops an element from  a generic group
2555          *
2556          * @param       $keyGroup       Main group for the key
2557          * @param       $subGroup       Sub group for the key
2558          * @param       $key            Key to unset
2559          * @return      $value          Last "popped" value
2560          */
2561         protected final function popGenericArrayElement ($keyGroup, $subGroup, $key) {
2562                 // Debug message
2563                 //* NOISY-DEBUG: */ $this->outputLine('[' . __METHOD__ . ':' . __LINE__ . '] keyGroup=' . $keyGroup . ',subGroup=' . $subGroup . ',key=' . $key);
2564
2565                 // Is it set?
2566                 if (!$this->isGenericArrayKeySet($keyGroup, $subGroup, $key)) {
2567                         // Not found
2568                         trigger_error(__METHOD__ . ': keyGroup=' . $keyGroup . ',subGroup=' . $subGroup . ',key=' . $key . ' not found.');
2569                         exit;
2570                 } // END - if
2571
2572                 // Then "pop" it
2573                 $value = array_pop($this->genericArray[$keyGroup][$subGroup][$key]);
2574
2575                 // Return value
2576                 //* DEBUG: */ print(__METHOD__ . ': genericArray=' . print_r($this->genericArray[$keyGroup][$subGroup][$key], TRUE));
2577                 //* DEBUG: */ print(__METHOD__ . ': value[' . gettype($value) . ']=' . print_r($value, TRUE) . PHP_EOL);
2578                 return $value;
2579         }
2580
2581         /**
2582          * Shifts an element from  a generic group
2583          *
2584          * @param       $keyGroup       Main group for the key
2585          * @param       $subGroup       Sub group for the key
2586          * @param       $key            Key to unset
2587          * @return      $value          Last "popped" value
2588          */
2589         protected final function shiftGenericArrayElement ($keyGroup, $subGroup, $key) {
2590                 // Debug message
2591                 //* NOISY-DEBUG: */ $this->outputLine('[' . __METHOD__ . ':' . __LINE__ . '] keyGroup=' . $keyGroup . ',subGroup=' . $subGroup . ',key=' . $key);
2592
2593                 // Is it set?
2594                 if (!$this->isGenericArrayKeySet($keyGroup, $subGroup, $key)) {
2595                         // Not found
2596                         trigger_error(__METHOD__ . ': keyGroup=' . $keyGroup . ',subGroup=' . $subGroup . ',key=' . $key . ' not found.');
2597                         exit;
2598                 } // END - if
2599
2600                 // Then "shift" it
2601                 $value = array_shift($this->genericArray[$keyGroup][$subGroup][$key]);
2602
2603                 // Return value
2604                 //* DEBUG: */ print(__METHOD__ . ': genericArray=' . print_r($this->genericArray[$keyGroup][$subGroup][$key], TRUE));
2605                 //* DEBUG: */ print(__METHOD__ . ': value[' . gettype($value) . ']=' . print_r($value, TRUE) . PHP_EOL);
2606                 return $value;
2607         }
2608
2609         /**
2610          * Count generic array group
2611          *
2612          * @param       $keyGroup       Main group for the key
2613          * @return      $count          Count of given group
2614          */
2615         protected final function countGenericArray ($keyGroup) {
2616                 // Debug message
2617                 //* NOISY-DEBUG: */ $this->outputLine('[' . __METHOD__ . ':' . __LINE__ . '] keyGroup=' . $keyGroup);
2618
2619                 // Is it there?
2620                 if (!isset($this->genericArray[$keyGroup])) {
2621                         // Abort here
2622                         trigger_error(__METHOD__ . ': keyGroup=' . $keyGroup . ' not found.');
2623                         exit;
2624                 } // END - if
2625
2626                 // Then count it
2627                 $count = count($this->genericArray[$keyGroup]);
2628
2629                 // Debug message
2630                 //* NOISY-DEBUG: */ $this->outputLine('[' . __METHOD__ . ':' . __LINE__ . '] keyGroup=' . $keyGroup . ',count=' . $count);
2631
2632                 // Return it
2633                 return $count;
2634         }
2635
2636         /**
2637          * Count generic array sub group
2638          *
2639          * @param       $keyGroup       Main group for the key
2640          * @param       $subGroup       Sub group for the key
2641          * @return      $count          Count of given group
2642          */
2643         protected final function countGenericArrayGroup ($keyGroup, $subGroup) {
2644                 // Debug message
2645                 //* NOISY-DEBUG: */ $this->outputLine('[' . __METHOD__ . ':' . __LINE__ . '] keyGroup=' . $keyGroup . ',subGroup=' . $subGroup);
2646
2647                 // Is it there?
2648                 if (!$this->isGenericArrayGroupSet($keyGroup, $subGroup)) {
2649                         // Abort here
2650                         trigger_error(__METHOD__ . ': keyGroup=' . $keyGroup . ',subGroup=' . $subGroup . ' not found.');
2651                         exit;
2652                 } // END - if
2653
2654                 // Then count it
2655                 $count = count($this->genericArray[$keyGroup][$subGroup]);
2656
2657                 // Debug message
2658                 //* NOISY-DEBUG: */ $this->outputLine('[' . __METHOD__ . ':' . __LINE__ . '] keyGroup=' . $keyGroup . ',subGroup=' . $subGroup . ',count=' . $count);
2659
2660                 // Return it
2661                 return $count;
2662         }
2663
2664         /**
2665          * Count generic array elements
2666          *
2667          * @param       $keyGroup       Main group for the key
2668          * @param       $subGroup       Sub group for the key
2669          * @para        $key            Key to count
2670          * @return      $count          Count of given key
2671          */
2672         protected final function countGenericArrayElements ($keyGroup, $subGroup, $key) {
2673                 // Debug message
2674                 //* NOISY-DEBUG: */ $this->outputLine('[' . __METHOD__ . ':' . __LINE__ . '] keyGroup=' . $keyGroup . ',subGroup=' . $subGroup . ',key=' . $key);
2675
2676                 // Is it there?
2677                 if (!$this->isGenericArrayKeySet($keyGroup, $subGroup, $key)) {
2678                         // Abort here
2679                         trigger_error(__METHOD__ . ': keyGroup=' . $keyGroup . ',subGroup=' . $subGroup . ' not found.');
2680                         exit;
2681                 } elseif (!$this->isValidGenericArrayGroup($keyGroup, $subGroup)) {
2682                         // Not valid
2683                         trigger_error(__METHOD__ . ': keyGroup=' . $keyGroup . ',subGroup=' . $subGroup . ' is not an array.');
2684                         exit;
2685                 }
2686
2687                 // Then count it
2688                 $count = count($this->genericArray[$keyGroup][$subGroup][$key]);
2689
2690                 // Debug message
2691                 //* NOISY-DEBUG: */ $this->outputLine('[' . __METHOD__ . ':' . __LINE__ . '] keyGroup=' . $keyGroup . ',subGroup=' . $subGroup . ',key=' . $key . ',count=' . $count);
2692
2693                 // Return it
2694                 return $count;
2695         }
2696
2697         /**
2698          * Getter for whole generic group array
2699          *
2700          * @param       $keyGroup       Key group to get
2701          * @return      $array          Whole generic array group
2702          */
2703         protected final function getGenericArray ($keyGroup) {
2704                 // Debug message
2705                 //* NOISY-DEBUG: */ $this->outputLine('[' . __METHOD__ . ':' . __LINE__ . '] keyGroup=' . $keyGroup);
2706
2707                 // Is it there?
2708                 if (!isset($this->genericArray[$keyGroup])) {
2709                         // Then abort here
2710                         trigger_error(__METHOD__ . ': keyGroup=' . $keyGroup . ' does not exist.');
2711                         exit;
2712                 } // END - if
2713
2714                 // Return it
2715                 return $this->genericArray[$keyGroup];
2716         }
2717
2718         /**
2719          * Setter for generic array key
2720          *
2721          * @param       $keyGroup       Key group to get
2722          * @param       $subGroup       Sub group for the key
2723          * @param       $key            Key to unset
2724          * @param       $value          Mixed value from generic array element
2725          * @return      void
2726          */
2727         protected final function setGenericArrayKey ($keyGroup, $subGroup, $key, $value) {
2728                 // Debug message
2729                 //* NOISY-DEBUG: */ if (!is_object($value)) $this->outputLine('[' . __METHOD__ . ':' . __LINE__ . '] keyGroup=' . $keyGroup . ',subGroup=' . $subGroup . ',key=' . $key . ',value[' . gettype($value) . ']=' . print_r($value, TRUE));
2730
2731                 // Set value here
2732                 $this->genericArray[$keyGroup][$subGroup][$key] = $value;
2733         }
2734
2735         /**
2736          * Getter for generic array key
2737          *
2738          * @param       $keyGroup       Key group to get
2739          * @param       $subGroup       Sub group for the key
2740          * @param       $key            Key to unset
2741          * @return      $value          Mixed value from generic array element
2742          */
2743         protected final function getGenericArrayKey ($keyGroup, $subGroup, $key) {
2744                 // Debug message
2745                 //* NOISY-DEBUG: */ $this->outputLine('[' . __METHOD__ . ':' . __LINE__ . '] keyGroup=' . $keyGroup . ',subGroup=' . $subGroup . ',key=' . $key);
2746
2747                 // Is it there?
2748                 if (!$this->isGenericArrayKeySet($keyGroup, $subGroup, $key)) {
2749                         // Then abort here
2750                         trigger_error(__METHOD__ . ': keyGroup=' . $keyGroup . ',subGroup=' . $subGroup . ',key=' . $key . ' does not exist.');
2751                         exit;
2752                 } // END - if
2753
2754                 // Return it
2755                 return $this->genericArray[$keyGroup][$subGroup][$key];
2756         }
2757
2758         /**
2759          * Sets a value in given generic array key/element
2760          *
2761          * @param       $keyGroup       Main group for the key
2762          * @param       $subGroup       Sub group for the key
2763          * @param       $key            Key to set
2764          * @param       $element        Element to set
2765          * @param       $value          Value to set
2766          * @return      void
2767          */
2768         protected final function setGenericArrayElement ($keyGroup, $subGroup, $key, $element, $value) {
2769                 // Debug message
2770                 //* NOISY-DEBUG: */ if (!is_object($value)) $this->outputLine('[' . __METHOD__ . ':' . __LINE__ . '] keyGroup=' . $keyGroup . ',subGroup=' . $subGroup . ',key=' . $key . ',element=' . $element . ',value[' . gettype($value) . ']=' . print_r($value, TRUE));
2771
2772                 // Then set it
2773                 $this->genericArray[$keyGroup][$subGroup][$key][$element] = $value;
2774         }
2775
2776         /**
2777          * Getter for generic array element
2778          *
2779          * @param       $keyGroup       Key group to get
2780          * @param       $subGroup       Sub group for the key
2781          * @param       $key            Key to look for
2782          * @param       $element        Element to look for
2783          * @return      $value          Mixed value from generic array element
2784          */
2785         protected final function getGenericArrayElement ($keyGroup, $subGroup, $key, $element) {
2786                 // Debug message
2787                 //* NOISY-DEBUG: */ $this->outputLine('[' . __METHOD__ . ':' . __LINE__ . '] keyGroup=' . $keyGroup . ',subGroup=' . $subGroup . ',key=' . $key . ',element=' . $element);
2788
2789                 // Is it there?
2790                 if (!$this->isGenericArrayElementSet($keyGroup, $subGroup, $key, $element)) {
2791                         // Then abort here
2792                         trigger_error(__METHOD__ . ': keyGroup=' . $keyGroup . ',subGroup=' . $subGroup . ',key=' . $key . ',element=' . $element . ' does not exist.');
2793                         exit;
2794                 } // END - if
2795
2796                 // Return it
2797                 return $this->genericArray[$keyGroup][$subGroup][$key][$element];
2798         }
2799
2800         /**
2801          * Checks if a given sub group is valid (array)
2802          *
2803          * @param       $keyGroup       Key group to get
2804          * @param       $subGroup       Sub group for the key
2805          * @return      $isValid        Whether given sub group is valid
2806          */
2807         protected final function isValidGenericArrayGroup ($keyGroup, $subGroup) {
2808                 // Debug message
2809                 //* NOISY-DEBUG: */ $this->outputLine('[' . __METHOD__ . ':' . __LINE__ . '] keyGroup=' . $keyGroup . ',subGroup=' . $subGroup);
2810
2811                 // Determine it
2812                 $isValid = (($this->isGenericArrayGroupSet($keyGroup, $subGroup)) && (is_array($this->getGenericSubArray($keyGroup, $subGroup))));
2813
2814                 // Return it
2815                 return $isValid;
2816         }
2817
2818         /**
2819          * Checks if a given key is valid (array)
2820          *
2821          * @param       $keyGroup       Key group to get
2822          * @param       $subGroup       Sub group for the key
2823          * @param       $key            Key to check
2824          * @return      $isValid        Whether given sub group is valid
2825          */
2826         protected final function isValidGenericArrayKey ($keyGroup, $subGroup, $key) {
2827                 // Debug message
2828                 //* NOISY-DEBUG: */ $this->outputLine('[' . __METHOD__ . ':' . __LINE__ . '] keyGroup=' . $keyGroup . ',subGroup=' . $subGroup . ',key=' . $key);
2829
2830                 // Determine it
2831                 $isValid = (($this->isGenericArrayKeySet($keyGroup, $subGroup, $key)) && (is_array($this->getGenericArrayKey($keyGroup, $subGroup, $key))));
2832
2833                 // Return it
2834                 return $isValid;
2835         }
2836
2837         /**
2838          * Translates boolean TRUE to 'Y' and FALSE to 'N'
2839          *
2840          * @param       $boolean                Boolean value
2841          * @return      $translated             Translated boolean value
2842          */
2843         public static final function translateBooleanToYesNo ($boolean) {
2844                 // Make sure it is really boolean
2845                 assert(is_bool($boolean));
2846
2847                 // "Translate" it
2848                 $translated = ($boolean === TRUE) ? 'Y' : 'N';
2849
2850                 // ... and return it
2851                 return $translated;
2852         }
2853 }
2854
2855 // [EOF]
2856 ?>