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