CompileProperties.java revision 553
1472N/A * Copyright (c) 2002, 2005, Oracle and/or its affiliates. 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. Oracle designates this 0N/A * particular file as subject to the "Classpath" exception as provided 0N/A * by Oracle 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 0N/A * or visit www.oracle.com if you need additional information or have any 342N/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 /* 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) log.
info(
" java CompileProperties path_to_properties_file path_to_java_output_file [super_class]");
log.
info(
" java CompileProperties {-compile path_to_properties_file path_to_java_output_file super_class} -or- -optionsfile filename");
log.
info(
" java CompileProperties -optionsfile option_file");
// This is taken from Properties.saveConvert with changes for Java strings for(
int x=
0; x<
len; x++) {
// Match common names, eliminating first "classes" entry from while (i >=
0 && j >=
0) {
"public final class {1} extends {2} '{'\n" +
" protected final Object[][] getContents() '{'\n" +
" return new Object[][] '{'\n" +
// This comes from Properties // This comes from Properties private static final char[]
hexDigit = {
'0',
'1',
'2',
'3',
'4',
'5',
'6',
'7',
'8',
'9',
'A',
'B',
'C',
'D',
'E',
'F' // Note: different from that in Properties