Class TZDBZoneRulesCompiler

java.lang.Object
javax.time.calendar.zone.TZDBZoneRulesCompiler

public final class TZDBZoneRulesCompiler extends Object
A builder that can read the TZDB TimeZone files and build ZoneRules instances.

TZDBZoneRulesCompiler is thread-safe.

  • Field Details

  • Constructor Details

    • TZDBZoneRulesCompiler

      public TZDBZoneRulesCompiler(String version, List<File> sourceFiles, boolean verbose)
      Constructor used if you want to invoke the compiler manually.
      Parameters:
      version - the version, such as 2009a, not null
      sourceFiles - the list of source files, not empty, not null
      verbose - whether to output verbose messages
  • Method Details

    • main

      public static void main(String[] args)
      Reads a set of TZDB files and builds a single combined data file.
      Parameters:
      args - the arguments
    • outputHelp

      private static void outputHelp()
      Output usage text for the command line.
    • process

      private static void process(List<File> srcDirs, List<String> srcFileNames, File dstDir, boolean verbose)
      Process to create the jar files.
    • outputFile

      private static void outputFile(File dstFile, String version, SortedMap<String,ZoneRules> builtZones)
      Outputs the file.
    • outputFile

      private static void outputFile(File dstFile, Map<String,SortedMap<String,ZoneRules>> allBuiltZones, Set<String> allRegionIds, Set<ZoneRules> allRules)
      Outputs the file.
    • compile

      public SortedMap<String,ZoneRules> compile() throws Exception
      Compile the rules file.
      Returns:
      the map of region ID to rules, not null
      Throws:
      Exception - if an error occurs
    • setDeduplicateMap

      void setDeduplicateMap(Map<Object,Object> deduplicateMap)
      Sets the deduplication map.
      Parameters:
      deduplicateMap - the map to deduplicate items
    • parseFiles

      private void parseFiles() throws Exception
      Parses the source files.
      Throws:
      Exception - if an error occurs
    • parseFile

      private void parseFile(File file) throws Exception
      Parses a source file.
      Parameters:
      file - the file being read, not null
      Throws:
      Exception - if an error occurs
    • parseRuleLine

      private void parseRuleLine(StringTokenizer st)
      Parses a Rule line.
      Parameters:
      st - the tokenizer, not null
    • parseZoneLine

      private boolean parseZoneLine(StringTokenizer st, List<TZDBZoneRulesCompiler.TZDBZone> zoneList)
      Parses a Zone line.
      Parameters:
      st - the tokenizer, not null
      Returns:
      true if the zone is complete
    • parseMonthDayTime

      private void parseMonthDayTime(StringTokenizer st, TZDBZoneRulesCompiler.TZDBMonthDayTime mdt)
      Parses a Rule line.
      Parameters:
      st - the tokenizer, not null
      mdt - the object to parse into, not null
    • parseYear

      private int parseYear(String str, int defaultYear)
    • parseMonth

      private MonthOfYear parseMonth(String str)
    • parseDayOfWeek

      private DayOfWeek parseDayOfWeek(String str)
    • matches

      private boolean matches(String str, String search)
    • parseOptional

      private String parseOptional(String str)
    • parseSecs

      private int parseSecs(String str)
    • parseOffset

      private ZoneOffset parseOffset(String str)
    • parsePeriod

      private Period parsePeriod(String str)
    • parseTimeDefinition

      private ZoneRulesBuilder.TimeDefinition parseTimeDefinition(char c)
    • buildZoneRules

      private void buildZoneRules() throws Exception
      Build the rules, zones and links into real zones.
      Throws:
      Exception - if an error occurs
    • deduplicate

      <T> T deduplicate(T object)
      Deduplicates an object instance.
      Type Parameters:
      T - the generic type
      Parameters:
      object - the object to deduplicate
      Returns:
      the deduplicated object
    • printVerbose

      private void printVerbose(String message)
      Prints a verbose message.
      Parameters:
      message - the message, not null