summaryrefslogtreecommitdiff
path: root/libjava/java/nio/charset
diff options
context:
space:
mode:
Diffstat (limited to 'libjava/java/nio/charset')
-rw-r--r--libjava/java/nio/charset/CharacterCodingException.h35
-rw-r--r--libjava/java/nio/charset/Charset.h80
-rw-r--r--libjava/java/nio/charset/Charset.java414
-rw-r--r--libjava/java/nio/charset/CharsetDecoder.h81
-rw-r--r--libjava/java/nio/charset/CharsetEncoder.h84
-rw-r--r--libjava/java/nio/charset/CoderMalfunctionError.h35
-rw-r--r--libjava/java/nio/charset/CoderResult$1.h36
-rw-r--r--libjava/java/nio/charset/CoderResult$2.h36
-rw-r--r--libjava/java/nio/charset/CoderResult$Cache.h39
-rw-r--r--libjava/java/nio/charset/CoderResult.h61
-rw-r--r--libjava/java/nio/charset/CodingErrorAction.h39
-rw-r--r--libjava/java/nio/charset/IllegalCharsetNameException.h37
-rw-r--r--libjava/java/nio/charset/MalformedInputException.h38
-rw-r--r--libjava/java/nio/charset/UnmappableCharacterException.h38
-rw-r--r--libjava/java/nio/charset/UnsupportedCharsetException.h38
-rw-r--r--libjava/java/nio/charset/spi/CharsetProvider.h39
-rw-r--r--libjava/java/nio/charset/spi/CharsetProvider.java96
17 files changed, 1226 insertions, 0 deletions
diff --git a/libjava/java/nio/charset/CharacterCodingException.h b/libjava/java/nio/charset/CharacterCodingException.h
new file mode 100644
index 000000000..35935cd1f
--- /dev/null
+++ b/libjava/java/nio/charset/CharacterCodingException.h
@@ -0,0 +1,35 @@
+
+// DO NOT EDIT THIS FILE - it is machine generated -*- c++ -*-
+
+#ifndef __java_nio_charset_CharacterCodingException__
+#define __java_nio_charset_CharacterCodingException__
+
+#pragma interface
+
+#include <java/io/IOException.h>
+extern "Java"
+{
+ namespace java
+ {
+ namespace nio
+ {
+ namespace charset
+ {
+ class CharacterCodingException;
+ }
+ }
+ }
+}
+
+class java::nio::charset::CharacterCodingException : public ::java::io::IOException
+{
+
+public:
+ CharacterCodingException();
+private:
+ static const jlong serialVersionUID = 8421532232154627783LL;
+public:
+ static ::java::lang::Class class$;
+};
+
+#endif // __java_nio_charset_CharacterCodingException__
diff --git a/libjava/java/nio/charset/Charset.h b/libjava/java/nio/charset/Charset.h
new file mode 100644
index 000000000..dabf4671d
--- /dev/null
+++ b/libjava/java/nio/charset/Charset.h
@@ -0,0 +1,80 @@
+
+// DO NOT EDIT THIS FILE - it is machine generated -*- c++ -*-
+
+#ifndef __java_nio_charset_Charset__
+#define __java_nio_charset_Charset__
+
+#pragma interface
+
+#include <java/lang/Object.h>
+#include <gcj/array.h>
+
+extern "Java"
+{
+ namespace java
+ {
+ namespace nio
+ {
+ class ByteBuffer;
+ class CharBuffer;
+ namespace charset
+ {
+ class Charset;
+ class CharsetDecoder;
+ class CharsetEncoder;
+ namespace spi
+ {
+ class CharsetProvider;
+ }
+ }
+ }
+ }
+}
+
+class java::nio::charset::Charset : public ::java::lang::Object
+{
+
+public: // actually protected
+ Charset(::java::lang::String *, JArray< ::java::lang::String * > *);
+private:
+ static void checkName(::java::lang::String *);
+public:
+ static ::java::nio::charset::Charset * defaultCharset();
+ static jboolean isSupported(::java::lang::String *);
+ static ::java::nio::charset::Charset * forName(::java::lang::String *);
+private:
+ static ::java::nio::charset::Charset * charsetForName(::java::lang::String *);
+public:
+ static ::java::util::SortedMap * availableCharsets();
+private:
+ static ::java::nio::charset::spi::CharsetProvider * provider();
+ static JArray< ::java::nio::charset::spi::CharsetProvider * > * providers2();
+public:
+ virtual ::java::lang::String * name();
+ virtual ::java::util::Set * aliases();
+ virtual ::java::lang::String * displayName();
+ virtual ::java::lang::String * displayName(::java::util::Locale *);
+ virtual jboolean isRegistered();
+ virtual jboolean contains(::java::nio::charset::Charset *) = 0;
+ virtual ::java::nio::charset::CharsetDecoder * newDecoder() = 0;
+ virtual ::java::nio::charset::CharsetEncoder * newEncoder() = 0;
+ virtual jboolean canEncode();
+ virtual ::java::nio::ByteBuffer * encode(::java::nio::CharBuffer *);
+ virtual ::java::nio::ByteBuffer * encode(::java::lang::String *);
+ virtual ::java::nio::CharBuffer * decode(::java::nio::ByteBuffer *);
+ virtual jint Charset$compareTo(::java::nio::charset::Charset *);
+ virtual jint hashCode();
+ virtual jboolean equals(::java::lang::Object *);
+ virtual ::java::lang::String * toString();
+ virtual jint compareTo(::java::lang::Object *);
+private:
+ ::java::nio::charset::CharsetEncoder * __attribute__((aligned(__alignof__( ::java::lang::Object)))) cachedEncoder;
+ ::java::nio::charset::CharsetDecoder * cachedDecoder;
+ static JArray< ::java::nio::charset::spi::CharsetProvider * > * providers;
+ ::java::lang::String * canonicalName;
+ JArray< ::java::lang::String * > * aliases__;
+public:
+ static ::java::lang::Class class$;
+};
+
+#endif // __java_nio_charset_Charset__
diff --git a/libjava/java/nio/charset/Charset.java b/libjava/java/nio/charset/Charset.java
new file mode 100644
index 000000000..04b381948
--- /dev/null
+++ b/libjava/java/nio/charset/Charset.java
@@ -0,0 +1,414 @@
+/* Charset.java --
+ Copyright (C) 2002, 2004, 2005, 2007 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package java.nio.charset;
+
+import gnu.classpath.ServiceFactory;
+import gnu.classpath.SystemProperties;
+import gnu.java.nio.charset.Provider;
+
+import java.io.BufferedReader;
+import java.io.InputStreamReader;
+import java.net.URL;
+import java.nio.ByteBuffer;
+import java.nio.CharBuffer;
+import java.nio.charset.spi.CharsetProvider;
+import java.util.Collections;
+import java.util.Enumeration;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.LinkedHashSet;
+import java.util.Locale;
+import java.util.Set;
+import java.util.SortedMap;
+import java.util.TreeMap;
+
+/**
+ * @author Jesse Rosenstock
+ * @since 1.4
+ * @status updated to 1.5
+ */
+public abstract class Charset implements Comparable<Charset>
+{
+ private CharsetEncoder cachedEncoder;
+ private CharsetDecoder cachedDecoder;
+
+ /**
+ * Extra Charset providers.
+ */
+ private static CharsetProvider[] providers;
+
+ private final String canonicalName;
+ private final String[] aliases;
+
+ protected Charset (String canonicalName, String[] aliases)
+ {
+ checkName (canonicalName);
+ if (aliases != null)
+ {
+ int n = aliases.length;
+ for (int i = 0; i < n; ++i)
+ checkName (aliases[i]);
+ }
+
+ cachedEncoder = null;
+ cachedDecoder = null;
+ this.canonicalName = canonicalName;
+ this.aliases = aliases;
+ }
+
+ /**
+ * @throws IllegalCharsetNameException if the name is illegal
+ */
+ private static void checkName (String name)
+ {
+ int n = name.length ();
+
+ if (n == 0)
+ throw new IllegalCharsetNameException (name);
+
+ char ch = name.charAt (0);
+ if (!(('A' <= ch && ch <= 'Z')
+ || ('a' <= ch && ch <= 'z')
+ || ('0' <= ch && ch <= '9')))
+ throw new IllegalCharsetNameException (name);
+
+ for (int i = 1; i < n; ++i)
+ {
+ ch = name.charAt (i);
+ if (!(('A' <= ch && ch <= 'Z')
+ || ('a' <= ch && ch <= 'z')
+ || ('0' <= ch && ch <= '9')
+ || ch == '-' || ch == '.' || ch == ':' || ch == '_'))
+ throw new IllegalCharsetNameException (name);
+ }
+ }
+
+ /**
+ * Returns the system default charset.
+ *
+ * This may be set by the user or VM with the file.encoding
+ * property.
+ *
+ * @since 1.5
+ */
+ public static Charset defaultCharset()
+ {
+ String encoding;
+
+ try
+ {
+ encoding = SystemProperties.getProperty("file.encoding");
+ }
+ catch(SecurityException e)
+ {
+ // Use fallback.
+ encoding = "ISO-8859-1";
+ }
+ catch(IllegalArgumentException e)
+ {
+ // Use fallback.
+ encoding = "ISO-8859-1";
+ }
+
+ try
+ {
+ return forName(encoding);
+ }
+ catch(UnsupportedCharsetException e)
+ {
+ // Ignore.
+ }
+ catch(IllegalCharsetNameException e)
+ {
+ // Ignore.
+ }
+ catch(IllegalArgumentException e)
+ {
+ // Ignore.
+ }
+
+ throw new IllegalStateException("Can't get default charset!");
+ }
+
+ public static boolean isSupported (String charsetName)
+ {
+ return charsetForName (charsetName) != null;
+ }
+
+ /**
+ * Returns the Charset instance for the charset of the given name.
+ *
+ * @param charsetName
+ * @return the Charset instance for the indicated charset
+ * @throws UnsupportedCharsetException if this VM does not support
+ * the charset of the given name.
+ * @throws IllegalCharsetNameException if the given charset name is
+ * legal.
+ * @throws IllegalArgumentException if <code>charsetName</code> is null.
+ */
+ public static Charset forName (String charsetName)
+ {
+ // Throws IllegalArgumentException as the JDK does.
+ if(charsetName == null)
+ throw new IllegalArgumentException("Charset name must not be null.");
+
+ Charset cs = charsetForName (charsetName);
+ if (cs == null)
+ throw new UnsupportedCharsetException (charsetName);
+ return cs;
+ }
+
+ /**
+ * Retrieves a charset for the given charset name.
+ *
+ * @return A charset object for the charset with the specified name, or
+ * <code>null</code> if no such charset exists.
+ *
+ * @throws IllegalCharsetNameException if the name is illegal
+ */
+ private static Charset charsetForName(String charsetName)
+ {
+ checkName (charsetName);
+ // Try the default provider first
+ // (so we don't need to load external providers unless really necessary)
+ // if it is an exotic charset try loading the external providers.
+ Charset cs = provider().charsetForName(charsetName);
+ if (cs == null)
+ {
+ CharsetProvider[] providers = providers2();
+ for (int i = 0; i < providers.length; i++)
+ {
+ cs = providers[i].charsetForName(charsetName);
+ if (cs != null)
+ break;
+ }
+ }
+ return cs;
+ }
+
+ public static SortedMap<String, Charset> availableCharsets()
+ {
+ TreeMap<String, Charset> charsets
+ = new TreeMap(String.CASE_INSENSITIVE_ORDER);
+ for (Iterator<Charset> i = provider().charsets(); i.hasNext(); )
+ {
+ Charset cs = i.next();
+ charsets.put(cs.name(), cs);
+ }
+
+ CharsetProvider[] providers = providers2();
+ for (int j = 0; j < providers.length; j++)
+ {
+ for (Iterator<Charset> i = providers[j].charsets(); i.hasNext(); )
+ {
+ Charset cs = (Charset) i.next();
+ charsets.put(cs.name(), cs);
+ }
+ }
+
+ return Collections.unmodifiableSortedMap(charsets);
+ }
+
+ private static CharsetProvider provider()
+ {
+ try
+ {
+ String s = System.getProperty("charset.provider");
+ if (s != null)
+ {
+ CharsetProvider p =
+ (CharsetProvider) ((Class.forName(s)).newInstance());
+ return p;
+ }
+ }
+ catch (Exception e)
+ {
+ // Ignore.
+ }
+
+ return Provider.provider();
+ }
+
+ /**
+ * We need to support multiple providers, reading them from
+ * java.nio.charset.spi.CharsetProvider in the resource directory
+ * META-INF/services. This returns the "extra" charset providers.
+ */
+ private static CharsetProvider[] providers2()
+ {
+ if (providers == null)
+ {
+ try
+ {
+ Iterator i = ServiceFactory.lookupProviders(CharsetProvider.class);
+ LinkedHashSet set = new LinkedHashSet();
+ while (i.hasNext())
+ set.add(i.next());
+
+ providers = new CharsetProvider[set.size()];
+ set.toArray(providers);
+ }
+ catch (Exception e)
+ {
+ throw new RuntimeException(e);
+ }
+ }
+ return providers;
+ }
+
+ public final String name ()
+ {
+ return canonicalName;
+ }
+
+ public final Set<String> aliases ()
+ {
+ if (aliases == null)
+ return Collections.<String>emptySet();
+
+ // should we cache the aliasSet instead?
+ int n = aliases.length;
+ HashSet<String> aliasSet = new HashSet<String> (n);
+ for (int i = 0; i < n; ++i)
+ aliasSet.add (aliases[i]);
+ return Collections.unmodifiableSet (aliasSet);
+ }
+
+ public String displayName ()
+ {
+ return canonicalName;
+ }
+
+ public String displayName (Locale locale)
+ {
+ return canonicalName;
+ }
+
+ public final boolean isRegistered ()
+ {
+ return (!canonicalName.startsWith ("x-")
+ && !canonicalName.startsWith ("X-"));
+ }
+
+ public abstract boolean contains (Charset cs);
+
+ public abstract CharsetDecoder newDecoder ();
+
+ public abstract CharsetEncoder newEncoder ();
+
+ public boolean canEncode ()
+ {
+ return true;
+ }
+
+ // NB: This implementation serializes different threads calling
+ // Charset.encode(), a potential performance problem. It might
+ // be better to remove the cache, or use ThreadLocal to cache on
+ // a per-thread basis.
+ public final synchronized ByteBuffer encode (CharBuffer cb)
+ {
+ try
+ {
+ if (cachedEncoder == null)
+ {
+ cachedEncoder = newEncoder ()
+ .onMalformedInput (CodingErrorAction.REPLACE)
+ .onUnmappableCharacter (CodingErrorAction.REPLACE);
+ } else
+ cachedEncoder.reset();
+ return cachedEncoder.encode (cb);
+ }
+ catch (CharacterCodingException e)
+ {
+ throw new AssertionError (e);
+ }
+ }
+
+ public final ByteBuffer encode (String str)
+ {
+ return encode (CharBuffer.wrap (str));
+ }
+
+ // NB: This implementation serializes different threads calling
+ // Charset.decode(), a potential performance problem. It might
+ // be better to remove the cache, or use ThreadLocal to cache on
+ // a per-thread basis.
+ public final synchronized CharBuffer decode (ByteBuffer bb)
+ {
+ try
+ {
+ if (cachedDecoder == null)
+ {
+ cachedDecoder = newDecoder ()
+ .onMalformedInput (CodingErrorAction.REPLACE)
+ .onUnmappableCharacter (CodingErrorAction.REPLACE);
+ } else
+ cachedDecoder.reset();
+
+ return cachedDecoder.decode (bb);
+ }
+ catch (CharacterCodingException e)
+ {
+ throw new AssertionError (e);
+ }
+ }
+
+ public final int compareTo (Charset other)
+ {
+ return canonicalName.compareToIgnoreCase (other.canonicalName);
+ }
+
+ public final int hashCode ()
+ {
+ return canonicalName.hashCode ();
+ }
+
+ public final boolean equals (Object ob)
+ {
+ if (ob instanceof Charset)
+ return canonicalName.equalsIgnoreCase (((Charset) ob).canonicalName);
+ else
+ return false;
+ }
+
+ public final String toString ()
+ {
+ return canonicalName;
+ }
+}
diff --git a/libjava/java/nio/charset/CharsetDecoder.h b/libjava/java/nio/charset/CharsetDecoder.h
new file mode 100644
index 000000000..fe75d48a5
--- /dev/null
+++ b/libjava/java/nio/charset/CharsetDecoder.h
@@ -0,0 +1,81 @@
+
+// DO NOT EDIT THIS FILE - it is machine generated -*- c++ -*-
+
+#ifndef __java_nio_charset_CharsetDecoder__
+#define __java_nio_charset_CharsetDecoder__
+
+#pragma interface
+
+#include <java/lang/Object.h>
+extern "Java"
+{
+ namespace java
+ {
+ namespace nio
+ {
+ class ByteBuffer;
+ class CharBuffer;
+ namespace charset
+ {
+ class Charset;
+ class CharsetDecoder;
+ class CoderResult;
+ class CodingErrorAction;
+ }
+ }
+ }
+}
+
+class java::nio::charset::CharsetDecoder : public ::java::lang::Object
+{
+
+ CharsetDecoder(::java::nio::charset::Charset *, jfloat, jfloat, ::java::lang::String *);
+public: // actually protected
+ CharsetDecoder(::java::nio::charset::Charset *, jfloat, jfloat);
+public:
+ virtual jfloat averageCharsPerByte();
+ virtual ::java::nio::charset::Charset * charset();
+ virtual ::java::nio::CharBuffer * decode(::java::nio::ByteBuffer *);
+ virtual ::java::nio::charset::CoderResult * decode(::java::nio::ByteBuffer *, ::java::nio::CharBuffer *, jboolean);
+public: // actually protected
+ virtual ::java::nio::charset::CoderResult * decodeLoop(::java::nio::ByteBuffer *, ::java::nio::CharBuffer *) = 0;
+public:
+ virtual ::java::nio::charset::Charset * detectedCharset();
+ virtual ::java::nio::charset::CoderResult * flush(::java::nio::CharBuffer *);
+public: // actually protected
+ virtual ::java::nio::charset::CoderResult * implFlush(::java::nio::CharBuffer *);
+public:
+ virtual ::java::nio::charset::CharsetDecoder * onMalformedInput(::java::nio::charset::CodingErrorAction *);
+public: // actually protected
+ virtual void implOnMalformedInput(::java::nio::charset::CodingErrorAction *);
+ virtual void implOnUnmappableCharacter(::java::nio::charset::CodingErrorAction *);
+ virtual void implReplaceWith(::java::lang::String *);
+ virtual void implReset();
+public:
+ virtual jboolean isAutoDetecting();
+ virtual jboolean isCharsetDetected();
+ virtual ::java::nio::charset::CodingErrorAction * malformedInputAction();
+ virtual jfloat maxCharsPerByte();
+ virtual ::java::nio::charset::CharsetDecoder * onUnmappableCharacter(::java::nio::charset::CodingErrorAction *);
+ virtual ::java::lang::String * replacement();
+ virtual ::java::nio::charset::CharsetDecoder * replaceWith(::java::lang::String *);
+ virtual ::java::nio::charset::CharsetDecoder * reset();
+ virtual ::java::nio::charset::CodingErrorAction * unmappableCharacterAction();
+private:
+ static const jint STATE_RESET = 0;
+ static const jint STATE_CODING = 1;
+ static const jint STATE_END = 2;
+ static const jint STATE_FLUSHED = 3;
+ static ::java::lang::String * DEFAULT_REPLACEMENT;
+ ::java::nio::charset::Charset * __attribute__((aligned(__alignof__( ::java::lang::Object)))) charset__;
+ jfloat averageCharsPerByte__;
+ jfloat maxCharsPerByte__;
+ ::java::lang::String * replacement__;
+ jint state;
+ ::java::nio::charset::CodingErrorAction * malformedInputAction__;
+ ::java::nio::charset::CodingErrorAction * unmappableCharacterAction__;
+public:
+ static ::java::lang::Class class$;
+};
+
+#endif // __java_nio_charset_CharsetDecoder__
diff --git a/libjava/java/nio/charset/CharsetEncoder.h b/libjava/java/nio/charset/CharsetEncoder.h
new file mode 100644
index 000000000..5a64e44f7
--- /dev/null
+++ b/libjava/java/nio/charset/CharsetEncoder.h
@@ -0,0 +1,84 @@
+
+// DO NOT EDIT THIS FILE - it is machine generated -*- c++ -*-
+
+#ifndef __java_nio_charset_CharsetEncoder__
+#define __java_nio_charset_CharsetEncoder__
+
+#pragma interface
+
+#include <java/lang/Object.h>
+#include <gcj/array.h>
+
+extern "Java"
+{
+ namespace java
+ {
+ namespace nio
+ {
+ class ByteBuffer;
+ class CharBuffer;
+ namespace charset
+ {
+ class Charset;
+ class CharsetEncoder;
+ class CoderResult;
+ class CodingErrorAction;
+ }
+ }
+ }
+}
+
+class java::nio::charset::CharsetEncoder : public ::java::lang::Object
+{
+
+public: // actually protected
+ CharsetEncoder(::java::nio::charset::Charset *, jfloat, jfloat);
+ CharsetEncoder(::java::nio::charset::Charset *, jfloat, jfloat, JArray< jbyte > *);
+public:
+ virtual jfloat averageBytesPerChar();
+ virtual jboolean canEncode(jchar);
+ virtual jboolean canEncode(::java::lang::CharSequence *);
+private:
+ jboolean canEncode(::java::nio::CharBuffer *);
+public:
+ virtual ::java::nio::charset::Charset * charset();
+ virtual ::java::nio::ByteBuffer * encode(::java::nio::CharBuffer *);
+ virtual ::java::nio::charset::CoderResult * encode(::java::nio::CharBuffer *, ::java::nio::ByteBuffer *, jboolean);
+public: // actually protected
+ virtual ::java::nio::charset::CoderResult * encodeLoop(::java::nio::CharBuffer *, ::java::nio::ByteBuffer *) = 0;
+public:
+ virtual ::java::nio::charset::CoderResult * flush(::java::nio::ByteBuffer *);
+public: // actually protected
+ virtual ::java::nio::charset::CoderResult * implFlush(::java::nio::ByteBuffer *);
+ virtual void implOnMalformedInput(::java::nio::charset::CodingErrorAction *);
+ virtual void implOnUnmappableCharacter(::java::nio::charset::CodingErrorAction *);
+ virtual void implReplaceWith(JArray< jbyte > *);
+ virtual void implReset();
+public:
+ virtual jboolean isLegalReplacement(JArray< jbyte > *);
+ virtual ::java::nio::charset::CodingErrorAction * malformedInputAction();
+ virtual jfloat maxBytesPerChar();
+ virtual ::java::nio::charset::CharsetEncoder * onMalformedInput(::java::nio::charset::CodingErrorAction *);
+ virtual ::java::nio::charset::CodingErrorAction * unmappableCharacterAction();
+ virtual ::java::nio::charset::CharsetEncoder * onUnmappableCharacter(::java::nio::charset::CodingErrorAction *);
+ virtual JArray< jbyte > * replacement();
+ virtual ::java::nio::charset::CharsetEncoder * replaceWith(JArray< jbyte > *);
+ virtual ::java::nio::charset::CharsetEncoder * reset();
+private:
+ static const jint STATE_RESET = 0;
+ static const jint STATE_CODING = 1;
+ static const jint STATE_END = 2;
+ static const jint STATE_FLUSHED = 3;
+ static JArray< jbyte > * DEFAULT_REPLACEMENT;
+ ::java::nio::charset::Charset * __attribute__((aligned(__alignof__( ::java::lang::Object)))) charset__;
+ jfloat averageBytesPerChar__;
+ jfloat maxBytesPerChar__;
+ JArray< jbyte > * replacement__;
+ jint state;
+ ::java::nio::charset::CodingErrorAction * malformedInputAction__;
+ ::java::nio::charset::CodingErrorAction * unmappableCharacterAction__;
+public:
+ static ::java::lang::Class class$;
+};
+
+#endif // __java_nio_charset_CharsetEncoder__
diff --git a/libjava/java/nio/charset/CoderMalfunctionError.h b/libjava/java/nio/charset/CoderMalfunctionError.h
new file mode 100644
index 000000000..b3ae83adf
--- /dev/null
+++ b/libjava/java/nio/charset/CoderMalfunctionError.h
@@ -0,0 +1,35 @@
+
+// DO NOT EDIT THIS FILE - it is machine generated -*- c++ -*-
+
+#ifndef __java_nio_charset_CoderMalfunctionError__
+#define __java_nio_charset_CoderMalfunctionError__
+
+#pragma interface
+
+#include <java/lang/Error.h>
+extern "Java"
+{
+ namespace java
+ {
+ namespace nio
+ {
+ namespace charset
+ {
+ class CoderMalfunctionError;
+ }
+ }
+ }
+}
+
+class java::nio::charset::CoderMalfunctionError : public ::java::lang::Error
+{
+
+public:
+ CoderMalfunctionError(::java::lang::Exception *);
+private:
+ static const jlong serialVersionUID = -1151412348057794301LL;
+public:
+ static ::java::lang::Class class$;
+};
+
+#endif // __java_nio_charset_CoderMalfunctionError__
diff --git a/libjava/java/nio/charset/CoderResult$1.h b/libjava/java/nio/charset/CoderResult$1.h
new file mode 100644
index 000000000..421777005
--- /dev/null
+++ b/libjava/java/nio/charset/CoderResult$1.h
@@ -0,0 +1,36 @@
+
+// DO NOT EDIT THIS FILE - it is machine generated -*- c++ -*-
+
+#ifndef __java_nio_charset_CoderResult$1__
+#define __java_nio_charset_CoderResult$1__
+
+#pragma interface
+
+#include <java/nio/charset/CoderResult$Cache.h>
+extern "Java"
+{
+ namespace java
+ {
+ namespace nio
+ {
+ namespace charset
+ {
+ class CoderResult;
+ class CoderResult$1;
+ }
+ }
+ }
+}
+
+class java::nio::charset::CoderResult$1 : public ::java::nio::charset::CoderResult$Cache
+{
+
+public: // actually package-private
+ CoderResult$1();
+public: // actually protected
+ virtual ::java::nio::charset::CoderResult * make(jint);
+public:
+ static ::java::lang::Class class$;
+};
+
+#endif // __java_nio_charset_CoderResult$1__
diff --git a/libjava/java/nio/charset/CoderResult$2.h b/libjava/java/nio/charset/CoderResult$2.h
new file mode 100644
index 000000000..60dcbdcb2
--- /dev/null
+++ b/libjava/java/nio/charset/CoderResult$2.h
@@ -0,0 +1,36 @@
+
+// DO NOT EDIT THIS FILE - it is machine generated -*- c++ -*-
+
+#ifndef __java_nio_charset_CoderResult$2__
+#define __java_nio_charset_CoderResult$2__
+
+#pragma interface
+
+#include <java/nio/charset/CoderResult$Cache.h>
+extern "Java"
+{
+ namespace java
+ {
+ namespace nio
+ {
+ namespace charset
+ {
+ class CoderResult;
+ class CoderResult$2;
+ }
+ }
+ }
+}
+
+class java::nio::charset::CoderResult$2 : public ::java::nio::charset::CoderResult$Cache
+{
+
+public: // actually package-private
+ CoderResult$2();
+public: // actually protected
+ virtual ::java::nio::charset::CoderResult * make(jint);
+public:
+ static ::java::lang::Class class$;
+};
+
+#endif // __java_nio_charset_CoderResult$2__
diff --git a/libjava/java/nio/charset/CoderResult$Cache.h b/libjava/java/nio/charset/CoderResult$Cache.h
new file mode 100644
index 000000000..38416bd9e
--- /dev/null
+++ b/libjava/java/nio/charset/CoderResult$Cache.h
@@ -0,0 +1,39 @@
+
+// DO NOT EDIT THIS FILE - it is machine generated -*- c++ -*-
+
+#ifndef __java_nio_charset_CoderResult$Cache__
+#define __java_nio_charset_CoderResult$Cache__
+
+#pragma interface
+
+#include <java/lang/Object.h>
+extern "Java"
+{
+ namespace java
+ {
+ namespace nio
+ {
+ namespace charset
+ {
+ class CoderResult;
+ class CoderResult$Cache;
+ }
+ }
+ }
+}
+
+class java::nio::charset::CoderResult$Cache : public ::java::lang::Object
+{
+
+public: // actually package-private
+ CoderResult$Cache();
+ virtual ::java::nio::charset::CoderResult * get(jint);
+public: // actually protected
+ virtual ::java::nio::charset::CoderResult * make(jint) = 0;
+private:
+ ::java::util::HashMap * __attribute__((aligned(__alignof__( ::java::lang::Object)))) cache;
+public:
+ static ::java::lang::Class class$;
+};
+
+#endif // __java_nio_charset_CoderResult$Cache__
diff --git a/libjava/java/nio/charset/CoderResult.h b/libjava/java/nio/charset/CoderResult.h
new file mode 100644
index 000000000..e2c84a61c
--- /dev/null
+++ b/libjava/java/nio/charset/CoderResult.h
@@ -0,0 +1,61 @@
+
+// DO NOT EDIT THIS FILE - it is machine generated -*- c++ -*-
+
+#ifndef __java_nio_charset_CoderResult__
+#define __java_nio_charset_CoderResult__
+
+#pragma interface
+
+#include <java/lang/Object.h>
+#include <gcj/array.h>
+
+extern "Java"
+{
+ namespace java
+ {
+ namespace nio
+ {
+ namespace charset
+ {
+ class CoderResult;
+ class CoderResult$Cache;
+ }
+ }
+ }
+}
+
+class java::nio::charset::CoderResult : public ::java::lang::Object
+{
+
+public: // actually package-private
+ CoderResult(jint, jint);
+public:
+ virtual jboolean isError();
+ virtual jboolean isMalformed();
+ virtual jboolean isOverflow();
+ virtual jboolean isUnderflow();
+ virtual jboolean isUnmappable();
+ virtual jint length();
+ static ::java::nio::charset::CoderResult * malformedForLength(jint);
+ virtual void throwException();
+ virtual ::java::lang::String * toString();
+ static ::java::nio::charset::CoderResult * unmappableForLength(jint);
+private:
+ static const jint TYPE_MALFORMED = 0;
+ static const jint TYPE_OVERFLOW = 1;
+ static const jint TYPE_UNDERFLOW = 2;
+ static const jint TYPE_UNMAPPABLE = 3;
+public:
+ static ::java::nio::charset::CoderResult * OVERFLOW;
+ static ::java::nio::charset::CoderResult * UNDERFLOW;
+private:
+ static JArray< ::java::lang::String * > * names;
+ static ::java::nio::charset::CoderResult$Cache * malformedCache;
+ static ::java::nio::charset::CoderResult$Cache * unmappableCache;
+ jint __attribute__((aligned(__alignof__( ::java::lang::Object)))) type;
+ jint length__;
+public:
+ static ::java::lang::Class class$;
+};
+
+#endif // __java_nio_charset_CoderResult__
diff --git a/libjava/java/nio/charset/CodingErrorAction.h b/libjava/java/nio/charset/CodingErrorAction.h
new file mode 100644
index 000000000..c0bf2aa66
--- /dev/null
+++ b/libjava/java/nio/charset/CodingErrorAction.h
@@ -0,0 +1,39 @@
+
+// DO NOT EDIT THIS FILE - it is machine generated -*- c++ -*-
+
+#ifndef __java_nio_charset_CodingErrorAction__
+#define __java_nio_charset_CodingErrorAction__
+
+#pragma interface
+
+#include <java/lang/Object.h>
+extern "Java"
+{
+ namespace java
+ {
+ namespace nio
+ {
+ namespace charset
+ {
+ class CodingErrorAction;
+ }
+ }
+ }
+}
+
+class java::nio::charset::CodingErrorAction : public ::java::lang::Object
+{
+
+ CodingErrorAction(::java::lang::String *);
+public:
+ virtual ::java::lang::String * toString();
+ static ::java::nio::charset::CodingErrorAction * IGNORE;
+ static ::java::nio::charset::CodingErrorAction * REPLACE;
+ static ::java::nio::charset::CodingErrorAction * REPORT;
+private:
+ ::java::lang::String * __attribute__((aligned(__alignof__( ::java::lang::Object)))) name;
+public:
+ static ::java::lang::Class class$;
+};
+
+#endif // __java_nio_charset_CodingErrorAction__
diff --git a/libjava/java/nio/charset/IllegalCharsetNameException.h b/libjava/java/nio/charset/IllegalCharsetNameException.h
new file mode 100644
index 000000000..c4b42474f
--- /dev/null
+++ b/libjava/java/nio/charset/IllegalCharsetNameException.h
@@ -0,0 +1,37 @@
+
+// DO NOT EDIT THIS FILE - it is machine generated -*- c++ -*-
+
+#ifndef __java_nio_charset_IllegalCharsetNameException__
+#define __java_nio_charset_IllegalCharsetNameException__
+
+#pragma interface
+
+#include <java/lang/IllegalArgumentException.h>
+extern "Java"
+{
+ namespace java
+ {
+ namespace nio
+ {
+ namespace charset
+ {
+ class IllegalCharsetNameException;
+ }
+ }
+ }
+}
+
+class java::nio::charset::IllegalCharsetNameException : public ::java::lang::IllegalArgumentException
+{
+
+public:
+ IllegalCharsetNameException(::java::lang::String *);
+ virtual ::java::lang::String * getCharsetName();
+private:
+ static const jlong serialVersionUID = 1457525358470002989LL;
+ ::java::lang::String * __attribute__((aligned(__alignof__( ::java::lang::IllegalArgumentException)))) charsetName;
+public:
+ static ::java::lang::Class class$;
+};
+
+#endif // __java_nio_charset_IllegalCharsetNameException__
diff --git a/libjava/java/nio/charset/MalformedInputException.h b/libjava/java/nio/charset/MalformedInputException.h
new file mode 100644
index 000000000..03a6d8d98
--- /dev/null
+++ b/libjava/java/nio/charset/MalformedInputException.h
@@ -0,0 +1,38 @@
+
+// DO NOT EDIT THIS FILE - it is machine generated -*- c++ -*-
+
+#ifndef __java_nio_charset_MalformedInputException__
+#define __java_nio_charset_MalformedInputException__
+
+#pragma interface
+
+#include <java/nio/charset/CharacterCodingException.h>
+extern "Java"
+{
+ namespace java
+ {
+ namespace nio
+ {
+ namespace charset
+ {
+ class MalformedInputException;
+ }
+ }
+ }
+}
+
+class java::nio::charset::MalformedInputException : public ::java::nio::charset::CharacterCodingException
+{
+
+public:
+ MalformedInputException(jint);
+ virtual jint getInputLength();
+ virtual ::java::lang::String * getMessage();
+private:
+ static const jlong serialVersionUID = -3438823399834806194LL;
+ jint __attribute__((aligned(__alignof__( ::java::nio::charset::CharacterCodingException)))) inputLength;
+public:
+ static ::java::lang::Class class$;
+};
+
+#endif // __java_nio_charset_MalformedInputException__
diff --git a/libjava/java/nio/charset/UnmappableCharacterException.h b/libjava/java/nio/charset/UnmappableCharacterException.h
new file mode 100644
index 000000000..f0ced263f
--- /dev/null
+++ b/libjava/java/nio/charset/UnmappableCharacterException.h
@@ -0,0 +1,38 @@
+
+// DO NOT EDIT THIS FILE - it is machine generated -*- c++ -*-
+
+#ifndef __java_nio_charset_UnmappableCharacterException__
+#define __java_nio_charset_UnmappableCharacterException__
+
+#pragma interface
+
+#include <java/nio/charset/CharacterCodingException.h>
+extern "Java"
+{
+ namespace java
+ {
+ namespace nio
+ {
+ namespace charset
+ {
+ class UnmappableCharacterException;
+ }
+ }
+ }
+}
+
+class java::nio::charset::UnmappableCharacterException : public ::java::nio::charset::CharacterCodingException
+{
+
+public:
+ UnmappableCharacterException(jint);
+ virtual jint getInputLength();
+ virtual ::java::lang::String * getMessage();
+private:
+ static const jlong serialVersionUID = -7026962371537706123LL;
+ jint __attribute__((aligned(__alignof__( ::java::nio::charset::CharacterCodingException)))) inputLength;
+public:
+ static ::java::lang::Class class$;
+};
+
+#endif // __java_nio_charset_UnmappableCharacterException__
diff --git a/libjava/java/nio/charset/UnsupportedCharsetException.h b/libjava/java/nio/charset/UnsupportedCharsetException.h
new file mode 100644
index 000000000..7f09678fe
--- /dev/null
+++ b/libjava/java/nio/charset/UnsupportedCharsetException.h
@@ -0,0 +1,38 @@
+
+// DO NOT EDIT THIS FILE - it is machine generated -*- c++ -*-
+
+#ifndef __java_nio_charset_UnsupportedCharsetException__
+#define __java_nio_charset_UnsupportedCharsetException__
+
+#pragma interface
+
+#include <java/lang/IllegalArgumentException.h>
+extern "Java"
+{
+ namespace java
+ {
+ namespace nio
+ {
+ namespace charset
+ {
+ class UnsupportedCharsetException;
+ }
+ }
+ }
+}
+
+class java::nio::charset::UnsupportedCharsetException : public ::java::lang::IllegalArgumentException
+{
+
+public:
+ UnsupportedCharsetException(::java::lang::String *);
+ virtual ::java::lang::String * getCharsetName();
+private:
+ static const jlong serialVersionUID = 1490765524727386367LL;
+public: // actually package-private
+ ::java::lang::String * __attribute__((aligned(__alignof__( ::java::lang::IllegalArgumentException)))) charsetName;
+public:
+ static ::java::lang::Class class$;
+};
+
+#endif // __java_nio_charset_UnsupportedCharsetException__
diff --git a/libjava/java/nio/charset/spi/CharsetProvider.h b/libjava/java/nio/charset/spi/CharsetProvider.h
new file mode 100644
index 000000000..b194e106b
--- /dev/null
+++ b/libjava/java/nio/charset/spi/CharsetProvider.h
@@ -0,0 +1,39 @@
+
+// DO NOT EDIT THIS FILE - it is machine generated -*- c++ -*-
+
+#ifndef __java_nio_charset_spi_CharsetProvider__
+#define __java_nio_charset_spi_CharsetProvider__
+
+#pragma interface
+
+#include <java/lang/Object.h>
+extern "Java"
+{
+ namespace java
+ {
+ namespace nio
+ {
+ namespace charset
+ {
+ class Charset;
+ namespace spi
+ {
+ class CharsetProvider;
+ }
+ }
+ }
+ }
+}
+
+class java::nio::charset::spi::CharsetProvider : public ::java::lang::Object
+{
+
+public: // actually protected
+ CharsetProvider();
+public:
+ virtual ::java::util::Iterator * charsets() = 0;
+ virtual ::java::nio::charset::Charset * charsetForName(::java::lang::String *) = 0;
+ static ::java::lang::Class class$;
+};
+
+#endif // __java_nio_charset_spi_CharsetProvider__
diff --git a/libjava/java/nio/charset/spi/CharsetProvider.java b/libjava/java/nio/charset/spi/CharsetProvider.java
new file mode 100644
index 000000000..d56723c3f
--- /dev/null
+++ b/libjava/java/nio/charset/spi/CharsetProvider.java
@@ -0,0 +1,96 @@
+/* CharsetProvider.java -- charset service provider interface
+ Copyright (C) 2002, 2006, 2007 Free Software Foundation
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+package java.nio.charset.spi;
+
+import java.nio.charset.Charset;
+import java.util.Iterator;
+
+
+/**
+ * This class allows an implementor to provide additional character sets. The
+ * subclass must have a nullary constructor, and be attached to charset
+ * implementation classes. These extensions are loaded via the context class
+ * loader. To provide the charset extension, all files named
+ * <code>META-INF/services/java.nio.charset.spi.CharsetProvider</code> are
+ * read from the classpath. Each one should be a UTF-8 encoded list of
+ * fully-qualified names of concrete subclasses of this class; whitespace is
+ * ignored, and '#' starts comments. Duplicates are ignored. The
+ * implementations must be accessible to the classloader that requests them.
+ *
+ * @author Eric Blake (ebb9@email.byu.edu)
+ * @see Charset
+ * @since 1.4
+ * @status updated to 1.4
+ */
+public abstract class CharsetProvider
+{
+ /**
+ * Initialize a new charset provider. This performs a security check on
+ * RuntimePermission("charsetProvider").
+ *
+ * @throws SecurityException if building a new set is not allowed
+ */
+ protected CharsetProvider()
+ {
+ // We only do the security check for custom providers, not for the
+ // built in ones.
+ SecurityManager s = System.getSecurityManager();
+ if (s != null &&
+ ! (this instanceof gnu.java.nio.charset.Provider))
+ // GCJ LOCAL - We have the iconv provider in standard.omit
+ // || this instanceof gnu.java.nio.charset.iconv.IconvProvider))
+ s.checkPermission(new RuntimePermission("charsetProvider"));
+ }
+
+ /**
+ * Returns an iterator over the charsets defined by this provider.
+ *
+ * @return the iterator
+ * @see Charset#availableCharsets()
+ */
+ public abstract Iterator<Charset> charsets();
+
+ /**
+ * Returns the named charset, by canonical name or alias.
+ *
+ * @param name the name of the character
+ *
+ * @return the charset, or null if not supported
+ */
+ public abstract Charset charsetForName(String name);
+} // class CharsetProvider