java.lang.Object
jsonvalues.Index
- All Implemented Interfaces:
Comparable<Position>
,Position
Represents the index of a value in a JSON array.
-
Field Summary
Fields -
Method Summary
Modifier and TypeMethodDescriptionasIndex()
Returns this index.asKey()
throws an UserError exception.int
Compares this index with another given position.boolean
Returns true if that is an index and both have the same value.int
hashCode()
Returns the hashcode of this index.boolean
isIndex()
Returns true.boolean
isKey()
Returns false.static Index
of
(int index) Returns a new instance witch represents the given index in an array.toString()
Returns the value of the index as a string.
-
Field Details
-
n
public final int nThe index number.
-
-
Method Details
-
of
Returns a new instance witch represents the given index in an array.- Parameters:
index
- the given position- Returns:
- an Index object
- Throws:
IndexOutOfBoundsException
- if the index is less than -1
-
compareTo
Compares this index with another given position. If the given position is an index, both are compared numerically, if it's a key, both are compared lexicographically.- Specified by:
compareTo
in interfaceComparable<Position>
- Parameters:
o
- the given position- Returns:
- 0 if they are equal, +1 if this is greater, -1 otherwise
-
asKey
throws an UserError exception. -
asIndex
Returns this index. -
isIndex
public boolean isIndex()Returns true. -
isKey
public boolean isKey()Returns false. -
hashCode
public int hashCode()Returns the hashcode of this index. -
equals
Returns true if that is an index and both have the same value. -
toString
Returns the value of the index as a string.
-