类java.nio.charset.spi.CharsetProvider源码实例Demo

下面列出了怎么用java.nio.charset.spi.CharsetProvider的API类实例代码及写法,或者点击链接到github查看源代码。

源代码1 项目: Bytecoder   文件: Charset.java
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);
            }});
}
 
源代码2 项目: openjdk-jdk9   文件: Charset.java
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);
            }});
}
 
源代码3 项目: jdk1.8-source-analysis   文件: Charset.java
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);
        }
    }
 
源代码4 项目: dragonwell8_jdk   文件: Charset.java
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);
        }
    }
 
源代码5 项目: TencentKona-8   文件: Charset.java
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);
        }
    }
 
源代码6 项目: jdk8u60   文件: Charset.java
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);
        }
    }
 
源代码7 项目: JDKSourceCode1.8   文件: Charset.java
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);
        }
    }
 
源代码8 项目: openjdk-jdk8u   文件: Charset.java
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);
        }
    }
 
源代码9 项目: openjdk-jdk8u-backup   文件: Charset.java
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);
        }
    }
 
源代码10 项目: Bytecoder   文件: Charset.java
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);
        }
    }
 
源代码11 项目: Bytecoder   文件: Charset.java
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;
}
 
源代码12 项目: openjdk-jdk9   文件: Charset.java
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);
        }
    }
 
源代码13 项目: openjdk-jdk9   文件: Charset.java
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;
}
 
源代码14 项目: jdk8u-jdk   文件: Charset.java
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);
        }
    }
 
源代码15 项目: Java8CN   文件: Charset.java
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);
        }
    }
 
源代码16 项目: hottub   文件: Charset.java
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);
        }
    }
 
源代码17 项目: openjdk-8-source   文件: Charset.java
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);
        }
    }
 
源代码18 项目: openjdk-8   文件: Charset.java
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);
        }
    }
 
源代码19 项目: jdk8u_jdk   文件: Charset.java
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);
        }
    }
 
源代码20 项目: jdk8u-jdk   文件: Charset.java
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);
        }
    }
 
源代码21 项目: jdk-1.7-annotated   文件: Charset.java
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);
        }
    }
 
源代码22 项目: jdk8u-dev-jdk   文件: Charset.java
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);
        }
    }
 
源代码23 项目: jdk1.8-source-analysis   文件: Charset.java
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();
            }

        };
}
 
源代码24 项目: jdk1.8-source-analysis   文件: Charset.java
private static Charset lookupExtendedCharset(String charsetName) {
    CharsetProvider ecp = ExtendedProviderHolder.extendedProvider;
    return (ecp != null) ? ecp.charsetForName(charsetName) : null;
}
 
源代码25 项目: jdk1.8-source-analysis   文件: Charset.java
/**
 * 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);
            }
        });
}
 
源代码26 项目: dragonwell8_jdk   文件: Charset.java
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();
            }

        };
}
 
源代码27 项目: dragonwell8_jdk   文件: Charset.java
private static Charset lookupExtendedCharset(String charsetName) {
    CharsetProvider ecp = ExtendedProviderHolder.extendedProvider;
    return (ecp != null) ? ecp.charsetForName(charsetName) : null;
}
 
源代码28 项目: dragonwell8_jdk   文件: Charset.java
/**
 * 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);
            }
        });
}
 
源代码29 项目: TencentKona-8   文件: Charset.java
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();
            }

        };
}
 
源代码30 项目: TencentKona-8   文件: Charset.java
private static Charset lookupExtendedCharset(String charsetName) {
    CharsetProvider ecp = ExtendedProviderHolder.extendedProvider;
    return (ecp != null) ? ecp.charsetForName(charsetName) : null;
}