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.intCompares this index with another given position.booleanReturns true if that is an index and both have the same value.inthashCode()Returns the hashcode of this index.booleanisIndex()Returns true.booleanisKey()Returns false.static Indexof(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:
compareToin 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.
-