java.lang.Object
org.bzdev.util.JSUtilities.Locator
- Enclosing class:
- JSUtilities
Determines a location in nested instances of
JSObject
and JSArray
.
To capture a location, set the locator and then use the
constructor Location(Locator)
.
When parsing or traversing a tree of nested instances of
JSObject
and JSArray
, one will call
pushLevel()
when starting to process an object
and popLevel()
when done. The method
setKey(String)
for each property name (or key) in a
JSObject
, and incrList()
is called whenever
moving to the next element in a JSArray
.
For a parser, each time the location changes one should use the
constructor Location(Locator)
to capture the
current location and add a map entry mapping that location to
an instance of JSUtilities.LocationPair
that contains the corresponding
line number and column number.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
incrList()
Increment the index at the current nesting level and remove any key that was set at this level.void
popLevel()
Add remove the deepest nesting level.void
Add the nest nesting level.void
Set the key for the current nesting level.int
size()
Get current nesting depth.toString()
-
Constructor Details
-
Locator
public Locator()Constructor.
-
-
Method Details
-
size
public int size()Get current nesting depth. The value is the sum of the number of keys and indexes at the current point in nested instances ofJSObject
andJSArray
.- Returns:
- the nesting depth
-
pushLevel
public void pushLevel()Add the nest nesting level. -
popLevel
public void popLevel()Add remove the deepest nesting level. -
incrList
public void incrList()Increment the index at the current nesting level and remove any key that was set at this level. -
setKey
Set the key for the current nesting level.- Parameters:
value
- the key
-
toString
-