KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > jfun > yan > xml > Location


1 package jfun.yan.xml;
2
3 /**
4  * This class represents a location within the config file.
5  *
6  * @author Ben Yu
7  *
8  */

9 public class Location implements java.io.Serializable JavaDoc {
10   private final String JavaDoc module;
11   private final int line;
12   private final int col;
13   /**
14    * Get the 1-based column number.
15    */

16   public int getColumnNo() {
17     return col;
18   }
19   /**
20    * Get the 1-based line number.
21    */

22   public int getLineNo() {
23     return line;
24   }
25   /**
26    * Get the module name.
27    */

28   public String JavaDoc getModule() {
29     return module;
30   }
31   /**
32    * To create a Location object.
33    * @param module the module name.
34    * @param line the line number.
35    * @param col the column number.
36    */

37   public Location(String JavaDoc module, int line, int col) {
38     this.col = col;
39     this.line = line;
40     this.module = module;
41   }
42   public boolean equals(Object JavaDoc obj) {
43     if(obj instanceof Location){
44       final Location other = (Location)obj;
45       return line==other.line && col==other.col && module.equals(other.module);
46     }
47     return false;
48   }
49   public int hashCode() {
50     return (module.hashCode()*31+line)*31+col;
51   }
52   public String JavaDoc toString() {
53     return module+"(line "+line+")";
54   }
55   
56 }
57
Popular Tags