/src/org/ubi/FileLocation.java

http://github.com/nddrylliog/ooc · Java · 71 lines · 37 code · 14 blank · 20 comment · 0 complexity · b045d7b2bb92bd1441bf03f01a494066 MD5 · raw file

  1. package org.ubi;
  2. /**
  3. * Information about a location in a file
  4. *
  5. * @author Amos Wenger
  6. */
  7. public class FileLocation {
  8. protected String fileName;
  9. protected int lineNumber;
  10. protected int linePos;
  11. protected int index;
  12. protected int length;
  13. public FileLocation(String fileName, int lineNumber, int linePos, int index) {
  14. this(fileName, lineNumber, linePos, index, 1);
  15. }
  16. public FileLocation(String fileName, int lineNumber, int linePos, int index, int length) {
  17. this.fileName = fileName;
  18. this.lineNumber = lineNumber;
  19. this.linePos = linePos;
  20. this.index = index;
  21. this.length = length;
  22. }
  23. /**
  24. * @return the name of the file
  25. */
  26. public String getFileName() {
  27. return fileName;
  28. }
  29. /**
  30. * @return the line number
  31. */
  32. public int getLineNumber() {
  33. return lineNumber;
  34. }
  35. /**
  36. * @return the position in line (e.g. number of characters after the last newline)
  37. */
  38. public int getLinePos() {
  39. return linePos;
  40. }
  41. /**
  42. * @return the number of characters (including whitespace) since the beginning of the file
  43. */
  44. public int getIndex() {
  45. return index;
  46. }
  47. /**
  48. * @return the length of the interesting location, in characters
  49. */
  50. public int getLength() {
  51. return length;
  52. }
  53. @Override
  54. public String toString() {
  55. return " "+fileName+":"+getLineNumber()+":"+getLinePos();
  56. }
  57. }