Package javax.time.calendar.zone
Class TZDBZoneRulesCompiler
- java.lang.Object
-
- javax.time.calendar.zone.TZDBZoneRulesCompiler
-
public final class TZDBZoneRulesCompiler extends java.lang.ObjectA builder that can read the TZDB TimeZone files and build ZoneRules instances.TZDBZoneRulesCompiler is thread-safe.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description (package private) classTZDBZoneRulesCompiler.TZDBMonthDayTimeClass representing a month-day-time in the TZDB file.(package private) classTZDBZoneRulesCompiler.TZDBRuleClass representing a rule line in the TZDB file.(package private) classTZDBZoneRulesCompiler.TZDBZoneClass representing a linked set of zone lines in the TZDB file.
-
Field Summary
Fields Modifier and Type Field Description private java.util.SortedMap<java.lang.String,ZoneRules>builtZonesThe built zones.private java.util.Map<java.lang.Object,java.lang.Object>deduplicateMapA map to deduplicate object instances.private java.util.Map<java.lang.String,java.lang.String>linksThe TZDB links.private java.util.Map<java.lang.String,java.util.List<TZDBZoneRulesCompiler.TZDBRule>>rulesThe TZDB rules.private java.util.List<java.io.File>sourceFilesThe source files.private static DateTimeFormatterTIME_PARSERTime parser.private booleanverboseThe version to produce.private java.lang.StringversionThe version to produce.private java.util.Map<java.lang.String,java.util.List<TZDBZoneRulesCompiler.TZDBZone>>zonesThe TZDB zones.
-
Constructor Summary
Constructors Constructor Description TZDBZoneRulesCompiler(java.lang.String version, java.util.List<java.io.File> sourceFiles, boolean verbose)Constructor used if you want to invoke the compiler manually.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description private voidbuildZoneRules()Build the rules, zones and links into real zones.java.util.SortedMap<java.lang.String,ZoneRules>compile()Compile the rules file.(package private) <T> Tdeduplicate(T object)Deduplicates an object instance.static voidmain(java.lang.String[] args)Reads a set of TZDB files and builds a single combined data file.private booleanmatches(java.lang.String str, java.lang.String search)private static voidoutputFile(java.io.File dstFile, java.lang.String version, java.util.SortedMap<java.lang.String,ZoneRules> builtZones)Outputs the file.private static voidoutputFile(java.io.File dstFile, java.util.Map<java.lang.String,java.util.SortedMap<java.lang.String,ZoneRules>> allBuiltZones, java.util.Set<java.lang.String> allRegionIds, java.util.Set<ZoneRules> allRules)Outputs the file.private static voidoutputHelp()Output usage text for the command line.private DayOfWeekparseDayOfWeek(java.lang.String str)private voidparseFile(java.io.File file)Parses a source file.private voidparseFiles()Parses the source files.private MonthOfYearparseMonth(java.lang.String str)private voidparseMonthDayTime(java.util.StringTokenizer st, TZDBZoneRulesCompiler.TZDBMonthDayTime mdt)Parses a Rule line.private ZoneOffsetparseOffset(java.lang.String str)private java.lang.StringparseOptional(java.lang.String str)private PeriodparsePeriod(java.lang.String str)private voidparseRuleLine(java.util.StringTokenizer st)Parses a Rule line.private intparseSecs(java.lang.String str)private ZoneRulesBuilder.TimeDefinitionparseTimeDefinition(char c)private intparseYear(java.lang.String str, int defaultYear)private booleanparseZoneLine(java.util.StringTokenizer st, java.util.List<TZDBZoneRulesCompiler.TZDBZone> zoneList)Parses a Zone line.private voidprintVerbose(java.lang.String message)Prints a verbose message.private static voidprocess(java.util.List<java.io.File> srcDirs, java.util.List<java.lang.String> srcFileNames, java.io.File dstDir, boolean verbose)Process to create the jar files.(package private) voidsetDeduplicateMap(java.util.Map<java.lang.Object,java.lang.Object> deduplicateMap)Sets the deduplication map.
-
-
-
Field Detail
-
TIME_PARSER
private static final DateTimeFormatter TIME_PARSER
Time parser.
-
rules
private final java.util.Map<java.lang.String,java.util.List<TZDBZoneRulesCompiler.TZDBRule>> rules
The TZDB rules.
-
zones
private final java.util.Map<java.lang.String,java.util.List<TZDBZoneRulesCompiler.TZDBZone>> zones
The TZDB zones.
-
links
private final java.util.Map<java.lang.String,java.lang.String> links
The TZDB links.
-
builtZones
private final java.util.SortedMap<java.lang.String,ZoneRules> builtZones
The built zones.
-
deduplicateMap
private java.util.Map<java.lang.Object,java.lang.Object> deduplicateMap
A map to deduplicate object instances.
-
version
private final java.lang.String version
The version to produce.
-
sourceFiles
private final java.util.List<java.io.File> sourceFiles
The source files.
-
verbose
private final boolean verbose
The version to produce.
-
-
Constructor Detail
-
TZDBZoneRulesCompiler
public TZDBZoneRulesCompiler(java.lang.String version, java.util.List<java.io.File> sourceFiles, boolean verbose)Constructor used if you want to invoke the compiler manually.- Parameters:
version- the version, such as 2009a, not nullsourceFiles- the list of source files, not empty, not nullverbose- whether to output verbose messages
-
-
Method Detail
-
main
public static void main(java.lang.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(java.util.List<java.io.File> srcDirs, java.util.List<java.lang.String> srcFileNames, java.io.File dstDir, boolean verbose)Process to create the jar files.
-
outputFile
private static void outputFile(java.io.File dstFile, java.lang.String version, java.util.SortedMap<java.lang.String,ZoneRules> builtZones)Outputs the file.
-
outputFile
private static void outputFile(java.io.File dstFile, java.util.Map<java.lang.String,java.util.SortedMap<java.lang.String,ZoneRules>> allBuiltZones, java.util.Set<java.lang.String> allRegionIds, java.util.Set<ZoneRules> allRules)Outputs the file.
-
compile
public java.util.SortedMap<java.lang.String,ZoneRules> compile() throws java.lang.Exception
Compile the rules file.- Returns:
- the map of region ID to rules, not null
- Throws:
java.lang.Exception- if an error occurs
-
setDeduplicateMap
void setDeduplicateMap(java.util.Map<java.lang.Object,java.lang.Object> deduplicateMap)
Sets the deduplication map.- Parameters:
deduplicateMap- the map to deduplicate items
-
parseFiles
private void parseFiles() throws java.lang.ExceptionParses the source files.- Throws:
java.lang.Exception- if an error occurs
-
parseFile
private void parseFile(java.io.File file) throws java.lang.ExceptionParses a source file.- Parameters:
file- the file being read, not null- Throws:
java.lang.Exception- if an error occurs
-
parseRuleLine
private void parseRuleLine(java.util.StringTokenizer st)
Parses a Rule line.- Parameters:
st- the tokenizer, not null
-
parseZoneLine
private boolean parseZoneLine(java.util.StringTokenizer st, java.util.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(java.util.StringTokenizer st, TZDBZoneRulesCompiler.TZDBMonthDayTime mdt)Parses a Rule line.- Parameters:
st- the tokenizer, not nullmdt- the object to parse into, not null
-
parseYear
private int parseYear(java.lang.String str, int defaultYear)
-
parseMonth
private MonthOfYear parseMonth(java.lang.String str)
-
parseDayOfWeek
private DayOfWeek parseDayOfWeek(java.lang.String str)
-
matches
private boolean matches(java.lang.String str, java.lang.String search)
-
parseOptional
private java.lang.String parseOptional(java.lang.String str)
-
parseSecs
private int parseSecs(java.lang.String str)
-
parseOffset
private ZoneOffset parseOffset(java.lang.String str)
-
parsePeriod
private Period parsePeriod(java.lang.String str)
-
parseTimeDefinition
private ZoneRulesBuilder.TimeDefinition parseTimeDefinition(char c)
-
buildZoneRules
private void buildZoneRules() throws java.lang.ExceptionBuild the rules, zones and links into real zones.- Throws:
java.lang.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(java.lang.String message)
Prints a verbose message.- Parameters:
message- the message, not null
-
-