1 package org.unicode.cldr.draft; 2 3 import java.text.ParseException; 4 import java.text.ParsePosition; 5 6 /** 7 * @author markdavis 8 * 9 */ 10 public interface Parser<T, S extends CharSequence> { 11 /** 12 * Parses text from the beginning of the given string to produce an object. 13 * The method may not use the entire text of the given string. 14 * 15 * @param source 16 * A <code>String</code> whose beginning should be parsed. 17 * @return An <code>Object</code> parsed from the string. 18 * @exception ParseException 19 * if the beginning of the specified string 20 * cannot be parsed. 21 */ parseObject(S source)22 public T parseObject(S source) throws ParseException; 23 24 /** 25 * Parses text from a string to produce an object. 26 * <p> 27 * The method attempts to parse text starting at the index given by <code>pos</code>. If parsing succeeds, then the 28 * index of <code>pos</code> is updated to the index after the last character used (parsing does not necessarily use 29 * all characters up to the end of the string), and the parsed object is returned. The updated <code>pos</code> can 30 * be used to indicate the starting point for the next call to this method. If an error occurs, then the index of 31 * <code>pos</code> is not changed, the error index of <code>pos</code> is set to the index of the character where 32 * the error occurred, and null is returned. 33 * 34 * @param source 35 * A <code>String</code>, part of which should be parsed. 36 * @param pos 37 * A <code>ParsePosition</code> object with index and error 38 * index information as described above. 39 * @return An <code>Object</code> parsed from the string. In case of 40 * error, returns null. 41 * @exception NullPointerException 42 * if <code>pos</code> is null. 43 */ parseObject(S source, ParsePosition pos)44 public T parseObject(S source, ParsePosition pos); 45 } 46