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 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 Details

    • DateComponentParser

      private DateComponentParser()
  • Method Details

    • checkLength

      protected void checkLength(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
    • formatComponent

      public abstract void formatComponent(StringBuilder buf, 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
    • padNum

      protected void padNum(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 buffer
      num - the number to add
      length - the required length
    • parseComponent

      public abstract int parseComponent(String s, int index, 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