1 /*
2  *  Copyright 2001-2014 Stephen Colebourne
3  *
4  *  Licensed under the Apache License, Version 2.0 (the "License");
5  *  you may not use this file except in compliance with the License.
6  *  You may obtain a copy of the License at
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
10  *  Unless required by applicable law or agreed to in writing, software
11  *  distributed under the License is distributed on an "AS IS" BASIS,
12  *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  *  See the License for the specific language governing permissions and
14  *  limitations under the License.
15  */

16 package org.joda.time.format;
17
18 /**
19  * Internal interface for parsing textual representations of datetimes.
20  * <p>
21  * This has been separated from {@link DateTimeParser} to change to using
22  * {@code CharSequence}.
23  *
24  * @author Stephen Colebourne
25  * @since 2.4
26  */

27 interface InternalParser {
28
29     /**
30      * Returns the expected maximum number of characters consumed.
31      * The actual amount should rarely exceed this estimate.
32      * 
33      * @return the estimated length
34      */

35     int estimateParsedLength();
36
37     /**
38      * Parse an element from the given text, saving any fields into the given
39      * DateTimeParserBucket. If the parse succeeds, the return value is the new
40      * text position. Note that the parse may succeed without fully reading the
41      * text.
42      * <p>
43      * If it fails, the return value is negative. To determine the position
44      * where the parse failed, apply the one's complement operator (~) on the
45      * return value.
46      *
47      * @param bucket  field are saved into this, not null
48      * @param text  the text to parse, not null
49      * @param position  position to start parsing from
50      * @return new position, negative value means parse failed -
51      *  apply complement operator (~) to get position of failure
52      * @throws IllegalArgumentException if any field is out of range
53      */

54     int parseInto(DateTimeParserBucket bucket, CharSequence text, int position);
55
56 }
57