Location.php 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. <?php
  2. /*
  3. * $Id: Location.php 905 2010-10-05 16:28:03Z mrook $
  4. *
  5. * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
  6. * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
  7. * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
  8. * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
  9. * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
  10. * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  11. * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
  12. * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
  13. * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  14. * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
  15. * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  16. *
  17. * This software consists of voluntary contributions made by many individuals
  18. * and is licensed under the LGPL. For more information please see
  19. * <http://phing.info>.
  20. */
  21. /**
  22. * Stores the file name and line number of a XML file
  23. *
  24. * @author Andreas Aderhold <andi@binarycloud.com>
  25. * @copyright © 2001,2002 THYRELL. All rights reserved
  26. * @version $Revision: 905 $ $Date: 2010-10-05 18:28:03 +0200 (Tue, 05 Oct 2010) $
  27. * @access public
  28. * @package phing.parser
  29. */
  30. class Location {
  31. private $fileName;
  32. private $lineNumber;
  33. private $columnNumber;
  34. /**
  35. * Constructs the location consisting of a file name and line number
  36. *
  37. * @param string the filename
  38. * @param integer the line number
  39. * @param integer the column number
  40. * @access public
  41. */
  42. function Location($fileName = null, $lineNumber = null, $columnNumber = null) {
  43. $this->fileName = $fileName;
  44. $this->lineNumber = $lineNumber;
  45. $this->columnNumber = $columnNumber;
  46. }
  47. /**
  48. * Returns the file name, line number and a trailing space.
  49. *
  50. * An error message can be appended easily. For unknown locations,
  51. * returns empty string.
  52. *
  53. * @return string the string representation of this Location object
  54. * @access public
  55. */
  56. function toString() {
  57. $buf = "";
  58. if ($this->fileName !== null) {
  59. $buf.=$this->fileName;
  60. if ($this->lineNumber !== null) {
  61. $buf.= ":".$this->lineNumber;
  62. }
  63. $buf.=":".$this->columnNumber;
  64. }
  65. return (string) $buf;
  66. }
  67. function __toString () {
  68. return $this->toString();
  69. }
  70. }