| 1 |
lars |
1 |
<?php
|
|
|
2 |
/*
|
|
|
3 |
* $Id: Location.php 123 2006-09-14 20:19:08Z 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 |
/**
|
|
|
23 |
* Stores the file name and line number of a XML file
|
|
|
24 |
*
|
|
|
25 |
* @author Andreas Aderhold <andi@binarycloud.com>
|
|
|
26 |
* @copyright © 2001,2002 THYRELL. All rights reserved
|
|
|
27 |
* @version $Revision: 1.6 $ $Date: 2006-09-14 22:19:08 +0200 (Thu, 14 Sep 2006) $
|
|
|
28 |
* @access public
|
|
|
29 |
* @package phing.parser
|
|
|
30 |
*/
|
|
|
31 |
|
|
|
32 |
class Location {
|
|
|
33 |
|
|
|
34 |
private $fileName;
|
|
|
35 |
private $lineNumber;
|
|
|
36 |
private $columnNumber;
|
|
|
37 |
|
|
|
38 |
/**
|
|
|
39 |
* Constructs the location consisting of a file name and line number
|
|
|
40 |
*
|
|
|
41 |
* @param string the filename
|
|
|
42 |
* @param integer the line number
|
|
|
43 |
* @param integer the column number
|
|
|
44 |
* @access public
|
|
|
45 |
*/
|
|
|
46 |
function Location($fileName = null, $lineNumber = null, $columnNumber = null) {
|
|
|
47 |
$this->fileName = $fileName;
|
|
|
48 |
$this->lineNumber = $lineNumber;
|
|
|
49 |
$this->columnNumber = $columnNumber;
|
|
|
50 |
}
|
|
|
51 |
|
|
|
52 |
/**
|
|
|
53 |
* Returns the file name, line number and a trailing space.
|
|
|
54 |
*
|
|
|
55 |
* An error message can be appended easily. For unknown locations,
|
|
|
56 |
* returns empty string.
|
|
|
57 |
*
|
|
|
58 |
* @return string the string representation of this Location object
|
|
|
59 |
* @access public
|
|
|
60 |
*/
|
|
|
61 |
function toString() {
|
|
|
62 |
$buf = "";
|
|
|
63 |
if ($this->fileName !== null) {
|
|
|
64 |
$buf.=$this->fileName;
|
|
|
65 |
if ($this->lineNumber !== null) {
|
|
|
66 |
$buf.= ":".$this->lineNumber;
|
|
|
67 |
}
|
|
|
68 |
$buf.=":".$this->columnNumber;
|
|
|
69 |
}
|
|
|
70 |
return (string) $buf;
|
|
|
71 |
}
|
|
|
72 |
}
|