GenerateMessageFile.java revision cd845149d3f0adb85c23d522477ffb6d7c16cc7e
0N/A * The contents of this file are subject to the terms of the 0N/A * Common Development and Distribution License, Version 1.0 only 0N/A * (the "License"). You may not use this file except in compliance 0N/A * You can obtain a copy of the license at 0N/A * See the License for the specific language governing permissions 0N/A * and limitations under the License. 0N/A * When distributing Covered Code, include this CDDL HEADER in each 0N/A * file and include the License file at 0N/A * add the following below this CDDL HEADER, with the fields enclosed 0N/A * by brackets "[]" replaced with your own identifying information: 0N/A * Portions Copyright [yyyy] [name of copyright owner] 0N/A * Copyright 2008 Sun Microsystems, Inc. 0N/A * Generates a Java class containing representations of messages 0N/A * found in a properties file. 0N/A * The registry filename is the result of the concatenation of the 0N/A * location of where the source are generated, the package name and the 0N/A * DESCRIPTORS_REG value. 0N/A * Used to set a category for all messages in the property file. 0N/A * If set, the category for each message need not be encoded in 0N/A * the message's property file key. 33N/A * Used to set a severity for all messages in the property file. 33N/A * If set, the severity for each message need not be encoded in 33N/A * the message's property file key. 0N/A * Used to set a category mask for all messages in the property 0N/A * file. If set, the category will automatically be assigned 0N/A * USER_DEFINED and the value of <code>GLOBAL_CATEGORY</code> 0N/A * When true generates messages that have no ordinals. 0N/A * When true and if the Java Web Start property is set use the class loader of 0N/A * the jar where the MessageDescriptor is contained to retrieve the 0N/A "global.use.message.jar.if.webstart";
0N/A "%(\\d+\\$)?([-#+ 0,(\\<]*)?(\\d+)?(\\.\\d+)?([tT])?([a-zA-Z%])";
0N/A * Message giving formatting rules for string keys. 0N/A .
append(
".\n\nOpenDS message property keys must be of the form\n\n")
0N/A .
append(
"\t\'[CATEGORY]_[SEVERITY]_[DESCRIPTION]_[ORDINAL]\'\n\n")
0N/A .
append(
"\n\nDESCRIPTION is a descriptive string composed ")
0N/A .
append(
"of uppercase character, digits and underscores ")
0N/A .
append(
"describing the purpose of the message ")
0N/A .
append(
"\n\nORDINAL is an integer between 0 and 65535 that is ")
0N/A .
append(
"unique to other messages defined in this file.\n\n")
0N/A .
append(
"You can relax the mandate for including the CATEGORY, ")
0N/A .
append(
"of the following respective property directives in your ")
0N/A .
append(
"and setting their value appropriately.")
0N/A * ISO_LANGUAGES contains all official supported languages for i18n 0N/A * ISO_COUNTRIES contains all official supported countries for i18n 0N/A * A Pattern instance that matches "<label>_<language>_<country>.properties" 0N/A * where <label> can be anything including '_' 0N/A * <language> a two characters code contained in the ISO_LANGUAGES list 0N/A * <country> a two characters code contained in the ISO_COUNTRIES list 63N/A * A Pattern instance that matches "<label>_<language>.properties" 0N/A * where <label> and <language> have same definition as above. 0N/A * Representation of a format specifier (for example %s). 0N/A * Creates a new specifier. 0N/A * @param sa specifier components 0N/A * Indicates whether or not the specifier uses arguement 0N/A * indexes (for example 2$). 63N/A * @return boolean true if this specifier uses indexing 63N/A * Returns a java class associated with a particular formatter 0N/A * based on the conversion type of the specifier. 0N/A * @return Class for representing the type of arguement used 0N/A * as a replacement for this specifier. 0N/A * Represents a message to be written into the messages files. 0N/A * Creates a parameterized instance. 0N/A * @param key of the message 0N/A * @param formatString of the message 0N/A * Gets the name of the Java class that will be used to represent 0N/A * this message's type. 0N/A * @return String representing the Java class name 0N/A * Gets a string representing the message type class' variable 0N/A * information (for example '<String,Integer>') that is based on 0N/A * the type of arguments specified by the specifiers in this message. 0N/A * @return String representing the message type class parameters 0N/A * Gets the javadoc comments that will appear above the messages declaration 0N/A * in the messages file. 0N/A * @return String comment 0N/A // Unwrapped so that you can search through the descriptor 0N/A // file for a message and not have to worry about line breaks 0N/A * Sets the arguments that will be supplied in the declaration 0N/A * @param s array of string arguments that will be passed 0N/A * in the constructor 0N/A * Indicates whether the generic message type class should 0N/A * be used. In general this is when a format specifier is 0N/A * more complicated than we support or when the number of 0N/A * arguments exceeeds the number of specific message type 0N/A * classes (MessageType0, MessageType1 ...) that are defined. 0N/A * @return boolean indicating 63N/A * Look for format specifiers in the format string. 63N/A * @param s format string 63N/A * @return list of format specifiers 63N/A // Anything between the start of the string and the beginning 63N/A // of the format specifier is either fixed text or contains 63N/A // an invalid format string. 63N/A // Make sure we didn't miss any invalid format specifiers 63N/A // Assume previous characters were fixed text 63N/A //al.add(new FixedString(s.substring(i, m.start()))); 63N/A // Expect 6 groups in regular expression 63N/A // No more valid format specifiers. Check for possible invalid 63N/A // format specifiers. 63N/A // The rest of the string is fixed text 0N/A //al.add(new FixedString(s.substring(i))); 0N/A // If there are any '%' in the given string, we got a bad format 0N/A * Sets the source of the messages. 0N/A * @param source File representing the properties 0N/A * file containing messages 0N/A * Sets the file that will be generated containing 0N/A * declarations of messages from <code>source</code>. 0N/A * @param dest File destination 0N/A * Set the descriptors.reg pathname to the same directory as the one used 0N/A * to generate files and ensure all messages are generated in one place. 0N/A ": unable to retrieve project's directory of ant's project (" +
0N/A // strip project directory prefix and replace properties filename with 0N/A // multiple messages are generated in several packages 0N/A // full pathname of $REGISTRY_FILE_NAME 0N/A // change from generated directory to properties files directory 0N/A // replace properties filename with source filename 0N/A ": all messages must be located in the same package thus " +
0N/A "name of the source file should be " +
sb);
0N/A * Indicates when true that an existing destination 0N/A * file will be overwritten. 0N/A * @param o boolean where true means overwrite 0N/A // this is an example-plugin call: 0N/A // - check the source file is not a localization 0N/A // - guess the destination filename from source filename 0N/A * Make sure only <label>.properties are generated thus avoiding to 0N/A * generate messages for localized properties files. 0N/A // do not generate message for <label>_<language>_<country>.properties 0N/A // do not generate message for <label>_<language>.properties 0N/A // filename without ".properties" 0N/A // change to src-generated directory keeping package name 0N/A // append characters from filename to pathname starting with an uppercase 0N/A // letter, ignoring '_' and uppering all characters prefixed with "_" 0N/A // Decide whether to generate messages based on modification 0N/A // times and print status messages. 0N/A // Determine the value of the global severity 0N/A // Check that this category is the same as all the 0N/A // others in this file. Maybe this should be an error? 0N/A "No category could be assigned to message " +
0N/A "must either be encoded in the property key or " +
0N/A "or must be set by including the property " +
0N/A "No severity could be assigned to message " +
0N/A "must either be encoded in the property key or " +
0N/A "or must be set by including the property " +
0N/A key +
" has been previously defined in " +
0N/A // Keep track of when we use the generic descriptor 0N/A // so that we can report it later 0N/A // Don't leave a malformed file laying around. Delete 0N/A // it so it will be forced to be regenerated. * Writes a record in the messages registry for the specifed * @param descClassName name of the message descriptor class * @return true if the class was acutally added to the registry; * false indicates that the class was already present. * @throws IOException if there is a problem with the file I/O // Get the path to build.xml and return the parent // directory else just return the working directory. * location: ant or jar file. // this is the OpenDS's ant project calling // this is the example plugin's ant project calling * @param args from command line