Class PropertyListConfiguration.DateComponentParser
java.lang.Object
org.apache.commons.configuration2.plist.PropertyListConfiguration.DateComponentParser
- Direct Known Subclasses:
PropertyListConfiguration.DateFieldParser,PropertyListConfiguration.DateSeparatorParser,PropertyListConfiguration.DateTimeZoneParser
- Enclosing class:
PropertyListConfiguration
A helper class for parsing and formatting date literals. Usually we would use
SimpleDateFormat for this
purpose, but in Java 1.3 the functionality of this class is limited. So we have a hierarchy of parser classes instead
that deal with the different components of a date literal.-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected voidcheckLength(String s, int index, int length) Checks whether the given string has at leastlengthcharacters starting from the given parsing position.abstract voidformatComponent(StringBuilder buf, Calendar cal) Formats a date component.protected voidpadNum(StringBuilder buf, int num, int length) Adds a number to the given string buffer and adds leading '0' characters until the given length is reached.abstract intparseComponent(String s, int index, Calendar cal) Parses a component from the given input string.
-
Constructor Details
-
DateComponentParser
private DateComponentParser()
-
-
Method Details
-
checkLength
Checks whether the given string has at leastlengthcharacters starting from the given parsing position. If this is not the case, an exception will be thrown.- Parameters:
s- the string to be testedindex- the current indexlength- the minimum length after the index- Throws:
ParseException- if the string is too short
-
formatComponent
Formats a date component. This method is used for converting a date in its internal representation into a string literal.- Parameters:
buf- the target buffercal- the calendar with the current date
-
padNum
Adds a number to the given string buffer and adds leading '0' characters until the given length is reached.- Parameters:
buf- the target buffernum- the number to addlength- the required length
-
parseComponent
Parses a component from the given input string.- Parameters:
s- the string to be parsedindex- the current parsing positioncal- the calendar where to store the result- Returns:
- the length of the processed component
- Throws:
ParseException- if the component cannot be extracted
-