*
* This class serializes objects and saves them to local files.
*
- * @author Roland Haeder <roland __NOSPAM__ [at] __REMOVE_ME__ mxchange [dot] org>
- * @version 0.1
+ * @author Roland Haeder <webmaster@mxchange.org>
+ * @version 0.3.0
+ * @copyright Copyright(c) 2007, 2008 Roland Haeder, this is free software
+ * @license GNU GPL 3.0 or any newer version
+ * @link http://www.mxchange.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/>.
*/
class LocalFileDatabase extends BaseDatabaseFrontend implements DatabaseFrontendInterface {
/**
*/
private $fileExtension = "serialized";
- /**
- * The IO handler for file handling which should be FileIOHandler.
- */
- private $ioInstance = null;
-
/**
* The last read file's name
*/
// Set save path and IO instance
$dbInstance->setSavePath($savePath);
- $dbInstance->setIOInstance($ioInstance);
+ $dbInstance->setFileIOInstance($ioInstance);
// Return database instance
return $dbInstance;
return $this->savePath;
}
- /**
- * Getter for file extension
- *
- * @return $fileExtension The file extension for all file names
- */
- public final function getFileExtension () {
- return $this->fileExtension;
- }
-
/**
* Saves a given object to the local file system by serializing and
* transparently compressing it
// Save the file to disc we don't care here if the path is there,
// this must be done in later methods.
- $this->getIOInstance()->saveFile($fqfn, array($this->getCompressorChannel()->getCompressorExtension(), $serialized));
+ $this->getFileIOInstance()->saveFile($fqfn, array($this->getCompressorChannel()->getCompressorExtension(), $serialized));
}
/**
$this->setLastFile($fqfn);
// Get instance for file handler
- $inputHandler = $this->getIOInstance();
+ $inputHandler = $this->getFileIOInstance();
// Try to read from it. This makes it sure that the file is
// readable and a valid database file
return $isUsed;
}
- /**
- * Getter for the file IO instance
- *
- * @return $ioInstance An instance for IO operations
- * @see FileIOHandler The concrete handler for IO operations
- */
- public final function getIOInstance () {
- return $this->ioInstance;
- }
-
- /**
- * Setter for the file IO instance
- *
- * @param $ioInstance An instance for IO operations (should be
- * FileIOHandler)
- * @return void
- */
- public final function setIOInstance (FileIOHandler $ioInstance) {
- $this->ioInstance = $ioInstance;
- }
-
/**
* Setter for the last read file
*
* @param $fqfn The FQFN of the last read file
* @return void
*/
- private function setLastFile ($fqfn) {
+ private final function setLastFile ($fqfn) {
// Cast string
$fqfn = (string) $fqfn;
$this->lastFile = $fqfn;
* @param $contents An array with header and data elements
* @return void
*/
- private function setLastFileContents ($contents) {
+ private final function setLastFileContents ($contents) {
// Cast array
$contents = (array) $contents;
$this->lastContents = $contents;
* serialized data
* @throws MismatchingCompressorsException If the compressor from
* the loaded file
- * mismatches with the
+ * mismatches with the
* current used one.
* @throws NullPointerException If the restored object
* is null
* @throws MissingMethodException If the required method
* toString() is missing
*/
- public function getObjectFromCachedData ($uniqueID) {
+ public final function getObjectFromCachedData ($uniqueID) {
// Get instance for file handler
- $inputHandler = $this->getIOInstance();
+ $inputHandler = $this->getFileIOInstance();
// Get last file's name and contents
$fqfn = $this->repairFQFN($this->getLastFile(), $uniqueID);