From: Roland Häder Date: Sun, 17 Apr 2011 18:16:13 +0000 (+0000) Subject: Added required method streamData(), maybe someday we will rewrite these classes? X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=c129ee85747926121abe1e2db43860121fa9b98e;p=core.git Added required method streamData(), maybe someday we will rewrite these classes? --- diff --git a/inc/classes/main/debug/class_DebugConsoleOutput.php b/inc/classes/main/debug/class_DebugConsoleOutput.php index a513d633..bf6e0980 100644 --- a/inc/classes/main/debug/class_DebugConsoleOutput.php +++ b/inc/classes/main/debug/class_DebugConsoleOutput.php @@ -70,6 +70,18 @@ class DebugConsoleOutput extends BaseFrameworkSystem implements Debugger, Output $this->outputStream($outStream); } // END - if } + + /** + * Streams the data and maybe does something to it + * + * @param $data The data (string mostly) to "stream" + * @return $data The data (string mostly) to "stream" + * @throws UnsupportedOperationException If this method is called + */ + public function streamData ($data) { + $this->debugOutput('Unhandled ' . strlen($data) . ' bytes in this stream.'); + throw new UnsupportedOperationException(array($this, __FUNCTION__), self::EXCEPTION_UNSPPORTED_OPERATION); + } } // [EOF] diff --git a/inc/classes/main/io/class_FileIoStream.php b/inc/classes/main/io/class_FileIoStream.php index 45f1021e..fb7096d4 100644 --- a/inc/classes/main/io/class_FileIoStream.php +++ b/inc/classes/main/io/class_FileIoStream.php @@ -159,7 +159,7 @@ class FileIoStream extends BaseFrameworkSystem implements FileInputStreamer, Fil // Remember last read line for avoiding possible infinite loops $lastBuffer = $inputBuffer; - } + } // END - while // Close directory handle $fileInstance->closeFile(); @@ -185,7 +185,7 @@ class FileIoStream extends BaseFrameworkSystem implements FileInputStreamer, Fil if (count($header) != 4) { // Throw an exception throw new InvalidArrayCountException(array($this, 'header', count($header), 4), self::EXCEPTION_ARRAY_HAS_INVALID_COUNT); - } + } // END - if } elseif (substr($rawLine, 0, 5) == $this->dataBlock) { // Is a data line! $data = explode($this->seperator, $rawLine); @@ -199,7 +199,7 @@ class FileIoStream extends BaseFrameworkSystem implements FileInputStreamer, Fil if (md5($data[0]) != $data[1]) { // MD5 hash did not match! throw new InvalidMD5ChecksumException(array($this, md5($data[0]), $data[1]), self::EXCEPTION_MD5_CHECKSUMS_MISMATCH); - } + } // END - if } else { // Invalid count! throw new InvalidArrayCountException(array($this, "data", count($data), 2), self::EXCEPTION_ARRAY_HAS_INVALID_COUNT); @@ -211,19 +211,19 @@ class FileIoStream extends BaseFrameworkSystem implements FileInputStreamer, Fil // Other raw lines than header/data tagged lines and re-add the new-line char $readData .= $rawLine . "\n"; } - } + } // END - foreach // Was raw lines read and no header/data? if ((!empty($readData)) && (count($header) == 0) && (count($data) == 0)) { // Return raw lines back return $readData; - } + } // END - if // Was a header found? if (count($header) != 4) { // Throw an exception throw new InvalidArrayCountException(array($this, 'header', count($header), 4), self::EXCEPTION_ARRAY_HAS_INVALID_COUNT); - } + } // END - if // Decode all from Base64 $readData = @base64_decode($readData); @@ -232,13 +232,13 @@ class FileIoStream extends BaseFrameworkSystem implements FileInputStreamer, Fil if (strlen($readData) != $header[2]) { // Size did not match throw new InvalidDataLengthException(array($this, strlen($readData), $header[2]), self::EXCEPTION_UNEXPECTED_STRING_SIZE); - } + } // END - if // Validate the decoded data with the final MD5 hash if (md5($readData) != $header[3]) { // MD5 hash did not match! throw new InvalidMD5ChecksumException(array($this, md5($readData), $header[3]), self::EXCEPTION_MD5_CHECKSUMS_MISMATCH); - } + } // END - if // Return all in an array return array( @@ -246,6 +246,18 @@ class FileIoStream extends BaseFrameworkSystem implements FileInputStreamer, Fil 'data' => $readData ); } + + /** + * Streams the data and maybe does something to it + * + * @param $data The data (string mostly) to "stream" + * @return $data The data (string mostly) to "stream" + * @throws UnsupportedOperationException If this method is called + */ + public function streamData ($data) { + $this->debugOutput('Unhandled ' . strlen($data) . ' bytes in this stream.'); + throw new UnsupportedOperationException(array($this, __FUNCTION__), self::EXCEPTION_UNSPPORTED_OPERATION); + } } // [EOF]