4762cb86414a11ea6521d63b2360fc61b53ed7b2
[shipsimu.git] / ship-simu / inc / classes / main / compressor / class_NullCompressor.php
1 <?php
2 /**
3  * Null compression and decompression class
4  */
5 class NullCompressor extends BaseFrameworkSystem implements Compressor {
6         /**
7          * Private constructor
8          *
9          * @return      void
10          */
11         private function __construct () {
12                 // Call parent constructor!
13                 parent::constructor(__CLASS__);
14
15                 // Debug message
16                 if (((defined('DEBUG_COMPRESSOR')) || (defined('DEBUG_ALL'))) && (defined('DEBUG_CONSTRUCT'))) $this->getDebugInstance()->output(sprintf("[%s:] Konstruktor erreicht.<br />\n",
17                         $this->__toString()
18                 ));
19
20                 // Set description
21                 $this->setPartDescr("Null-Kompressor");
22
23                 // Create an unique ID
24                 $this->createUniqueID();
25         }
26
27         /**
28          * Create a new compressor channel based a given compression handler
29          *
30          * @return      $cInstance      An instance of this class
31          */
32         public final static function createNullCompressor () {
33                 // Get new instance
34                 $cInstance = new NullCompressor();
35
36                 // Return the compressor instance
37                 return $cInstance;
38         }
39
40         /**
41          * Null compression stream
42          *
43          * @param               $streamData                     Mixed non-object stream data
44          * @return      $streamData                     The compressed stream data      
45          * @throws      InvalidObjectException  If the stream is an object
46          */
47         public function compressStream ($streamData) {
48                 if (is_object($streamData)) {
49                         // Throw an exception
50                         throw new InvalidObjectException($streamData, self::EXCEPTION_UNEXPECTED_OBJECT);
51                 }
52
53                 // Return the compressed stream
54                 return $streamData;
55         }
56
57         /**
58          * Null decompression stream
59          *
60          * @param               $streamData                     Mixed non-object stream data
61          * @return      $streamData                     The decompressed stream data    
62          * @throws      InvalidObjectException  If the stream is an object
63          */
64         public function decompressStream ($streamData) {
65                 if (is_object($streamData)) {
66                         // Throw an exception
67                         throw new InvalidObjectException($streamData, self::EXCEPTION_UNEXPECTED_OBJECT);
68                 }
69
70                 // Return the decompressed stream
71                 return $streamData;
72         }
73
74         /**
75          * Getter for the file extension of this compressor
76          *
77          * @return      $string Returns always "bz2"
78          */
79         public final function getCompressorExtension () {
80                 if ((defined('DEBUG_COMPRESSOR')) || (defined('DEBUG_ALL'))) $this->getDebugInstance()->output(sprintf("[%s:] Dateierweiterung angefordert.<br />\n",
81                         $this->__toString()
82                 ));
83                 return "null";
84         }
85 }
86
87 // [EOF]
88 ?>