1/* 2 ******************************************************************************* 3 * Copyright (C) 1996-2011, International Business Machines Corporation and * 4 * others. All Rights Reserved. * 5 ******************************************************************************* 6 * 7 */ 8 9package com.ibm.icu.dev.test.serializable; 10 11import java.net.URL; 12 13import com.ibm.icu.util.VersionInfo; 14 15/** 16 * This class writes the test objects for each class to a file. The work is 17 * actually done by the superclass, CoverageTest. This class just constructs 18 * a CoverageTest w/ a non-null path, which tells it to write the data. 19 * 20 */ 21public class SerializableWriter extends CoverageTest 22{ 23 public SerializableWriter(String path) 24 { 25 super(path); 26 } 27 28 private static String folderName() 29 { 30 int major = VersionInfo.ICU_VERSION.getMajor(); 31 int minor = VersionInfo.ICU_VERSION.getMinor(); 32 int milli = VersionInfo.ICU_VERSION.getMilli(); 33 int micro = VersionInfo.ICU_VERSION.getMicro(); 34 StringBuffer result = new StringBuffer("ICU_"); 35 36 result.append(major); 37 result.append("."); 38 result.append(minor); 39 40 if (milli != 0 || micro != 0) { 41 result.append("."); 42 result.append(milli); 43 44 if (micro != 0) { 45 result.append("."); 46 result.append(micro); 47 } 48 } 49 50 return result.toString(); 51 } 52 53 public static void main(String[] args) 54 { 55 String outDir = null; 56 if (args.length == 0) { 57 URL dataURL = SerializableWriter.class.getResource("data"); 58 outDir = dataURL.getPath() + "/" + folderName(); 59 } else { 60 outDir = args[0] + "/" + folderName(); 61 } 62 CoverageTest test = new SerializableWriter(outDir); 63 64 test.run(args); 65 66 } 67} 68