Class Source
java.lang.Object
com.oracle.js.parser.Source
-
Method Summary
Modifier and TypeMethodDescriptionbooleangetBase()Get the "directory" part of the file or "base" of the URL.intgetColumn(int position) Return column number of character position.Get the content of this source as aString.Get explicit source URL.longGet the last modified time of this script.intGet the length in chars for this sourceintgetLine(int position) Return line number of character position.getName()Get the user supplied name of this script.getSourceLine(int position) Return line text including character position.getString(int start, int len) Fetch a portion of source content.getString(long token) Fetch a portion of source content associated with a token.getURL()Returns the source URL of this script Source.inthashCode()booleanReturns whether this source was submitted via 'eval' call or not.static StringRead all of the source until end of file.voidsetExplicitURL(String explicitURL) Set explicit source URL.static SourcesourceFor(String name, CharSequence content, boolean isEval) Returns a Source instancestatic SourceReturns a Source instancetoString()
-
Method Details
-
sourceFor
Returns a Source instance- Parameters:
name- source namecontent- contents asCharSequenceisEval- does this represent code from 'eval' call?- Returns:
- source instance
-
sourceFor
-
equals
-
hashCode
-
getName
Get the user supplied name of this script.- Returns:
- User supplied source name.
-
getLastModified
public long getLastModified()Get the last modified time of this script.- Returns:
- Last modified time.
-
getBase
Get the "directory" part of the file or "base" of the URL.- Returns:
- base of file or URL.
-
getString
Fetch a portion of source content.- Parameters:
start- start index in sourcelen- length of portion- Returns:
- Source content portion.
-
getString
Fetch a portion of source content associated with a token.- Parameters:
token- Token descriptor.- Returns:
- Source content portion.
-
getURL
Returns the source URL of this script Source. Can be null if Source was created from a String or a char[].- Returns:
- URL source or null
-
getExplicitURL
-
setExplicitURL
Set explicit source URL.- Parameters:
explicitURL- URL set via sourceURL directive
-
isEvalCode
public boolean isEvalCode()Returns whether this source was submitted via 'eval' call or not.- Returns:
- true if this source represents code submitted via 'eval'
-
getLine
public int getLine(int position) Return line number of character position.This method can be expensive for large sources as it iterates through all characters up to
position.- Parameters:
position- Position of character in source content.- Returns:
- Line number.
-
getColumn
public int getColumn(int position) Return column number of character position.- Parameters:
position- Position of character in source content.- Returns:
- Column number.
-
getSourceLine
Return line text including character position.- Parameters:
position- Position of character in source content.- Returns:
- Line text.
-
getContent
-
getLength
public int getLength()Get the length in chars for this source- Returns:
- length
-
readFully
Read all of the source until end of file.- Parameters:
reader- reader opened to source stream- Returns:
- source as content
- Throws:
IOException- if source could not be read
-
toString
-