]> git.mxchange.org Git - core.git/blobdiff - framework/main/classes/file_directories/binary/index/class_IndexFile.php
Continued:
[core.git] / framework / main / classes / file_directories / binary / index / class_IndexFile.php
index 10bc85203cf27136767c7088e82ba49cc95e26ac..bed690ff714585a744464ce231bdf95d7733ae1d 100644 (file)
@@ -6,6 +6,7 @@ namespace Org\Mxchange\CoreFramework\Filesystem\Index;
 use Org\Mxchange\CoreFramework\Bootstrap\FrameworkBootstrap;
 use Org\Mxchange\CoreFramework\Filesystem\File\BaseBinaryFile;
 use Org\Mxchange\CoreFramework\Filesystem\Index\IndexableFile;
+use Org\Mxchange\CoreFramework\Generic\FrameworkInterface;
 use Org\Mxchange\CoreFramework\Generic\UnsupportedOperationException;
 use Org\Mxchange\CoreFramework\Index\Indexable;
 use Org\Mxchange\CoreFramework\Utils\Crypto\CryptoUtils;
@@ -20,7 +21,7 @@ use \SplFileInfo;
  *
  * @author             Roland Haeder <webmaster@ship-simu.org>
  * @version            0.0.0
- * @copyright  Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2022 Core Developer Team
+ * @copyright  Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2023 Core Developer Team
  * @license            GNU GPL 3.0 or any newer version
  * @link               http://www.ship-simu.org
  *
@@ -92,7 +93,7 @@ class IndexFile extends BaseBinaryFile implements IndexableFile {
                }
 
                // Call block instance
-               /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('INDEX-FILE: Calling this->indexInstance->flushFileHeader() ...');
+               /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('INDEX-FILE: Invoking this->indexInstance->flushFileHeader() ...');
                $this->getIndexInstance()->flushFileHeader();
 
                // Trace message
@@ -112,7 +113,7 @@ class IndexFile extends BaseBinaryFile implements IndexableFile {
                //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('INDEX-FILE: type=%s - CALLED!', $type));
                if (empty($type)) {
                        // Empty type
-                       throw new InvalidArgumentException('Parameter "type" is empty');
+                       throw new InvalidArgumentException('Parameter "type" is empty', FrameworkInterface::EXCEPTION_INVALID_ARGUMENT);
                } elseif (!($this->getIndexInstance() instanceof Indexable)) {
                        // Index instance not set
                        throw new BadMethodCallException('this->indexInstance[] is not properly set.');
@@ -125,6 +126,7 @@ class IndexFile extends BaseBinaryFile implements IndexableFile {
                $minimumBlockLength = $this->getIndexInstance()->calculateMinimumBlockLength();
 
                // Call protected method
+               /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('INDEX-FILE: Invoking this->preAllocateFileByTypeLength(%s,%d) ...', $type, $minimumBlockLength));
                $this->preAllocateFileByTypeLength($type, $minimumBlockLength);
 
                // Trace message
@@ -148,11 +150,11 @@ class IndexFile extends BaseBinaryFile implements IndexableFile {
                }
 
                // Get length from index
-               /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('INDEX-FILE: Calling this->indexInstance->calculateMinimumBlockLength() ...');
+               /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('INDEX-FILE: Invoking this->indexInstance->calculateMinimumBlockLength() ...');
                $length = $this->getIndexInstance()->calculateMinimumBlockLength();
 
                // Call protected method
-               /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('INDEX-FILE: Calling this->isValidByLength(%d) ...', $length));
+               /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('INDEX-FILE: Invoking this->isValidByLength(%d) ...', $length));
                $isValid = $this->isValidByLength($length);
 
                // Return result
@@ -173,7 +175,7 @@ class IndexFile extends BaseBinaryFile implements IndexableFile {
                $length = $this->getIndexInstance()->calculateMinimumBlockLength();
 
                // Call protected method
-               //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('INDEX-FILE: Calling parent::readNextBlockByLength(%d) ...', $length));
+               //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('INDEX-FILE: Invoking parent::readNextBlockByLength(%d) ...', $length));
                parent::readNextBlockByLength($length);
 
                // Trace message
@@ -187,7 +189,7 @@ class IndexFile extends BaseBinaryFile implements IndexableFile {
         */
        public function readFileHeader () {
                // Call index class' method
-               /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('INDEX-FILE: Calling this->indexInstance->readIndexHeader() - CALLED!');
+               /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('INDEX-FILE: Invoking this->indexInstance->readIndexHeader() - CALLED!');
                $this->getIndexInstance()->readIndexHeader();
 
                // Trace message
@@ -208,7 +210,7 @@ class IndexFile extends BaseBinaryFile implements IndexableFile {
                /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('INDEX-FILE: stackName=%s,value[]=%s - CALLED!', $stackName, gettype($value)));
                if (empty($stackName)) {
                        // Throw IAE
-                       throw new InvalidArgumentException('Parameter "stackName" is empty');
+                       throw new InvalidArgumentException('Parameter "stackName" is empty', FrameworkInterface::EXCEPTION_INVALID_ARGUMENT);
                } elseif (is_object($value) || is_resource($value)) {
                        // Not wanted here
                        throw new InvalidArgumentException(sprintf('value[]=%s is not stackable in files', gettype($value)));
@@ -218,10 +220,11 @@ class IndexFile extends BaseBinaryFile implements IndexableFile {
                }
 
                // Encode/convert the value into a "binary format"
+               /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('INDEX-FILE: Invoking StringUtils::encodeData(value[]=%s) ...', gettype($value)));
                $encoded = StringUtils::encodeData($value);
 
                // Get a strong hash for the "encoded" data
-               /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('INDEX-FILE: encoded=%s', $encoded));
+               /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('INDEX-FILE: encoded(%d)=%s', strlen($encoded), $encoded));
                $hash = CryptoUtils::hash($encoded);
 
                // Then write it to the next free gap
@@ -244,7 +247,7 @@ class IndexFile extends BaseBinaryFile implements IndexableFile {
         */
        public function writeDataToFreeGap (string $stackName, string $hash, string $encoded) {
                self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('INDEX-FILE: stackName=' . $stackName . ',hash=' . $hash . ',encoded()=' . strlen($encoded));
-               throw new UnsupportedOperationException([$this, __FUNCTION__], self::EXCEPTION_UNSPPORTED_OPERATION);
+               throw new UnsupportedOperationException([$this, __FUNCTION__], FrameworkInterface::EXCEPTION_UNSPPORTED_OPERATION);
        }
 
 }