/[classpath]/classpath/gnu/java/nio/charset/Provider.java
ViewVC logotype

Diff of /classpath/gnu/java/nio/charset/Provider.java

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

revision 1.2.2.1 by gnu_andrew, Fri Feb 4 09:44:44 2005 UTC revision 1.2.2.2 by gnu_andrew, Mon Apr 18 01:37:36 2005 UTC
# Line 77  public final class Provider extends Char Line 77  public final class Provider extends Char
77     */     */
78    private final HashMap charsets;    private final HashMap charsets;
79    
80      /**
81       * We don't load all available charsets at the start
82       */
83      private boolean extendedLoaded;
84    
85    private Provider ()    private Provider ()
86    {    {
87        extendedLoaded = false;
88      canonicalNames = new HashMap ();      canonicalNames = new HashMap ();
89      charsets = new HashMap ();      charsets = new HashMap ();
90    
# Line 99  public final class Provider extends Char Line 105  public final class Provider extends Char
105    
106      // UTF-16      // UTF-16
107      addCharset (new UTF_16 ());      addCharset (new UTF_16 ());
108    
109        // UTF-16LE (marked)
110        addCharset (new UnicodeLittle ());
111    
112        // Windows-1250 aka cp-1250 (East European)
113        addCharset (new Windows1250 ());
114    
115        // Windows-1251 (Cyrillic)
116        addCharset (new Windows1251 ());
117    
118        // Windows-1252 aka cp-1252 (Latin-1)
119        addCharset (new Windows1252 ());
120    
121        // Windows-1253 (Greek)
122        addCharset (new Windows1253 ());
123    
124        // Windows-1254 (Turkish)
125        addCharset (new Windows1254 ());
126    
127        // Windows-1257 (Baltic)
128        addCharset (new Windows1257 ());
129    
130        // ISO-8859-2 aka ISO-LATIN-2
131        addCharset (new ISO_8859_2 ());
132    
133        // ISO-8859-4 aka ISO-LATIN-4
134        addCharset (new ISO_8859_4 ());
135    
136        // ISO-8859-5 (Cyrillic)
137        addCharset (new ISO_8859_5 ());
138    
139        // ISO-8859-7 (Greek)
140        addCharset (new ISO_8859_7 ());
141    
142        // ISO-8859-9 aka ISO-LATIN-5
143        addCharset (new ISO_8859_9 ());
144    
145        // ISO-8859-13 aka ISO-LATIN-7
146        addCharset (new ISO_8859_13 ());
147    
148        // ISO-8859-15 aka ISO-LATIN-9
149        addCharset (new ISO_8859_15 ());
150    
151        // KOI8 (Cyrillic)
152        addCharset (new KOI_8 ());
153      }
154    
155     /**
156      * Load non-mandatory charsets.
157      */
158      private void loadExtended ()
159      {
160        if(extendedLoaded)
161          return;
162    
163        addCharset (new ISO_8859_3 ());    // ISO-8859-3 aka ISO-LATIN-3
164        addCharset (new ISO_8859_6 ());    // ISO-8859-6 (Arabic)
165        addCharset (new ISO_8859_8 ());    // ISO-8859-8 (Hebrew)
166    
167        // Some more codepages
168        addCharset (new Cp855()); // IBM Cyrillic
169        addCharset (new Cp857()); // IBM Turkish
170        addCharset (new Cp860()); // MSDOS Portugese
171        addCharset (new Cp861()); // MSDOS Icelandic
172        addCharset (new Cp862()); // PC Hebrew
173        addCharset (new Cp863()); // MSDOS Can. French
174        addCharset (new Cp864()); // PC Arabic
175        addCharset (new Cp865()); // MSDOS Nordic
176        addCharset (new Cp866()); // MSDOS Russian
177        addCharset (new Cp869()); // IBM modern Greek
178        addCharset (new Cp874()); // IBM Thai
179        extendedLoaded = true;
180    }    }
181    
182    public Iterator charsets ()    public Iterator charsets ()
183    {    {
184        loadExtended();
185      return Collections.unmodifiableCollection (charsets.values ())      return Collections.unmodifiableCollection (charsets.values ())
186                        .iterator ();                        .iterator ();
187    }    }
# Line 119  public final class Provider extends Char Line 198  public final class Provider extends Char
198     */     */
199    public Charset charsetForName (String charsetName)    public Charset charsetForName (String charsetName)
200    {    {
201      return (Charset) charsets.get(canonicalNames.get(charsetName.toLowerCase()));      Charset cs = (Charset) charsets.get(canonicalNames.get(charsetName.toLowerCase()));
202        if(cs == null && !extendedLoaded)
203         {
204           loadExtended();
205           cs = (Charset) charsets.get(canonicalNames.get(charsetName.toLowerCase()));
206         }
207        return cs;
208    }    }
209    
210    /**    /**

Legend:
Removed from v.1.2.2.1  
changed lines
  Added in v.1.2.2.2

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