Code example for ParsePosition

Methods: getIndex, setErrorIndex, setIndex

0
     */ 
    public static boolean parseFixedstring(final String source,
                                           final String expected,
                                           final ParsePosition pos) {
 
        final int startIndex = pos.getIndex();
        final int endIndex = startIndex + expected.length();
        if ((startIndex >= source.length()) ||
            (endIndex > source.length()) ||
            (source.substring(startIndex, endIndex).compareTo(expected) != 0)) {
            // set index back to start, error index should be the start index 
            pos.setIndex(startIndex);
            pos.setErrorIndex(startIndex);
            return false; 
        } 
 
        // the string was here 
        pos.setIndex(endIndex);
        return true; 
    } 
 
    /** 
     * Formats a double value to produce a string.  In general, the value is