< prev index next >

jdk/src/java.base/share/classes/java/text/Format.java

Print this page




 209     /**
 210      * Parses text from a string to produce an object.
 211      * <p>
 212      * The method attempts to parse text starting at the index given by
 213      * <code>pos</code>.
 214      * If parsing succeeds, then the index of <code>pos</code> is updated
 215      * to the index after the last character used (parsing does not necessarily
 216      * use all characters up to the end of the string), and the parsed
 217      * object is returned. The updated <code>pos</code> can be used to
 218      * indicate the starting point for the next call to this method.
 219      * If an error occurs, then the index of <code>pos</code> is not
 220      * changed, the error index of <code>pos</code> is set to the index of
 221      * the character where the error occurred, and null is returned.
 222      *
 223      * @param source A <code>String</code>, part of which should be parsed.
 224      * @param pos A <code>ParsePosition</code> object with index and error
 225      *            index information as described above.
 226      * @return An <code>Object</code> parsed from the string. In case of
 227      *         error, returns null.
 228      * @exception NullPointerException if <code>pos</code> is null.

 229      */
 230     public abstract Object parseObject (String source, ParsePosition pos);
 231 
 232     /**
 233      * Parses text from the beginning of the given string to produce an object.
 234      * The method may not use the entire text of the given string.
 235      *
 236      * @param source A <code>String</code> whose beginning should be parsed.
 237      * @return An <code>Object</code> parsed from the string.
 238      * @exception ParseException if the beginning of the specified string
 239      *            cannot be parsed.

 240      */
 241     public Object parseObject(String source) throws ParseException {
 242         ParsePosition pos = new ParsePosition(0);
 243         Object result = parseObject(source, pos);
 244         if (pos.index == 0) {
 245             throw new ParseException("Format.parseObject(String) failed",
 246                 pos.errorIndex);
 247         }
 248         return result;
 249     }
 250 
 251     /**
 252      * Creates and returns a copy of this object.
 253      *
 254      * @return a clone of this instance.
 255      */
 256     public Object clone() {
 257         try {
 258             return super.clone();
 259         } catch (CloneNotSupportedException e) {




 209     /**
 210      * Parses text from a string to produce an object.
 211      * <p>
 212      * The method attempts to parse text starting at the index given by
 213      * <code>pos</code>.
 214      * If parsing succeeds, then the index of <code>pos</code> is updated
 215      * to the index after the last character used (parsing does not necessarily
 216      * use all characters up to the end of the string), and the parsed
 217      * object is returned. The updated <code>pos</code> can be used to
 218      * indicate the starting point for the next call to this method.
 219      * If an error occurs, then the index of <code>pos</code> is not
 220      * changed, the error index of <code>pos</code> is set to the index of
 221      * the character where the error occurred, and null is returned.
 222      *
 223      * @param source A <code>String</code>, part of which should be parsed.
 224      * @param pos A <code>ParsePosition</code> object with index and error
 225      *            index information as described above.
 226      * @return An <code>Object</code> parsed from the string. In case of
 227      *         error, returns null.
 228      * @exception NullPointerException if <code>pos</code> is null.
 229      * @throws NullPointerException if {@code source} is null.
 230      */
 231     public abstract Object parseObject (String source, ParsePosition pos);
 232 
 233     /**
 234      * Parses text from the beginning of the given string to produce an object.
 235      * The method may not use the entire text of the given string.
 236      *
 237      * @param source A <code>String</code> whose beginning should be parsed.
 238      * @return An <code>Object</code> parsed from the string.
 239      * @exception ParseException if the beginning of the specified string
 240      *            cannot be parsed.
 241      * @throws NullPointerException if {@code source} is null.
 242      */
 243     public Object parseObject(String source) throws ParseException {
 244         ParsePosition pos = new ParsePosition(0);
 245         Object result = parseObject(source, pos);
 246         if (pos.index == 0) {
 247             throw new ParseException("Format.parseObject(String) failed",
 248                 pos.errorIndex);
 249         }
 250         return result;
 251     }
 252 
 253     /**
 254      * Creates and returns a copy of this object.
 255      *
 256      * @return a clone of this instance.
 257      */
 258     public Object clone() {
 259         try {
 260             return super.clone();
 261         } catch (CloneNotSupportedException e) {


< prev index next >