equal
deleted
inserted
replaced
1 /* |
1 /* |
2 * Copyright (c) 2000, 2015, Oracle and/or its affiliates. All rights reserved. |
2 * Copyright (c) 2000, 2011, Oracle and/or its affiliates. All rights reserved. |
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
4 * |
4 * |
5 * This code is free software; you can redistribute it and/or modify it |
5 * This code is free software; you can redistribute it and/or modify it |
6 * under the terms of the GNU General Public License version 2 only, as |
6 * under the terms of the GNU General Public License version 2 only, as |
7 * published by the Free Software Foundation. Oracle designates this |
7 * published by the Free Software Foundation. Oracle designates this |
46 * @author Josh Bloch |
46 * @author Josh Bloch |
47 * @see Preferences |
47 * @see Preferences |
48 * @since 1.4 |
48 * @since 1.4 |
49 */ |
49 */ |
50 class FileSystemPreferences extends AbstractPreferences { |
50 class FileSystemPreferences extends AbstractPreferences { |
51 |
|
52 /** |
|
53 * The code point U+0000, assigned to the null control character, is the |
|
54 * only character encoded in Unicode and ISO/IEC 10646 that is always |
|
55 * invalid in any XML 1.0 and 1.1 document. |
|
56 */ |
|
57 private static final String CODE_POINT_U0000 = String.valueOf('\u0000'); |
|
58 |
51 |
59 static { |
52 static { |
60 PrivilegedAction<Void> load = () -> { |
53 PrivilegedAction<Void> load = () -> { |
61 System.loadLibrary("prefs"); |
54 System.loadLibrary("prefs"); |
62 return null; |
55 return null; |
530 public boolean isUserNode() { |
523 public boolean isUserNode() { |
531 return isUserNode; |
524 return isUserNode; |
532 } |
525 } |
533 |
526 |
534 protected void putSpi(String key, String value) { |
527 protected void putSpi(String key, String value) { |
535 if (key.indexOf(CODE_POINT_U0000) != -1) { |
|
536 throw new IllegalArgumentException("Key contains code point U+0000"); |
|
537 } else if (value.indexOf(CODE_POINT_U0000) != -1) { |
|
538 throw new IllegalArgumentException("Value contains code point U+0000"); |
|
539 } |
|
540 initCacheIfNecessary(); |
528 initCacheIfNecessary(); |
541 changeLog.add(new Put(key, value)); |
529 changeLog.add(new Put(key, value)); |
542 prefsCache.put(key, value); |
530 prefsCache.put(key, value); |
543 } |
531 } |
544 |
532 |