org.apache.commons.configuration.plist
Class PropertyListConfiguration.DateComponentParser

java.lang.Object
  extended by org.apache.commons.configuration.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 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
private PropertyListConfiguration.DateComponentParser()
           
 
Method Summary
protected  void checkLength(java.lang.String s, int index, int length)
          Checks whether the given string has at least length characters starting from the given parsing position.
abstract  void formatComponent(java.lang.StringBuffer buf, java.util.Calendar cal)
          Formats a date component.
protected  void padNum(java.lang.StringBuffer 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.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

PropertyListConfiguration.DateComponentParser

private PropertyListConfiguration.DateComponentParser()
Method Detail

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 parsed
index - the current parsing position
cal - the calendar where to store the result
Returns:
the length of the processed component
Throws:
ParseException - if the component cannot be extracted

formatComponent

public abstract void formatComponent(java.lang.StringBuffer 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 buffer
cal - the calendar with the current date

checkLength

protected void checkLength(java.lang.String s,
                           int index,
                           int length)
                    throws ParseException
Checks whether the given string has at least length characters starting from the given parsing position. If this is not the case, an exception will be thrown.

Parameters:
s - the string to be tested
index - the current index
length - the minimum length after the index
Throws:
ParseException - if the string is too short

padNum

protected void padNum(java.lang.StringBuffer 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 buffer
num - the number to add
length - the required length