The StaDyn Programming Language
Source code documentation of StaDyn, a hybrid static and dynamic typing language.
ErrorAdapter.cs
Go to the documentation of this file.
1 // --------------------------------------------------------------------------
3 // Project rROTOR
4 // --------------------------------------------------------------------------
5 // File: ErrorAdapter.cs
6 // Author: Francisco Ortin - francisco.ortin@gmail.com
7 // Description:
8 // Represents an adapter of existing features in every error.
9 // Implements Adapter pattern [Adapter].
10 // --------------------------------------------------------------------------
11 // Create date: 30-05-2007
12 // Modification date: 30-05-2007
14 
15 using System;
16 using System.Collections.Generic;
17 using System.Text;
18 
19 namespace ErrorManagement {
23  public class ErrorAdapter : IError {
24  #region Fields
25  // the ocurrence of an intem in the text program
29  protected Location location;
33  string description;
34  #endregion
35  #region Properties
36 
37 
38  public Location Location {
39  get { return location; }
40  }
41 
45  public string ErrorType {
46  get { return "Semantic error"; }
47  }
48 
52  public string Description {
53  get { return this.description; }
54  set { this.description = value; }
55  }
56 
57  #endregion
58 
59  #region Constructor
61  this.location = location;
62  }
63  public ErrorAdapter() {
64  this.location = new Location();
65  }
66  #endregion
67  #region Equals&GetHashCode
68  public override bool Equals(object obj) {
69  ErrorAdapter error = obj as ErrorAdapter;
70  if (error==null)
71  return false;
72  return error.description.Equals(this.description) &&location.Equals(error.location);
73  }
74  public override int GetHashCode() {
75  return this.description.GetHashCode() *location.GetHashCode();
76  }
77  #endregion
78 
79  }
80 }
string Description
Gets the description for the error type.
Definition: ErrorAdapter.cs:52
override bool Equals(object obj)
Definition: Location.cs:116
This class encapsulates a location in a specific file. Implements an Inmutable pattern. So it can be used in any context, that is his internal fields never change.
Definition: Location.cs:24
ErrorAdapter(Location location)
Definition: ErrorAdapter.cs:60
string ErrorType
Gets the name for the error type.
Definition: ErrorAdapter.cs:45
Interfaz for the different error types.
Definition: IError.cs:23
Represents an adapter of existing features in every error.
Definition: ErrorAdapter.cs:23
override int GetHashCode()
Definition: Location.cs:111
override bool Equals(object obj)
Definition: ErrorAdapter.cs:68