Continued:
authorRoland Häder <roland@mxchange.org>
Wed, 9 Dec 2020 05:40:21 +0000 (06:40 +0100)
committerRoland Häder <roland@mxchange.org>
Wed, 9 Dec 2020 05:40:21 +0000 (06:40 +0100)
- interface Block was abused for file classes (index file/file-based stack) and
  is now free of it
- BinaryFile replaces it and other inheriting interfaces are cleared (moved
  methods to BinaryFile)

Signed-off-by: Roland Häder <roland@mxchange.org>
52 files changed:
framework/main/classes/actions/class_
framework/main/classes/container/class_
framework/main/classes/controller/html/class_Html
framework/main/classes/discovery/class_
framework/main/classes/factories/index/class_FileStackIndexFactory.php
framework/main/classes/feature/class_
framework/main/classes/file_directories/binary/class_BaseBinaryFile.php
framework/main/classes/file_directories/binary/index/class_IndexFile.php
framework/main/classes/file_directories/binary/stack/class_StackFile.php
framework/main/classes/file_directories/class_BaseFileIo.php
framework/main/classes/file_directories/input/raw/class_FrameworkRawFileInputPointer.php
framework/main/classes/file_directories/input/text/class_FrameworkTextFileInputPointer.php
framework/main/classes/file_directories/io/class_FrameworkFileInputOutputPointer.php
framework/main/classes/file_directories/output/raw/class_FrameworkRawFileOutputPointer.php
framework/main/classes/file_directories/output/text/class_FrameworkTextFileOutputPointer.php
framework/main/classes/handler/class_
framework/main/classes/helper/captcha/class_
framework/main/classes/helper/html/class_
framework/main/classes/index/class_
framework/main/classes/index/class_BaseIndex.php
framework/main/classes/index/file_stack/class_FileStackIndex.php
framework/main/classes/iterator/class_
framework/main/classes/iterator/file/class_FileIterator.php
framework/main/classes/mailer/class_
framework/main/classes/output/class_
framework/main/classes/registry/class_
framework/main/classes/request/class_
framework/main/classes/stacker/class_
framework/main/classes/stacker/file/class_BaseFileStack.php
framework/main/classes/streams/class_
framework/main/classes/streams/input/class_
framework/main/classes/streams/output/class_
framework/main/classes/tasks/class_
framework/main/classes/template/class_
framework/main/classes/visitor/class_
framework/main/exceptions/file_directory/class_FileReadProtectedException.php
framework/main/exceptions/file_directory/class_FileWriteProtectedException.php
framework/main/exceptions/stacker/class_InvalidMagicException.php
framework/main/interfaces/block/class_Block.php
framework/main/interfaces/class_
framework/main/interfaces/filesystem/binary/class_BinaryFile.php [new file with mode: 0644]
framework/main/interfaces/filesystem/class_Filesystem.php
framework/main/interfaces/filesystem/index/class_IndexableFile.php [new file with mode: 0644]
framework/main/interfaces/filesystem/stack/class_FileStacker.php [new file with mode: 0644]
framework/main/interfaces/index/class_Indexable
framework/main/interfaces/index/stack/class_IndexableStack.php
framework/main/interfaces/stacker/class_Stackable.php
framework/main/interfaces/stacker/file/class_StackableFile.php
framework/main/tests/filter/tests/class_Tests
framework/main/tests/filter/tests/configuration/class_TestConfiguration
framework/main/traits/file/class_BinaryFileTrait.php [new file with mode: 0644]
framework/main/traits/index/stack/class_IndexableStackTrait.php [new file with mode: 0644]

index d4f9866f8dee4837fcebd266859336d1d4d7c88b..9a53fd965b586792924243c304d111fa9c29d7ce 100644 (file)
@@ -1,6 +1,6 @@
 <?php
 // Own namespace
-namespace CoreFramework\Action\!!!;
+namespace Org\Mxchange\CoreFramework\Action\!!!;
 
 // Import framework stuff
 use Org\Mxchange\CoreFramework\Action\BaseAction;
index 0d2c61c85a3f568855f0dd3e1740b58828cd66d4..3e25fa6068dfa29f9c071ce3e5860a2375866f75 100644 (file)
@@ -1,6 +1,6 @@
 <?php
 // Own namespace
-namespace CoreFramework\Container\;
+namespace Org\Mxchange\CoreFramework\Container\;
 
 // Import framework stuff
 use Org\Mxchange\CoreFramework\Container\BaseContainer;
index 13827b7b3dfbbc2016f826865cd923e8818a8b4b..0cc9d67ea78aa987b279da9c626376a1dc1228f7 100644 (file)
@@ -1,6 +1,6 @@
 <?php
 // Own namespace
-namespace CoreFramework\Controller\!!!;
+namespace Org\Mxchange\CoreFramework\Controller\!!!;
 
 // Import framework stuff
 use Org\Mxchange\CoreFramework\Controller\BaseController;
index 3a14cd910de4d34e7ee33018efa26578c90b2bc5..f8d90b094db05adca76764af9d79590c053a0b2a 100644 (file)
@@ -1,6 +1,6 @@
 <?php
 // Own namespace
-namespace CoreFramework\Disovery\;
+namespace Org\Mxchange\CoreFramework\Disovery\;
 
 // Import framework stuff
 use Org\Mxchange\CoreFramework\Helper\Template\HelpableTemplate;
