/[classpath]/classpath/java/nio/charset/Charset.java
ViewVC logotype

Diff of /classpath/java/nio/charset/Charset.java

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.25 by green, Thu Sep 15 14:42:36 2005 UTC revision 1.26 by tromey, Sun Sep 18 00:56:22 2005 UTC
# Line 38  exception statement from your version. * Line 38  exception statement from your version. *
38    
39  package java.nio.charset;  package java.nio.charset;
40    
41    import gnu.classpath.ServiceFactory;
42  import gnu.classpath.SystemProperties;  import gnu.classpath.SystemProperties;
   
43  import gnu.java.nio.charset.Provider;  import gnu.java.nio.charset.Provider;
44  import gnu.java.nio.charset.iconv.IconvProvider;  import gnu.java.nio.charset.iconv.IconvProvider;
45    
 import java.io.BufferedReader;  
 import java.io.InputStreamReader;  
 import java.net.URL;  
46  import java.nio.ByteBuffer;  import java.nio.ByteBuffer;
47  import java.nio.CharBuffer;  import java.nio.CharBuffer;
48  import java.nio.charset.spi.CharsetProvider;  import java.nio.charset.spi.CharsetProvider;
49  import java.util.Collections;  import java.util.Collections;
 import java.util.Enumeration;  
50  import java.util.HashSet;  import java.util.HashSet;
51  import java.util.Iterator;  import java.util.Iterator;
52  import java.util.LinkedHashSet;  import java.util.LinkedHashSet;
# Line 174  public abstract class Charset implements Line 170  public abstract class Charset implements
170     * Returns the Charset instance for the charset of the given name.     * Returns the Charset instance for the charset of the given name.
171     *     *
172     * @param charsetName     * @param charsetName
173     * @return     * @return the Charset instance for the indicated charset
174     * @throws UnsupportedCharsetException if this VM does not support     * @throws UnsupportedCharsetException if this VM does not support
175     * the charset of the given name.     * the charset of the given name.
176     * @throws IllegalCharsetNameException if the given charset name is     * @throws IllegalCharsetNameException if the given charset name is
# Line 265  public abstract class Charset implements Line 261  public abstract class Charset implements
261        {        {
262          try          try
263            {            {
264              Enumeration en = ClassLoader.getSystemResources              Iterator i = ServiceFactory.lookupProviders(CharsetProvider.class);
               ("META-INF/services/java.nio.charset.spi.CharsetProvider");  
265              LinkedHashSet set = new LinkedHashSet();              LinkedHashSet set = new LinkedHashSet();
266              while (en.hasMoreElements())              while (i.hasNext())
267                {                set.add(i.next());
                 BufferedReader rdr = new BufferedReader(new InputStreamReader  
                   (((URL) (en.nextElement())).openStream()));  
                 while (true)  
                   {  
                     String s = rdr.readLine();  
                     if (s == null)  
                       break;  
                     CharsetProvider p =  
                       (CharsetProvider) ((Class.forName(s)).newInstance());  
                     set.add(p);  
                   }  
                 rdr.close();  
                }  
268    
269              providers = new CharsetProvider[set.size()];              providers = new CharsetProvider[set.size()];
270              set.toArray(providers);              set.toArray(providers);

Legend:
Removed from v.1.25  
changed lines
  Added in v.1.26

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26