use Org\Mxchange\CoreFramework\Filesystem\File\BinaryFile;
use Org\Mxchange\CoreFramework\Generic\FrameworkInterface;
use Org\Mxchange\CoreFramework\Generic\UnsupportedOperationException;
+use Org\Mxchange\CoreFramework\Middleware\Debug\DebugMiddleware;
use Org\Mxchange\CoreFramework\Stack\BaseStacker;
use Org\Mxchange\CoreFramework\Traits\Index\IndexableTrait;
use Org\Mxchange\CoreFramework\Traits\Iterator\IteratorTrait;
*
* @author Roland Haeder <webmaster@ship-simu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2022 Core Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2023 Core Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.ship-simu.org
*
strlen($data),
$data,
$this->getIteratorInstance()->getBinaryFileInstance()->getHeaderSize()
- ));
+ ), FrameworkInterface::EXCEPTION_UNEXPECTED_VALUE);
} elseif (empty(trim($data, chr(0)))) {
// Empty header, file is freshly pre-allocated
/* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('BASE-FILE-STACK: Empty file header detected - EXIT!');
throw new UnexpectedValueException(sprintf('data=%s does not have separator=0x%s at the end.',
$data,
dechex(BinaryFile::SEPARATOR_HEADER_ENTRIES)
- ));
+ ), FrameworkInterface::EXCEPTION_UNEXPECTED_VALUE);
}
// Okay, then remove it
$data,
count($header),
BinaryFile::HEADER_STACK_ELEMENT_COUNT
- ));
+ ), FrameworkInterface::EXCEPTION_UNEXPECTED_VALUE);
} elseif ($header[BinaryFile::HEADER_NAME_MAGIC] != StackableFile::STACK_MAGIC) {
// Bad magic
throw new InvalidMagicException($data, self::EXCEPTION_BAD_MAGIC);
strlen($header[BinaryFile::HEADER_NAME_TOTAL_ENTRIES]),
$header[BinaryFile::HEADER_NAME_TOTAL_ENTRIES],
BinaryFile::LENGTH_COUNT
- ));
+ ), FrameworkInterface::EXCEPTION_UNEXPECTED_VALUE);
} elseif (strlen($header[BinaryFile::HEADER_NAME_SEEK_POSITION]) != BinaryFile::LENGTH_POSITION) {
// Position length not valid
throw new UnexpectedValueException(sprintf('header[%s](%d)=%s is not expected %d length',
strlen($header[BinaryFile::HEADER_NAME_SEEK_POSITION]),
$header[BinaryFile::HEADER_NAME_SEEK_POSITION],
BinaryFile::LENGTH_POSITION
- ));
+ ), FrameworkInterface::EXCEPTION_UNEXPECTED_VALUE);
}
// Decode count and seek position
throw new InvalidArgumentException('Parameter "stackerName" is empty', FrameworkInterface::EXCEPTION_INVALID_ARGUMENT);
} elseif ($this->isStackFull($stackerName)) {
// Stacker is full
- throw new FullStackerException([$this, $stackerName, $value], self::EXCEPTION_STACKER_IS_FULL);
+ throw new BadMethodCallException(sprintf('stackerName=%s is full but method call.', $stackerName), FrameworkInterface::EXCEPTION_BAD_METHOD_CALL);
} elseif (is_resource($value) || is_object($value)) {
// Not wanted type
throw new InvalidArgumentException(sprintf('value[]=%s is not supported', gettype($value)));
* Now add the value to the file stack which returns gap position, a
* hash and length of the raw data.
*/
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('BASE-FILE-STACK: Invoking this->iteratorInstance->binaryFileInstance->writeValueToFile(%s,value[]=%s) ...', $stackerName, gettype($value)));
$data = $this->getIteratorInstance()->getBinaryFileInstance()->writeValueToFile($stackerName, $value);
// Add the hash and gap position to the index
throw new InvalidArgumentException('Parameter "stackerName" is empty', FrameworkInterface::EXCEPTION_INVALID_ARGUMENT);
} elseif ($this->isStackEmpty($stackerName)) {
// Throw an exception
- throw new BadMethodCallException([$this, $stackerName], self::EXCEPTION_STACKER_IS_EMPTY);
+ throw new BadMethodCallException([$this, $stackerName], FrameworkInterface::EXCEPTION_BAD_METHOD_CALL);
}
// Now get the last value
- /* NOISY-DEBUG: */ $this->partialStub('[' . __METHOD__ . ':' . __LINE__ . '] stackerName=' . $stackerName);
+ /* NOISY-DEBUG: */ DebugMiddleware::getSelfInstance()->partialStub('[' . __METHOD__ . ':' . __LINE__ . '] stackerName=' . $stackerName);
$value = NULL;
// Return it
throw new InvalidArgumentException('Parameter "stackerName" is empty', FrameworkInterface::EXCEPTION_INVALID_ARGUMENT);
} elseif ($this->isStackEmpty($stackerName)) {
// Throw an exception
- throw new BadMethodCallException([$this, $stackerName], self::EXCEPTION_STACKER_IS_EMPTY);
+ throw new BadMethodCallException([$this, $stackerName], FrameworkInterface::EXCEPTION_BAD_METHOD_CALL);
}
// Now get the first value
- /* NOISY-DEBUG: */ $this->partialStub('[' . __METHOD__ . ':' . __LINE__ . '] stackerName=' . $stackerName);
+ /* NOISY-DEBUG: */ DebugMiddleware::getSelfInstance()->partialStub('[' . __METHOD__ . ':' . __LINE__ . '] stackerName=' . $stackerName);
$value = NULL;
// Return it
throw new InvalidArgumentException('Parameter "stackerName" is empty', FrameworkInterface::EXCEPTION_INVALID_ARGUMENT);
} elseif ($this->isStackEmpty($stackerName)) {
// Throw an exception
- throw new BadMethodCallException([$this, $stackerName], self::EXCEPTION_STACKER_IS_EMPTY);
+ throw new BadMethodCallException([$this, $stackerName], FrameworkInterface::EXCEPTION_BAD_METHOD_CALL);
}
// Now, remove the last entry, we don't care about the return value here, see elseif() block above
- /* NOISY-DEBUG: */ $this->partialStub('[' . __METHOD__ . ':' . __LINE__ . '] stackerName=' . $stackerName);
+ /* NOISY-DEBUG: */ DebugMiddleware::getSelfInstance()->partialStub('[' . __METHOD__ . ':' . __LINE__ . '] stackerName=' . $stackerName);
return NULL;
}
throw new InvalidArgumentException('Parameter "stackerName" is empty', FrameworkInterface::EXCEPTION_INVALID_ARGUMENT);
} elseif ($this->isStackEmpty($stackerName)) {
// Throw an exception
- throw new BadMethodCallException([$this, $stackerName], self::EXCEPTION_STACKER_IS_EMPTY);
+ throw new BadMethodCallException([$this, $stackerName], FrameworkInterface::EXCEPTION_BAD_METHOD_CALL);
}
// Now, remove the last entry, we don't care about the return value here, see elseif() block above
- /* NOISY-DEBUG: */ $this->partialStub('[' . __METHOD__ . ':' . __LINE__ . '] stackerName=' . $stackerName);
+ /* NOISY-DEBUG: */ DebugMiddleware::getSelfInstance()->partialStub('[' . __METHOD__ . ':' . __LINE__ . '] stackerName=' . $stackerName);
return NULL;
}
}
// @TODO Please implement this, returning false
- /* NOISY-DEBUG: */ $this->partialStub('[' . __METHOD__ . ':' . __LINE__ . '] stackerName=' . $stackerName);
+ /* NOISY-DEBUG: */ DebugMiddleware::getSelfInstance()->partialStub('[' . __METHOD__ . ':' . __LINE__ . '] stackerName=' . $stackerName);
$isFull = false;
// Return result
* @throws UnsupportedOperationException This method is not (and maybe never will be) supported
*/
public function isStackInitialized (string $stackerName) {
- throw new UnsupportedOperationException(array($this, __FUNCTION__, $this->getIteratorInstance()->getBinaryFileInstance()), self::EXCEPTION_UNSPPORTED_OPERATION);
+ throw new UnsupportedOperationException(array($this, __FUNCTION__, $this->getIteratorInstance()->getBinaryFileInstance()), FrameworkInterface::EXCEPTION_UNSPPORTED_OPERATION);
}
/**
* @throws UnsupportedOperationException This method is not (and maybe never will be) supported
*/
public function isEndOfFileReached () {
- throw new UnsupportedOperationException(array($this, __FUNCTION__, $this->getIteratorInstance()->getBinaryFileInstance()), self::EXCEPTION_UNSPPORTED_OPERATION);
+ throw new UnsupportedOperationException(array($this, __FUNCTION__, $this->getIteratorInstance()->getBinaryFileInstance()), FrameworkInterface::EXCEPTION_UNSPPORTED_OPERATION);
}
/**
* @throws UnsupportedOperationException This method is not (and maybe never will be) supported
*/
public function initCountersGapsArray () {
- throw new UnsupportedOperationException(array($this, __FUNCTION__, $this->getIteratorInstance()->getBinaryFileInstance()), self::EXCEPTION_UNSPPORTED_OPERATION);
+ throw new UnsupportedOperationException(array($this, __FUNCTION__, $this->getIteratorInstance()->getBinaryFileInstance()), FrameworkInterface::EXCEPTION_UNSPPORTED_OPERATION);
}
/**
* @throws UnsupportedOperationException This method is not (and maybe never will be) supported
*/
public final function getHeaderSize () {
- throw new UnsupportedOperationException(array($this, __FUNCTION__, $this->getIteratorInstance()->getBinaryFileInstance()), self::EXCEPTION_UNSPPORTED_OPERATION);
+ throw new UnsupportedOperationException(array($this, __FUNCTION__, $this->getIteratorInstance()->getBinaryFileInstance()), FrameworkInterface::EXCEPTION_UNSPPORTED_OPERATION);
}
/**
* @throws UnsupportedOperationException This method is not (and maybe never will be) supported
*/
public final function setHeaderSize (int $headerSize) {
- throw new UnsupportedOperationException(array($this, __FUNCTION__, $this->getIteratorInstance()->getBinaryFileInstance()), self::EXCEPTION_UNSPPORTED_OPERATION);
+ throw new UnsupportedOperationException(array($this, __FUNCTION__, $this->getIteratorInstance()->getBinaryFileInstance()), FrameworkInterface::EXCEPTION_UNSPPORTED_OPERATION);
}
/**
* @throws UnsupportedOperationException This method is not (and maybe never will be) supported
*/
public final function getHeader () {
- throw new UnsupportedOperationException(array($this, __FUNCTION__, $this->getIteratorInstance()->getBinaryFileInstance()), self::EXCEPTION_UNSPPORTED_OPERATION);
+ throw new UnsupportedOperationException(array($this, __FUNCTION__, $this->getIteratorInstance()->getBinaryFileInstance()), FrameworkInterface::EXCEPTION_UNSPPORTED_OPERATION);
}
/**
* @throws UnsupportedOperationException This method is not (and maybe never will be) supported
*/
public final function setHeader (array $header) {
- throw new UnsupportedOperationException(array($this, __FUNCTION__, $this->getIteratorInstance()->getBinaryFileInstance()), self::EXCEPTION_UNSPPORTED_OPERATION);
+ throw new UnsupportedOperationException(array($this, __FUNCTION__, $this->getIteratorInstance()->getBinaryFileInstance()), FrameworkInterface::EXCEPTION_UNSPPORTED_OPERATION);
}
/**
* @throws UnsupportedOperationException This method is not (and maybe never will be) supported
*/
public function updateSeekPosition () {
- throw new UnsupportedOperationException(array($this, __FUNCTION__, $this->getIteratorInstance()->getBinaryFileInstance()), self::EXCEPTION_UNSPPORTED_OPERATION);
+ throw new UnsupportedOperationException(array($this, __FUNCTION__, $this->getIteratorInstance()->getBinaryFileInstance()), FrameworkInterface::EXCEPTION_UNSPPORTED_OPERATION);
}
/**
* @throws UnsupportedOperationException This method is not (and maybe never will be) supported
*/
public final function getCounter () {
- throw new UnsupportedOperationException(array($this, __FUNCTION__, $this->getIteratorInstance()->getBinaryFileInstance()), self::EXCEPTION_UNSPPORTED_OPERATION);
+ throw new UnsupportedOperationException(array($this, __FUNCTION__, $this->getIteratorInstance()->getBinaryFileInstance()), FrameworkInterface::EXCEPTION_UNSPPORTED_OPERATION);
}
/**
*/
public function writeData (int $seekPosition, string $data, bool $flushHeader = true) {
// Not supported
- throw new UnsupportedOperationException(array($this, __FUNCTION__, $this->getIteratorInstance()->getBinaryFileInstance()), self::EXCEPTION_UNSPPORTED_OPERATION);
+ throw new UnsupportedOperationException(array($this, __FUNCTION__, $this->getIteratorInstance()->getBinaryFileInstance()), FrameworkInterface::EXCEPTION_UNSPPORTED_OPERATION);
}
/**
*/
public function writeAtPosition (int $seekPosition, string $dataStream) {
// Not supported
- throw new UnsupportedOperationException(array($this, __FUNCTION__, $this->getIteratorInstance()->getBinaryFileInstance()), self::EXCEPTION_UNSPPORTED_OPERATION);
+ throw new UnsupportedOperationException(array($this, __FUNCTION__, $this->getIteratorInstance()->getBinaryFileInstance()), FrameworkInterface::EXCEPTION_UNSPPORTED_OPERATION);
}
/**
* @throws UnsupportedOperationException This method is not (and maybe never will be) supported
*/
public function writeValueToFile (string $stackName, $value) {
- throw new UnsupportedOperationException(array($this, __FUNCTION__, $this->getIteratorInstance()->getBinaryFileInstance()), self::EXCEPTION_UNSPPORTED_OPERATION);
+ throw new UnsupportedOperationException(array($this, __FUNCTION__, $this->getIteratorInstance()->getBinaryFileInstance()), FrameworkInterface::EXCEPTION_UNSPPORTED_OPERATION);
}
/**
*/
public function searchNextGap (int $length) {
// Not supported here
- throw new UnsupportedOperationException(array($this, __FUNCTION__, $this->getIteratorInstance()->getBinaryFileInstance()), self::EXCEPTION_UNSPPORTED_OPERATION);
+ throw new UnsupportedOperationException(array($this, __FUNCTION__, $this->getIteratorInstance()->getBinaryFileInstance()), FrameworkInterface::EXCEPTION_UNSPPORTED_OPERATION);
}
/**
gettype($gapPosition),
$gapPosition,
$this->getIteratorInstance()->getBinaryFileInstance()->getHeaderSize()
- ));
+ ), FrameworkInterface::EXCEPTION_UNEXPECTED_VALUE);
}
// Then write the data at that gap