public class SourceModel extends java.lang.Object implements LineNumberConverter, java.lang.Cloneable
Modifier and Type | Field and Description |
---|---|
protected int |
countImportLines
The number of import lines in the initial script.
|
protected java.util.SortedMap<java.lang.Integer,Var> |
fields
The fields.
|
protected boolean |
hasSingletonMethod
True if there is a singleton method.
|
protected java.util.SortedMap<java.lang.Integer,Method> |
methods
The methods.
|
Constructor and Description |
---|
SourceModel(java.lang.String scriptContent,
boolean hasSingletonMethod,
int offset,
int countImportLines)
Constructor.
|
Modifier and Type | Method and Description |
---|---|
void |
addField(Var var)
Add a field.
|
void |
addMethod(Method method)
Add a method.
|
SourceModel |
clone() |
int |
countImportLines()
Return the number of import lines.
|
java.util.SortedMap<java.lang.Integer,Var> |
getFields()
Return the fields.
|
java.util.SortedSet<Var> |
getFieldVariables()
Return the list of variables seen in a specified line number.
|
int |
getFirstLine()
Return the first effective line of the script, after the import declarations.
|
int |
getLineNumber(int lineNumber,
boolean isException)
Return the effective line number of a line detected in the script runtime.
|
java.util.SortedMap<java.lang.Integer,Method> |
getMethods()
Return the methods.
|
int |
getOffset()
Return the offset.
|
java.lang.String |
getScriptContent()
Return the script content.
|
java.lang.String |
getSource(int lineNumber)
Return the source for a line number.
|
java.util.SortedSet<Var> |
getVariables(int lineNumber)
Return the list of variables seen in a specified line number.
|
boolean |
hasSingletonMethod()
Return true if there is a singleton method.
|
protected void |
replace(SourceModel model)
Replace the content of the model.
|
void |
setFirstLine(int firstLine)
Set the first effective line of the script, after the import declarations.
|
void |
setScriptContent(java.lang.String scriptContent)
Set the script content.
|
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
getLineNumber
protected boolean hasSingletonMethod
protected int countImportLines
protected final java.util.SortedMap<java.lang.Integer,Var> fields
protected final java.util.SortedMap<java.lang.Integer,Method> methods
public SourceModel(java.lang.String scriptContent, boolean hasSingletonMethod, int offset, int countImportLines)
scriptContent
- the script contenthasSingletonMethod
- true if there is a singleton methodoffset
- the line offsetcountImportLines
- the number of specific import lines in the scriptpublic void setScriptContent(java.lang.String scriptContent)
scriptContent
- the script contentpublic boolean hasSingletonMethod()
public int getOffset()
public int countImportLines()
protected final void replace(SourceModel model) throws java.lang.CloneNotSupportedException
model
- the source modeljava.lang.CloneNotSupportedException
public SourceModel clone() throws java.lang.CloneNotSupportedException
clone
in class java.lang.Object
java.lang.CloneNotSupportedException
public java.lang.String getScriptContent()
public void setFirstLine(int firstLine)
firstLine
- the first effective line of the scriptpublic int getFirstLine()
public void addMethod(Method method)
method
- the methodpublic void addField(Var var)
var
- the fieldpublic java.util.SortedSet<Var> getFieldVariables()
public java.util.SortedSet<Var> getVariables(int lineNumber)
lineNumber
- the line numberpublic java.util.SortedMap<java.lang.Integer,Var> getFields()
public java.util.SortedMap<java.lang.Integer,Method> getMethods()
public int getLineNumber(int lineNumber, boolean isException)
getLineNumber
in interface LineNumberConverter
lineNumber
- the line numberisException
- true for getting the line number for an exceptionpublic java.lang.String getSource(int lineNumber)
lineNumber
- the line numberCopyright © 2019-2024 Herve Girod. All Rights Reserved. Documentation and source under the BSD licence