1 33 34 package edu.rice.cs.drjava.model; 35 36 import java.io.File ; 37 import java.lang.ref.WeakReference ; 38 import javax.swing.text.Position ; 39 40 44 public class StaticDocumentRegion implements DocumentRegion { 45 protected final OpenDefinitionsDocument _doc; 46 protected final File _file; 47 protected final int _startOffset; 48 protected final int _endOffset; 49 protected final String _string; 50 51 52 public StaticDocumentRegion(OpenDefinitionsDocument doc, File file, int so, int eo, String s) { 53 _doc = doc; 54 _file = file; 55 _startOffset = so; 56 _endOffset = eo; 57 _string = s; 58 } 59 60 61 public OpenDefinitionsDocument getDocument() { return _doc; } 62 63 64 public File getFile() { return _file; } 65 66 67 public int getStartOffset() { 68 return ((_doc==null)||(_doc.getLength()>=_startOffset))?_startOffset:_doc.getLength(); 69 } 70 71 72 public int getEndOffset() { 73 return ((_doc==null)||(_doc.getLength()>=_endOffset))?_endOffset:_doc.getLength(); 74 } 75 76 77 public String getString() { 78 return _string; 79 } 80 81 82 public boolean equals(Object other) { 83 if (!(other instanceof StaticDocumentRegion) || (other==null)) return false; 84 StaticDocumentRegion o = (StaticDocumentRegion)other; 85 return ((((_doc==null) && (o._doc==null)) || (_doc.equals(o._doc))) && 86 (((_file==null) && (o._file==null)) || (_file.equals(o._file))) && 87 (_startOffset == o._startOffset) && 88 (_endOffset == o._endOffset) && 89 (_string.equals(o._string))); 90 } 91 92 public String toString() { 93 return ((_doc!=null)?_doc.toString():"null") + " "+_startOffset+" .. "+_endOffset; 94 } 95 } 96 | Popular Tags |