CompileProperties.java revision 0
2273N/A * Copyright 2002-2005 Sun Microsystems, Inc. All Rights Reserved. 0N/A * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 0N/A * This code is free software; you can redistribute it and/or modify it 0N/A * under the terms of the GNU General Public License version 2 only, as 0N/A * published by the Free Software Foundation. Sun designates this 0N/A * particular file as subject to the "Classpath" exception as provided 0N/A * by Sun in the LICENSE file that accompanied this code. 0N/A * This code is distributed in the hope that it will be useful, but WITHOUT 0N/A * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 0N/A * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 0N/A * version 2 for more details (a copy is included in the LICENSE file that 0N/A * accompanied this code). 0N/A * You should have received a copy of the GNU General Public License version 0N/A * 2 along with this work; if not, write to the Free Software Foundation, 1472N/A * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 1472N/A * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, 0N/A * CA 95054 USA or visit www.sun.com if you need additional information or 0N/A * have any questions. 1879N/A/** Translates a .properties file into a .java file containing the 0N/A * compiled with javac. <P> 0N/A * Usage: java CompileProperties [path to .properties file] [path to .java file to be output] [super class] 0N/A * Infers the package by looking at the common suffix of the two 0N/A * inputs, eliminating "classes" from it. 0N/A * @author Scott Violet 0N/A * @author Kenneth Russell 0N/A /* Original usage */ 0N/A /* New batch usage */ 0N/A /* Need at least one file. */ 0N/A // Get class name from java filename, not the properties filename. 0N/A // (zh_TW properties might be used to create zh_HK files) 0N/A log.
info(
" java CompileProperties path_to_properties_file path_to_java_output_file [super_class]");
0N/A log.
info(
" java CompileProperties {-compile path_to_properties_file path_to_java_output_file super_class} -or- -optionsfile filename");
0N/A log.
info(
" java CompileProperties -optionsfile option_file");
0N/A // This is taken from Properties.saveConvert with changes for Java strings 0N/A // Normalize file names 0N/A // Match common names, eliminating first "classes" entry from 0N/A while (i >=
0 && j >=
0) {
0N/A "import java.util.ListResourceBundle;\n\n" +
0N/A "public final class {1} extends {2} '{'\n" +
0N/A " protected final Object[][] getContents() '{'\n" +
0N/A " return new Object[][] '{'\n" +
0N/A // This comes from Properties 0N/A // This comes from Properties 0N/A '0',
'1',
'2',
'3',
'4',
'5',
'6',
'7',
'8',
'9',
'A',
'B',
'C',
'D',
'E',
'F' 0N/A // Note: different from that in Properties