Changeset 1359
- Timestamp:
- 02/22/08 18:13:10 (7 months ago)
- Files:
-
- trunk/src/main/php/net/stubbles/xml/stubAbstractXMLStreamWriter.php (modified) (4 diffs)
- trunk/src/main/php/net/stubbles/xml/stubDomXMLStreamWriter.php (modified) (2 diffs)
- trunk/src/main/php/net/stubbles/xml/stubLibXmlXMLStreamWriter.php (modified) (2 diffs)
- trunk/src/main/php/net/stubbles/xml/stubXMLStreamWriter.php (modified) (1 diff)
- trunk/src/test/php/net/stubbles/xml/stubDomXMLStreamWriterTestCase.php (modified) (1 diff)
- trunk/src/test/php/net/stubbles/xml/stubLibXmlXMLStreamWriterTestCase.php (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/src/main/php/net/stubbles/xml/stubAbstractXMLStreamWriter.php
r1296 r1359 1 1 <?php 2 2 /** 3 * Abstract base class for XML stream writers 3 * Abstract base class for XML stream writers. 4 4 * 5 5 * @author Stephan Schmidt <schst@stubbles.net> … … 9 9 */ 10 10 /** 11 * Abstract base class for XML stream writers 11 * Abstract base class for XML stream writers. 12 12 * 13 13 * @package stubbles … … 34 34 */ 35 35 protected $features = array(); 36 /** 37 * depth, i.e. amount of opened tags 38 * 39 * @var int 40 */ 41 protected $depth = 0; 36 42 37 43 /** … … 65 71 return in_array($feature, $this->features); 66 72 } 73 74 /** 75 * Write an opening tag 76 * 77 * @param string $elementName 78 */ 79 public function writeStartElement($elementName) 80 { 81 $this->doWriteStartElement($elementName); 82 $this->depth++; 83 } 84 85 /** 86 * really writes an opening tag 87 * 88 * @param string $elementName 89 */ 90 protected abstract function doWriteStartElement($elementName); 91 92 /** 93 * Write an end element 94 */ 95 public function writeEndElement() 96 { 97 $this->doWriteEndElement(); 98 $this->depth--; 99 } 100 101 /** 102 * really writes an end element 103 */ 104 protected abstract function doWriteEndElement(); 105 106 /** 107 * checks whether the document is finished meaning no open tags are left 108 * 109 * @return bool 110 */ 111 public function isFinished() 112 { 113 return 0 === $this->depth; 114 } 67 115 } 68 116 ?> trunk/src/main/php/net/stubbles/xml/stubDomXMLStreamWriter.php
r1301 r1359 63 63 64 64 /** 65 * Writean opening tag65 * really writes an opening tag 66 66 * 67 67 * @param string $elementName 68 68 * @throws stubXMLException 69 69 */ 70 p ublic function writeStartElement($elementName)70 protected function doWriteStartElement($elementName) 71 71 { 72 72 try { … … 226 226 227 227 /** 228 * Writean end element229 * 230 * @throws stubXMLException 231 */ 232 p ublic function writeEndElement()228 * really writes an end element 229 * 230 * @throws stubXMLException 231 */ 232 protected function doWriteEndElement() 233 233 { 234 234 if (count($this->elementStack) === 0) { trunk/src/main/php/net/stubbles/xml/stubLibXmlXMLStreamWriter.php
r1301 r1359 62 62 63 63 /** 64 * Writean opening tag64 * really writes an opening tag 65 65 * 66 66 * @param string $elementName 67 67 */ 68 p ublic function writeStartElement($elementName)68 protected function doWriteStartElement($elementName) 69 69 { 70 70 $this->writer->startElement($elementName); … … 134 134 135 135 /** 136 * Writean end element136 * really writes an end element 137 137 */ 138 p ublic function writeEndElement()138 protected function doWriteEndElement() 139 139 { 140 140 $this->writer->endElement(); trunk/src/main/php/net/stubbles/xml/stubXMLStreamWriter.php
r1301 r1359 138 138 139 139 /** 140 * checks whether the document is finished meaning no open tags are left 141 * 142 * @return bool 143 */ 144 public function isFinished(); 145 146 /** 140 147 * Return the XML as a string 141 148 * trunk/src/test/php/net/stubbles/xml/stubDomXMLStreamWriterTestCase.php
r1271 r1359 340 340 $writer->writeEndElement(); 341 341 } 342 343 /** 344 * checks if the finished status is reported properly 345 * 346 * @test 347 */ 348 public function isFinished() 349 { 350 $writer = new stubDomXMLStreamWriter(); 351 $this->assertTrue($writer->isFinished()); 352 $writer->writeStartElement('root'); 353 $this->assertFalse($writer->isFinished()); 354 $writer->writeEndElement(); 355 $this->assertTrue($writer->isFinished()); 356 } 342 357 } 343 358 ?> trunk/src/test/php/net/stubbles/xml/stubLibXmlXMLStreamWriterTestCase.php
r1271 r1359 199 199 $this->assertTrue($writer->hasFeature(stubXMLStreamWriter::FEATURE_AS_DOM)); 200 200 $this->assertFalse($writer->hasFeature(stubXMLStreamWriter::FEATURE_IMPORT_WRITER)); 201 } 201 } 202 203 /** 204 * checks if the finished status is reported properly 205 * 206 * @test 207 */ 208 public function isFinished() 209 { 210 $writer = new stubLibXmlXMLStreamWriter(); 211 $this->assertTrue($writer->isFinished()); 212 $writer->writeStartElement('root'); 213 $this->assertFalse($writer->isFinished()); 214 $writer->writeEndElement(); 215 $this->assertTrue($writer->isFinished()); 216 } 202 217 } 203 218 ?>
