laser.util
Class SourceInfo

java.lang.Object
  extended by laser.util.SourceInfo
All Implemented Interfaces:
java.io.Serializable, Annotation

public class SourceInfo
extends java.lang.Object
implements Annotation

The SourceInfo class holds information about a source location such as file name, line number, and character position.

Typically this information is connected to artifacts to allow the user to hyperlink back to the source.

Author:
Rick Hudson (laser-software@cs.umass.edu), Jamieson M. Cobleigh
See Also:
Serialized Form

Field Summary
static int CHARACTER_POSITION_DEFAULT
          The character position default value
static java.lang.String FILE_NAME_DEFAULT
          The file name default value
static int LINE_NUMBER_DEFAULT
          The line number default value
static java.lang.String SOURCE_INFO_SEPARATOR
          The SourceInfo separator
 
Constructor Summary
SourceInfo()
          Creates a new SourceInfo.
SourceInfo(java.lang.String inputString)
          Creates a new SourceInfo from the given input string.
SourceInfo(java.lang.String fileName, int lineNumber, int characterPosition)
          Creates a new SourceInfo with the given file name, line number, and character position.
 
Method Summary
 java.lang.Object clone()
          Returns a clone of this SourceInfo
 Annotation copyAnnotation(Annotatable container)
          Returns a copy of this SourceInfo
 java.util.Collection<Annotation> createAnnotationCollection()
          Creates a new empty Collection
 int getCharacterPosition()
          Gets the character position (column number)
 java.lang.String getFileName()
          Gets the name of the file
 int getLineNumber()
          Gets the line number
 void setCharacterPosition(int characterPosition)
          Sets the character position (column number)
 void setFileName(java.lang.String fileName)
          Sets the name of the file
 void setLineNumber(int lineNumber)
          Sets the line number
 java.lang.String toDot()
          Returns the dot representation of this SourceInfo.
 java.lang.String toString()
          Returns a string representation of this SourceInfo.
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface laser.util.Annotation
equals
 

Field Detail

FILE_NAME_DEFAULT

public static final java.lang.String FILE_NAME_DEFAULT
The file name default value


LINE_NUMBER_DEFAULT

public static final int LINE_NUMBER_DEFAULT
The line number default value

See Also:
Constant Field Values

CHARACTER_POSITION_DEFAULT

public static final int CHARACTER_POSITION_DEFAULT
The character position default value

See Also:
Constant Field Values

SOURCE_INFO_SEPARATOR

public static final java.lang.String SOURCE_INFO_SEPARATOR
The SourceInfo separator

See Also:
Constant Field Values
Constructor Detail

SourceInfo

public SourceInfo()
Creates a new SourceInfo. The file name, line number, and character position are set to their default values.

See Also:
FILE_NAME_DEFAULT, LINE_NUMBER_DEFAULT, CHARACTER_POSITION_DEFAULT

SourceInfo

public SourceInfo(java.lang.String inputString)
           throws java.lang.NumberFormatException
Creates a new SourceInfo from the given input string.

NOTE: The format is "fileName, lineNumber#, characterPosition#".

Parameters:
inputString - The input string to be parsed
Throws:
java.lang.NumberFormatException - if the line number or character position is not formatted correctly
NoSuchElementException - if all three parts are not specified

SourceInfo

public SourceInfo(java.lang.String fileName,
                  int lineNumber,
                  int characterPosition)
Creates a new SourceInfo with the given file name, line number, and character position.

Parameters:
fileName - The String name of the file
lineNumber - The int line number in the file
characterPosition - The int character position in the line in the file
Method Detail

getFileName

public java.lang.String getFileName()
Gets the name of the file

Returns:
The file name

setFileName

public void setFileName(java.lang.String fileName)
Sets the name of the file

Parameters:
fileName - The new file name

getLineNumber

public int getLineNumber()
Gets the line number

Returns:
The line number

setLineNumber

public void setLineNumber(int lineNumber)
Sets the line number

Parameters:
lineNumber - The new line number

getCharacterPosition

public int getCharacterPosition()
Gets the character position (column number)

Returns:
The character position

setCharacterPosition

public void setCharacterPosition(int characterPosition)
Sets the character position (column number)

Parameters:
characterPosition - the new character position

clone

public java.lang.Object clone()
Returns a clone of this SourceInfo

Overrides:
clone in class java.lang.Object
Returns:
A clone of this Object

createAnnotationCollection

public java.util.Collection<Annotation> createAnnotationCollection()
Creates a new empty Collection

Specified by:
createAnnotationCollection in interface Annotation
Returns:
The new empty Collection

copyAnnotation

public Annotation copyAnnotation(Annotatable container)
Returns a copy of this SourceInfo

Specified by:
copyAnnotation in interface Annotation
Parameters:
container - The containter to associate it with
Returns:
The copy of this Annotation

toDot

public java.lang.String toDot()
Returns the dot representation of this SourceInfo.

Returns:
A string which contains the dot form of this object

toString

public java.lang.String toString()
Returns a string representation of this SourceInfo.

Specified by:
toString in interface Annotation
Overrides:
toString in class java.lang.Object
Returns:
The string representation of this Object