Package nz.org.riskscape.dsl
Class Source
java.lang.Object
nz.org.riskscape.dsl.Source
Represents a bit of source code - something that we will parse using RiskScape's DSL API.
For now, this is effectively a wrapper around a string that remembers the location, but having a minimal matching API would allow:
- to parse the file without having to read the whole thing up front first.
- to not keep the whole thing in RAM once it's parsed.
But debatable whether it's worth the effort - but might improve start up times for larger projects?
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic SourceCreate a Source object that doesn't retain its location - avoid using this where possible.protected booleancharcharAt(int index) static SourceCreate a Source object from a string and a URIbooleanstatic SourceCreate a Source object from aResourcestatic SourceCreate a Source object from a file pathstatic Source@NonNull URIinthashCode()booleanbooleanintlength()booleanregionMatches(boolean b, int position, String string, int i, int length) booleanregionMatches(int position, String string, int i, int length) subSequence(int start, int end) substring(int begin) substring(int begin, int end) toString()toSummaryString(int maxLength)
-
Constructor Details
-
Source
-
-
Method Details
-
create
Create a Source object from a string and a URI
-
from
Create a Source object from a
Resource -
fromPath
Create a Source object from a file path
- Throws:
RiskscapeIOException
-
fromPath
- Throws:
RiskscapeIOException
-
anon
Create a Source object that doesn't retain its location - avoid using this where possible.
-
toString
-
isAnonymous
public boolean isAnonymous() -
readFully
-
length
public int length() -
charAt
public char charAt(int index) -
subSequence
-
substring
-
substring
-
isSingleLine
public boolean isSingleLine() -
regionMatches
-
regionMatches
-
toSummaryString
- Returns:
- a truncated version of the source, removing leading whitespace and showing only up to a max limit of characters (or the first line)
-
equals
-
canEqual
-
hashCode
public int hashCode() -
getLocation
-