public final class Source extends Object
Modifier and Type | Method and Description |
---|---|
boolean |
equals(Object obj) |
String |
getBase()
Get the "directory" part of the file or "base" of the URL.
|
int |
getColumn(int position)
Return column number of character position.
|
String |
getContent()
Get the content of this source as a
String . |
String |
getDigest()
Get a Base64-encoded SHA1 digest for this source.
|
String |
getExplicitURL()
Get explicit source URL.
|
long |
getLastModified()
Get the last modified time of this script.
|
int |
getLength()
Get the length in chars for this source
|
int |
getLine(int position)
Return line number of character position.
|
String |
getName()
Get the user supplied name of this script.
|
String |
getSourceLine(int position)
Return line text including character position.
|
String |
getString(int start,
int len)
Fetch a portion of source content.
|
String |
getString(long token)
Fetch a portion of source content associated with a token.
|
URL |
getURL()
Returns the source URL of this script Source.
|
int |
hashCode() |
boolean |
isEvalCode()
Returns whether this source was submitted via 'eval' call or not.
|
static String |
readFully(Reader reader)
Read all of the source until end of file.
|
void |
setExplicitURL(String explicitURL)
Set explicit source URL.
|
static Source |
sourceFor(String name,
CharSequence content,
boolean isEval)
Returns a Source instance
|
static Source |
sourceFor(String name,
String content)
Returns a Source instance
|
String |
toString() |
public static Source sourceFor(String name, CharSequence content, boolean isEval)
name
- source namecontent
- contents as CharSequence
isEval
- does this represent code from 'eval' call?public static Source sourceFor(String name, String content)
name
- source namecontent
- contents as stringpublic String getName()
public long getLastModified()
public String getBase()
public String getString(int start, int len)
start
- start index in sourcelen
- length of portionpublic String getString(long token)
token
- Token descriptor.public URL getURL()
public String getExplicitURL()
public void setExplicitURL(String explicitURL)
explicitURL
- URL set via sourceURL directivepublic boolean isEvalCode()
public int getLine(int position)
This method can be expensive for large sources as it iterates through all characters up to
position
.
position
- Position of character in source content.public int getColumn(int position)
position
- Position of character in source content.public String getSourceLine(int position)
position
- Position of character in source content.public int getLength()
public static String readFully(Reader reader) throws IOException
reader
- reader opened to source streamIOException
- if source could not be readpublic String getDigest()