Lob Class Reference

Inheritance diagram for Lob:

Blob Clob

List of all members.

Public Member Functions

 __construct ($data=null)
 Construct a new Lob.
 getContents ()
 Get the contents of the LOB.
 setContents ($data)
 Set the contents of this LOB.
 dump ()
 Dump the contents of the file to stdout.
 setInputFile ($filePath)
 Specify the file that we want this LOB read from.
 getInputFile ()
 Get the file that we want this LOB read from.
 setOutputFile ($filePath)
 Specify the file that we want this LOB saved to.
 getOutputFile ()
 Get the file that we want this LOB saved to.
 isFromFile ()
 Returns whether this Lob is loaded from file.
 readFromFile ($file=null)
 Read LOB data from file (binary safe).
 writeToFile ($file=null)
 Write LOB data to file (binary safe).
 __toString ()
 Convenience method to get contents of LOB as string.
 setModified ($b)
 Set whether LOB contents have been modified after initial setting.
 isModified ()
 Whether LOB contents have been modified after initial setting.

Protected Attributes

 $data
 $outFile
 $inFile

Private Attributes

 $modified = null


Detailed Description

Definition at line 29 of file Lob.php.


Constructor & Destructor Documentation

Lob::__construct ( data = null  ) 

Construct a new Lob.

Parameters:
sttring $data The data contents of the Lob.
See also:
setContents()

Definition at line 66 of file Lob.php.

References $data, and setContents().

00067     {
00068         if ($data !== null) {
00069             $this->setContents($data);
00070         }
00071     }


Member Function Documentation

Lob::__toString (  ) 

Convenience method to get contents of LOB as string.

Returns:
string

Definition at line 219 of file Lob.php.

References getContents().

00220     {
00221         return $this->getContents();
00222     }

Lob::dump (  )  [abstract]

Dump the contents of the file to stdout.

Must be implemented by subclasses so that binary status is handled correctly. (i.e. ignored for Clob, handled for Blob)

Returns:
void
Exceptions:
Exception if no file or contents.

Reimplemented in Blob, and Clob.

Lob::getContents (  ) 

Get the contents of the LOB.

Returns:
string The characters in this LOB.
Exceptions:
Exception 

Definition at line 78 of file Lob.php.

References isFromFile(), and readFromFile().

Referenced by __toString().

00079     {
00080         if ($this->data === null && $this->isFromFile()) {
00081             $this->readFromFile();
00082         }
00083         return $this->data;
00084     }

Lob::getInputFile (  ) 

Get the file that we want this LOB read from.

Returns:
string The location of the file.

Definition at line 133 of file Lob.php.

00134     {
00135         return $this->inFile;
00136     }    

Lob::getOutputFile (  ) 

Get the file that we want this LOB saved to.

Returns:
string $filePath The location of the file.

Definition at line 152 of file Lob.php.

00153     {
00154         return $this->outFile;
00155     }

Lob::isFromFile (  ) 

Returns whether this Lob is loaded from file.

This is useful for bypassing need to read in the contents of the Lob.

Returns:
boolean Whether this LOB is to be read from a file.

Definition at line 162 of file Lob.php.

Referenced by getContents().

00163     {
00164         return ($this->inFile !== null);
00165     }

Lob::isModified (  ) 

Whether LOB contents have been modified after initial setting.

Returns:
boolean TRUE if the contents have been modified after initial setting. FALSE if contents have not been modified or if no contents have bene set.

Definition at line 238 of file Lob.php.

00239     {
00240         // cast it so that NULL will also eval to false
00241         return (boolean) $this->modified;
00242     }

Lob::readFromFile ( file = null  ) 

Read LOB data from file (binary safe).

(Implementation may need to be moved into Clob / Blob subclasses, but since file_get_contents() is binary-safe, it hasn't been necessary so far.)

Parameters:
string $file Filename may also be specified here (if not specified using setInputFile()).
Returns:
void
Exceptions:
Exception - if no file specified or error on read.
See also:
setInputFile()

Reimplemented in Clob.

Definition at line 176 of file Lob.php.

References $data, setContents(), and setInputFile().

Referenced by getContents().

00177     {
00178         if ($file !== null) {
00179             $this->setInputFile($file);
00180         }
00181         if (!$this->inFile) {
00182             throw Exception('No file specified for read.');
00183         }        
00184         $data = @file_get_contents($this->inFile);
00185         if ($data === false) {
00186             throw new Exception('Unable to read from file: '.$this->inFile);
00187         }        
00188         $this->setContents($data);                
00189     }

Lob::setContents ( data  ) 

Set the contents of this LOB.

Sets the modified flag to FALSE if this is the first call to setContents() for this object. Sets the bit to TRUE if this any subsequent call to setContents().

Parameters:
string $bytes

Definition at line 93 of file Lob.php.

References $data.

Referenced by __construct(), readFromFile(), and Clob::readFromFile().

00094     {
00095         $this->data = $data;
00096                
00097         if ($this->modified === null) {
00098              // if modified bit hasn't been set yet,
00099             // then it should now be set to FALSE, since
00100             // we just did inital population
00101             $this->modified = false;
00102         } elseif ($this->modified === false) {
00103             // if it was already FALSE, then it should
00104             // now be set to TRUE, since this is a subsequent
00105             // modfiication.
00106             $this->modified = true;
00107         }
00108     }

Lob::setInputFile ( filePath  ) 

Specify the file that we want this LOB read from.

Parameters:
string $filePath The location of the file.
Returns:
void

Definition at line 124 of file Lob.php.

Referenced by readFromFile(), and Clob::readFromFile().

00125     {
00126         $this->inFile = $filePath;
00127     }    

Lob::setModified ( b  ) 

Set whether LOB contents have been modified after initial setting.

Parameters:
boolean $b

Definition at line 228 of file Lob.php.

00229     {
00230         $this->modified = $b;
00231     }

Lob::setOutputFile ( filePath  ) 

Specify the file that we want this LOB saved to.

Parameters:
string $filePath The location of the file.
Returns:
void

Definition at line 143 of file Lob.php.

Referenced by writeToFile(), and Clob::writeToFile().

00144     {
00145         $this->outFile = $filePath;        
00146     }

Lob::writeToFile ( file = null  ) 

Write LOB data to file (binary safe).

(Impl may need to move into subclasses, but so far not necessary.)

Parameters:
string $file Filename may also be specified here (if not set using setOutputFile()).
Exceptions:
Exception - if no file specified, no contents to write, or error on write.
See also:
setOutputFile()

Reimplemented in Clob.

Definition at line 199 of file Lob.php.

References setOutputFile().

00200     {
00201         if ($file !== null) {
00202             $this->setOutputFile($file);
00203         }        
00204         if (!$this->outFile) {
00205             throw new Exception('No file specified for write');
00206         }
00207         if ($this->data === null) {
00208             throw new Exception('No data to write to file');
00209         }        
00210         if (false === @file_put_contents($this->outFile, $this->data)) {
00211             throw new Exception('Unable to write to file: '.$this->outFile);
00212         }
00213     }


Member Data Documentation

Lob::$data [protected]

Definition at line 37 of file Lob.php.

Referenced by __construct(), readFromFile(), Clob::readFromFile(), and setContents().

Lob::$inFile [protected]

Definition at line 49 of file Lob.php.

Lob::$modified = null [private]

Definition at line 59 of file Lob.php.

Lob::$outFile [protected]

Definition at line 43 of file Lob.php.


The documentation for this class was generated from the following file:

Generated on Wed May 6 23:10:49 2009 for fareofficelib by  doxygen 1.5.8