index f2945d5548a3934ede6375862b8698ad44652679..9e11ddccbce7e5c0834f48e7d3ec8c57355abba5 100644 (file)
@@ -47,11 +47,11 @@ class FileStackIndexFactory extends BaseFactory {
        /**
         * Returns a singleton (registry-based) StackableFile instance
         *
-        * @param       $infoInstance   An instance of a SplFileInfo class
+        * @param       $fileInfoInstance       An instance of a SplFileInfo class
         * @return      $indexInstance  An instance of a IndexableStack class
         * @throws      InvalidArgumentException        If a parameter is invalid
         */
-       public static final function createFileStackIndexInstance (SplFileInfo $infoInstance, string $type) {
+       public static final function createFileStackIndexInstance (SplFileInfo $fileInfoInstance, string $type) {
                // If there is no handler?
                if (empty($type)) {
                        // Throw IAE
@@ -61,7 +61,7 @@ class FileStackIndexFactory extends BaseFactory {
                        $indexInstance = GenericRegistry::getRegistry()->getInstance($type . '_index');
                } else {
                        // Get the handler instance
-                       $indexInstance = ObjectFactory::createObjectByConfiguredName($type . '_file_stack_index_class', array($infoInstance));
+                       $indexInstance = ObjectFactory::createObjectByConfiguredName($type . '_file_stack_index_class', [$fileInfoInstance]);
 
                        // Add it to the registry
                        GenericRegistry::getRegistry()->addInstance($type . '_index', $indexInstance);
index 49f5f862d7a0783bde34e8dda0889a743987d087..febb25f81c56351099688a6cae4f06cda9050303 100644 (file)
@@ -1,6 +1,6 @@
 <?php
 // Own namespace
-namespace CoreFramework\Feature\!!!;
+namespace Org\Mxchange\CoreFramework\Feature\!!!;
 
 // Import framework stuff
 use Org\Mxchange\CoreFramework\Feature\BaseFeature;
index 35beea36dcb71f80d222b8f2d8558dd4735e679c..440c7f86329c3924c4b92b64bf4ab5430f93d90f 100644 (file)
@@ -8,10 +8,15 @@ use Org\Mxchange\CoreFramework\Factory\Object\ObjectFactory;
 use Org\Mxchange\CoreFramework\Filesystem\Block;
 use Org\Mxchange\CoreFramework\Filesystem\Block\CalculatableBlock;
 use Org\Mxchange\CoreFramework\Filesystem\File\BaseAbstractFile;
+use Org\Mxchange\CoreFramework\Stack\File\StackableFile;
+use Org\Mxchange\CoreFramework\Index\Stack\IndexableStack;
+use Org\Mxchange\CoreFramework\Traits\Index\Stack\IndexableStackTrait;
+use Org\Mxchange\CoreFramework\Traits\Stack\StackableTrait;
 
 // Import SPL stuff
 use \BadMethodCallException;
 use \InvalidArgumentException;
+use \LogicException;
 use \SplFileInfo;
 use \UnexpectedValueException;
 
@@ -37,7 +42,11 @@ use \UnexpectedValueException;
  * You should have received a copy of the GNU General Public License
  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
  */
-abstract class BaseBinaryFile extends BaseAbstractFile {
+abstract class BaseBinaryFile extends BaseAbstractFile implements BinaryFile {
+       // Load traits
+       use StackableTrait;
+       use IndexableStackTrait;
+
        /**
         * Separator for header data
         */
@@ -135,11 +144,6 @@ abstract class BaseBinaryFile extends BaseAbstractFile {
         */
        private $currentBlock = '';
 
-       /**
-        * An instance of a Block class
-        */
-       private $blockInstance = NULL;
-
        /**
         * Protected constructor
         *
@@ -154,25 +158,6 @@ abstract class BaseBinaryFile extends BaseAbstractFile {
                $this->initCountersGapsArray();
        }
 
-       /**
-        * Setter for Block instance
-        *
-        * @param       $blockInstance  An instance of an Block class
-        * @return      void
-        */
-       protected final function setBlockInstance (Block $blockInstance) {
-               $this->blockInstance = $blockInstance;
-       }
-
-       /**
-        * Getter for Block instance
-        *
-        * @return      $blockInstance  An instance of an Block class
-        */
-       public final function getBlockInstance () {
-               return $this->blockInstance;
-       }
-
        /**
         * Setter for backBuffer field
         *
@@ -695,7 +680,7 @@ abstract class BaseBinaryFile extends BaseAbstractFile {
                self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('BASE-BINARY-FILE: Pre-allocating file ...');
 
                // Calculate minimum length for one entry and get file size
-               $minimumBlockLength = $this->getBlockInstance()->calculateMinimumBlockLength();
+               $minimumBlockLength = $this->getIndexableStackInstance()->calculateMinimumBlockLength();
                $fileSize = $this->getFileSize();
 
                // Calulcate seek position
@@ -902,7 +887,7 @@ abstract class BaseBinaryFile extends BaseAbstractFile {
 
                // First calculate minimum block length
                //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('BASE-BINARY-FILE: this->seekPosition=%d', $this->determineSeekPosition()));
-               $length = $this->getBlockInstance()->calculateMinimumBlockLength();
+               $length = $this->getIndexableStackInstance()->calculateMinimumBlockLength();
                //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('BASE-BINARY-FILE: length=%d', $length));
 
                // Read possibly back-buffered bytes from previous call of next().
@@ -980,7 +965,7 @@ abstract class BaseBinaryFile extends BaseAbstractFile {
        public function isValid () {
                // First calculate minimum block length
                //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('BASE-BINARY-FILE: CALLED!');
-               $length = $this->getBlockInstance()->calculateMinimumBlockLength();
+               $length = $this->getIndexableStackInstance()->calculateMinimumBlockLength();
 
                // Short be more than zero!
                //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('BASE-BINARY-FILE: length=%d', $length));
@@ -1023,11 +1008,23 @@ abstract class BaseBinaryFile extends BaseAbstractFile {
         * Reads the file header
         *
         * @return      void
+        * @throws      LogicException  If both instances are not set
         */
        public function readFileHeader () {
-               // Call block instance
+               // Is index set or stack?
                /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('BASE-BINARY-FILE: CALLED!');
-               $this->getBlockInstance()->readFileHeader();
+               if ($this->getIndexableStackInstance() instanceof IndexableStack) {
+                       // Call index instance
+                       /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('BASE-BINARY-FILE: Calling this->indexableStackInstance->readFileHeader() ...');
+                       $this->getIndexableStackInstance()->readFileHeader();
+               } elseif ($this->getStackInstance() instanceof StackableFile) {
+                       // Call stacke instance
+                       /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('BASE-BINARY-FILE: Calling this->stackInstance->readFileHeader() ...');
+                       $this->getStackInstance()->readFileHeader();
+               } else {
+                       // Bad logic?
+                       throw new LogicException('Wether indexableStackInstance nor stackableFileInstance are set');
+               }
 
                // Trace message
                /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('BASE-BINARY-FILE: EXIT!');
@@ -1041,7 +1038,7 @@ abstract class BaseBinaryFile extends BaseAbstractFile {
        public function flushFileHeader () {
                // Call block instance
                /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('BASE-BINARY-FILE: CALLED!');
-               $this->getBlockInstance()->flushFileHeader();
+               $this->getIndexableStackInstance()->flushFileHeader();
 
                // Trace message
                /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('BASE-BINARY-FILE: EXIT!');
index c485275fa1e2b7d416280d781dd85668f69d046a..010927136fd069a19bc37b933c2b75278462cc7f 100644 (file)
@@ -3,9 +3,10 @@
 namespace Org\Mxchange\CoreFramework\Filesystem\Index;
 
 // Import framework stuff
-use Org\Mxchange\CoreFramework\Filesystem\Block;
 use Org\Mxchange\CoreFramework\Filesystem\File\BaseBinaryFile;
+use Org\Mxchange\CoreFramework\Filesystem\Index\IndexableFile;
 use Org\Mxchange\CoreFramework\Generic\UnsupportedOperationException;
+use Org\Mxchange\CoreFramework\Index\Stack\IndexableStack;
 
 // Import SPL stuff
 use \SplFileInfo;
@@ -32,7 +33,7 @@ use \SplFileInfo;
  * You should have received a copy of the GNU General Public License
  * along with this program. If not, see <http://www.gnu.org/licenses/>.
  */
-class IndexFile extends BaseBinaryFile implements Block {
+class IndexFile extends BaseBinaryFile implements IndexableFile {
        /**
         * Protected constructor
         *
@@ -47,26 +48,26 @@ class IndexFile extends BaseBinaryFile implements Block {
         * Creates an instance of this File class and prepares it for usage
         *
         * @param       $fileInfoInstance       An instance of a SplFileInfo class
-        * @param       $blockInstance  An instance of a Block class
-        * @return      $fileInstance   An instance of this File class
+        * @param       $indexInstance  An instance of a IndexableStack class
+        * @return      $indexFileInstance      An instance of an IndexableFile class
         */
-       public final static function createIndexFile (SplFileInfo $fileInfoInstance, Block $blockInstance) {
+       public final static function createIndexFile (SplFileInfo $fileInfoInstance, IndexableStack $indexInstance) {
                // Get a new instance
-               /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('INDEX-FILE: fileInfoInstance[%s]=%s,blockInstance=%s - CALLED!', get_class($fileInfoInstance), $fileInfoInstance, $blockInstance->__toString()));
-               $fileInstance = new IndexFile();
+               /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('INDEX-FILE: fileInfoInstance[%s]=%s,indexInstance=%s - CALLED!', get_class($fileInfoInstance), $fileInfoInstance, $indexInstance->__toString()));
+               $indexFileInstance = new IndexFile();
 
-               // Set block instance here for callbacks
-               $fileInstance->setBlockInstance($blockInstance);
+               // Set file instance here for callbacks
+               $indexFileInstance->setIndexableStackInstance($indexInstance);
 
                // Expand file name with .idx
                $indexInfoInstance = new SplFileInfo(sprintf('%s.idx', $fileInfoInstance->__toString()));
 
                // Init this abstract file
-               $fileInstance->initFile($indexInfoInstance);
+               $indexFileInstance->initFile($indexInfoInstance);
 
                // Return the prepared instance
-               /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('INDEX-FILE: fileInstance=%s - EXIT!', $fileInstance->__toString()));
-               return $fileInstance;
+               /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('INDEX-FILE: indexFileInstance=%s - EXIT!', $indexFileInstance->__toString()));
+               return $indexFileInstance;
        }
 
        /**
index 86c800a2e3ac4ce8071d798563938508f10f1088..2cd5dde0c62edad2e84be1cb2a7393893b9728f4 100644 (file)
@@ -3,12 +3,14 @@
 namespace Org\Mxchange\CoreFramework\Stack\File;
 
 // Import framework stuff
-use Org\Mxchange\CoreFramework\Filesystem\Block;
+use Org\Mxchange\CoreFramework\Filesystem\Stack\FileStacker;
 use Org\Mxchange\CoreFramework\Filesystem\File\BaseBinaryFile;
 use Org\Mxchange\CoreFramework\Generic\UnsupportedOperationException;
+use Org\Mxchange\CoreFramework\Stack\File\StackableFile;
 use Org\Mxchange\CoreFramework\Utils\String\StringUtils;
 
 // Import SPL stuff
+use \InvalidArgumentException;
 use \SplFileInfo;
 
 /**
@@ -33,7 +35,7 @@ use \SplFileInfo;
  * You should have received a copy of the GNU General Public License
  * along with this program. If not, see <http://www.gnu.org/licenses/>.
  */
-class StackFile extends BaseBinaryFile implements Block {
+class StackFile extends BaseBinaryFile implements FileStacker {
        /**
         * Protected constructor
         *
@@ -48,20 +50,22 @@ class StackFile extends BaseBinaryFile implements Block {
         * Creates an instance of this File class and prepares it for usage
         *
         * @param       $infoInstance   An instance of a SplFileInfo class
-        * @param       $blockInstance  An instance of a Block class
+        * @param       $stackInstance  An instance of a StackableFile class
         * @return      $fileInstance   An instance of this File class
         */
-       public final static function createStackFile (SplFileInfo $infoInstance, Block $blockInstance) {
+       public final static function createStackFile (SplFileInfo $infoInstance, StackableFile $stackInstance) {
                // Get a new instance
+               /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('STACK-FILE: infoInstance[%s]=%s,stackInstance=%s - CALLED!', get_class($infoInstance), $infoInstance, $stackInstance->__toString()));
                $fileInstance = new StackFile();
 
-               // Set block instance here for callbacks
-               $fileInstance->setBlockInstance($blockInstance);
+               // Set stack instance here for callbacks
+               $fileInstance->setStackInstance($stackInstance);
 
                // Init this abstract file
                $fileInstance->initFile($infoInstance);
 
                // Return the prepared instance
+               /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('STACK-FILE: fileInstance=%s - EXIT!', $fileInstance->__toString()));
                return $fileInstance;
        }
 
@@ -71,11 +75,18 @@ class StackFile extends BaseBinaryFile implements Block {
         * @param       $groupId        Group identifier
         * @param       $value          Value to be added to the stack
         * @return      $data           Hash and gap position
+        * @throws      InvalidArgumentException        If a parameter is not valid
         */
-       public function writeValueToFile ($groupId, $value) {
-               // Make sure no objects/resources are added as the serialization may fail
-               assert(!is_object($value));
-               assert(!is_resource($value));
+       public function writeValueToFile (string $groupId, $value) {
+               // Validate parameter
+               /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('STACK-FILE: groupId=%s,value[]=%s - CALLED!', $groupId, gettype($value)));
+               if (empty($groupId)) {
+                       // Throw IAE
+                       throw new InvalidArgumentException('Parameter "groupId" is empty');
+               } elseif (is_object($value) || is_resource($value)) {
+                       // Not wanted here
+                       throw new InvalidArgumentException(sprintf('value[]=%s is not stackable in files', gettype($value)));
+               }
 
                // Encode/convert the value into a "binary format"
                $encoded = StringUtils::encodeData($value);
@@ -84,7 +95,7 @@ class StackFile extends BaseBinaryFile implements Block {
                $hash = self::hash($encoded);
 
                // Then write it to the next free gap
-               $data = $this->getBlockInstance()->writeDataToFreeGap($groupId, $hash, $encoded);
+               $data = $this->getStackInstance()->writeDataToFreeGap($groupId, $hash, $encoded);
 
                // Return info
                return $data;
index 32df15b58a30dc1072143b515a4f98da5b4569c0..c1c716629456066604165c140c144e66757b9547 100644 (file)
@@ -1,6 +1,6 @@
 <?php
 // Own namespace
-namespace Org\Mxchange\CoreFramework\FileSystem;
+namespace Org\Mxchange\CoreFramework\Filesystem;
 
 // Import framework stuff
 use Org\Mxchange\CoreFramework\Filesystem\CloseableFile;
index 7ac1dc1308aac352a3a491d2f15e4f0b1f54ad9a..a064162a36f6e388f43e755aac244615feb19466 100644 (file)
@@ -4,9 +4,9 @@ namespace Org\Mxchange\CoreFramework\Filesystem\Pointer\Input;
 
 // Import framework stuff
 use Org\Mxchange\CoreFramework\Bootstrap\FrameworkBootstrap;
-use Org\Mxchange\CoreFramework\FileSystem\BaseFileIo;
+use Org\Mxchange\CoreFramework\Filesystem\BaseFileIo;
 use Org\Mxchange\CoreFramework\Filesystem\FileNotFoundException;
-use Org\Mxchange\CoreFramework\FileSystem\FileReadProtectedException;
+use Org\Mxchange\CoreFramework\Filesystem\FileReadProtectedException;
 use Org\Mxchange\CoreFramework\Filesystem\Pointer\InputPointer;
 use Org\Mxchange\CoreFramework\Generic\NullPointerException;
 use Org\Mxchange\CoreFramework\Generic\UnsupportedOperationException;
index 3fc1fc93ea631439d87eddfbfcc4867dd8a4686c..eef4a749e0ce16e1e6f2144f26f0cfbcb5de9858 100644 (file)
@@ -4,9 +4,9 @@ namespace Org\Mxchange\CoreFramework\Filesystem\Pointer\Input;
 
 // Import framework stuff
 use Org\Mxchange\CoreFramework\Bootstrap\FrameworkBootstrap;
-use Org\Mxchange\CoreFramework\FileSystem\BaseFileIo;
+use Org\Mxchange\CoreFramework\Filesystem\BaseFileIo;
 use Org\Mxchange\CoreFramework\Filesystem\FileNotFoundException;
-use Org\Mxchange\CoreFramework\FileSystem\FileReadProtectedException;
+use Org\Mxchange\CoreFramework\Filesystem\FileReadProtectedException;
 use Org\Mxchange\CoreFramework\Filesystem\Pointer\InputPointer;
 use Org\Mxchange\CoreFramework\Generic\NullPointerException;
 use Org\Mxchange\CoreFramework\Generic\UnsupportedOperationException;
index 3fa010894761998a4c33f0b1823043108c507a87..ff58e65e4eb02955d9e4e3476e00c7811522f0c6 100644 (file)
@@ -4,9 +4,9 @@ namespace Org\Mxchange\CoreFramework\Filesystem\Pointer;
 
 // Import framework stuff
 use Org\Mxchange\CoreFramework\Bootstrap\FrameworkBootstrap;
-use Org\Mxchange\CoreFramework\FileSystem\BaseFileIo;
-use Org\Mxchange\CoreFramework\FileSystem\FileReadProtectedException;
-use Org\Mxchange\CoreFramework\FileSystem\FileWriteProtectedException;
+use Org\Mxchange\CoreFramework\Filesystem\BaseFileIo;
+use Org\Mxchange\CoreFramework\Filesystem\FileReadProtectedException;
+use Org\Mxchange\CoreFramework\Filesystem\FileWriteProtectedException;
 use Org\Mxchange\CoreFramework\Filesystem\PathWriteProtectedException;
 use Org\Mxchange\CoreFramework\Generic\NullPointerException;
 use Org\Mxchange\CoreFramework\Generic\UnsupportedOperationException;
index 9cb509aa39f64f60ab4cee4a8082d487ed76a014..a081f64e21fa1c8f959bc193a89adc4e8949348c 100644 (file)
@@ -3,7 +3,7 @@
 namespace Org\Mxchange\CoreFramework\Filesystem\Pointer\Output;
 
 // Import framework stuff
-use Org\Mxchange\CoreFramework\FileSystem\BaseFileIo;
+use Org\Mxchange\CoreFramework\Filesystem\BaseFileIo;
 use Org\Mxchange\CoreFramework\Filesystem\Pointer\OutputPointer;
 use Org\Mxchange\CoreFramework\Generic\NullPointerException;
 
index 2d5dbe256d31cbc6db26ac36b2baad93df57b7b1..51e0938c64cc5ba29adaa975828c9b6639741847 100644 (file)
@@ -3,7 +3,7 @@
 namespace Org\Mxchange\CoreFramework\Filesystem\Pointer\Text;
 
 // Import framework stuff
-use Org\Mxchange\CoreFramework\FileSystem\BaseFileIo;
+use Org\Mxchange\CoreFramework\Filesystem\BaseFileIo;
 use Org\Mxchange\CoreFramework\Filesystem\Pointer\OutputPointer;
 use Org\Mxchange\CoreFramework\Generic\NullPointerException;
 use Org\Mxchange\CoreFramework\Generic\UnsupportedOperationException;
index 980a9c461db28948f4ec58c487d2bef0b6d5fdea..23e92ec62bffbe92b108cb9f7229e56a6d640df1 100644 (file)
@@ -1,6 +1,6 @@
 <?php
 // Own namespace
-namespace CoreFramework\Handler\;
+namespace Org\Mxchange\CoreFramework\Handler\;
 
 // Import framework stuff
 use Org\Mxchange\CoreFramework\Handler\BaseHandler;
index 7b6e0d9ca3be4fd4816c31432745d18136ee140a..a169d9502df7faf047c1038d01d0d61481caa58f 100644 (file)
@@ -1,6 +1,6 @@
 <?php
 // Own namespace
-namespace CoreFramework\Captcha\;
+namespace Org\Mxchange\CoreFramework\Captcha\;
 
 // Import framework stuff
 use Org\Mxchange\CoreFramework\Generic\FrameworkInterface;
index 3f68614bd1827640b5a0f6ef899f2809ae8c6b2d..5163204f6eec9ac0d173dc177af1ae475c6b79be 100644 (file)
@@ -1,6 +1,6 @@
 <?php
 // Own namespace
-namespace CoreFramework\Helper\;
+namespace Org\Mxchange\CoreFramework\Helper\;
 
 // Import framework stuff
 use Org\Mxchange\CoreFramework\Helper\Template\HelpableTemplate;
index a130144f05101e6c6a8878e7d8c2a4394b88eaf2..f4713de8b7bde149854eb27c0d1216a46bd63f2d 100644 (file)
@@ -1,11 +1,14 @@
 <?php
 // Own namespace
-namespace CoreFramework\Index\!!!;
+namespace Org\Mxchange\CoreFramework\Index\!!!;
 
 // Import framework stuff
 use Org\Mxchange\CoreFramework\Index\BaseIndex;
 use Org\Mxchange\CoreFramework\Index\Indexable;
 
+// Import SPL stuff
+use \SplFileInfo;
+
 /**
  * A ??? index class
  *
@@ -45,12 +48,12 @@ class ???Index extends BaseIndex implements Indexable, Registerable {
         * @param       $fileName               Name of the file stack to create an index file for
         * @return      $indexInstance  An instance of this Index class
         */
-       public final static function create???Index ($fileName) {
+       public final static function create???Index (SplFileInfo $fileInfoInstance) {
                // Get a new instance
                $indexInstance = new ???Index();
 
                // Initialize index
-               $indexInstance->initIndex($fileName);
+               $indexInstance->initIndex($fileInfoInstance);
 
                // Return the prepared instance
                return $indexInstance;
index 79e1c054e33edd5c12cd72fd4403eda5f629a84c..5e56d1dc1c7222add6bd3e6a6a486cb591d80046 100644 (file)
@@ -37,7 +37,7 @@ use \UnexpectedValueException;
  * You should have received a copy of the GNU General Public License
  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
  */
-abstract class BaseIndex extends BaseFrameworkSystem {
+abstract class BaseIndex extends BaseFrameworkSystem implements Indexable {
        // Load traits
        use IteratorTrait;
 
@@ -174,7 +174,7 @@ abstract class BaseIndex extends BaseFrameworkSystem {
                $fileInstance = ObjectFactory::createObjectByConfiguredName('index_file_class', array($fileInfoInstance, $this));
 
                // Get iterator instance
-               $iteratorInstance = ObjectFactory::createObjectByConfiguredName('file_iterator_class', array($fileInstance));
+               $iteratorInstance = ObjectFactory::createObjectByConfiguredName('file_iterator_class', [$fileInstance]);
 
                // Set iterator here
                $this->setIteratorInstance($iteratorInstance);
@@ -219,7 +219,7 @@ abstract class BaseIndex extends BaseFrameworkSystem {
                // Freshly created?
                /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('BASE-INDEX: created=%d', intval($created)));
                if (!$created) {
-                       // Count all entries in file
+                       // Analyze file structure
                        /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('BASE-INDEX: Calling this->iteratorInstance->analyzeFileStructure() ...');
                        $this->getIteratorInstance()->analyzeFileStructure();
                }
index 0d1692463daa09ecf6b4abd484c82db45f389ea8..570cc8fd24fbaf40f7e31daf50fa98bcfbfcde9b 100644 (file)
@@ -7,7 +7,7 @@ use Org\Mxchange\CoreFramework\Index\BaseIndex;
 use Org\Mxchange\CoreFramework\Index\Indexable;
 use Org\Mxchange\CoreFramework\Registry\Registerable;
 use Org\Mxchange\CoreFramework\Stack\File\StackableFile;
-use Org\Mxchange\CoreFramework\Stack\Index\IndexableStack;
+use Org\Mxchange\CoreFramework\Index\Stack\IndexableStack;
 
 // Import SPL stuff
 use \InvalidArgumentException;
@@ -67,16 +67,35 @@ class FileStackIndex extends BaseIndex implements IndexableStack, Registerable {
        }
 
        /**
-        * Adds given hash to an index file
+        * Adds given data's hash to an index file
         *
         * @param       $groupId        Name of stack to add hash for
         * @param       $data           Hash and gap position to be added to the index
         * @return      void
+        * @throws      InvalidArgumentException        If a parameter is not valid
         * @throws      UnexpectedValueException        If an invalid gap position is being returned
         */
-       public function addHashToIndex (string $groupId, array $data) {
+       public function addHashedDataToIndex (string $groupId, array $data) {
+               // Validate parameter
+               /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('FILE-STACK-INDEX: groupId=%s,data()=%d - CALLED!', $groupId, count($data)));
+               if (empty($groupId)) {
+                       // Throw IAE
+                       throw new InvalidArgumentException('Parameter "groupId" is empty');
+               } elseif (count($data) == 0) {
+                       // Throw it again
+                       throw new InvalidArgumentException('Parameter "data" is an empty array');
+               } elseif (!isset($data[StackableFile::ARRAY_NAME_HASH])) {
+                       // Important array element missing
+                       throw new InvalidArgumentException(sprintf('data[%s] not found', $data[StackableFile::ARRAY_NAME_HASH]));
+               } elseif (!isset($data[StackableFile::ARRAY_NAME_GAP_POSITION])) {
+                       // Important array element missing
+                       throw new InvalidArgumentException(sprintf('data[%s] not found', $data[StackableFile::ARRAY_NAME_GAP_POSITION]));
+               } elseif (!isset($data[StackableFile::ARRAY_NAME_DATA_LENGTH])) {
+                       // Important array element missing
+                       throw new InvalidArgumentException(sprintf('data[%s] not found', $data[StackableFile::ARRAY_NAME_DATA_LENGTH]));
+               }
+
                // Raw data been written to the file
-               /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('FILE-STACK-INDEX: groupId=%s,hash=%s,gap=%d,length=%d - CALLED!', $groupId, $data[StackableFile::ARRAY_NAME_HASH], $data[StackableFile::ARRAY_NAME_GAP_POSITION], $data[StackableFile::ARRAY_NAME_DATA_LENGTH]));
                $rawData = sprintf('%s%s%s%s%s%s%s',
                        $groupId,
                        Indexable::SEPARATOR_GROUP_HASH,
@@ -122,6 +141,9 @@ class FileStackIndex extends BaseIndex implements IndexableStack, Registerable {
                        // Throw IAE
                        throw new InvalidArgumentException(sprintf('length=%d is not valid', $length));
                }
+
+               // Partial stub!
+               $this->partialStub('length=' . $length);
        }
 
        /**
@@ -152,4 +174,15 @@ class FileStackIndex extends BaseIndex implements IndexableStack, Registerable {
                return $status;
        }
 
+       /**
+        * Checks if this index file has been fully and properly loaded.
+        *
+        * @return      $isLoaded       Whether this index file has been loaded
+        */
+       public function isIndexFileLoaded () {
+               // Trace message
+               /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('FILE-STACK-INDEX: CALLED!');
+               /* DEBUG-DIE: */ die(sprintf('[%s:%d]: this=%s', __METHOD__, __LINE__, print_r($this, true)));
+       }
+
 }
index d15b26e9a5c93676807542c082647ca622e4248f..1c99c2d71695c1f10bb640585875bda762cc3c89 100644 (file)
@@ -1,6 +1,6 @@
 <?php
 // Own namespace
-namespace CoreFramework\Iterator\!!!;
+namespace Org\Mxchange\CoreFramework\Iterator\!!!;
 
 // Import framework stuff
 use Org\Mxchange\CoreFramework\Iterator\BaseIterator;
index 2442fb55fa1093a68102df2dd11a2bd8b3fcd90f..0163ffed79afa326e269fa4a0fa3d4dc65575f1d 100644 (file)
@@ -3,9 +3,10 @@
 namespace Org\Mxchange\CoreFramework\Iterator\File;
 
 // Import framework stuff
-use Org\Mxchange\CoreFramework\Filesystem\Block;
+use Org\Mxchange\CoreFramework\Filesystem\File\BinaryFile;
 use Org\Mxchange\CoreFramework\Iterator\BaseIterator;
 use Org\Mxchange\CoreFramework\Iterator\Filesystem\SeekableWritableFileIterator;
+use Org\Mxchange\CoreFramework\Traits\File\BinaryFileTrait;
 
 // Import SPL stuff
 use \BadMethodCallException;
@@ -34,10 +35,8 @@ use \InvalidArgumentException;
  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
  */
 class FileIterator extends BaseIterator implements SeekableWritableFileIterator {
-       /**
-        * An instance of a Block class
-        */
-       private $blockInstance = NULL;
+       // Load traits
+       use BinaryFileTrait;
 
        /**
         * Protected constructor
@@ -52,41 +51,22 @@ class FileIterator extends BaseIterator implements SeekableWritableFileIterator
        /**
         * Creates an instance of this class
         *
-        * @param       $blockInstance  An instance of a Block class
+        * @param       $binaryFileInstance     An instance of a BinaryFile class
         * @return      $iteratorInstance       An instance of a Iterator class
         */
-       public final static function createFileIterator (Block $blockInstance) {
+       public final static function createFileIterator (BinaryFile $binaryFileInstance) {
                // Get new instance
-               //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('FILE-ITERATOR: blockInstance=%s - CALLED!', $blockInstance->__toString()));
+               //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('FILE-ITERATOR: binaryFileInstance=%s - CALLED!', $binaryFileInstance->__toString()));
                $iteratorInstance = new FileIterator();
 
                // Set the instance here
-               $iteratorInstance->setBlockInstance($blockInstance);
+               $iteratorInstance->setBinaryFileInstance($binaryFileInstance);
 
                // Return the prepared instance
                //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('FILE-ITERATOR: iteratorInstance=%s - EXIT!', $iteratorInstance->__toString()));
                return $iteratorInstance;
        }
 
-       /**
-        * Setter for Block instance
-        *
-        * @param       $blockInstance  An instance of an Block class
-        * @return      void
-        */
-       protected final function setBlockInstance (Block $blockInstance) {
-               $this->blockInstance = $blockInstance;
-       }
-
-       /**
-        * Getter for Block instance
-        *
-        * @return      $blockInstance  An instance of an Block class
-        */
-       public final function getBlockInstance () {
-               return $this->blockInstance;
-       }
-
        /**
         * Gets currently read data
         *
@@ -101,8 +81,8 @@ class FileIterator extends BaseIterator implements SeekableWritableFileIterator
                        throw new BadMethodCallException('Current key cannot be valid, forgot to invoke valid()?');
                }
 
-               // Call block instance
-               $current = $this->getBlockInstance()->current();
+               // Call file instance
+               $current = $this->getBinaryFileInstance()->current();
 
                // Return it
                //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('FILE-ITERATOR: current[]=%s - EXIT!', gettype($current)));
@@ -123,8 +103,8 @@ class FileIterator extends BaseIterator implements SeekableWritableFileIterator
                        throw new BadMethodCallException('Current key cannot be valid, forgot to invoke valid()?');
                }
 
-               // Get key from block instance
-               $key = $this->getBlockInstance()->determineSeekPosition();
+               // Get key from file instance
+               $key = $this->getBinaryFileInstance()->determineSeekPosition();
 
                // Return key
                //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('FILE-ITERATOR: key[%s]=%s - EXIT!', gettype($key), $key));
@@ -132,14 +112,14 @@ class FileIterator extends BaseIterator implements SeekableWritableFileIterator
        }
 
        /**
-        * Advances to next "block" of bytes
+        * Advances to next "file" of bytes
         *
         * @return      void
         */
        public function next () {
-               // Call block instance
+               // Call file instance
                //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('FILE-ITERATOR: CALLED!');
-               $this->getBlockInstance()->next();
+               $this->getBinaryFileInstance()->next();
 
                // Trace message
                //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('FILE-ITERATOR: EXIT!');
@@ -151,9 +131,9 @@ class FileIterator extends BaseIterator implements SeekableWritableFileIterator
         * @return      $status         Status of this operation
         */
        public function rewind () {
-               // Call block instance
+               // Call file instance
                //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('FILE-ITERATOR: CALLED!');
-               $this->getBlockInstance()->rewind();
+               $this->getBinaryFileInstance()->rewind();
 
                // Trace message
                //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('FILE-ITERATOR: EXIT!');
@@ -166,9 +146,9 @@ class FileIterator extends BaseIterator implements SeekableWritableFileIterator
         * @return      $isValid        Whether the next entry is valid
         */
        public function valid () {
-               // Call block instance
+               // Call file instance
                //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('FILE-ITERATOR: CALLED!');
-               $isValid = $this->getBlockInstance()->valid();
+               $isValid = $this->getBinaryFileInstance()->valid();
 
                // Return flag
                //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('FILE-ITERATOR: isValid=%d - EXIT!', intval($isValid)));
@@ -191,8 +171,8 @@ class FileIterator extends BaseIterator implements SeekableWritableFileIterator
                        throw new InvalidArgumentException(sprintf('seekPosition=%d is not valid', $seekPosition));
                }
 
-               // Call block instance
-               $status = $this->getBlockInstance()->seek($seekPosition, $whence);
+               // Call file instance
+               $status = $this->getBinaryFileInstance()->seek($seekPosition, $whence);
 
                // Return status
                //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('FILE-ITERATOR: status=%d - EXIT!', intval($status)));
@@ -205,9 +185,9 @@ class FileIterator extends BaseIterator implements SeekableWritableFileIterator
         * @return      $size   Size (in bytes) of file
         */
        public function size () {
-               // Call the block object
+               // Call the file object
                //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('FILE-ITERATOR: CALLED!');
-               $size = $this->getBlockInstance()->size();
+               $size = $this->getBinaryFileInstance()->size();
 
                // Return size
                //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('FILE-ITERATOR: size=%d - EXIT!', $size));
@@ -228,8 +208,8 @@ class FileIterator extends BaseIterator implements SeekableWritableFileIterator
                        throw new InvalidArgumentException(sprintf('bytes=%d is not valid', $bytes));
                }
 
-               // Call block instance
-               $data = $this->getBlockInstance()->read($bytes);
+               // Call file instance
+               $data = $this->getBinaryFileInstance()->read($bytes);
 
                // Return data
                //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('FILE-ITERATOR: data[]=%s - EXIT!', gettype($data)));
@@ -244,9 +224,9 @@ class FileIterator extends BaseIterator implements SeekableWritableFileIterator
         * @return      void
         */
        public function analyzeFileStructure () {
-               // Just call the block instance
+               // Just call the file instance
                //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('FILE-ITERATOR: CALLED!');
-               $this->getBlockInstance()->analyzeFileStructure();
+               $this->getBinaryFileInstance()->analyzeFileStructure();
 
                // Trace message
                //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('FILE-ITERATOR: EXIT!');
@@ -258,9 +238,9 @@ class FileIterator extends BaseIterator implements SeekableWritableFileIterator
         * @return      $isInitialized  Whether the file header is initialized
         */
        public function isFileHeaderInitialized () {
-               // Just call the block instance
+               // Just call the file instance
                //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('FILE-ITERATOR: CALLED!');
-               $isInitialized = $this->getBlockInstance()->isFileHeaderInitialized();
+               $isInitialized = $this->getBinaryFileInstance()->isFileHeaderInitialized();
 
                // Return flag
                //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('FILE-ITERATOR: isInitialized=%d - EXIT!', intval($isInitialized)));
@@ -273,9 +253,9 @@ class FileIterator extends BaseIterator implements SeekableWritableFileIterator
         * @return      void
         */
        public function createFileHeader () {
-               // Just call the block instance
+               // Just call the file instance
                //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('FILE-ITERATOR: CALLED!');
-               $this->getBlockInstance()->createFileHeader();
+               $this->getBinaryFileInstance()->createFileHeader();
 
                // Trace message
                //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('FILE-ITERATOR: EXIT!');
@@ -296,8 +276,8 @@ class FileIterator extends BaseIterator implements SeekableWritableFileIterator
                        throw new InvalidArgumentException('Parameter "type" is empty');
                }
 
-               // Just call the block instance
-               $this->getBlockInstance()->preAllocateFile($type);
+               // Just call the file instance
+               $this->getBinaryFileInstance()->preAllocateFile($type);
 
                // Trace message
                //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('FILE-ITERATOR: EXIT!');
@@ -312,9 +292,9 @@ class FileIterator extends BaseIterator implements SeekableWritableFileIterator
         * @return      void
         */
        public function initCountersGapsArray () {
-               // Call block instance
+               // Call file instance
                //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('FILE-ITERATOR: CALLED!');
-               $this->getBlockInstance()->initCountersGapsArray();
+               $this->getBinaryFileInstance()->initCountersGapsArray();
 
                // Trace message
                //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('FILE-ITERATOR: EXIT!');
@@ -326,9 +306,9 @@ class FileIterator extends BaseIterator implements SeekableWritableFileIterator
         * @return      $totalEntries   Size of file header
         */
        public final function getHeaderSize () {
-               // Call block instance
+               // Call file instance
                //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('FILE-ITERATOR: CALLED!');
-               $size = $this->getBlockInstance()->getHeaderSize();
+               $size = $this->getBinaryFileInstance()->getHeaderSize();
 
                // Return size
                //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('FILE-ITERATOR: size=%d - EXIT!', $size));
@@ -342,9 +322,9 @@ class FileIterator extends BaseIterator implements SeekableWritableFileIterator
         * @return      void
         */
        public final function setHeaderSize (int $headerSize) {
-               // Call block instance
+               // Call file instance
                //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('FILE-ITERATOR: headerSize=%d - CALLED!', $headerSize));
-               $this->getBlockInstance()->setHeaderSize($headerSize);
+               $this->getBinaryFileInstance()->setHeaderSize($headerSize);
 
                // Trace message
                //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('FILE-ITERATOR: EXIT!');
@@ -356,9 +336,9 @@ class FileIterator extends BaseIterator implements SeekableWritableFileIterator
         * @return      $header         Header array
         */
        public final function getHeader () {
-               // Call block instance
+               // Call file instance
                //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('FILE-ITERATOR: CALLED!');
-               $header = $this->getBlockInstance()->getHeader();
+               $header = $this->getBinaryFileInstance()->getHeader();
 
                // Return it
                //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('FILE-ITERATOR: header()=%d - EXIT!', count($header)));
@@ -372,9 +352,9 @@ class FileIterator extends BaseIterator implements SeekableWritableFileIterator
         * @return      void
         */
        public final function setHeader (array $header) {
-               // Call block instance
+               // Call file instance
                //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('FILE-ITERATOR: header()=%d - CALLED!', count($header)));
-               $this->getBlockInstance()->setHeader($header);
+               $this->getBinaryFileInstance()->setHeader($header);
 
                // Trace message
                //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('FILE-ITERATOR: EXIT!');
@@ -386,9 +366,9 @@ class FileIterator extends BaseIterator implements SeekableWritableFileIterator
         * @return      void
         */
        public function updateSeekPosition () {
-               // Call block instance
+               // Call file instance
                //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('FILE-ITERATOR: CALLED!');
-               $this->getBlockInstance()->updateSeekPosition();
+               $this->getBinaryFileInstance()->updateSeekPosition();
 
                // Trace message
                //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('FILE-ITERATOR: EXIT!');
@@ -400,9 +380,9 @@ class FileIterator extends BaseIterator implements SeekableWritableFileIterator
         * @return      $totalEntries   Total entries in this file
         */
        public final function getCounter () {
-               // Call block instance
+               // Call file instance
                //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('FILE-ITERATOR: CALLED!');
-               $counter = $this->getBlockInstance()->getCounter();
+               $counter = $this->getBinaryFileInstance()->getCounter();
 
                // Return counter
                //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('FILE-ITERATOR: counter=%d - EXIT!', $counter));
@@ -415,9 +395,9 @@ class FileIterator extends BaseIterator implements SeekableWritableFileIterator
         * @return      $fileSize       Size of currently loaded file
         */
        public function getFileSize () {
-               // Call block instance
+               // Call file instance
                //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('FILE-ITERATOR: CALLED!');
-               $size = $this->getBlockInstance()->getFileSize();
+               $size = $this->getBinaryFileInstance()->getFileSize();
 
                // Return size
                //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('FILE-ITERATOR: size=%d - EXIT!', $size));
@@ -444,9 +424,9 @@ class FileIterator extends BaseIterator implements SeekableWritableFileIterator
                        throw new InvalidArgumentException('Parameter "data" is empty');
                }
 
-               // Call block instance
-               //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('FILE-ITERATOR: Calling this->blockInstance->writeData(%d,data()=%d,%d) ...', $seekPosition, strlen($data), intval($flushHeader)));
-               $this->getBlockInstance()->writeData($seekPosition, $data, $flushHeader);
+               // Call file instance
+               //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('FILE-ITERATOR: Calling this->binaryFileInstance->writeData(%d,data()=%d,%d) ...', $seekPosition, strlen($data), intval($flushHeader)));
+               $this->getBinaryFileInstance()->writeData($seekPosition, $data, $flushHeader);
 
                // Trace message
                //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('FILE-ITERATOR: EXIT!');
@@ -472,8 +452,8 @@ class FileIterator extends BaseIterator implements SeekableWritableFileIterator
                }
 
                // Call iterated object's method
-               //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('FILE-ITERATOR: Calling this->blockInstance->writeAtPosition(%d, %s) ...', $seekPosition, $dataStream));
-               $status = $this->getBlockInstance()->writeAtPosition($seekPosition, $dataStream);
+               //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('FILE-ITERATOR: Calling this->binaryFileInstance->writeAtPosition(%d, %s) ...', $seekPosition, $dataStream));
+               $status = $this->getBinaryFileInstance()->writeAtPosition($seekPosition, $dataStream);
 
                // Return status
                //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('FILE-ITERATOR: status[%s]=%d - EXIT!', gettype($status), $status));
@@ -486,9 +466,9 @@ class FileIterator extends BaseIterator implements SeekableWritableFileIterator
         * @return      $seekPosition   Current seek position (stored here in object)
         */
        public function getSeekPosition () {
-               // Call block instance
+               // Call file instance
                //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('FILE-ITERATOR: CALLED!');
-               $seekPosition = $this->getBlockInstance()->getSeekPosition();
+               $seekPosition = $this->getBinaryFileInstance()->getSeekPosition();
 
                // Return position
                //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('FILE-ITERATOR: seekPosition[%s]=%d - EXIT!', gettype($seekPosition), $seekPosition));
@@ -514,8 +494,8 @@ class FileIterator extends BaseIterator implements SeekableWritableFileIterator
                        throw new InvalidArgumentException(sprintf('value[]=%s is not supported by file-based indexes', gettype($value)));
                }
 
-               // Call block instance
-               $data = $this->getBlockInstance()->writeValueToFile($groupId, $value);
+               // Call file instance
+               $data = $this->getBinaryFileInstance()->writeValueToFile($groupId, $value);
 
                // Return data
                //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('FILE-ITERATOR: data[]=%s - EXIT!', gettype($data)));
@@ -532,10 +512,10 @@ class FileIterator extends BaseIterator implements SeekableWritableFileIterator
         */
        public function writeDataToFreeGap (string $groupId, string $hash, string $encoded) {
                // Validate parameter
-               //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('FILE-ITERATOR: groupId=%s,hash=%s,encoded()=%d - CALLED!', $groupId, $hash, strlen($encoded)));
+               //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('FILE-ITERATOR: groupId=%s,hash=%s,encoded(%d)=%s - CALLED!', $groupId, $hash, strlen($encoded), $encoded));
 
-               // Call block instance
-               $data = $this->getBlockInstance()->writeDataToFreeGap($groupId, $hash, $encoded);
+               // Call file instance
+               $data = $this->getBinaryFileInstance()->writeDataToFreeGap($groupId, $hash, $encoded);
 
                // Return data
                //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('FILE-ITERATOR: data[]=%s - EXIT!', gettype($data)));
@@ -558,8 +538,8 @@ class FileIterator extends BaseIterator implements SeekableWritableFileIterator
                        throw new InvalidArgumentException(sprintf('length=%d is not valid', $length));
                }
 
-               // Call block instance
-               $seekPosition = $this->getBlockInstance()->searchNextGap($length);
+               // Call file instance
+               $seekPosition = $this->getBinaryFileInstance()->searchNextGap($length);
 
                // Return position
                //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('FILE-ITERATOR: seekPosition[%s]=%d - EXIT!', gettype($seekPosition), $seekPosition));
index 7412028a65fe2c50844d5800212e8a80107a0115..37ffef16a2ab01a5b6a9e4ff0546ad37c2c5caf2 100644 (file)
@@ -1,6 +1,6 @@
 <?php
 // Own namespace
-namespace CoreFramework\Mailer\!!!;
+namespace Org\Mxchange\CoreFramework\Mailer\!!!;
 
 // Import framwork stuff
 use Org\Mxchange\CoreFramework\Mailer\BaseMailer;
index 1f1588ddfa5c58957f2e1def0fece2b572fe2e70..bbb32de7c9777b50ec8675b2bc712ae78da0017b 100644 (file)
@@ -1,6 +1,6 @@
 <?php
 // Own namespace
-namespace CoreFramework\Output\;
+namespace Org\Mxchange\CoreFramework\Output\;
 
 // Import framework stuff
 use Org\Mxchange\CoreFramework\Bootstrap\FrameworkBootstrap;
index 9dc14bfc6cbe521f5dd851b141ac9e99b546ce1a..d3f6f212519b0c72564e32ad279aefc08abdffbe 100644 (file)
@@ -1,6 +1,6 @@
 <?php
 // Own namespace
-namespace CoreFramework\Registry\!!!;
+namespace Org\Mxchange\CoreFramework\Registry\!!!;
 
 // Import framework stuff
 use Org\Mxchange\CoreFramework\Registry\BaseRegistry;
index 696ea3f64d3fedbf987129da2450b8eb46834864..253a921dea4e1082a74fe99834ad00ba3dcb6b00 100644 (file)
@@ -1,6 +1,6 @@
 <?php
 // Own namespace
-namespace CoreFramework\Request;
+namespace Org\Mxchange\CoreFramework\Request;
 
 /**
  * A concrete request class
index 3ccb959f35ba8d569544491a9e0b7d2f55a9ecfc..01e94f78c66c19e2eaef0b7d28ebc0cc32847f69 100644 (file)
@@ -1,10 +1,10 @@
 <?php
 // Own namespace
-namespace CoreFramework\Stacker\!!!;
+namespace Org\Mxchange\CoreFramework\Stack\!!!;
 
 // Import framework stuff
-use Org\Mxchange\CoreFramework\Stacker\BaseStacker;
-use Org\Mxchange\CoreFramework\Stacker\Stackable;
+use Org\Mxchange\CoreFramework\Stack\BaseStacker;
+use Org\Mxchange\CoreFramework\Stack\Stackable;
 
 /**
  * A ??? Stacker class
index 63686de9f14a0640f8876a43b16670ff11cd2477..66345fd72112ad7f76bbc920d0912a4268df91af 100644 (file)
@@ -9,8 +9,6 @@ use Org\Mxchange\CoreFramework\Filesystem\File\BaseBinaryFile;
 use Org\Mxchange\CoreFramework\Generic\UnsupportedOperationException;
 use Org\Mxchange\CoreFramework\Iterator\Filesystem\SeekableWritableFileIterator;
 use Org\Mxchange\CoreFramework\Stack\BaseStacker;
-use Org\Mxchange\CoreFramework\Stack\File\InvalidMagicException;
-use Org\Mxchange\CoreFramework\Stack\File\StackableFile;
 use Org\Mxchange\CoreFramework\Traits\Index\IndexableTrait;
 use Org\Mxchange\CoreFramework\Traits\Iterator\IteratorTrait;
 use Org\Mxchange\CoreFramework\Utils\String\StringUtils;
@@ -42,7 +40,7 @@ use \UnexpectedValueException;
  * You should have received a copy of the GNU General Public License
  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
  */
-abstract class BaseFileStack extends BaseStacker implements StackableFile {
+abstract class BaseFileStack extends BaseStacker {
        // Load traits
        use IndexableTrait;
        use IteratorTrait;
@@ -244,9 +242,6 @@ abstract class BaseFileStack extends BaseStacker implements StackableFile {
                /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('BASE-FILE-STACK: Calling this->iteratorInstance->initCountersGapsArray() ...');
                $this->getIteratorInstance()->initCountersGapsArray();
 
-               // Default is not created/already exists
-               $created = false;
-
                // Is the file's header initialized?
                if (!$this->getIteratorInstance()->isFileHeaderInitialized()) {
                        // First pre-allocate a bit
@@ -256,33 +251,39 @@ abstract class BaseFileStack extends BaseStacker implements StackableFile {
                        // Then create file header
                        /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('BASE-FILE-STACK: this->iteratorInstance->createFileHeader() ...');
                        $this->getIteratorInstance()->createFileHeader();
-
-                       // Set flag
-                       $created = true;
                }
 
                // Load the file header
                /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('BASE-FILE-STACK: Calling this->readFileHeader() ...');
                $this->readFileHeader();
 
-               // Not created/already exists?
-               /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('BASE-FILE-STACK: created=%d', intval($created)));
-               if (!$created) {
-                       // Count all entries in file
-                       /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('BASE-FILE-STACK: Calling this->iteratorInstance->analyzeFileStructure() ...');
-                       $this->getIteratorInstance()->analyzeFileStructure();
-               }
-
                /*
                 * Get stack index instance. This can be used for faster
                 * "defragmentation" and startup.
                 */
-               /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('BASE-FILE-STACK: fileInfoInstance[%s]=%s,type=%s', get_class($fileInfoInstance), $fileInfoInstance, $type));
+               /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('BASE-FILE-STACK: Creating index instance for fileInfoInstance[%s]=%s,type=%s ...', get_class($fileInfoInstance), $fileInfoInstance, $type));
                $indexInstance = FileStackIndexFactory::createFileStackIndexInstance($fileInfoInstance, $type);
 
                // And set it here
+               /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('BASE-FILE-STACK: indexInstance=%s', $indexInstance->__toString()));
                $this->setIndexInstance($indexInstance);
 
+               // Is the index loaded correctly and the stack file is just created?
+               /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('BASE-FILE-STACK: Calling this->indexInstance->isIndexFileLoaded() ...');
+               if (!$this->getIndexInstance()->isIndexFileLoaded()) {
+                       /*
+                        * Something horrible has happened to the index as it should be
+                        * loaded at this point. The stack's file structure then needs to
+                        * be analyzed and the index rebuild.
+                        */
+                       /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('BASE-FILE-STACK: Calling this->iteratorInstance->analyzeFileStructure() ...');
+                       $this->getIteratorInstance()->analyzeFileStructure();
+
+                       // Rebuild index from file
+                       /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('BASE-FILE-STACK: Calling this->iteratorInstance->rebuildIndexFromStack(%s) ...', $this->__toString()));
+                       $this->getIndexInstance()->rebuildIndexFromStack($this);
+               }
+
                // Trace message
                /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('BASE-FILE-STACK: EXIT!');
        }
@@ -299,7 +300,8 @@ abstract class BaseFileStack extends BaseStacker implements StackableFile {
         */
        protected function addValueToStack (string $stackerName, $value) {
                // Validate parameter
-               /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('BASE-FILE-STACK: stackerName=%s,value[%s]=%s - CALLED!', $stackerName, gettype($value), print_r($value, true)));
+               /* PRINTR-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('BASE-FILE-STACK: stackerName=%s,value[]=%s - CALLED!', $stackerName, gettype($value)));
+               //* PRINTR-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('BASE-FILE-STACK: stackerName=%s,value[%s]=%s', $stackerName, gettype($value), print_r($value, true)));
                if (empty($stackerName)) {
                        // No empty stack name
                        throw new InvalidArgumentException('Parameter "stackerName" is empty');
@@ -318,7 +320,9 @@ abstract class BaseFileStack extends BaseStacker implements StackableFile {
                $data = $this->getIteratorInstance()->writeValueToFile($stackerName, $value);
 
                // Add the hash and gap position to the index
-               $this->getIndexInstance()->addHashToIndex($stackerName, $data);
+               //* PRINTR-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('BASE-FILE-STACK: data=%s', print_r($data, true));
+               /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('BASE-FILE-STACK: Calling this->indexInstance->addHashedDataToIndex(%s,data()=%d) ...', $stackerName, count($data)));
+               $this->getIndexInstance()->addHashedDataToIndex($stackerName, $data);
 
                // Trace message
                /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('BASE-FILE-STACK: EXIT!');
@@ -476,28 +480,6 @@ abstract class BaseFileStack extends BaseStacker implements StackableFile {
                return $isEmpty;
        }
 
-       /**
-        * Initializes given stacker
-        *
-        * @param       $stackerName    Name of the stack
-        * @param       $forceReInit    Force re-initialization
-        * @return      void
-        * @throws      UnsupportedOperationException   This method is not (and maybe never will be) supported
-        */
-       public function initStack (string $stackerName, bool $forceReInit = false) {
-               throw new UnsupportedOperationException(array($this, __FUNCTION__, $this->getIteratorInstance()->getPointerInstance()), self::EXCEPTION_UNSPPORTED_OPERATION);
-       }
-
-       /**
-        * Initializes all stacks
-        *
-        * @return      void
-        * @throws      UnsupportedOperationException   This method is not (and maybe never will be) supported
-        */
-       public function initStacks (array $stacks, bool $forceReInit = false) {
-               throw new UnsupportedOperationException(array($this, __FUNCTION__, $this->getIteratorInstance()->getPointerInstance()), self::EXCEPTION_UNSPPORTED_OPERATION);
-       }
-
        /**
         * Checks whether the given stack is initialized (set in array $stackers)
         *
index da201e4d19f9533104e6856ce61f8ca8dab183e9..6400b38a331c327d110040438dc9136aa683e55e 100644 (file)
@@ -1,6 +1,6 @@
 <?php
 // Own namespace
-namespace CoreFramework\Stream\;
+namespace Org\Mxchange\CoreFramework\Stream\;
 
 // Import framework stuff
 use Org\Mxchange\CoreFramework\Generic\UnsupportedOperationException;
index 332d2b0815c7e705693459f948187596d809051a..89d73f332b13eda5054fb52a2e4f552e0f9e763f 100644 (file)
@@ -1,6 +1,6 @@
 <?php
 // Own namespace
-namespace CoreFramework\Stream\Input\;
+namespace Org\Mxchange\CoreFramework\Stream\Input\;
 
 // Import framework stuff
 use Org\Mxchange\CoreFramework\Generic\UnsupportedOperationException;
index 6e636b87bcf5c14806f2eca1da0f9b416da5784b..e195450f7979a093b7fe8a1277c00d4e0bb4a41b 100644 (file)
@@ -1,6 +1,6 @@
 <?php
 // Own namespace
-namespace CoreFramework\Stream\Output\;
+namespace Org\Mxchange\CoreFramework\Stream\Output\;
 
 // Import framework stuff
 use Org\Mxchange\CoreFramework\Generic\UnsupportedOperationException;
index 883c920fdf42e6b1d8dacc8fa5c306de96784c86..787d94438b985fad51d2328e05fa98ac9ec129ea 100644 (file)
@@ -1,6 +1,6 @@
 <?php
 // Own namespace
-namespace CoreFramework\Task\___;
+namespace Org\Mxchange\CoreFramework\Task\___;
 
 // Import framework stuff
 use Org\Mxchange\CoreFramework\Task\BaseTask;
index 4590f17f7f74fb8d1b32703b38d7be54d4780e62..18f019bdf1373fe350a7cd8e3b0475e44341e935 100644 (file)
@@ -1,6 +1,6 @@
 <?php
 // Own namespace
-namespace CoreFramework\Template\Engine\;
+namespace Org\Mxchange\CoreFramework\Template\Engine\;
 
 // Import framework stuff
 use Org\Mxchange\CoreFramework\Bootstrap\FrameworkBootstrap;
index f0f03c3bf140ced4d6e9d1cadf87662f5bfde90e..88dc4813754716779b20bcccc0fec25a552d465c 100644 (file)
@@ -1,6 +1,6 @@
 <?php
 // Own namespace
-namespace CoreFramework\Visitor\;
+namespace Org\Mxchange\CoreFramework\Visitor\;
 
 // Import framework stuff
 use Org\Mxchange\CoreFramework\Visitor\BaseVisitor;
index 47272db30223e5128f3b70ac3c5fc1ebfdcd90b9..0142a7f269060ba36703dd05655580c1ab622e1f 100644 (file)
@@ -1,6 +1,6 @@
 <?php
 // Own namespace
-namespace Org\Mxchange\CoreFramework\FileSystem;
+namespace Org\Mxchange\CoreFramework\Filesystem;
 
 // Import framework stuff
 use Org\Mxchange\CoreFramework\Generic\FrameworkException;
index d440737f75f8770533997e3c570fd536e2afe65f..0c855994e5fb6c5f71d698e9034c382c95d0ce78 100644 (file)
@@ -1,6 +1,6 @@
 <?php
 // Own namespace
-namespace Org\Mxchange\CoreFramework\FileSystem;
+namespace Org\Mxchange\CoreFramework\Filesystem;
 
 // Import framework stuff
 use Org\Mxchange\CoreFramework\Generic\FrameworkException;
index 54f3f697c4f9648f26dc1c6dc9e0701d2392162d..bfabc9a192d66a8a95132344894d45e078b0b4b6 100644 (file)
@@ -4,6 +4,7 @@ namespace Org\Mxchange\CoreFramework\Stack\File;
 
 // Import framework stuff
 use Org\Mxchange\CoreFramework\Generic\FrameworkException;
+use Org\Mxchange\CoreFramework\Stack\File\StackableFile;
 
 /**
  * Invalid/bad magic found
index af107eb98a9194f0faaf1b44f678161fd528f87c..bc151e741840a4623905e32b3db5f2c7425ed0cc 100644 (file)
@@ -28,134 +28,5 @@ use Org\Mxchange\CoreFramework\Generic\FrameworkInterface;
  * along with this program. If not, see <http://www.gnu.org/licenses/>.
  */
 interface Block extends FrameworkInterface {
-       /**
-        * Reads the file header
-        *
-        * @return      void
-        */
-       function readFileHeader ();
-
-       /**
-        * Flushes the file header
-        *
-        * @return      void
-        */
-       function flushFileHeader ();
-
-       /**
-        * Determines whether the EOF has been reached
-        *
-        * @return      $isEndOfFileReached             Whether the EOF has been reached
-        */
-       function isEndOfFileReached ();
-
-       /**
-        * Initializes counter for valid entries, arrays for damaged entries and
-        * an array for gap seek positions. If you call this method on your own,
-        * please re-analyze the file structure. So you are better to call
-        * analyzeFileStructure() instead of this method.
-        *
-        * @return      void
-        */
-       function initCountersGapsArray ();
-
-       /**
-        * Getter for header size
-        *
-        * @return      $totalEntries   Size of file header
-        */
-       function getHeaderSize ();
-
-       /**
-        * Setter for header size
-        *
-        * @param       $headerSize             Size of file header
-        * @return      void
-        */
-       function setHeaderSize (int $headerSize);
-
-       /**
-        * Getter for header array
-        *
-        * @return      $totalEntries   Size of file header
-        */
-       function getHeader ();
-
-       /**
-        * Setter for header
-        *
-        * @param       $header         Array for a file header
-        * @return      void
-        */
-       function setHeader (array $header);
-
-       /**
-        * Updates seekPosition attribute from file to avoid to much access on file.
-        *
-        * @return      void
-        */
-       function updateSeekPosition ();
-
-       /**
-        * Getter for total entries
-        *
-        * @return      $totalEntries   Total entries in this file
-        */
-       function getCounter ();
-
-       /**
-        * "Getter" for file size
-        *
-        * @return      $fileSize       Size of currently loaded file
-        */
-       function getFileSize ();
-
-       /**
-        * Writes given value to the file and returns a hash and gap position for it
-        *
-        * @param       $groupId        Group identifier
-        * @param       $value          Value to be added to the stack
-        * @return      $data           Hash and gap position
-        */
-       function writeValueToFile (string $groupId, string $rawData);
-
-       /**
-        * Writes given raw data to the file and returns a gap position and length
-        *
-        * @param       $groupId        Group identifier
-        * @param       $hash           Hash from encoded value
-        * @param       $encoded        Encoded value to be written to the file
-        * @return      $data           Gap position and length of the raw data
-        */
-       function writeDataToFreeGap (string $groupId, string $hash, string $encoded);
-
-       /**
-        * Writes data at given position
-        *
-        * @param       $seekPosition   Seek position
-        * @param       $data                   Data to be written
-        * @param       $flushHeader    Whether to flush the header (default: flush)
-        * @return      void
-        */
-       function writeData (int $seekPosition, string $data, bool $flushHeader = true);
-
-       /**
-        * Writes at given position by seeking to it.
-        *
-        * @param       $seekPosition   Seek position in file
-        * @param       $dataStream             Data to be written
-        * @return      mixed                   Number of writes bytes or false on error
-        * @throws      InvalidArgumentException        If a parameter is not valid
-        */
-       function writeAtPosition (int $seekPosition, string $dataStream);
-
-       /**
-        * Searches for next suitable gap the given length of data can fit in
-        * including padding bytes.
-        *
-        * @param       $length                 Length of raw data
-        * @return      $seekPosition   Found next gap's seek position
-        */
-       function searchNextGap (int $length);
 
 }
index 241c8ced838c2d933a2f56657ceb93ae0077b9bb..d3a90f587cdfdb561567c1afb706a0e04b9f125b 100644 (file)
@@ -1,6 +1,6 @@
 <?php
 // Own namespace
-namespace CoreFramework\!!!;
+namespace Org\Mxchange\CoreFramework\!!!;
 
 // Import framework stuff
 use Org\Mxchange\CoreFramework\Generic\FrameworkInterface;
diff --git a/framework/main/interfaces/filesystem/binary/class_BinaryFile.php b/framework/main/interfaces/filesystem/binary/class_BinaryFile.php
new file mode 100644 (file)
index 0000000..5dcd2c4
--- /dev/null
@@ -0,0 +1,161 @@
+<?php
+// Own namespace
+namespace Org\Mxchange\CoreFramework\Filesystem\File;
+
+// Import framework stuff
+use Org\Mxchange\CoreFramework\Filesystem\Filesystem;
+
+/**
+ * A virtual file system interface
+ *
+ * @author             Roland Haeder <webmaster@ship-simu.org>
+ * @version            0.0.0
+ * @copyright  Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2020 Core Developer Team
+ * @license            GNU GPL 3.0 or any newer version
+ * @link               http://www.ship-simu.org
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+interface BinaryFile extends Filesystem {
+       /**
+        * Reads the file header
+        *
+        * @return      void
+        */
+       function readFileHeader ();
+
+       /**
+        * Flushes the file header
+        *
+        * @return      void
+        */
+       function flushFileHeader ();
+
+       /**
+        * Determines whether the EOF has been reached
+        *
+        * @return      $isEndOfFileReached             Whether the EOF has been reached
+        */
+       function isEndOfFileReached ();
+
+       /**
+        * Getter for header size
+        *
+        * @return      $totalEntries   Size of file header
+        */
+       function getHeaderSize ();
+
+       /**
+        * Setter for header size
+        *
+        * @param       $headerSize             Size of file header
+        * @return      void
+        */
+       function setHeaderSize (int $headerSize);
+
+       /**
+        * Getter for header array
+        *
+        * @return      $totalEntries   Size of file header
+        */
+       function getHeader ();
+
+       /**
+        * Setter for header
+        *
+        * @param       $header         Array for a file header
+        * @return      void
+        */
+       function setHeader (array $header);
+
+       /**
+        * Initializes counter for valid entries, arrays for damaged entries and
+        * an array for gap seek positions. If you call this method on your own,
+        * please re-analyze the file structure. So you are better to call
+        * analyzeFileStructure() instead of this method.
+        *
+        * @return      void
+        */
+       function initCountersGapsArray ();
+
+       /**
+        * Updates seekPosition attribute from file to avoid to much access on file.
+        *
+        * @return      void
+        */
+       function updateSeekPosition ();
+
+       /**
+        * Getter for total entries
+        *
+        * @return      $totalEntries   Total entries in this file
+        */
+       function getCounter ();
+
+       /**
+        * "Getter" for file size
+        *
+        * @return      $fileSize       Size of currently loaded file
+        */
+       function getFileSize ();
+
+       /**
+        * Searches for next suitable gap the given length of data can fit in
+        * including padding bytes.
+        *
+        * @param       $length                 Length of raw data
+        * @return      $seekPosition   Found next gap's seek position
+        */
+       function searchNextGap (int $length);
+
+       /**
+        * Writes given value to the file and returns a hash and gap position for it
+        *
+        * @param       $groupId        Group identifier
+        * @param       $value          Value to be added to the stack
+        * @return      $data           Hash and gap position
+        */
+       function writeValueToFile (string $groupId, string $rawData);
+
+       /**
+        * Writes given raw data to the file and returns a gap position and length
+        *
+        * @param       $groupId        Group identifier
+        * @param       $hash           Hash from encoded value
+        * @param       $encoded        Encoded value to be written to the file
+        * @return      $data           Gap position and length of the raw data
+        */
+       function writeDataToFreeGap (string $groupId, string $hash, string $encoded);
+
+       /**
+        * Writes data at given position
+        *
+        * @param       $seekPosition   Seek position
+        * @param       $data                   Data to be written
+        * @param       $flushHeader    Whether to flush the header (default: flush)
+        * @return      void
+        */
+       function writeData (int $seekPosition, string $data, bool $flushHeader = true);
+
+       /**
+        * Writes at given position by seeking to it.
+        *
+        * @param       $seekPosition   Seek position in file
+        * @param       $dataStream             Data to be written
+        * @return      mixed                   Number of writes bytes or false on error
+        * @throws      InvalidArgumentException        If a parameter is not valid
+        */
+       function writeAtPosition (int $seekPosition, string $dataStream);
+
+}
index e3b94b9330a2156b2820c64bb918dcfdf19011cf..a2877ab10bcee76ee72e1008553715d9cae68a3c 100644 (file)
@@ -1,6 +1,6 @@
 <?php
 // Own namespace
-namespace Org\Mxchange\CoreFramework\FileSystem;
+namespace Org\Mxchange\CoreFramework\Filesystem;
 
 // Import framework stuff
 use Org\Mxchange\CoreFramework\Generic\FrameworkInterface;
diff --git a/framework/main/interfaces/filesystem/index/class_IndexableFile.php b/framework/main/interfaces/filesystem/index/class_IndexableFile.php
new file mode 100644 (file)
index 0000000..730cbac
--- /dev/null
@@ -0,0 +1,32 @@
+<?php
+// Own namespace
+namespace Org\Mxchange\CoreFramework\Filesystem\Index;
+
+// Import framework stuff
+use Org\Mxchange\CoreFramework\Filesystem\File\BinaryFile;
+
+/**
+ * An interface for Indexable file classes
+ *
+ * @author             Roland Haeder <webmaster@ship-simu.org>
+ * @version            0.0.0
+ * @copyright  Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2020 Core Developer Team
+ * @license            GNU GPL 3.0 or any newer version
+ * @link               http://www.ship-simu.org
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+interface IndexableFile extends BinaryFile {
+
+}
diff --git a/framework/main/interfaces/filesystem/stack/class_FileStacker.php b/framework/main/interfaces/filesystem/stack/class_FileStacker.php
new file mode 100644 (file)
index 0000000..754df63
--- /dev/null
@@ -0,0 +1,32 @@
+<?php
+// Own namespace
+namespace Org\Mxchange\CoreFramework\Filesystem\Stack;
+
+// Import framework stuff
+use Org\Mxchange\CoreFramework\Filesystem\File\BinaryFile;
+
+/**
+ * An interface for files of file-based stacks
+ *
+ * @author             Roland Haeder <webmaster@ship-simu.org>
+ * @version            0.0.0
+ * @copyright  Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2020 Core Developer Team
+ * @license            GNU GPL 3.0 or any newer version
+ * @link               http://www.ship-simu.org
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+interface FileStacker extends BinaryFile {
+
+}
index 1b7f41b79bb32653faf4f60ebef64c5c8ad921c0..e7d6507301b5c769594ef98b99de77bf8857854a 100644 (file)
@@ -1,6 +1,6 @@
 <?php
 // Own namespace
-namespace CoreFramework\Index\!!!;
+namespace Org\Mxchange\CoreFramework\Index\!!!;
 
 // Import framework stuff
 use Org\Mxchange\CoreFramework\Index\Indexable;
index bcc39b660569af4380c6f8907d0e3ea29a564d86..2576ce5a4288b408a7da11255f6478c3cdbf455c 100644 (file)
@@ -1,6 +1,6 @@
 <?php
 // Own namespace
-namespace Org\Mxchange\CoreFramework\Stack\Index;
+namespace Org\Mxchange\CoreFramework\Index\Stack;
 
 // Import framework stuff
 use Org\Mxchange\CoreFramework\Filesystem\Block\CalculatableBlock;
@@ -30,12 +30,20 @@ use Org\Mxchange\CoreFramework\Index\Indexable;
  */
 interface IndexableStack extends Indexable, CalculatableBlock {
        /**
-        * Adds given hash to an index file
+        * Adds given data's hash to the index file
         *
         * @param       $stackName      Name of stack to add hash
         * @param       $data           Hash and gap position to be added to the index
         * @return      void
+        * @throws      InvalidArgumentException        If a parameter is not valid
         */
-       function addHashToIndex (string $stackName, array $data);
+       function addHashedDataToIndex (string $stackName, array $data);
+
+       /**
+        * Checks whether the index' file has been fully loaded (and parsed)
+        *
+        * @return      $isLoaded       Whether the index' file has been loaded
+        */
+       function isIndexFileLoaded ();
 
 }
index 3a2ddb2cacff27a16afa06161c1a6d3163e65c4c..f7f3872b865e307ef2b54460d83a67da1539807f 100644 (file)
@@ -75,4 +75,30 @@ interface Stackable extends FrameworkInterface {
         */
        function isStackEmpty (string $stackerName);
 
+       /**
+        * Initializes given stacker
+        *
+        * @param       $stackerName    Name of the stack
+        * @param       $forceReInit    Force re-initialization
+        * @return      void
+        * @throws      UnsupportedOperationException   This method is not (and maybe never will be) supported
+        */
+       function initStack (string $stackerName, bool $forceReInit = false);
+
+       /**
+        * Initializes all stacks
+        *
+        * @return      void
+        * @throws      UnsupportedOperationException   This method is not (and maybe never will be) supported
+        */
+       function initStacks (array $stacks, bool $forceReInit = false);
+
+       /**
+        * Getter for size of given stack (array count)
+        *
+        * @param       $stackerName    Name of the stack
+        * @return      $count                  Size of stack (array count)
+        */
+       function getStackCount (string $stackerName);
+
 }
index 0d35c82b36c09ee88d87c66288e645474a1da5b8..f01e8b3d39c57521828d2ebce7e0a9b066798e0f 100644 (file)
@@ -63,4 +63,155 @@ interface StackableFile extends Stackable {
         */
        function size ();
 
+       /**
+        * Reads the file header
+        *
+        * @return      void
+        * @todo        To hard assertions here, better rewrite them to exceptions
+        * @throws      UnexpectedValueException        If header is not proper length
+        * @throws      InvalidMagicException   If a bad magic was found
+        */
+       function readFileHeader ();
+
+       /**
+        * Flushes the file header
+        *
+        * @return      void
+        */
+       function flushFileHeader ();
+
+       /**
+        * Determines whether the EOF has been reached
+        *
+        * @return      $isEndOfFileReached             Whether the EOF has been reached
+        * @throws      UnsupportedOperationException   This method is not (and maybe never will be) supported
+        */
+       function isEndOfFileReached ();
+
+       /**
+        * Calculates minimum length for one entry/block
+        *
+        * @return      $length         Minimum length for one entry/block
+        */
+       function calculateMinimumBlockLength ();
+
+       /**
+        * Initializes counter for valid entries, arrays for damaged entries and
+        * an array for gap seek positions. If you call this method on your own,
+        * please re-analyze the file structure. So you are better to call
+        * analyzeFileStructure() instead of this method.
+        *
+        * @return      void
+        * @throws      UnsupportedOperationException   This method is not (and maybe never will be) supported
+        */
+       function initCountersGapsArray ();
+
+       /**
+        * Getter for header size
+        *
+        * @return      $totalEntries   Size of file header
+        * @throws      UnsupportedOperationException   This method is not (and maybe never will be) supported
+        */
+       function getHeaderSize ();
+
+       /**
+        * Setter for header size
+        *
+        * @param       $headerSize             Size of file header
+        * @return      void
+        * @throws      UnsupportedOperationException   This method is not (and maybe never will be) supported
+        */
+       function setHeaderSize (int $headerSize);
+
+       /**
+        * Getter for header array
+        *
+        * @return      $totalEntries   Size of file header
+        * @throws      UnsupportedOperationException   This method is not (and maybe never will be) supported
+        */
+       function getHeader ();
+
+       /**
+        * Setter for header
+        *
+        * @param       $header         Array for a file header
+        * @return      void
+        * @throws      UnsupportedOperationException   This method is not (and maybe never will be) supported
+        */
+       function setHeader (array $header);
+
+       /**
+        * Updates seekPosition attribute from file to avoid to much access on file.
+        *
+        * @return      void
+        * @throws      UnsupportedOperationException   This method is not (and maybe never will be) supported
+        */
+       function updateSeekPosition ();
+
+       /**
+        * Getter for total entries
+        *
+        * @return      $totalEntries   Total entries in this file
+        * @throws      UnsupportedOperationException   This method is not (and maybe never will be) supported
+        */
+       function getCounter ();
+
+       /**
+        * Writes data at given position
+        *
+        * @param       $seekPosition   Seek position
+        * @param       $data                   Data to be written
+        * @param       $flushHeader    Whether to flush the header (default: flush)
+        * @return      void
+        * @throws      UnsupportedOperationException   This method is not (and maybe never will be) supported
+        */
+       function writeData (int $seekPosition, string $data, bool $flushHeader = true);
+
+       /**
+        * Writes at given position by seeking to it.
+        *
+        * @param       $seekPosition   Seek position in file
+        * @param       $dataStream             Data to be written
+        * @return      mixed                   Number of writes bytes or false on error
+        * @throws      UnsupportedOperationException   This method is not (and maybe never will be) supported
+        */
+       function writeAtPosition (int $seekPosition, string $dataStream);
+
+       /**
+        * Writes given value to the file and returns a hash and gap position for it
+        *
+        * @param       $groupId        Group identifier
+        * @param       $value          Value to be added to the stack
+        * @return      $data           Hash and gap position
+        * @throws      UnsupportedOperationException   This method is not (and maybe never will be) supported
+        */
+       function writeValueToFile (string $groupId, $value);
+
+       /**
+        * Searches for next suitable gap the given length of data can fit in
+        * including padding bytes.
+        *
+        * @param       $length                 Length of raw data
+        * @return      $seekPosition   Found next gap's seek position
+        * @throws      UnsupportedOperationException   This method is not (and maybe never will be) supported
+        */
+       function searchNextGap (int $length);
+
+       /**
+        * "Getter" for file size
+        *
+        * @return      $fileSize       Size of currently loaded file
+        */
+       function getFileSize ();
+
+       /**
+        * Writes given raw data to the file and returns a gap position and length
+        *
+        * @param       $groupId        Group identifier
+        * @param       $hash           Hash from encoded value
+        * @param       $encoded        Encoded value to be written to the file
+        * @return      $data           Gap position and length of the raw data
+        */
+       function writeDataToFreeGap (string $groupId, string $hash, string $encoded);
+
 }
index 617734d42417c1d5b734a6d8272cbe5fcc2e7556..38eaef8c01964f4e743478b6f79792691fe82451 100644 (file)
@@ -1,6 +1,6 @@
 <?php
 // Own namespace
-namespace CoreFramework\Tests\Filter\!!!;
+namespace Org\Mxchange\CoreFramework\Tests\Filter\!!!;
 
 // Import framework stuff
 use Org\Mxchange\CoreFramework\Filter\Filterable;
index ab57e6f131533d867cb8fa613abf12f1dbd8ff6f..dcad1a2655a5e79b157d881a2024061dd2188dde 100644 (file)
@@ -1,6 +1,6 @@
 <?php
 // Own namespace
-namespace CoreFramework\Tests\Filter\Configuration\!!!;
+namespace Org\Mxchange\CoreFramework\Tests\Filter\Configuration\!!!;
 
 // Import framework stuff
 use Org\Mxchange\CoreFramework\Filter\Filterable;
diff --git a/framework/main/traits/file/class_BinaryFileTrait.php b/framework/main/traits/file/class_BinaryFileTrait.php
new file mode 100644 (file)
index 0000000..36dde85
--- /dev/null
@@ -0,0 +1,55 @@
+<?php
+// Own namespace
+namespace Org\Mxchange\CoreFramework\Traits\File;
+
+// Import framework stuff
+use Org\Mxchange\CoreFramework\Filesystem\File\BinaryFile;
+
+/**
+ * A trait for binary files
+ *
+ * @author             Roland Haeder <webmaster@ship-simu.org>
+ * @version            0.0.0
+ * @copyright  Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2020 Core Developer Team
+ * @license            GNU GPL 3.0 or any newer version
+ * @link               http://www.ship-simu.org
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ */
+trait BinaryFileTrait {
+       /**
+        * An instance of an BinaryFile class
+        */
+       private $binaryFileInstance = NULL;
+
+       /**
+        * Setter for BinaryFile instance
+        *
+        * @param       $binaryFileInstance     An instance of an BinaryFile class
+        * @return      void
+        */
+       protected final function setBinaryFileInstance (BinaryFile $binaryFileInstance) {
+               $this->binaryFileInstance = $binaryFileInstance;
+       }
+
+       /**
+        * Getter for BinaryFile instance
+        *
+        * @return      $binaryFileInstance     An instance of an BinaryFile class
+        */
+       public final function getBinaryFileInstance () {
+               return $this->binaryFileInstance;
+       }
+
+}
diff --git a/framework/main/traits/index/stack/class_IndexableStackTrait.php b/framework/main/traits/index/stack/class_IndexableStackTrait.php
new file mode 100644 (file)
index 0000000..15e46ac
--- /dev/null
@@ -0,0 +1,55 @@
+<?php
+// Own namespace
+namespace Org\Mxchange\CoreFramework\Traits\Index\Stack;
+
+// Import framework stuff
+use Org\Mxchange\CoreFramework\Index\Stack\IndexableStack;
+
+/**
+ * A trait for indexable stacks
+ *
+ * @author             Roland Haeder <webmaster@ship-simu.org>
+ * @version            0.0.0
+ * @copyright  Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2020 Core Developer Team
+ * @license            GNU GPL 3.0 or any newer version
+ * @link               http://www.ship-simu.org
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ */
+trait IndexableStackTrait {
+       /**
+        * An instance of an IndexableStack class
+        */
+       private $indexInstance = NULL;
+
+       /**
+        * Setter for IndexableStack instance
+        *
+        * @param       $indexInstance  An instance of an IndexableStack class
+        * @return      void
+        */
+       protected final function setIndexableStackInstance (IndexableStack $indexInstance) {
+               $this->indexInstance = $indexInstance;
+       }
+
+       /**
+        * Getter for IndexableStack instance
+        *
+        * @return      $indexInstance  An instance of an IndexableStack class
+        */
+       public final function getIndexableStackInstance () {
+               return $this->indexInstance;
+       }
+
+}