/[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.3 by rschuster, Thu Feb 3 22:37:29 2005 UTC revision 1.4 by smarothy, Fri Apr 8 21:46:05 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        // Windows-1250 aka cp-1250 (East European)
110        addCharset (new Windows1250 ());
111    
112        // Windows-1251 (Cyrillic)
113        addCharset (new Windows1251 ());
114    
115        // Windows-1252 aka cp-1252 (Latin-1)
116        addCharset (new Windows1252 ());
117    
118        // Windows-1253 (Greek)
119        addCharset (new Windows1253 ());
120    
121        // Windows-1254 (Turkish)
122        addCharset (new Windows1254 ());
123    
124        // Windows-1257 (Baltic)
125        addCharset (new Windows1257 ());
126    
127        // ISO-8859-2 aka ISO-LATIN-2
128        addCharset (new ISO_8859_2 ());
129    
130        // ISO-8859-4 aka ISO-LATIN-4
131        addCharset (new ISO_8859_4 ());
132    
133        // ISO-8859-5 (Cyrillic)
134        addCharset (new ISO_8859_5 ());
135    
136        // ISO-8859-7 (Greek)
137        addCharset (new ISO_8859_7 ());
138    
139        // ISO-8859-9 aka ISO-LATIN-5
140        addCharset (new ISO_8859_9 ());
141    
142        // ISO-8859-13 aka ISO-LATIN-7
143        addCharset (new ISO_8859_13 ());
144    
145        // ISO-8859-15 aka ISO-LATIN-9
146        addCharset (new ISO_8859_15 ());
147    
148        // KOI8 (Cyrillic)
149        addCharset (new KOI_8 ());
150      }
151    
152     /**
153      * Load non-mandatory charsets.
154      */
155      private void loadExtended ()
156      {
157        if(extendedLoaded)
158          return;
159    
160        addCharset (new ISO_8859_3 ());    // ISO-8859-3 aka ISO-LATIN-3
161        addCharset (new ISO_8859_6 ());    // ISO-8859-6 (Arabic)
162        addCharset (new ISO_8859_8 ());    // ISO-8859-8 (Hebrew)
163    
164        // Some more codepages
165        addCharset (new Cp855()); // IBM Cyrillic
166        addCharset (new Cp857()); // IBM Turkish
167        addCharset (new Cp860()); // MSDOS Portugese
168        addCharset (new Cp861()); // MSDOS Icelandic
169        addCharset (new Cp862()); // PC Hebrew
170        addCharset (new Cp863()); // MSDOS Can. French
171        addCharset (new Cp864()); // PC Arabic
172        addCharset (new Cp865()); // MSDOS Nordic
173        addCharset (new Cp866()); // MSDOS Russian
174        addCharset (new Cp869()); // IBM modern Greek
175        addCharset (new Cp874()); // IBM Thai
176        extendedLoaded = true;
177    }    }
178    
179    public Iterator charsets ()    public Iterator charsets ()
180    {    {
181        loadExtended();
182      return Collections.unmodifiableCollection (charsets.values ())      return Collections.unmodifiableCollection (charsets.values ())
183                        .iterator ();                        .iterator ();
184    }    }
# Line 119  public final class Provider extends Char Line 195  public final class Provider extends Char
195     */     */
196    public Charset charsetForName (String charsetName)    public Charset charsetForName (String charsetName)
197    {    {
198      return (Charset) charsets.get(canonicalNames.get(charsetName.toLowerCase()));      Charset cs = (Charset) charsets.get(canonicalNames.get(charsetName.toLowerCase()));
199        if(cs == null && !extendedLoaded)
200         {
201           loadExtended();
202           cs = (Charset) charsets.get(canonicalNames.get(charsetName.toLowerCase()));
203         }
204        return cs;
205    }    }
206    
207    /**    /**

Legend:
Removed from v.1.3  
changed lines
  Added in v.1.4

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