org.erights.e.elib.base
Class SourceSpan

java.lang.Object
  |
  +--org.erights.e.elib.base.SourceSpan
All Implemented Interfaces:
DeepPassByCopy, Marker, PassByConstruction, Persistent, Selfless, Serializable

public class SourceSpan
extends Object
implements Persistent, DeepPassByCopy

Untamed: A description of where a particular piece of Twine came from, such as a range of source code, suitable for use by a debugger.

Woven into a piece of Twine so it remembers where it came from.

Author:
Mark S. Miller
See Also:
Serialized Form

Field Summary
private  int myEndCol
           
private  int myEndLine
           
private  boolean myIsOneToOne
           
private  int myStartCol
           
private  int myStartLine
           
private  String myUrl
           
private static long serialVersionUID
           
static StaticMaker SourceSpanMaker
          Enabled:
 
Fields inherited from interface org.erights.e.elib.serial.Persistent
HONORARY, HONORED_NAMES
 
Fields inherited from interface org.erights.e.elib.serial.DeepPassByCopy
HONORARY, HONORED_NAMES
 
Constructor Summary
SourceSpan(String url, boolean isOneToOne, int startLine, int startCol, int endLine, int endCol)
          Enabled:
 
Method Summary
 int getEndCol()
          Enabled: Position of last character of span within this last line.
 int getEndLine()
          Enabled: Line number of line holding the last character of the span.
 Object[] getSpreadUncall()
          Enabled: '__makeSourceSpan(myUrl, myIsOneToOne, myStartLine, myStartCol, myEndLine, myEndCol)'
 int getStartCol()
          Enabled: Position of first character of span within the first line.
 int getStartLine()
          Enabled: Line number of beginning of span, in the text unit (file?) described by url.
 String getUrl()
          Enabled: Where might (this version of) the source text be found? Users of SourceSpan should prevent or prepare for the possibility that the text retrieved from a remembered Url may no longer be the original version.
 boolean isOneToOne()
          Enabled: Does each character in that Twine map to the corresponding source character position?
 SourceSpan notOneToOne()
          Enabled: Return a non-oneToOne form of this SourceSpan
static SourceSpan optCover(SourceSpan optA, SourceSpan optB)
          Enabled: Returns a new SourceSpan that covers the original two.
 String toString()
          Suppressed:
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

serialVersionUID

private static final long serialVersionUID

SourceSpanMaker

public static final StaticMaker SourceSpanMaker
Enabled:


myUrl

private final String myUrl

myIsOneToOne

private final boolean myIsOneToOne

myStartLine

private final int myStartLine

myStartCol

private final int myStartCol

myEndLine

private final int myEndLine

myEndCol

private final int myEndCol
Constructor Detail

SourceSpan

public SourceSpan(String url,
                  boolean isOneToOne,
                  int startLine,
                  int startCol,
                  int endLine,
                  int endCol)
Enabled:

Method Detail

getSpreadUncall

public Object[] getSpreadUncall()
Enabled: '__makeSourceSpan(myUrl, myIsOneToOne, myStartLine, myStartCol, myEndLine, myEndCol)'

Specified by:
getSpreadUncall in interface Selfless

getUrl

public String getUrl()
Enabled: Where might (this version of) the source text be found? Users of SourceSpan should prevent or prepare for the possibility that the text retrieved from a remembered Url may no longer be the original version. When possible, version integrity information should be included in the Url, like a cryptographic hash of the contents. However, such issues are beyond the scope of SourceSpan or Twine by themselves. To them, the Url is simply a String.


isOneToOne

public boolean isOneToOne()
Enabled: Does each character in that Twine map to the corresponding source character position?

If so, then startLine must be the same as endLine, and the described Twine's size should be 'endCol - startCol + 1'. Otherwise, all the characters in the Twine map to all the characters described by this SourceSpan.


getStartLine

public int getStartLine()
Enabled: Line number of beginning of span, in the text unit (file?) described by url. Line numbers are counted starting at 1.


getStartCol

public int getStartCol()
Enabled: Position of first character of span within the first line. Column numbers are couunted starting at 0.


getEndLine

public int getEndLine()
Enabled: Line number of line holding the last character of the span. Note, this is inclusive.


getEndCol

public int getEndCol()
Enabled: Position of last character of span within this last line. Note, this is inclusive.


optCover

public static SourceSpan optCover(SourceSpan optA,
                                  SourceSpan optB)
Enabled: Returns a new SourceSpan that covers the original two.

Either input may be null, as may the output. If either input is null, the result is null. If the two don't have the same Url, the result is null. Finally, the result describes the minimal span that includes both the originals. Iff the originals are both oneToOne and optB immediately follows optA on the same line, then the result is also oneToOne.


notOneToOne

public SourceSpan notOneToOne()
Enabled: Return a non-oneToOne form of this SourceSpan


toString

public String toString()
Suppressed:

Overrides:
toString in class Object
Returns:
a string representation of the object.


comments?