java.nio.charset.spi.CharsetProvider Java Examples
The following examples show how to use
java.nio.charset.spi.CharsetProvider.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: Charset.java From openjdk-jdk9 with GNU General Public License v2.0 | 6 votes |
private static CharsetProvider[] extendedProviders() { return AccessController.doPrivileged(new PrivilegedAction<>() { public CharsetProvider[] run() { CharsetProvider[] cps = new CharsetProvider[1]; int n = 0; ServiceLoader<CharsetProvider> sl = ServiceLoader.loadInstalled(CharsetProvider.class); for (CharsetProvider cp : sl) { if (n + 1 > cps.length) { cps = Arrays.copyOf(cps, cps.length << 1); } cps[n++] = cp; } return n == cps.length ? cps : Arrays.copyOf(cps, n); }}); }
Example #2
Source File: Charset.java From Bytecoder with Apache License 2.0 | 6 votes |
private static CharsetProvider[] extendedProviders() { return AccessController.doPrivileged(new PrivilegedAction<>() { public CharsetProvider[] run() { CharsetProvider[] cps = new CharsetProvider[1]; int n = 0; ServiceLoader<CharsetProvider> sl = ServiceLoader.loadInstalled(CharsetProvider.class); for (CharsetProvider cp : sl) { if (n + 1 > cps.length) { cps = Arrays.copyOf(cps, cps.length << 1); } cps[n++] = cp; } return n == cps.length ? cps : Arrays.copyOf(cps, n); }}); }
Example #3
Source File: Charset.java From Java8CN with Apache License 2.0 | 5 votes |
private static Charset lookupViaProviders(final String charsetName) { // The runtime startup sequence looks up standard charsets as a // consequence of the VM's invocation of System.initializeSystemClass // in order to, e.g., set system properties and encode filenames. At // that point the application class loader has not been initialized, // however, so we can't look for providers because doing so will cause // that loader to be prematurely initialized with incomplete // information. // if (!sun.misc.VM.isBooted()) return null; if (gate.get() != null) // Avoid recursive provider lookups return null; try { gate.set(gate); return AccessController.doPrivileged( new PrivilegedAction<Charset>() { public Charset run() { for (Iterator<CharsetProvider> i = providers(); i.hasNext();) { CharsetProvider cp = i.next(); Charset cs = cp.charsetForName(charsetName); if (cs != null) return cs; } return null; } }); } finally { gate.set(null); } }
Example #4
Source File: Charset.java From dragonwell8_jdk with GNU General Public License v2.0 | 5 votes |
private static Charset lookupViaProviders(final String charsetName) { // The runtime startup sequence looks up standard charsets as a // consequence of the VM's invocation of System.initializeSystemClass // in order to, e.g., set system properties and encode filenames. At // that point the application class loader has not been initialized, // however, so we can't look for providers because doing so will cause // that loader to be prematurely initialized with incomplete // information. // if (!sun.misc.VM.isBooted()) return null; if (gate.get() != null) // Avoid recursive provider lookups return null; try { gate.set(gate); return AccessController.doPrivileged( new PrivilegedAction<Charset>() { public Charset run() { for (Iterator<CharsetProvider> i = providers(); i.hasNext();) { CharsetProvider cp = i.next(); Charset cs = cp.charsetForName(charsetName); if (cs != null) return cs; } return null; } }); } finally { gate.set(null); } }
Example #5
Source File: Charset.java From jdk-1.7-annotated with Apache License 2.0 | 5 votes |
private static Charset lookupViaProviders(final String charsetName) { // The runtime startup sequence looks up standard charsets as a // consequence of the VM's invocation of System.initializeSystemClass // in order to, e.g., set system properties and encode filenames. At // that point the application class loader has not been initialized, // however, so we can't look for providers because doing so will cause // that loader to be prematurely initialized with incomplete // information. // if (!sun.misc.VM.isBooted()) return null; if (gate.get() != null) // Avoid recursive provider lookups return null; try { gate.set(gate); return AccessController.doPrivileged( new PrivilegedAction<Charset>() { public Charset run() { for (Iterator i = providers(); i.hasNext();) { CharsetProvider cp = (CharsetProvider)i.next(); Charset cs = cp.charsetForName(charsetName); if (cs != null) return cs; } return null; } }); } finally { gate.set(null); } }
Example #6
Source File: Charset.java From jdk8u60 with GNU General Public License v2.0 | 5 votes |
private static Charset lookupViaProviders(final String charsetName) { // The runtime startup sequence looks up standard charsets as a // consequence of the VM's invocation of System.initializeSystemClass // in order to, e.g., set system properties and encode filenames. At // that point the application class loader has not been initialized, // however, so we can't look for providers because doing so will cause // that loader to be prematurely initialized with incomplete // information. // if (!sun.misc.VM.isBooted()) return null; if (gate.get() != null) // Avoid recursive provider lookups return null; try { gate.set(gate); return AccessController.doPrivileged( new PrivilegedAction<Charset>() { public Charset run() { for (Iterator<CharsetProvider> i = providers(); i.hasNext();) { CharsetProvider cp = i.next(); Charset cs = cp.charsetForName(charsetName); if (cs != null) return cs; } return null; } }); } finally { gate.set(null); } }
Example #7
Source File: Charset.java From jdk8u-dev-jdk with GNU General Public License v2.0 | 5 votes |
private static Charset lookupViaProviders(final String charsetName) { // The runtime startup sequence looks up standard charsets as a // consequence of the VM's invocation of System.initializeSystemClass // in order to, e.g., set system properties and encode filenames. At // that point the application class loader has not been initialized, // however, so we can't look for providers because doing so will cause // that loader to be prematurely initialized with incomplete // information. // if (!sun.misc.VM.isBooted()) return null; if (gate.get() != null) // Avoid recursive provider lookups return null; try { gate.set(gate); return AccessController.doPrivileged( new PrivilegedAction<Charset>() { public Charset run() { for (Iterator<CharsetProvider> i = providers(); i.hasNext();) { CharsetProvider cp = i.next(); Charset cs = cp.charsetForName(charsetName); if (cs != null) return cs; } return null; } }); } finally { gate.set(null); } }
Example #8
Source File: Charset.java From TencentKona-8 with GNU General Public License v2.0 | 5 votes |
private static Charset lookupViaProviders(final String charsetName) { // The runtime startup sequence looks up standard charsets as a // consequence of the VM's invocation of System.initializeSystemClass // in order to, e.g., set system properties and encode filenames. At // that point the application class loader has not been initialized, // however, so we can't look for providers because doing so will cause // that loader to be prematurely initialized with incomplete // information. // if (!sun.misc.VM.isBooted()) return null; if (gate.get() != null) // Avoid recursive provider lookups return null; try { gate.set(gate); return AccessController.doPrivileged( new PrivilegedAction<Charset>() { public Charset run() { for (Iterator<CharsetProvider> i = providers(); i.hasNext();) { CharsetProvider cp = i.next(); Charset cs = cp.charsetForName(charsetName); if (cs != null) return cs; } return null; } }); } finally { gate.set(null); } }
Example #9
Source File: Charset.java From jdk8u-jdk with GNU General Public License v2.0 | 5 votes |
private static Charset lookupViaProviders(final String charsetName) { // The runtime startup sequence looks up standard charsets as a // consequence of the VM's invocation of System.initializeSystemClass // in order to, e.g., set system properties and encode filenames. At // that point the application class loader has not been initialized, // however, so we can't look for providers because doing so will cause // that loader to be prematurely initialized with incomplete // information. // if (!sun.misc.VM.isBooted()) return null; if (gate.get() != null) // Avoid recursive provider lookups return null; try { gate.set(gate); return AccessController.doPrivileged( new PrivilegedAction<Charset>() { public Charset run() { for (Iterator<CharsetProvider> i = providers(); i.hasNext();) { CharsetProvider cp = i.next(); Charset cs = cp.charsetForName(charsetName); if (cs != null) return cs; } return null; } }); } finally { gate.set(null); } }
Example #10
Source File: Charset.java From JDKSourceCode1.8 with MIT License | 5 votes |
private static Charset lookupViaProviders(final String charsetName) { // The runtime startup sequence looks up standard charsets as a // consequence of the VM's invocation of System.initializeSystemClass // in order to, e.g., set system properties and encode filenames. At // that point the application class loader has not been initialized, // however, so we can't look for providers because doing so will cause // that loader to be prematurely initialized with incomplete // information. // if (!sun.misc.VM.isBooted()) return null; if (gate.get() != null) // Avoid recursive provider lookups return null; try { gate.set(gate); return AccessController.doPrivileged( new PrivilegedAction<Charset>() { public Charset run() { for (Iterator<CharsetProvider> i = providers(); i.hasNext();) { CharsetProvider cp = i.next(); Charset cs = cp.charsetForName(charsetName); if (cs != null) return cs; } return null; } }); } finally { gate.set(null); } }
Example #11
Source File: Charset.java From openjdk-jdk8u with GNU General Public License v2.0 | 5 votes |
private static Charset lookupViaProviders(final String charsetName) { // The runtime startup sequence looks up standard charsets as a // consequence of the VM's invocation of System.initializeSystemClass // in order to, e.g., set system properties and encode filenames. At // that point the application class loader has not been initialized, // however, so we can't look for providers because doing so will cause // that loader to be prematurely initialized with incomplete // information. // if (!sun.misc.VM.isBooted()) return null; if (gate.get() != null) // Avoid recursive provider lookups return null; try { gate.set(gate); return AccessController.doPrivileged( new PrivilegedAction<Charset>() { public Charset run() { for (Iterator<CharsetProvider> i = providers(); i.hasNext();) { CharsetProvider cp = i.next(); Charset cs = cp.charsetForName(charsetName); if (cs != null) return cs; } return null; } }); } finally { gate.set(null); } }
Example #12
Source File: Charset.java From jdk8u_jdk with GNU General Public License v2.0 | 5 votes |
private static Charset lookupViaProviders(final String charsetName) { // The runtime startup sequence looks up standard charsets as a // consequence of the VM's invocation of System.initializeSystemClass // in order to, e.g., set system properties and encode filenames. At // that point the application class loader has not been initialized, // however, so we can't look for providers because doing so will cause // that loader to be prematurely initialized with incomplete // information. // if (!sun.misc.VM.isBooted()) return null; if (gate.get() != null) // Avoid recursive provider lookups return null; try { gate.set(gate); return AccessController.doPrivileged( new PrivilegedAction<Charset>() { public Charset run() { for (Iterator<CharsetProvider> i = providers(); i.hasNext();) { CharsetProvider cp = i.next(); Charset cs = cp.charsetForName(charsetName); if (cs != null) return cs; } return null; } }); } finally { gate.set(null); } }
Example #13
Source File: Charset.java From openjdk-8 with GNU General Public License v2.0 | 5 votes |
private static Charset lookupViaProviders(final String charsetName) { // The runtime startup sequence looks up standard charsets as a // consequence of the VM's invocation of System.initializeSystemClass // in order to, e.g., set system properties and encode filenames. At // that point the application class loader has not been initialized, // however, so we can't look for providers because doing so will cause // that loader to be prematurely initialized with incomplete // information. // if (!sun.misc.VM.isBooted()) return null; if (gate.get() != null) // Avoid recursive provider lookups return null; try { gate.set(gate); return AccessController.doPrivileged( new PrivilegedAction<Charset>() { public Charset run() { for (Iterator<CharsetProvider> i = providers(); i.hasNext();) { CharsetProvider cp = i.next(); Charset cs = cp.charsetForName(charsetName); if (cs != null) return cs; } return null; } }); } finally { gate.set(null); } }
Example #14
Source File: Charset.java From jdk1.8-source-analysis with Apache License 2.0 | 5 votes |
private static Charset lookupViaProviders(final String charsetName) { // The runtime startup sequence looks up standard charsets as a // consequence of the VM's invocation of System.initializeSystemClass // in order to, e.g., set system properties and encode filenames. At // that point the application class loader has not been initialized, // however, so we can't look for providers because doing so will cause // that loader to be prematurely initialized with incomplete // information. // if (!sun.misc.VM.isBooted()) return null; if (gate.get() != null) // Avoid recursive provider lookups return null; try { gate.set(gate); return AccessController.doPrivileged( new PrivilegedAction<Charset>() { public Charset run() { for (Iterator<CharsetProvider> i = providers(); i.hasNext();) { CharsetProvider cp = i.next(); Charset cs = cp.charsetForName(charsetName); if (cs != null) return cs; } return null; } }); } finally { gate.set(null); } }
Example #15
Source File: Charset.java From hottub with GNU General Public License v2.0 | 5 votes |
private static Charset lookupViaProviders(final String charsetName) { // The runtime startup sequence looks up standard charsets as a // consequence of the VM's invocation of System.initializeSystemClass // in order to, e.g., set system properties and encode filenames. At // that point the application class loader has not been initialized, // however, so we can't look for providers because doing so will cause // that loader to be prematurely initialized with incomplete // information. // if (!sun.misc.VM.isBooted()) return null; if (gate.get() != null) // Avoid recursive provider lookups return null; try { gate.set(gate); return AccessController.doPrivileged( new PrivilegedAction<Charset>() { public Charset run() { for (Iterator<CharsetProvider> i = providers(); i.hasNext();) { CharsetProvider cp = i.next(); Charset cs = cp.charsetForName(charsetName); if (cs != null) return cs; } return null; } }); } finally { gate.set(null); } }
Example #16
Source File: Charset.java From jdk8u-jdk with GNU General Public License v2.0 | 5 votes |
private static Charset lookupViaProviders(final String charsetName) { // The runtime startup sequence looks up standard charsets as a // consequence of the VM's invocation of System.initializeSystemClass // in order to, e.g., set system properties and encode filenames. At // that point the application class loader has not been initialized, // however, so we can't look for providers because doing so will cause // that loader to be prematurely initialized with incomplete // information. // if (!sun.misc.VM.isBooted()) return null; if (gate.get() != null) // Avoid recursive provider lookups return null; try { gate.set(gate); return AccessController.doPrivileged( new PrivilegedAction<Charset>() { public Charset run() { for (Iterator<CharsetProvider> i = providers(); i.hasNext();) { CharsetProvider cp = i.next(); Charset cs = cp.charsetForName(charsetName); if (cs != null) return cs; } return null; } }); } finally { gate.set(null); } }
Example #17
Source File: Charset.java From openjdk-8-source with GNU General Public License v2.0 | 5 votes |
private static Charset lookupViaProviders(final String charsetName) { // The runtime startup sequence looks up standard charsets as a // consequence of the VM's invocation of System.initializeSystemClass // in order to, e.g., set system properties and encode filenames. At // that point the application class loader has not been initialized, // however, so we can't look for providers because doing so will cause // that loader to be prematurely initialized with incomplete // information. // if (!sun.misc.VM.isBooted()) return null; if (gate.get() != null) // Avoid recursive provider lookups return null; try { gate.set(gate); return AccessController.doPrivileged( new PrivilegedAction<Charset>() { public Charset run() { for (Iterator<CharsetProvider> i = providers(); i.hasNext();) { CharsetProvider cp = i.next(); Charset cs = cp.charsetForName(charsetName); if (cs != null) return cs; } return null; } }); } finally { gate.set(null); } }
Example #18
Source File: Charset.java From openjdk-jdk9 with GNU General Public License v2.0 | 5 votes |
private static Charset lookupExtendedCharset(String charsetName) { if (!VM.isBooted()) // see lookupViaProviders() return null; CharsetProvider[] ecps = ExtendedProviderHolder.extendedProviders; for (CharsetProvider cp : ecps) { Charset cs = cp.charsetForName(charsetName); if (cs != null) return cs; } return null; }
Example #19
Source File: Charset.java From openjdk-jdk9 with GNU General Public License v2.0 | 5 votes |
private static Charset lookupViaProviders(final String charsetName) { // The runtime startup sequence looks up standard charsets as a // consequence of the VM's invocation of System.initializeSystemClass // in order to, e.g., set system properties and encode filenames. At // that point the application class loader has not been initialized, // however, so we can't look for providers because doing so will cause // that loader to be prematurely initialized with incomplete // information. // if (!VM.isBooted()) return null; if (gate.get() != null) // Avoid recursive provider lookups return null; try { gate.set(gate); return AccessController.doPrivileged( new PrivilegedAction<>() { public Charset run() { for (Iterator<CharsetProvider> i = providers(); i.hasNext();) { CharsetProvider cp = i.next(); Charset cs = cp.charsetForName(charsetName); if (cs != null) return cs; } return null; } }); } finally { gate.set(null); } }
Example #20
Source File: Charset.java From Bytecoder with Apache License 2.0 | 5 votes |
private static Charset lookupExtendedCharset(String charsetName) { if (!VM.isBooted()) // see lookupViaProviders() return null; CharsetProvider[] ecps = ExtendedProviderHolder.extendedProviders; for (CharsetProvider cp : ecps) { Charset cs = cp.charsetForName(charsetName); if (cs != null) return cs; } return null; }
Example #21
Source File: Charset.java From Bytecoder with Apache License 2.0 | 5 votes |
private static Charset lookupViaProviders(final String charsetName) { // The runtime startup sequence looks up standard charsets as a // consequence of the VM's invocation of System.initializeSystemClass // in order to, e.g., set system properties and encode filenames. At // that point the application class loader has not been initialized, // however, so we can't look for providers because doing so will cause // that loader to be prematurely initialized with incomplete // information. // if (!VM.isBooted()) return null; if (gate.get() != null) // Avoid recursive provider lookups return null; try { gate.set(gate); return AccessController.doPrivileged( new PrivilegedAction<>() { public Charset run() { for (Iterator<CharsetProvider> i = providers(); i.hasNext();) { CharsetProvider cp = i.next(); Charset cs = cp.charsetForName(charsetName); if (cs != null) return cs; } return null; } }); } finally { gate.set(null); } }
Example #22
Source File: Charset.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 5 votes |
private static Charset lookupViaProviders(final String charsetName) { // The runtime startup sequence looks up standard charsets as a // consequence of the VM's invocation of System.initializeSystemClass // in order to, e.g., set system properties and encode filenames. At // that point the application class loader has not been initialized, // however, so we can't look for providers because doing so will cause // that loader to be prematurely initialized with incomplete // information. // if (!sun.misc.VM.isBooted()) return null; if (gate.get() != null) // Avoid recursive provider lookups return null; try { gate.set(gate); return AccessController.doPrivileged( new PrivilegedAction<Charset>() { public Charset run() { for (Iterator<CharsetProvider> i = providers(); i.hasNext();) { CharsetProvider cp = i.next(); Charset cs = cp.charsetForName(charsetName); if (cs != null) return cs; } return null; } }); } finally { gate.set(null); } }
Example #23
Source File: Charset.java From hottub with GNU General Public License v2.0 | 4 votes |
private static Iterator<CharsetProvider> providers() { return new Iterator<CharsetProvider>() { ClassLoader cl = ClassLoader.getSystemClassLoader(); ServiceLoader<CharsetProvider> sl = ServiceLoader.load(CharsetProvider.class, cl); Iterator<CharsetProvider> i = sl.iterator(); CharsetProvider next = null; private boolean getNext() { while (next == null) { try { if (!i.hasNext()) return false; next = i.next(); } catch (ServiceConfigurationError sce) { if (sce.getCause() instanceof SecurityException) { // Ignore security exceptions continue; } throw sce; } } return true; } public boolean hasNext() { return getNext(); } public CharsetProvider next() { if (!getNext()) throw new NoSuchElementException(); CharsetProvider n = next; next = null; return n; } public void remove() { throw new UnsupportedOperationException(); } }; }
Example #24
Source File: Charset.java From jdk8u-dev-jdk with GNU General Public License v2.0 | 4 votes |
private static Iterator<CharsetProvider> providers() { return new Iterator<CharsetProvider>() { ClassLoader cl = ClassLoader.getSystemClassLoader(); ServiceLoader<CharsetProvider> sl = ServiceLoader.load(CharsetProvider.class, cl); Iterator<CharsetProvider> i = sl.iterator(); CharsetProvider next = null; private boolean getNext() { while (next == null) { try { if (!i.hasNext()) return false; next = i.next(); } catch (ServiceConfigurationError sce) { if (sce.getCause() instanceof SecurityException) { // Ignore security exceptions continue; } throw sce; } } return true; } public boolean hasNext() { return getNext(); } public CharsetProvider next() { if (!getNext()) throw new NoSuchElementException(); CharsetProvider n = next; next = null; return n; } public void remove() { throw new UnsupportedOperationException(); } }; }
Example #25
Source File: Charset.java From openjdk-8-source with GNU General Public License v2.0 | 4 votes |
private static Charset lookupExtendedCharset(String charsetName) { CharsetProvider ecp = ExtendedProviderHolder.extendedProvider; return (ecp != null) ? ecp.charsetForName(charsetName) : null; }
Example #26
Source File: Charset.java From hottub with GNU General Public License v2.0 | 4 votes |
/** * Constructs a sorted map from canonical charset names to charset objects. * * <p> The map returned by this method will have one entry for each charset * for which support is available in the current Java virtual machine. If * two or more supported charsets have the same canonical name then the * resulting map will contain just one of them; which one it will contain * is not specified. </p> * * <p> The invocation of this method, and the subsequent use of the * resulting map, may cause time-consuming disk or network I/O operations * to occur. This method is provided for applications that need to * enumerate all of the available charsets, for example to allow user * charset selection. This method is not used by the {@link #forName * forName} method, which instead employs an efficient incremental lookup * algorithm. * * <p> This method may return different results at different times if new * charset providers are dynamically made available to the current Java * virtual machine. In the absence of such changes, the charsets returned * by this method are exactly those that can be retrieved via the {@link * #forName forName} method. </p> * * @return An immutable, case-insensitive map from canonical charset names * to charset objects */ public static SortedMap<String,Charset> availableCharsets() { return AccessController.doPrivileged( new PrivilegedAction<SortedMap<String,Charset>>() { public SortedMap<String,Charset> run() { TreeMap<String,Charset> m = new TreeMap<String,Charset>( ASCIICaseInsensitiveComparator.CASE_INSENSITIVE_ORDER); put(standardProvider.charsets(), m); CharsetProvider ecp = ExtendedProviderHolder.extendedProvider; if (ecp != null) put(ecp.charsets(), m); for (Iterator<CharsetProvider> i = providers(); i.hasNext();) { CharsetProvider cp = i.next(); put(cp.charsets(), m); } return Collections.unmodifiableSortedMap(m); } }); }
Example #27
Source File: SettableCharsetProvider.java From j2objc with Apache License 2.0 | 4 votes |
public static void setDelegate(CharsetProvider cp) { delegate = cp; }
Example #28
Source File: Charset.java From jdk1.8-source-analysis with Apache License 2.0 | 4 votes |
private static Iterator<CharsetProvider> providers() { return new Iterator<CharsetProvider>() { ClassLoader cl = ClassLoader.getSystemClassLoader(); ServiceLoader<CharsetProvider> sl = ServiceLoader.load(CharsetProvider.class, cl); Iterator<CharsetProvider> i = sl.iterator(); CharsetProvider next = null; private boolean getNext() { while (next == null) { try { if (!i.hasNext()) return false; next = i.next(); } catch (ServiceConfigurationError sce) { if (sce.getCause() instanceof SecurityException) { // Ignore security exceptions continue; } throw sce; } } return true; } public boolean hasNext() { return getNext(); } public CharsetProvider next() { if (!getNext()) throw new NoSuchElementException(); CharsetProvider n = next; next = null; return n; } public void remove() { throw new UnsupportedOperationException(); } }; }
Example #29
Source File: Charset.java From hottub with GNU General Public License v2.0 | 4 votes |
private static Charset lookupExtendedCharset(String charsetName) { CharsetProvider ecp = ExtendedProviderHolder.extendedProvider; return (ecp != null) ? ecp.charsetForName(charsetName) : null; }
Example #30
Source File: Charset.java From jdk8u-dev-jdk with GNU General Public License v2.0 | 4 votes |
private static Charset lookupExtendedCharset(String charsetName) { CharsetProvider ecp = ExtendedProviderHolder.extendedProvider; return (ecp != null) ? ecp.charsetForName(charsetName) : null; }