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
private abstract static class PropertyListConfiguration.DateComponentParser extends java.lang.Object
A helper class for parsing and formatting date literals. Usually we would useSimpleDateFormat
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 Modifier Constructor Description private
DateComponentParser()
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected void
checkLength(java.lang.String s, int index, int length)
Checks whether the given string has at leastlength
characters starting from the given parsing position.abstract void
formatComponent(java.lang.StringBuilder buf, java.util.Calendar cal)
Formats a date component.protected void
padNum(java.lang.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 int
parseComponent(java.lang.String s, int index, java.util.Calendar cal)
Parses a component from the given input string.
-
-
-
Method Detail
-
checkLength
protected void checkLength(java.lang.String s, int index, int length) throws ParseException
Checks whether the given string has at leastlength
characters 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
public abstract void formatComponent(java.lang.StringBuilder buf, java.util.Calendar cal)
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
protected void padNum(java.lang.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.- Parameters:
buf
- the target buffernum
- the number to addlength
- the required length
-
parseComponent
public abstract int parseComponent(java.lang.String s, int index, java.util.Calendar cal) throws ParseException
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
-
-