//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\
// PLEASE DO NOT EDIT WITHOUT THE EXPLICIT CONSENT OF THE AUTHOR! \\
//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\
using System;
namespace Ilog.Language.Util
{
/**
* A class denoting a character's location as (line,column) in a text
* file.
*
* @version Last modified on Fri May 27 11:05:16 2005 by hak
* @author Hassan Aït-Kaci
* @copyright © 2000 ILOG, S.A.
*/
public class Location
{
private String _file = "";
private int _line;
private int _column;
public Location ()
{
}
public Location (int line, int column)
{
_line = line;
_column = column;
}
public Location (String file, int line, int column)
{
SetFile(file);
_line = line;
_column = column;
}
public Location SetFile (String file)
{
if (file != null)
_file = String.Intern(file);
return this;
}
public String GetFile ()
{
return _file;
}
public Location SetLine (int line)
{
_line = line;
return this;
}
public int GetLine ()
{
return _line;
}
public Location SetColumn (int column)
{
_column = column;
return this;
}
public int GetColumn ()
{
return _column;
}
/**
* Returns true if this location precedes the specified one.
* This makes sense only for if the locations are within the same file.
*/
public bool Precedes (Location other)
{
if (other == null)
throw new ApplicationException("Can't compare a null location");
return GetLine() == other.GetLine() && GetColumn() < other.GetColumn()
|| GetLine() < other.GetLine();
}
public override bool Equals (Object o)
{
if (!(o is Location))
return false;
return _file == ((Location)o).GetFile()
&& _line == ((Location)o).GetLine()
&& _column == ((Location)o).GetColumn();
}
public override int GetHashCode ()
{
return _file.GetHashCode() ^ _line ^ _column;
}
public override String ToString ()
{
return _file+"("+_line+","+_column+")";
}
}
}