1 /* 2 * Copyright (C) 2012 The Libphonenumber Authors 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17 package com.google.i18n.phonenumbers.buildtools; 18 19 import com.google.i18n.phonenumbers.Command; 20 21 import java.io.File; 22 import java.io.IOException; 23 import java.util.logging.Level; 24 import java.util.logging.Logger; 25 26 /** 27 * Entry point class used to invoke the generation of the binary time zone data files. 28 * 29 * @author Walter Erquinigo 30 * @author Philippe Liard 31 */ 32 public class GenerateTimeZonesMapDataEntryPoint extends Command { 33 private static final Logger logger = Logger.getLogger(GenerateTimeZonesMapData.class.getName()); 34 private static final String USAGE_DESCRIPTION = 35 "usage: GenerateTimeZonesMapData /path/to/input/directory /path/to/output/directory" 36 + " [outputJarName]"; 37 38 @Override getCommandName()39 public String getCommandName() { 40 return "GenerateTimeZonesMapData"; 41 } 42 43 @Override start()44 public boolean start() { 45 String[] args = getArgs(); 46 47 if (args.length < 3 || args.length > 4) { 48 logger.log(Level.SEVERE, USAGE_DESCRIPTION); 49 return false; 50 } 51 try { 52 File inputPath = new File(args[1]); 53 File outputPath = new File(args[2]); 54 AbstractPhonePrefixDataIOHandler ioHandler = 55 args.length == 3 56 ? new PhonePrefixDataIOHandler(outputPath) 57 : new JarPhonePrefixDataIOHandler( 58 outputPath, args[3], GeneratePhonePrefixData.class.getPackage()); 59 GenerateTimeZonesMapData generateTimeZonesMapData = new GenerateTimeZonesMapData(inputPath, ioHandler); 60 generateTimeZonesMapData.run(); 61 } catch (IOException e) { 62 logger.log(Level.SEVERE, e.getMessage()); 63 return false; 64 } 65 return true; 66 } 67 } 68