283 if (sce.getCause() instanceof SecurityException) {
284 // Ignore the security exception, try the next provider
285 continue;
286 }
287 throw sce;
288 }
289 }
290
291 // 3. Use platform-specific system-wide default
292 String osName = System.getProperty("os.name");
293 String platformFactory;
294 if (osName.startsWith("Windows")) {
295 platformFactory = "java.util.prefs.WindowsPreferencesFactory";
296 } else if (osName.contains("OS X")) {
297 platformFactory = "java.util.prefs.MacOSXPreferencesFactory";
298 } else {
299 platformFactory = "java.util.prefs.FileSystemPreferencesFactory";
300 }
301 try {
302 return (PreferencesFactory)
303 Class.forName(platformFactory, false, null).newInstance();
304 } catch (Exception e) {
305 throw new InternalError(
306 "Can't instantiate platform default Preferences factory "
307 + platformFactory, e);
308 }
309 }
310
311 /**
312 * Maximum length of string allowed as a key (80 characters).
313 */
314 public static final int MAX_KEY_LENGTH = 80;
315
316 /**
317 * Maximum length of string allowed as a value (8192 characters).
318 */
319 public static final int MAX_VALUE_LENGTH = 8*1024;
320
321 /**
322 * Maximum length of a node name (80 characters).
323 */
|
283 if (sce.getCause() instanceof SecurityException) {
284 // Ignore the security exception, try the next provider
285 continue;
286 }
287 throw sce;
288 }
289 }
290
291 // 3. Use platform-specific system-wide default
292 String osName = System.getProperty("os.name");
293 String platformFactory;
294 if (osName.startsWith("Windows")) {
295 platformFactory = "java.util.prefs.WindowsPreferencesFactory";
296 } else if (osName.contains("OS X")) {
297 platformFactory = "java.util.prefs.MacOSXPreferencesFactory";
298 } else {
299 platformFactory = "java.util.prefs.FileSystemPreferencesFactory";
300 }
301 try {
302 return (PreferencesFactory)
303 Class.forName(platformFactory, false,
304 Preferences.class.getClassLoader()).newInstance();
305 } catch (Exception e) {
306 throw new InternalError(
307 "Can't instantiate platform default Preferences factory "
308 + platformFactory, e);
309 }
310 }
311
312 /**
313 * Maximum length of string allowed as a key (80 characters).
314 */
315 public static final int MAX_KEY_LENGTH = 80;
316
317 /**
318 * Maximum length of string allowed as a value (8192 characters).
319 */
320 public static final int MAX_VALUE_LENGTH = 8*1024;
321
322 /**
323 * Maximum length of a node name (80 characters).
324 */
|