FileDocCategorySizeDatePackage
ParsePosition.javaAPI DocAndroid 1.5 API3667Wed May 06 22:41:06 BST 2009java.text

ParsePosition

public class ParsePosition extends Object
Tracks the current position in a parsed string. In case of an error the error index can be set to the position where the error occurred without having to change the parse position.
since
Android 1.0

Fields Summary
private int
currentPosition
private int
errorIndex
Constructors Summary
public ParsePosition(int index)
Constructs a new {@code ParsePosition} with the specified index.

param
index the index to begin parsing.
since
Android 1.0


                                        
       
        currentPosition = index;
    
Methods Summary
public booleanequals(java.lang.Object object)
Compares the specified object to this {@code ParsePosition} and indicates if they are equal. In order to be equal, {@code object} must be an instance of {@code ParsePosition} and it must have the same index and error index.

param
object the object to compare with this object.
return
{@code true} if the specified object is equal to this {@code ParsePosition}; {@code false} otherwise.
see
#hashCode
since
Android 1.0

        if (!(object instanceof ParsePosition)) {
            return false;
        }
        ParsePosition pos = (ParsePosition) object;
        return currentPosition == pos.currentPosition
                && errorIndex == pos.errorIndex;
    
public intgetErrorIndex()
Returns the index at which the parse could not continue.

return
the index of the parse error or -1 if there is no error.
since
Android 1.0

        return errorIndex;
    
public intgetIndex()
Returns the current parse position.

return
the current position.
since
Android 1.0

        return currentPosition;
    
public inthashCode()

        return currentPosition + errorIndex;
    
public voidsetErrorIndex(int index)
Sets the index at which the parse could not continue.

param
index the index of the parse error.
since
Android 1.0

        errorIndex = index;
    
public voidsetIndex(int index)
Sets the current parse position.

param
index the current parse position.
since
Android 1.0

        currentPosition = index;
    
public java.lang.StringtoString()
Returns the string representation of this parse position.

return
the string representation of this parse position.
since
Android 1.0

        return getClass().getName() + "[index=" + currentPosition //$NON-NLS-1$
                + ", errorIndex=" + errorIndex + "]"; //$NON-NLS-1$ //$NON-NLS-2$