1 21 22 package org.apache.derbyBuild; 23 24 import java.io.*; 25 import java.util.*; 26 27 import org.apache.derby.iapi.services.i18n.MessageService; 28 import org.apache.derby.shared.common.reference.SQLState; 29 30 public class splitmessages { 31 35 36 46 private static TreeSet clientMessageIds = new TreeSet(); 47 48 54 static void initClientMessageIds() 55 { 56 clientMessageIds.add(SQLState.NO_CURRENT_CONNECTION); 58 clientMessageIds.add(SQLState.NOT_IMPLEMENTED); 59 clientMessageIds.add(SQLState.CANNOT_CLOSE_ACTIVE_CONNECTION); 60 clientMessageIds.add(SQLState.XACT_SAVEPOINT_RELEASE_ROLLBACK_FAIL); 61 clientMessageIds.add(SQLState.UNSUPPORTED_ENCODING); 62 clientMessageIds.add(SQLState.LANG_FORMAT_EXCEPTION); 63 clientMessageIds.add(SQLState.LANG_DATA_TYPE_GET_MISMATCH); 64 clientMessageIds.add(SQLState.LANG_DATA_TYPE_SET_MISMATCH); 65 clientMessageIds.add(SQLState.LANG_DATE_SYNTAX_EXCEPTION); 66 clientMessageIds.add(SQLState.CHARACTER_CONVERTER_NOT_AVAILABLE); 67 clientMessageIds.add(SQLState.LANG_OUTSIDE_RANGE_FOR_DATATYPE); 68 clientMessageIds.add(SQLState.LANG_STATEMENT_CLOSED_NO_REASON); 69 clientMessageIds.add(SQLState.LANG_INVALID_COLUMN_POSITION); 70 clientMessageIds.add(SQLState.INVALID_COLUMN_NAME); 71 clientMessageIds.add(SQLState.HOLDABLE_RESULT_SET_NOT_AVAILABLE); 72 clientMessageIds.add(SQLState.LANG_RETURN_OUTPUT_PARAM_CANNOT_BE_SET); 73 clientMessageIds.add(SQLState.LANG_NULL_INTO_NON_NULL); 74 clientMessageIds.add(SQLState.JDBC_METHOD_NOT_IMPLEMENTED); 75 clientMessageIds.add(SQLState.JDBC_METHOD_NOT_SUPPORTED_BY_SERVER); 76 clientMessageIds.add(SQLState.DRDA_NO_AUTOCOMMIT_UNDER_XA); 77 clientMessageIds.add(SQLState.DRDA_INVALID_XA_STATE_ON_COMMIT_OR_ROLLBACK); 78 clientMessageIds.add(SQLState.HOLDABLE_RESULT_SET_NOT_AVAILABLE); 79 clientMessageIds.add(SQLState.INVALID_RESULTSET_TYPE); 80 clientMessageIds.add(SQLState.INVALID_RESULTSET_CONCURRENCY); 81 clientMessageIds.add(SQLState.SCROLL_SENSITIVE_NOT_SUPPORTED); 82 clientMessageIds.add(SQLState.INSENSITIVE_UPDATABLE_NOT_SUPPORTED); 83 clientMessageIds.add(SQLState.UNABLE_TO_OBTAIN_MESSAGE_TEXT_FROM_SERVER ); 84 clientMessageIds.add(SQLState.NUMBER_OF_ROWS_TOO_LARGE_FOR_INT); 85 clientMessageIds.add(SQLState.NOGETCONN_ON_CLOSED_POOLED_CONNECTION); 86 clientMessageIds.add(SQLState.LOB_METHOD_ON_CLOSED_CONNECTION); 87 clientMessageIds.add(SQLState.QUERY_NOT_QUALIFIED_FOR_UPDATABLE_RESULTSET); 88 clientMessageIds.add(SQLState.MULTIPLE_RESULTS_ON_EXECUTE_QUERY); 89 clientMessageIds.add(SQLState.USE_EXECUTE_UPDATE_WITH_NO_RESULTS); 90 clientMessageIds.add(SQLState.LANG_INVALID_CALL_TO_EXECUTE_UPDATE); 91 clientMessageIds.add(SQLState.LANG_CANT_INVALIDATE_OPEN_RESULT_SET); 92 clientMessageIds.add(SQLState.YEAR_EXCEEDS_MAXIMUM); 93 clientMessageIds.add(SQLState.LANG_INVALID_PARAM_POSITION); 94 clientMessageIds.add(SQLState.LANG_MISSING_PARMS); 95 clientMessageIds.add(SQLState.LANG_NO_CURRENT_ROW); 96 clientMessageIds.add(SQLState.LANG_STREAM_RETRIEVED_ALREADY); 97 clientMessageIds.add(SQLState.CONNECTION_FAILED_ON_RESET); 98 clientMessageIds.add(SQLState.DECIMAL_TOO_MANY_DIGITS); 99 clientMessageIds.add(SQLState.NUMERIC_OVERFLOW); 100 clientMessageIds.add(SQLState.UNSUPPORTED_HOLDABILITY_PROPERTY); 101 clientMessageIds.add(SQLState.CANCEL_NOT_SUPPORTED_BY_SERVER); 102 clientMessageIds.add(SQLState.LANG_INVALID_CALL_STATEMENT); 103 clientMessageIds.add(SQLState.LOSS_OF_PRECISION_EXCEPTION); 104 clientMessageIds.add(SQLState.LANG_INVALID_SQL_IN_BATCH); 105 clientMessageIds.add(SQLState.CLIENT_RESULT_SET_NOT_OPEN); 106 clientMessageIds.add(SQLState.CANT_CONVERT_UNICODE_TO_EBCDIC); 107 clientMessageIds.add(SQLState.SECMECH_NOT_SUPPORTED); 108 clientMessageIds.add(SQLState.DRDA_COMMAND_NOT_IMPLEMENTED); 109 clientMessageIds.add(SQLState.DATA_TYPE_NOT_SUPPORTED); 110 clientMessageIds.add(SQLState.JDBC_DRIVER_REGISTER); 111 clientMessageIds.add(SQLState.NO_CURRENT_ROW); 112 clientMessageIds.add(SQLState.LANG_IDENTIFIER_TOO_LONG); 113 clientMessageIds.add(SQLState.DRDA_CURSOR_NOT_OPEN); 114 clientMessageIds.add(SQLState.PROPERTY_UNSUPPORTED_CHANGE); 115 clientMessageIds.add(SQLState.NET_INVALID_JDBC_TYPE_FOR_PARAM); 116 clientMessageIds.add(SQLState.UNRECOGNIZED_JAVA_SQL_TYPE); 117 clientMessageIds.add(SQLState.NET_UNRECOGNIZED_JDBC_TYPE); 118 clientMessageIds.add(SQLState.NET_SQLCDTA_INVALID_FOR_RDBCOLID); 119 clientMessageIds.add(SQLState.NET_SQLCDTA_INVALID_FOR_PKGID); 120 clientMessageIds.add(SQLState.NET_PGNAMCSN_INVALID_AT_SQLAM); 121 clientMessageIds.add(SQLState.NET_VCM_VCS_LENGTHS_INVALID); 122 clientMessageIds.add(SQLState.LANG_STRING_TOO_LONG); 123 } 124 125 public static void main(String [] args) throws Exception { 126 127 initClientMessageIds(); 128 129 Properties p = new Properties(); 130 131 File dir = new File(args[0]); 132 133 File source = new File(args[1]); 134 File clientDir = new File(args[2]); 135 136 String s = source.getName(); 137 s = s.substring(0, s.lastIndexOf('.')); 139 String locale = s.substring(s.indexOf('_')); 141 142 boolean addBase = "_en".equals(locale); 143 144 145 InputStream is = new BufferedInputStream(new FileInputStream(source), 64 * 1024); 146 147 p.load(is); 148 is.close(); 149 150 151 Properties[] c = new Properties[50]; 152 for (int i = 0; i < 50; i++) { 153 c[i] = new Properties(); 154 } 155 156 Properties clientProps = new Properties(); 157 158 String clientPropsFileName = "clientmessages" + locale + ".properties"; 159 160 for (Enumeration e = p.keys(); e.hasMoreElements(); ) { 161 String key = (String ) e.nextElement(); 162 163 c[MessageService.hashString50(key)].put(key, p.getProperty(key)); 164 165 if ( isClientMessage(key) ) 167 { 168 clientProps.put(key, p.getProperty(key)); 169 } 170 } 171 172 for (int i = 0; i < 50; i++) { 173 if (c[i].size() == 0) 174 continue; 175 OutputStream fos = new BufferedOutputStream( 176 new FileOutputStream(new File(dir, "m"+i+locale+".properties")), 16 * 1024); 177 178 179 c[i].save(fos, (String ) null); 180 fos.flush(); 181 fos.close(); 182 183 if (addBase) { 184 fos = new BufferedOutputStream( 186 new FileOutputStream(new File(dir, "m"+i+".properties")), 16 * 1024); 187 c[i].save(fos, (String ) null); 188 fos.flush(); 189 fos.close(); 190 } 191 192 193 } 194 195 System.out.println("split messages" + locale); 196 197 OutputStream clientOutStream = new BufferedOutputStream( 201 new FileOutputStream(new File(dir, clientPropsFileName)), 202 16 * 1024); 203 204 clientProps.save(clientOutStream, (String )null); 205 clientOutStream.flush(); 206 clientOutStream.close(); 207 208 if ( addBase ) 209 { 210 clientOutStream = new BufferedOutputStream( 212 new FileOutputStream(new File(dir, "clientmessages.properties")), 213 16 * 1024); 214 215 clientProps.save(clientOutStream, (String )null); 216 clientOutStream.flush(); 217 clientOutStream.close(); 218 } 219 System.out.println("Copied client messages for " + locale); 220 } 221 222 231 static boolean isClientMessage(String messageId) 232 { 233 if ( messageId.startsWith("XJ") || messageId.startsWith("J") || 237 messageId.startsWith("XN") || messageId.startsWith("58") || 238 messageId.startsWith("57") || messageId.startsWith("08")) 239 { 240 return true; 241 } 242 243 if ( clientMessageIds.contains(messageId)) 244 { 245 return true; 246 } 247 248 return false; 249 } 250 } 251 | Popular Tags |