//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\ // PLEASE DO NOT EDIT WITHOUT THE EXPLICIT CONSENT OF THE AUTHOR! \\ //\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\ using Ilog.Language.Util; namespace Ilog.Language.Parsing { /** * This is the class of objects representing errors. * * @version Last modified on Sun May 29 08:28:30 2005 by hak * @author Hassan Aït-Kaci * @copyright © 2001 ILOG, S.A. */ public class Error : Locatable { /** * A string starting this error's message. Default is "*** ". */ private string prefix = "*** "; public string Prefix { get { return prefix; } set { prefix = value; } } /** * A label identifying this error's message. Default is "Error: ". */ private string label = "Error: "; public string Label { get { return label; } set { label = value; } } /** * This error's message. Defaults to "an error happened". */ private string message = "an error happened"; public string Message { get { return message; } set { message = value; } } /** * This error's location indicator. Defaults to " - see ". */ private string see = " - see "; public string See { get { return see; } set { see = value; } } /** * This error's location extent. Defaults to null. */ private Locatable extent; public Locatable Extent { get { return extent; } set { extent = value; } } /** * Sets this error's prefix to the specified string, and returns * this error. */ public Error SetPrefix (string prefix) { this.prefix = prefix; return this; } /** * Sets this error's label to the specified string, and returns * this error. */ public Error SetLabel (string label) { this.label = label; return this; } /** * Sets this error's message to the specified string, and returns * this error. */ public Error SetMessage (string message) { this.message = message; return this; } /** * Sets this error's the string indicating this error's location * to specified string, and returns this error. */ public Error SetSee (string see) { this.see = see; return this; } /** * Sets this error's location extent to the specified Locatable, * and returns this error. */ public Error SetExtent (Locatable extent) { this.extent = extent; return this; } /** * Returns the start of this error's location extent as a Location. */ public Location GetStart () { return (extent == null) ? null : extent.GetStart(); } /** * Returns the end of this error's location extent as a Location. */ public Location GetEnd () { return (extent == null) ? null : extent.GetEnd(); } /** * Sets the start of this error's location extent to the specified * Location and returns this. */ public Locatable SetStart (Location location) { if (extent == null) extent = new Span(); extent.SetStart(location); return this; } /** * Sets the end of this error's location extent to the specified * Location and returns this. */ public Locatable SetEnd (Location location) { if (extent == null) extent = new Span(); extent.SetEnd(location); return this; } /** * Returns an explicit string describing the location extent. The * default is GetExtent().LocationString() if this * error's location extent is non null, or the empty * string otherwise. This method may be overridden. */ public virtual string LocationString () { return (extent == null) ? "" : extent.LocationString(); } /** * Returns a string composed of all the elements of this error in * the form: Prefix+Label+Message+See+LocationString(). * Thus, the default is "*** Error: an error happened - see * "+LocationString(). This method may be overridden. */ public override string ToString () { return prefix + label + message + see + LocationString(); } } }