[llvm-commits] [llvm-gcc-4.2] r43913 [22/80] - in /llvm-gcc-4.2/trunk: boehm-gc/ boehm-gc/Mac_files/ boehm-gc/cord/ boehm-gc/doc/ boehm-gc/include/ boehm-gc/include/private/ boehm-gc/tests/ libffi/ libffi/include/ libffi/src/ libffi/src/alpha/ libffi/src/arm/ libffi/src/cris/ libffi/src/frv/ libffi/src/ia64/ libffi/src/m32r/ libffi/src/m68k/ libffi/src/mips/ libffi/src/pa/ libffi/src/powerpc/ libffi/src/s390/ libffi/src/sh/ libffi/src/sh64/ libffi/src/sparc/ libffi/src/x86/ libffi/testsuite/ libffi/testsuite/config/ li...
Bill Wendling
isanbard at gmail.com
Thu Nov 8 14:57:11 PST 2007
Added: llvm-gcc-4.2/trunk/libjava/classpath/gnu/java/lang/reflect/GenericSignatureParser.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/gnu/java/lang/reflect/GenericSignatureParser.java?rev=43913&view=auto
==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/gnu/java/lang/reflect/GenericSignatureParser.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/gnu/java/lang/reflect/GenericSignatureParser.java Thu Nov 8 16:56:19 2007
@@ -0,0 +1,622 @@
+/* GenericSignatureParser.java
+ Copyright (C) 2005
+ 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 gnu.java.lang.reflect;
+
+import java.lang.reflect.*;
+import java.util.ArrayList;
+import java.util.Arrays;
+
+final class TypeVariableImpl extends TypeImpl implements TypeVariable
+{
+ private GenericDeclaration decl;
+ private Type[] bounds;
+ private String name;
+
+ TypeVariableImpl(GenericDeclaration decl, Type[] bounds, String name)
+ {
+ this.decl = decl;
+ this.bounds = bounds;
+ this.name = name;
+ }
+
+ Type resolve()
+ {
+ return this;
+ }
+
+ /* FIXME[GENERICS]: Remove cast */
+ public Type[] getBounds()
+ {
+ resolve(bounds);
+ return (Type[]) bounds.clone();
+ }
+
+ public GenericDeclaration getGenericDeclaration()
+ {
+ return decl;
+ }
+
+ public String getName()
+ {
+ return name;
+ }
+
+ public boolean equals(Object obj)
+ {
+ if (obj instanceof TypeVariableImpl)
+ {
+ TypeVariableImpl other = (TypeVariableImpl)obj;
+ return decl.equals(other.decl) && name.equals(other.name);
+ }
+ return false;
+ }
+
+ public int hashCode()
+ {
+ return 0x5f4d5156 ^ decl.hashCode() ^ name.hashCode();
+ }
+
+ public String toString()
+ {
+ return name;
+ }
+}
+
+final class ParameterizedTypeImpl extends TypeImpl implements ParameterizedType
+{
+ private String rawTypeName;
+ private ClassLoader loader;
+ private Class rawType;
+ private Type owner;
+ private Type[] typeArgs;
+
+ ParameterizedTypeImpl(String rawTypeName, ClassLoader loader, Type owner,
+ Type[] typeArgs)
+ {
+ this.rawTypeName = rawTypeName;
+ this.loader = loader;
+ this.owner = owner;
+ this.typeArgs = typeArgs;
+ }
+
+ Type resolve()
+ {
+ if (rawType == null)
+ {
+ try
+ {
+ rawType = Class.forName(rawTypeName, false, loader);
+ }
+ catch (ClassNotFoundException x)
+ {
+ throw new TypeNotPresentException(rawTypeName, x);
+ }
+ }
+ if (typeArgs == null)
+ {
+ if (owner == null)
+ {
+ return rawType;
+ }
+ typeArgs = new Type[0];
+ }
+ resolve(typeArgs);
+ owner = resolve(owner);
+ return this;
+ }
+
+ /* FIXME[GENERICS]: Remove cast */
+ public Type[] getActualTypeArguments()
+ {
+ return (Type[]) typeArgs.clone();
+ }
+
+ public Type getRawType()
+ {
+ return rawType;
+ }
+
+ public Type getOwnerType()
+ {
+ return owner;
+ }
+
+ public boolean equals(Object obj)
+ {
+ if (obj instanceof ParameterizedTypeImpl)
+ {
+ ParameterizedTypeImpl other = (ParameterizedTypeImpl)obj;
+ return rawType.equals(other.rawType)
+ && ((owner == null && other.owner == null)
+ || owner.equals(other.owner))
+ && Arrays.deepEquals(typeArgs, other.typeArgs);
+ }
+ return false;
+ }
+
+ public int hashCode()
+ {
+ int h = 0x58158970 ^ rawType.hashCode();
+ if (owner != null)
+ {
+ h ^= Integer.reverse(owner.hashCode());
+ }
+ for (int i = 0; i < typeArgs.length; i++)
+ {
+ h ^= Integer.rotateLeft(typeArgs[i].hashCode(), i);
+ }
+ return h;
+ }
+
+ public String toString()
+ {
+ StringBuilder sb = new StringBuilder();
+ if (owner != null)
+ {
+ sb.append(owner);
+ sb.append('.');
+ sb.append(rawType.getSimpleName());
+ }
+ else
+ {
+ sb.append(rawTypeName);
+ }
+ if (typeArgs.length > 0)
+ {
+ sb.append('<');
+ for (int i = 0; i < typeArgs.length; i++)
+ {
+ if (i > 0)
+ sb.append(", ");
+ if (typeArgs[i] instanceof Class)
+ {
+ sb.append(((Class)typeArgs[i]).getName());
+ }
+ else
+ {
+ sb.append(typeArgs[i]);
+ }
+ }
+ sb.append('>');
+ }
+ return sb.toString();
+ }
+}
+
+final class GenericArrayTypeImpl extends TypeImpl implements GenericArrayType
+{
+ private Type componentType;
+
+ GenericArrayTypeImpl(Type componentType)
+ {
+ this.componentType = componentType;
+ }
+
+ Type resolve()
+ {
+ componentType = resolve(componentType);
+ return this;
+ }
+
+ public Type getGenericComponentType()
+ {
+ return componentType;
+ }
+
+ public boolean equals(Object obj)
+ {
+ if (obj instanceof GenericArrayTypeImpl)
+ {
+ GenericArrayTypeImpl other = (GenericArrayTypeImpl)obj;
+ return componentType.equals(other.componentType);
+ }
+ return false;
+ }
+
+ public int hashCode()
+ {
+ return 0x4be37a7f ^ componentType.hashCode();
+ }
+
+ public String toString()
+ {
+ return componentType + "[]";
+ }
+}
+
+final class UnresolvedTypeVariable extends TypeImpl implements Type
+{
+ private GenericDeclaration decl;
+ private String name;
+
+ UnresolvedTypeVariable(GenericDeclaration decl, String name)
+ {
+ this.decl = decl;
+ this.name = name;
+ }
+
+ Type resolve()
+ {
+ GenericDeclaration d = decl;
+ while (d != null)
+ {
+ TypeVariable[] vars = d.getTypeParameters();
+ for (int a = 0; a < vars.length ; ++a)
+ {
+ if (vars[a].getName().equals(name))
+ {
+ return vars[a];
+ }
+ }
+ d = getParent(d);
+ }
+ throw new MalformedParameterizedTypeException();
+ }
+
+ private static GenericDeclaration getParent(GenericDeclaration d)
+ {
+ if (d instanceof Class)
+ {
+ Method m = ((Class)d).getEnclosingMethod();
+ if (m != null)
+ {
+ return m;
+ }
+ Constructor c = ((Class)d).getEnclosingConstructor();
+ if (c != null)
+ {
+ return c;
+ }
+ return ((Class)d).getEnclosingClass();
+ }
+ else if (d instanceof Method)
+ {
+ return ((Method)d).getDeclaringClass();
+ }
+ else if (d instanceof Constructor)
+ {
+ return ((Constructor)d).getDeclaringClass();
+ }
+ else
+ {
+ // TODO figure out what this represents
+ throw new Error();
+ }
+ }
+}
+
+final class WildcardTypeImpl extends TypeImpl implements WildcardType
+{
+ private Type lower;
+ private Type upper;
+
+ WildcardTypeImpl(Type lower, Type upper)
+ {
+ this.lower = lower;
+ this.upper = upper;
+ }
+
+ Type resolve()
+ {
+ upper = resolve(upper);
+ lower = resolve(lower);
+ return this;
+ }
+
+ public Type[] getUpperBounds()
+ {
+ if (upper == null)
+ {
+ return new Type[0];
+ }
+ return new Type[] { upper };
+ }
+
+ public Type[] getLowerBounds()
+ {
+ if (lower == null)
+ {
+ return new Type[0];
+ }
+ return new Type[] { lower };
+ }
+
+ public boolean equals(Object obj)
+ {
+ if (obj instanceof WildcardTypeImpl)
+ {
+ WildcardTypeImpl other = (WildcardTypeImpl)obj;
+ return Arrays.deepEquals(getUpperBounds(), other.getUpperBounds())
+ && Arrays.deepEquals(getLowerBounds(), other.getLowerBounds());
+ }
+ return false;
+ }
+
+ public int hashCode()
+ {
+ int h = 0x75d074fd;
+ if (upper != null)
+ {
+ h ^= upper.hashCode();
+ }
+ if (lower != null)
+ {
+ h ^= lower.hashCode();
+ }
+ return h;
+ }
+
+ public String toString()
+ {
+ if (lower != null)
+ {
+ return "? super " + lower;
+ }
+ if (upper == java.lang.Object.class)
+ {
+ return "?";
+ }
+ return "? extends " + upper;
+ }
+}
+
+class GenericSignatureParser
+{
+ private ClassLoader loader;
+ private GenericDeclaration container;
+ private String signature;
+ private int pos;
+
+ GenericSignatureParser(GenericDeclaration container, ClassLoader loader,
+ String signature)
+ {
+ this.container = container;
+ this.loader = loader;
+ this.signature = signature;
+ }
+
+ TypeVariable[] readFormalTypeParameters()
+ {
+ consume('<');
+ ArrayList params = new ArrayList();
+ do
+ {
+ // TODO should we handle name clashes?
+ params.add(readFormalTypeParameter());
+ } while (peekChar() != '>');
+ consume('>');
+ TypeVariable[] list = new TypeVariable[params.size()];
+ params.toArray(list);
+ return list;
+ }
+
+ private TypeVariable readFormalTypeParameter()
+ {
+ String identifier = readIdentifier();
+ consume(':');
+ ArrayList bounds = new ArrayList();
+ if (peekChar() != ':')
+ {
+ bounds.add(readFieldTypeSignature());
+ }
+ while (peekChar() == ':')
+ {
+ consume(':');
+ bounds.add(readFieldTypeSignature());
+ }
+ Type[] b = new Type[bounds.size()];
+ bounds.toArray(b);
+ return new TypeVariableImpl(container, b, identifier);
+ }
+
+ Type readFieldTypeSignature()
+ {
+ switch (peekChar())
+ {
+ case 'L':
+ return readClassTypeSignature();
+ case '[':
+ return readArrayTypeSignature();
+ case 'T':
+ return readTypeVariableSignature();
+ default:
+ throw new GenericSignatureFormatError();
+ }
+ }
+
+ Type readClassTypeSignature()
+ {
+ consume('L');
+ String className = "";
+ for (;;)
+ {
+ String part = readIdentifier();
+ if (peekChar() != '/')
+ {
+ className += part;
+ break;
+ }
+ consume('/');
+ className += part + ".";
+ }
+ Type[] typeArguments = null;
+ if (peekChar() == '<')
+ {
+ typeArguments = readTypeArguments();
+ }
+ Type type = new ParameterizedTypeImpl(className, loader, null,
+ typeArguments);
+ while (peekChar() == '.')
+ {
+ consume('.');
+ className += "$" + readIdentifier();
+ typeArguments = null;
+ if (peekChar() == '<')
+ {
+ typeArguments = readTypeArguments();
+ }
+ type = new ParameterizedTypeImpl(className, loader, type,
+ typeArguments);
+ }
+ consume(';');
+ return type;
+ }
+
+ private Type[] readTypeArguments()
+ {
+ consume('<');
+ ArrayList list = new ArrayList();
+ do
+ {
+ list.add(readTypeArgument());
+ } while ((peekChar() != '>'));
+ consume('>');
+ Type[] arr = new Type[list.size()];
+ list.toArray(arr);
+ return arr;
+ }
+
+ private Type readTypeArgument()
+ {
+ char c = peekChar();
+ if (c == '+')
+ {
+ consume('+');
+ return new WildcardTypeImpl(null, readFieldTypeSignature());
+ }
+ else if (c == '-')
+ {
+ consume('-');
+ return new WildcardTypeImpl(readFieldTypeSignature(),
+ java.lang.Object.class);
+ }
+ else if (c == '*')
+ {
+ consume('*');
+ return new WildcardTypeImpl(null, java.lang.Object.class);
+ }
+ else
+ {
+ return readFieldTypeSignature();
+ }
+ }
+
+ Type readArrayTypeSignature()
+ {
+ consume('[');
+ switch (peekChar())
+ {
+ case 'L':
+ case '[':
+ case 'T':
+ return new GenericArrayTypeImpl(readFieldTypeSignature());
+ case 'Z':
+ consume('Z');
+ return boolean[].class;
+ case 'B':
+ consume('B');
+ return byte[].class;
+ case 'S':
+ consume('S');
+ return short[].class;
+ case 'C':
+ consume('C');
+ return char[].class;
+ case 'I':
+ consume('I');
+ return int[].class;
+ case 'F':
+ consume('F');
+ return float[].class;
+ case 'J':
+ consume('J');
+ return long[].class;
+ case 'D':
+ consume('D');
+ return double[].class;
+ default:
+ throw new GenericSignatureFormatError();
+ }
+ }
+
+ Type readTypeVariableSignature()
+ {
+ consume('T');
+ String identifier = readIdentifier();
+ consume(';');
+ return new UnresolvedTypeVariable(container, identifier);
+ }
+
+ private String readIdentifier()
+ {
+ int start = pos;
+ char c;
+ do
+ {
+ readChar();
+ c = peekChar();
+ } while (";:./<>-+*".indexOf(c) == -1);
+ return signature.substring(start, pos);
+ }
+
+ final char peekChar()
+ {
+ if (pos == signature.length())
+ return '\u0000';
+ else
+ return signature.charAt(pos);
+ }
+
+ final char readChar()
+ {
+ return signature.charAt(pos++);
+ }
+
+ final void consume(char c)
+ {
+ if (readChar() != c)
+ throw new GenericSignatureFormatError();
+ }
+
+ final void end()
+ {
+ if (pos != signature.length())
+ throw new GenericSignatureFormatError();
+ }
+}
Added: llvm-gcc-4.2/trunk/libjava/classpath/gnu/java/lang/reflect/MethodSignatureParser.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/gnu/java/lang/reflect/MethodSignatureParser.java?rev=43913&view=auto
==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/gnu/java/lang/reflect/MethodSignatureParser.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/gnu/java/lang/reflect/MethodSignatureParser.java Thu Nov 8 16:56:19 2007
@@ -0,0 +1,167 @@
+/* MethodSignatureParser.java
+ Copyright (C) 2005
+ 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 gnu.java.lang.reflect;
+
+import java.lang.reflect.*;
+import java.util.ArrayList;
+
+public class MethodSignatureParser extends GenericSignatureParser
+{
+ private TypeVariable[] typeParameters;
+ private Type[] argTypes;
+ private Type retType;
+ private Type[] throwsSigs;
+
+ public MethodSignatureParser(Method method, String signature)
+ {
+ this(method, method.getDeclaringClass().getClassLoader(), signature);
+ }
+
+ public MethodSignatureParser(Constructor method, String signature)
+ {
+ this(method, method.getDeclaringClass().getClassLoader(), signature);
+ }
+
+ private MethodSignatureParser(GenericDeclaration wrapper,
+ ClassLoader loader, String signature)
+ {
+ super(wrapper, loader, signature);
+
+ if (peekChar() == '<')
+ {
+ typeParameters = readFormalTypeParameters();
+ }
+ else
+ {
+ typeParameters = new TypeVariable[0];
+ }
+ consume('(');
+ ArrayList args = new ArrayList();
+ while (peekChar() != ')')
+ {
+ args.add(readTypeSignature());
+ }
+ argTypes = new Type[args.size()];
+ args.toArray(argTypes);
+ consume(')');
+ retType = readTypeSignature();
+ ArrayList throwsSigs = new ArrayList();
+ while (peekChar() == '^')
+ {
+ consume('^');
+ if(peekChar() == 'T')
+ {
+ throwsSigs.add(readTypeVariableSignature());
+ }
+ else
+ {
+ throwsSigs.add(readClassTypeSignature());
+ }
+ }
+ this.throwsSigs = new Type[throwsSigs.size()];
+ throwsSigs.toArray(this.throwsSigs);
+ end();
+ }
+
+ public TypeVariable[] getTypeParameters()
+ {
+ TypeImpl.resolve(typeParameters);
+ return typeParameters;
+ }
+
+ public Type[] getGenericParameterTypes()
+ {
+ TypeImpl.resolve(argTypes);
+ return argTypes;
+ }
+
+ public Type getGenericReturnType()
+ {
+ retType = TypeImpl.resolve(retType);
+ return retType;
+ }
+
+ public Type[] getGenericExceptionTypes()
+ {
+ TypeImpl.resolve(throwsSigs);
+ return throwsSigs;
+ }
+
+ private Type readTypeSignature()
+ {
+ switch (peekChar())
+ {
+ case 'T':
+ return readTypeVariableSignature();
+ case 'L':
+ return readClassTypeSignature();
+ case '[':
+ return readArrayTypeSignature();
+ case 'Z':
+ consume('Z');
+ return boolean.class;
+ case 'B':
+ consume('B');
+ return byte.class;
+ case 'S':
+ consume('S');
+ return short.class;
+ case 'C':
+ consume('C');
+ return char.class;
+ case 'I':
+ consume('I');
+ return int.class;
+ case 'F':
+ consume('F');
+ return float.class;
+ case 'J':
+ consume('J');
+ return long.class;
+ case 'D':
+ consume('D');
+ return double.class;
+ case 'V':
+ consume('V');
+ return void.class;
+ default:
+ throw new GenericSignatureFormatError();
+ }
+ }
+}
Added: llvm-gcc-4.2/trunk/libjava/classpath/gnu/java/lang/reflect/TypeImpl.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/gnu/java/lang/reflect/TypeImpl.java?rev=43913&view=auto
==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/gnu/java/lang/reflect/TypeImpl.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/gnu/java/lang/reflect/TypeImpl.java Thu Nov 8 16:56:19 2007
@@ -0,0 +1,63 @@
+/* TypeImpl.java
+ Copyright (C) 2005
+ 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 gnu.java.lang.reflect;
+
+import java.lang.reflect.Type;
+
+abstract class TypeImpl implements Type
+{
+ abstract Type resolve();
+
+ static void resolve(Type[] types)
+ {
+ for (int i = 0; i < types.length; i++)
+ {
+ types[i] = resolve(types[i]);
+ }
+ }
+
+ static Type resolve(Type type)
+ {
+ if (type instanceof TypeImpl)
+ {
+ type = ((TypeImpl) type).resolve();
+ }
+ return type;
+ }
+}
Added: llvm-gcc-4.2/trunk/libjava/classpath/gnu/java/lang/reflect/TypeSignature.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/gnu/java/lang/reflect/TypeSignature.java?rev=43913&view=auto
==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/gnu/java/lang/reflect/TypeSignature.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/gnu/java/lang/reflect/TypeSignature.java Thu Nov 8 16:56:19 2007
@@ -0,0 +1,288 @@
+/* TypeSignature.java -- Class used to compute type signatures
+ Copyright (C) 1998, 2000, 2002 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 gnu.java.lang.reflect;
+
+import java.lang.reflect.Constructor;
+import java.lang.reflect.Field;
+import java.lang.reflect.Member;
+import java.lang.reflect.Method;
+
+/**
+ * This class provides static methods that can be used to compute
+ * type-signatures of <code>Class</code>s or <code>Member</code>s.
+ * More specific methods are also provided for computing the
+ * type-signature of <code>Constructor</code>s and
+ * <code>Method</code>s. Methods are also provided to go in the
+ * reverse direction.
+ *
+ * @author Eric Blake (ebb9 at email.byu.edu)
+ */
+public class TypeSignature
+{
+ /**
+ * Returns a <code>String</code> representing the type-encoding of a class.
+ * The .class file format has different encodings for classes, depending
+ * on whether it must be disambiguated from primitive types or not; hence
+ * the descriptor parameter to choose between them. If you are planning
+ * on decoding primitive types along with classes, then descriptor should
+ * be true for correct results. Type-encodings are computed as follows:
+ *
+ * <pre>
+ * boolean -> "Z"
+ * byte -> "B"
+ * char -> "C"
+ * double -> "D"
+ * float -> "F"
+ * int -> "I"
+ * long -> "J"
+ * short -> "S"
+ * void -> "V"
+ * arrays -> "[" + descriptor format of component type
+ * object -> class format: fully qualified name with '.' replaced by '/'
+ * descriptor format: "L" + class format + ";"
+ * </pre>
+ *
+ * @param type the class name to encode
+ * @param descriptor true to return objects in descriptor format
+ * @return the class name, as it appears in bytecode constant pools
+ * @see #getClassForEncoding(String)
+ */
+ public static String getEncodingOfClass(String type, boolean descriptor)
+ {
+ if (! descriptor || type.charAt(0) == '[')
+ return type.replace('.', '/');
+ if (type.equals("boolean"))
+ return "Z";
+ if (type.equals("byte"))
+ return "B";
+ if (type.equals("short"))
+ return "S";
+ if (type.equals("char"))
+ return "C";
+ if (type.equals("int"))
+ return "I";
+ if (type.equals("long"))
+ return "J";
+ if (type.equals("float"))
+ return "F";
+ if (type.equals("double"))
+ return "D";
+ if (type.equals("void"))
+ return "V";
+ return 'L' + type.replace('.', '/') + ';';
+ }
+
+ /**
+ * Gets the descriptor encoding for a class.
+ *
+ * @param clazz the class to encode
+ * @param descriptor true to return objects in descriptor format
+ * @return the class name, as it appears in bytecode constant pools
+ * @see #getEncodingOfClass(String, boolean)
+ */
+ public static String getEncodingOfClass(Class clazz, boolean descriptor)
+ {
+ return getEncodingOfClass(clazz.getName(), descriptor);
+ }
+
+ /**
+ * Gets the descriptor encoding for a class.
+ *
+ * @param clazz the class to encode
+ * @return the class name, as it appears in bytecode constant pools
+ * @see #getEncodingOfClass(String, boolean)
+ */
+ public static String getEncodingOfClass(Class clazz)
+ {
+ return getEncodingOfClass(clazz.getName(), true);
+ }
+
+
+ /**
+ * This function is the inverse of <code>getEncodingOfClass</code>. This
+ * accepts both object and descriptor formats, but must know which style
+ * of string is being passed in (usually, descriptor should be true). In
+ * descriptor format, "I" is treated as int.class, in object format, it
+ * is treated as a class named I in the unnamed package. This method is
+ * strictly equivalent to {@link #getClassForEncoding(java.lang.String, boolean, java.lang.ClassLoader)}
+ * with a class loader equal to <code>null</code>. In that case, it
+ * uses the default class loader on the calling stack.
+ *
+ * @param type_code the class name to decode
+ * @param descriptor if the string is in descriptor format
+ * @return the corresponding Class object
+ * @throws ClassNotFoundException if the class cannot be located
+ * @see #getEncodingOfClass(Class, boolean)
+ */
+ public static Class getClassForEncoding(String type_code, boolean descriptor)
+ throws ClassNotFoundException
+ {
+ return getClassForEncoding(type_code, descriptor, null);
+ }
+
+ /**
+ * This function is the inverse of <code>getEncodingOfClass</code>. This
+ * accepts both object and descriptor formats, but must know which style
+ * of string is being passed in (usually, descriptor should be true). In
+ * descriptor format, "I" is treated as int.class, in object format, it
+ * is treated as a class named I in the unnamed package.
+ *
+ * @param type_code The class name to decode.
+ * @param descriptor If the string is in descriptor format.
+ * @param loader The class loader when resolving generic object name. If
+ * <code>loader</code> is null then it uses the default class loader on the
+ * calling stack.
+ * @return the corresponding Class object.
+ * @throws ClassNotFoundException if the class cannot be located.
+ * @see #getEncodingOfClass(Class, boolean)
+ * @see #getClassForEncoding(String, boolean)
+ */
+ public static Class getClassForEncoding(String type_code, boolean descriptor,
+ ClassLoader loader)
+ throws ClassNotFoundException
+ {
+ if (descriptor)
+ {
+ switch (type_code.charAt(0))
+ {
+ case 'B':
+ return byte.class;
+ case 'C':
+ return char.class;
+ case 'D':
+ return double.class;
+ case 'F':
+ return float.class;
+ case 'I':
+ return int.class;
+ case 'J':
+ return long.class;
+ case 'S':
+ return short.class;
+ case 'V':
+ return void.class;
+ case 'Z':
+ return boolean.class;
+ default:
+ throw new ClassNotFoundException("Invalid class name: "
+ + type_code);
+ case 'L':
+ type_code = type_code.substring(1, type_code.length() - 1);
+ // Fallthrough.
+ case '[':
+ }
+ }
+ return Class.forName(type_code.replace('/', '.'), true, loader);
+ }
+
+ /**
+ * Gets the Class object for a type name.
+ *
+ * @param type_code the class name to decode
+ * @return the corresponding Class object
+ * @throws ClassNotFoundException if the class cannot be located
+ * @see #getClassForEncoding(String, boolean)
+ */
+ public static Class getClassForEncoding(String type_code)
+ throws ClassNotFoundException
+ {
+ return getClassForEncoding(type_code, true);
+ }
+
+ /**
+ * Returns a <code>String</code> representing the type-encoding of a
+ * method. The type-encoding of a method is:
+ *
+ * "(" + parameter type descriptors + ")" + return type descriptor
+ *
+ * XXX This could be faster if it were implemented natively.
+ *
+ * @param m the method to encode
+ * @return the encoding
+ */
+ public static String getEncodingOfMethod(Method m)
+ {
+ Class[] paramTypes = m.getParameterTypes();
+ StringBuffer buf = new StringBuffer().append('(');
+ for (int i = 0; i < paramTypes.length; i++)
+ buf.append(getEncodingOfClass(paramTypes[i].getName(), true));
+ buf.append(')').append(getEncodingOfClass(m.getReturnType().getName(),
+ true));
+ return buf.toString();
+ }
+
+ /**
+ * Returns a <code>String</code> representing the type-encoding of a
+ * constructor. The type-encoding of a method is:
+ *
+ * "(" + parameter type descriptors + ")V"
+ *
+ * XXX This could be faster if it were implemented natively.
+ *
+ * @param c the constructor to encode
+ * @return the encoding
+ */
+ public static String getEncodingOfConstructor(Constructor c)
+ {
+ Class[] paramTypes = c.getParameterTypes();
+ StringBuffer buf = new StringBuffer().append('(');
+ for (int i = 0; i < paramTypes.length; i++)
+ buf.append(getEncodingOfClass(paramTypes[i].getName(), true));
+ buf.append(")V");
+ return buf.toString();
+ }
+
+ /**
+ * Returns a <code>String</code> representing the type-encoding of a
+ * class member. This appropriately handles Constructors, Methods, and
+ * Fields.
+ *
+ * @param mem the member to encode
+ * @return the encoding
+ */
+ public static String getEncodingOfMember(Member mem)
+ {
+ if (mem instanceof Constructor)
+ return getEncodingOfConstructor((Constructor) mem);
+ if (mem instanceof Method)
+ return getEncodingOfMethod((Method) mem);
+ else // Field
+ return getEncodingOfClass(((Field) mem).getType().getName(), true);
+ }
+} // class TypeSignature
Added: llvm-gcc-4.2/trunk/libjava/classpath/gnu/java/lang/reflect/package.html
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/gnu/java/lang/reflect/package.html?rev=43913&view=auto
==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/gnu/java/lang/reflect/package.html (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/gnu/java/lang/reflect/package.html Thu Nov 8 16:56:19 2007
@@ -0,0 +1,46 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
+<!-- package.html - describes classes in gnu.java.lang.reflect package.
+ Copyright (C) 2005 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. -->
+
+<html>
+<head><title>GNU Classpath - gnu.java.lang.reflect</title></head>
+
+<body>
+<p></p>
+
+</body>
+</html>
Added: llvm-gcc-4.2/trunk/libjava/classpath/gnu/java/locale/LocaleHelper.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/gnu/java/locale/LocaleHelper.java?rev=43913&view=auto
==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/gnu/java/locale/LocaleHelper.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/gnu/java/locale/LocaleHelper.java Thu Nov 8 16:56:19 2007
@@ -0,0 +1,211 @@
+/* LocaleHelper.java -- helper routines for localization
+ Copyright (C) 2004, 2005 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 gnu.java.locale;
+
+import java.text.Collator;
+import java.util.Locale;
+import java.util.MissingResourceException;
+import java.util.ResourceBundle;
+
+/**
+ * This class provides common helper methods
+ * for handling localized data.
+ *
+ * @author Andrew John Hughes (gnu_andrew at member.fsf.org)
+ *
+ * @see java.util.Locale
+ * @see java.util.ResourceBundle
+ */
+public class LocaleHelper
+{
+ /**
+ * This method is used by the localized name lookup methods to retrieve
+ * the localized name of a particular piece of locale data.
+ * If the display name can not be localized to the supplied
+ * locale, it will fall back on other output in the following order:
+ *
+ * <ul>
+ * <li>the localized name in the default locale</li>
+ * <li>the localized name in English (optional)</li>
+ * <li>the localized name in the root locale bundle (optional)</li>
+ * <li>the localized input string</li>
+ * </ul>
+ * <p>
+ * If the supplied key is merely the empty string, then the empty string is
+ * returned.
+ * </p>
+ *
+ * @param inLocale the locale to use for formatting the display string.
+ * @param key the locale data used as a key to the localized lookup tables.
+ * @param name the name of the hashtable containing the localized data.
+ * @param checkEnglish true if the method should fall back on data
+ * from the English locale.
+ * @param checkRoot true if the method should fall back on data from the
+ * unlocalized root locale.
+ * @return a <code>String</code>, hopefully containing the localized
+ * variant of the input data.
+ * @throws NullPointerException if <code>inLocale</code> is null.
+ */
+ public static String getLocalizedString(Locale inLocale, String key,
+ String name, boolean checkEnglish,
+ boolean checkRoot)
+ {
+ String localizedString;
+ String property;
+
+ if (key.equals(""))
+ return "";
+ property = name + "." + key;
+ /* Localize to inLocale */
+ try
+ {
+ localizedString =
+ ResourceBundle.getBundle("gnu.java.locale.LocaleInformation",
+ inLocale).getString(property);
+ }
+ catch (MissingResourceException exception)
+ {
+ localizedString = null;
+ }
+ /* Localize to default locale */
+ if (localizedString == null)
+ {
+ try
+ {
+ ResourceBundle bundle;
+
+ bundle =
+ ResourceBundle.getBundle("gnu.java.locale.LocaleInformation");
+ localizedString = bundle.getString(property);
+ }
+ catch (MissingResourceException exception)
+ {
+ localizedString = null;
+ }
+ }
+ /* Localize to English */
+ if (localizedString == null && checkEnglish)
+ {
+ try
+ {
+ localizedString =
+ ResourceBundle.getBundle("gnu.java.locale.LocaleInformation",
+ Locale.ENGLISH).getString(property);
+ }
+ catch (MissingResourceException exception)
+ {
+ localizedString = null;
+ }
+ }
+ /* Return unlocalized version */
+ if (localizedString == null && checkRoot)
+ {
+ try
+ {
+ localizedString =
+ ResourceBundle.getBundle("gnu.java.locale.LocaleInformation",
+ new Locale("","","")
+ ).getString(property);
+ }
+ catch (MissingResourceException exception)
+ {
+ localizedString = null;
+ }
+ }
+ /* Return original input string */
+ if (localizedString == null)
+ {
+ localizedString = key;
+ }
+ return localizedString;
+ }
+
+ /**
+ * Return an array of all the locales for which there is a
+ * {@link Collator} instance. A new array is returned each time.
+ */
+ public static Locale[] getCollatorLocales()
+ {
+ // For now we don't bother caching. This is probably
+ // not called very frequently. And, we would have to
+ // clone the array anyway.
+ if (LocaleData.collatorLocaleNames.length == 0)
+ return new Locale[] { Locale.US };
+ Locale[] result = new Locale[LocaleData.collatorLocaleNames.length];
+ for (int i = 0; i < result.length; ++i)
+ {
+ String language;
+ String region = "";
+ String variant = "";
+ String name = LocaleData.collatorLocaleNames[i];
+
+ language = name.substring(0, 2);
+
+ if (name.length() > 2)
+ region = name.substring(3);
+
+ int index = region.indexOf("_");
+ if (index > 0)
+ {
+ variant = region.substring(index + 1);
+ region = region.substring(0, index - 1);
+ }
+
+ result[i] = new Locale(language, region, variant);
+ }
+ return result;
+ }
+
+ /**
+ * Return the number of locales we know of.
+ */
+ public static int getLocaleCount()
+ {
+ return LocaleData.localeNames.length;
+ }
+
+ /**
+ * Return the Nth locale name.
+ */
+ public static String getLocaleName(int n)
+ {
+ return LocaleData.localeNames[n];
+ }
+}
+
Added: llvm-gcc-4.2/trunk/libjava/classpath/gnu/java/locale/package.html
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/gnu/java/locale/package.html?rev=43913&view=auto
==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/gnu/java/locale/package.html (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/gnu/java/locale/package.html Thu Nov 8 16:56:19 2007
@@ -0,0 +1,46 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
+<!-- package.html - describes classes in gnu.java.locale package.
+ Copyright (C) 2005 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. -->
+
+<html>
+<head><title>GNU Classpath - gnu.java.locale</title></head>
+
+<body>
+<p></p>
+
+</body>
+</html>
Added: llvm-gcc-4.2/trunk/libjava/classpath/gnu/java/math/MPN.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/gnu/java/math/MPN.java?rev=43913&view=auto
==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/gnu/java/math/MPN.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/gnu/java/math/MPN.java Thu Nov 8 16:56:19 2007
@@ -0,0 +1,771 @@
+/* gnu.java.math.MPN
+ Copyright (C) 1999, 2000, 2001, 2004 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. */
+
+// Included from Kawa 1.6.62 with permission of the author,
+// Per Bothner <per at bothner.com>.
+
+package gnu.java.math;
+
+/** This contains various low-level routines for unsigned bigints.
+ * The interfaces match the mpn interfaces in gmp,
+ * so it should be easy to replace them with fast native functions
+ * that are trivial wrappers around the mpn_ functions in gmp
+ * (at least on platforms that use 32-bit "limbs").
+ */
+
+public class MPN
+{
+ /** Add x[0:size-1] and y, and write the size least
+ * significant words of the result to dest.
+ * Return carry, either 0 or 1.
+ * All values are unsigned.
+ * This is basically the same as gmp's mpn_add_1. */
+ public static int add_1 (int[] dest, int[] x, int size, int y)
+ {
+ long carry = (long) y & 0xffffffffL;
+ for (int i = 0; i < size; i++)
+ {
+ carry += ((long) x[i] & 0xffffffffL);
+ dest[i] = (int) carry;
+ carry >>= 32;
+ }
+ return (int) carry;
+ }
+
+ /** Add x[0:len-1] and y[0:len-1] and write the len least
+ * significant words of the result to dest[0:len-1].
+ * All words are treated as unsigned.
+ * @return the carry, either 0 or 1
+ * This function is basically the same as gmp's mpn_add_n.
+ */
+ public static int add_n (int dest[], int[] x, int[] y, int len)
+ {
+ long carry = 0;
+ for (int i = 0; i < len; i++)
+ {
+ carry += ((long) x[i] & 0xffffffffL)
+ + ((long) y[i] & 0xffffffffL);
+ dest[i] = (int) carry;
+ carry >>>= 32;
+ }
+ return (int) carry;
+ }
+
+ /** Subtract Y[0:size-1] from X[0:size-1], and write
+ * the size least significant words of the result to dest[0:size-1].
+ * Return borrow, either 0 or 1.
+ * This is basically the same as gmp's mpn_sub_n function.
+ */
+
+ public static int sub_n (int[] dest, int[] X, int[] Y, int size)
+ {
+ int cy = 0;
+ for (int i = 0; i < size; i++)
+ {
+ int y = Y[i];
+ int x = X[i];
+ y += cy; /* add previous carry to subtrahend */
+ // Invert the high-order bit, because: (unsigned) X > (unsigned) Y
+ // iff: (int) (X^0x80000000) > (int) (Y^0x80000000).
+ cy = (y^0x80000000) < (cy^0x80000000) ? 1 : 0;
+ y = x - y;
+ cy += (y^0x80000000) > (x ^ 0x80000000) ? 1 : 0;
+ dest[i] = y;
+ }
+ return cy;
+ }
+
+ /** Multiply x[0:len-1] by y, and write the len least
+ * significant words of the product to dest[0:len-1].
+ * Return the most significant word of the product.
+ * All values are treated as if they were unsigned
+ * (i.e. masked with 0xffffffffL).
+ * OK if dest==x (not sure if this is guaranteed for mpn_mul_1).
+ * This function is basically the same as gmp's mpn_mul_1.
+ */
+
+ public static int mul_1 (int[] dest, int[] x, int len, int y)
+ {
+ long yword = (long) y & 0xffffffffL;
+ long carry = 0;
+ for (int j = 0; j < len; j++)
+ {
+ carry += ((long) x[j] & 0xffffffffL) * yword;
+ dest[j] = (int) carry;
+ carry >>>= 32;
+ }
+ return (int) carry;
+ }
+
+ /**
+ * Multiply x[0:xlen-1] and y[0:ylen-1], and
+ * write the result to dest[0:xlen+ylen-1].
+ * The destination has to have space for xlen+ylen words,
+ * even if the result might be one limb smaller.
+ * This function requires that xlen >= ylen.
+ * The destination must be distinct from either input operands.
+ * All operands are unsigned.
+ * This function is basically the same gmp's mpn_mul. */
+
+ public static void mul (int[] dest,
+ int[] x, int xlen,
+ int[] y, int ylen)
+ {
+ dest[xlen] = MPN.mul_1 (dest, x, xlen, y[0]);
+
+ for (int i = 1; i < ylen; i++)
+ {
+ long yword = (long) y[i] & 0xffffffffL;
+ long carry = 0;
+ for (int j = 0; j < xlen; j++)
+ {
+ carry += ((long) x[j] & 0xffffffffL) * yword
+ + ((long) dest[i+j] & 0xffffffffL);
+ dest[i+j] = (int) carry;
+ carry >>>= 32;
+ }
+ dest[i+xlen] = (int) carry;
+ }
+ }
+
+ /* Divide (unsigned long) N by (unsigned int) D.
+ * Returns (remainder << 32)+(unsigned int)(quotient).
+ * Assumes (unsigned int)(N>>32) < (unsigned int)D.
+ * Code transcribed from gmp-2.0's mpn_udiv_w_sdiv function.
+ */
+ public static long udiv_qrnnd (long N, int D)
+ {
+ long q, r;
+ long a1 = N >>> 32;
+ long a0 = N & 0xffffffffL;
+ if (D >= 0)
+ {
+ if (a1 < ((D - a1 - (a0 >>> 31)) & 0xffffffffL))
+ {
+ /* dividend, divisor, and quotient are nonnegative */
+ q = N / D;
+ r = N % D;
+ }
+ else
+ {
+ /* Compute c1*2^32 + c0 = a1*2^32 + a0 - 2^31*d */
+ long c = N - ((long) D << 31);
+ /* Divide (c1*2^32 + c0) by d */
+ q = c / D;
+ r = c % D;
+ /* Add 2^31 to quotient */
+ q += 1 << 31;
+ }
+ }
+ else
+ {
+ long b1 = D >>> 1; /* d/2, between 2^30 and 2^31 - 1 */
+ //long c1 = (a1 >> 1); /* A/2 */
+ //int c0 = (a1 << 31) + (a0 >> 1);
+ long c = N >>> 1;
+ if (a1 < b1 || (a1 >> 1) < b1)
+ {
+ if (a1 < b1)
+ {
+ q = c / b1;
+ r = c % b1;
+ }
+ else /* c1 < b1, so 2^31 <= (A/2)/b1 < 2^32 */
+ {
+ c = ~(c - (b1 << 32));
+ q = c / b1; /* (A/2) / (d/2) */
+ r = c % b1;
+ q = (~q) & 0xffffffffL; /* (A/2)/b1 */
+ r = (b1 - 1) - r; /* r < b1 => new r >= 0 */
+ }
+ r = 2 * r + (a0 & 1);
+ if ((D & 1) != 0)
+ {
+ if (r >= q) {
+ r = r - q;
+ } else if (q - r <= ((long) D & 0xffffffffL)) {
+ r = r - q + D;
+ q -= 1;
+ } else {
+ r = r - q + D + D;
+ q -= 2;
+ }
+ }
+ }
+ else /* Implies c1 = b1 */
+ { /* Hence a1 = d - 1 = 2*b1 - 1 */
+ if (a0 >= ((long)(-D) & 0xffffffffL))
+ {
+ q = -1;
+ r = a0 + D;
+ }
+ else
+ {
+ q = -2;
+ r = a0 + D + D;
+ }
+ }
+ }
+
+ return (r << 32) | (q & 0xFFFFFFFFl);
+ }
+
+ /** Divide divident[0:len-1] by (unsigned int)divisor.
+ * Write result into quotient[0:len-1.
+ * Return the one-word (unsigned) remainder.
+ * OK for quotient==dividend.
+ */
+
+ public static int divmod_1 (int[] quotient, int[] dividend,
+ int len, int divisor)
+ {
+ int i = len - 1;
+ long r = dividend[i];
+ if ((r & 0xffffffffL) >= ((long)divisor & 0xffffffffL))
+ r = 0;
+ else
+ {
+ quotient[i--] = 0;
+ r <<= 32;
+ }
+
+ for (; i >= 0; i--)
+ {
+ int n0 = dividend[i];
+ r = (r & ~0xffffffffL) | (n0 & 0xffffffffL);
+ r = udiv_qrnnd (r, divisor);
+ quotient[i] = (int) r;
+ }
+ return (int)(r >> 32);
+ }
+
+ /* Subtract x[0:len-1]*y from dest[offset:offset+len-1].
+ * All values are treated as if unsigned.
+ * @return the most significant word of
+ * the product, minus borrow-out from the subtraction.
+ */
+ public static int submul_1 (int[] dest, int offset, int[] x, int len, int y)
+ {
+ long yl = (long) y & 0xffffffffL;
+ int carry = 0;
+ int j = 0;
+ do
+ {
+ long prod = ((long) x[j] & 0xffffffffL) * yl;
+ int prod_low = (int) prod;
+ int prod_high = (int) (prod >> 32);
+ prod_low += carry;
+ // Invert the high-order bit, because: (unsigned) X > (unsigned) Y
+ // iff: (int) (X^0x80000000) > (int) (Y^0x80000000).
+ carry = ((prod_low ^ 0x80000000) < (carry ^ 0x80000000) ? 1 : 0)
+ + prod_high;
+ int x_j = dest[offset+j];
+ prod_low = x_j - prod_low;
+ if ((prod_low ^ 0x80000000) > (x_j ^ 0x80000000))
+ carry++;
+ dest[offset+j] = prod_low;
+ }
+ while (++j < len);
+ return carry;
+ }
+
+ /** Divide zds[0:nx] by y[0:ny-1].
+ * The remainder ends up in zds[0:ny-1].
+ * The quotient ends up in zds[ny:nx].
+ * Assumes: nx>ny.
+ * (int)y[ny-1] < 0 (i.e. most significant bit set)
+ */
+
+ public static void divide (int[] zds, int nx, int[] y, int ny)
+ {
+ // This is basically Knuth's formulation of the classical algorithm,
+ // but translated from in scm_divbigbig in Jaffar's SCM implementation.
+
+ // Correspondance with Knuth's notation:
+ // Knuth's u[0:m+n] == zds[nx:0].
+ // Knuth's v[1:n] == y[ny-1:0]
+ // Knuth's n == ny.
+ // Knuth's m == nx-ny.
+ // Our nx == Knuth's m+n.
+
+ // Could be re-implemented using gmp's mpn_divrem:
+ // zds[nx] = mpn_divrem (&zds[ny], 0, zds, nx, y, ny).
+
+ int j = nx;
+ do
+ { // loop over digits of quotient
+ // Knuth's j == our nx-j.
+ // Knuth's u[j:j+n] == our zds[j:j-ny].
+ int qhat; // treated as unsigned
+ if (zds[j]==y[ny-1])
+ qhat = -1; // 0xffffffff
+ else
+ {
+ long w = (((long)(zds[j])) << 32) + ((long)zds[j-1] & 0xffffffffL);
+ qhat = (int) udiv_qrnnd (w, y[ny-1]);
+ }
+ if (qhat != 0)
+ {
+ int borrow = submul_1 (zds, j - ny, y, ny, qhat);
+ int save = zds[j];
+ long num = ((long)save&0xffffffffL) - ((long)borrow&0xffffffffL);
+ while (num != 0)
+ {
+ qhat--;
+ long carry = 0;
+ for (int i = 0; i < ny; i++)
+ {
+ carry += ((long) zds[j-ny+i] & 0xffffffffL)
+ + ((long) y[i] & 0xffffffffL);
+ zds[j-ny+i] = (int) carry;
+ carry >>>= 32;
+ }
+ zds[j] += carry;
+ num = carry - 1;
+ }
+ }
+ zds[j] = qhat;
+ } while (--j >= ny);
+ }
+
+ /** Number of digits in the conversion base that always fits in a word.
+ * For example, for base 10 this is 9, since 10**9 is the
+ * largest number that fits into a words (assuming 32-bit words).
+ * This is the same as gmp's __mp_bases[radix].chars_per_limb.
+ * @param radix the base
+ * @return number of digits */
+ public static int chars_per_word (int radix)
+ {
+ if (radix < 10)
+ {
+ if (radix < 8)
+ {
+ if (radix <= 2)
+ return 32;
+ else if (radix == 3)
+ return 20;
+ else if (radix == 4)
+ return 16;
+ else
+ return 18 - radix;
+ }
+ else
+ return 10;
+ }
+ else if (radix < 12)
+ return 9;
+ else if (radix <= 16)
+ return 8;
+ else if (radix <= 23)
+ return 7;
+ else if (radix <= 40)
+ return 6;
+ // The following are conservative, but we don't care.
+ else if (radix <= 256)
+ return 4;
+ else
+ return 1;
+ }
+
+ /** Count the number of leading zero bits in an int. */
+ public static int count_leading_zeros (int i)
+ {
+ if (i == 0)
+ return 32;
+ int count = 0;
+ for (int k = 16; k > 0; k = k >> 1) {
+ int j = i >>> k;
+ if (j == 0)
+ count += k;
+ else
+ i = j;
+ }
+ return count;
+ }
+
+ public static int set_str (int dest[], byte[] str, int str_len, int base)
+ {
+ int size = 0;
+ if ((base & (base - 1)) == 0)
+ {
+ // The base is a power of 2. Read the input string from
+ // least to most significant character/digit. */
+
+ int next_bitpos = 0;
+ int bits_per_indigit = 0;
+ for (int i = base; (i >>= 1) != 0; ) bits_per_indigit++;
+ int res_digit = 0;
+
+ for (int i = str_len; --i >= 0; )
+ {
+ int inp_digit = str[i];
+ res_digit |= inp_digit << next_bitpos;
+ next_bitpos += bits_per_indigit;
+ if (next_bitpos >= 32)
+ {
+ dest[size++] = res_digit;
+ next_bitpos -= 32;
+ res_digit = inp_digit >> (bits_per_indigit - next_bitpos);
+ }
+ }
+
+ if (res_digit != 0)
+ dest[size++] = res_digit;
+ }
+ else
+ {
+ // General case. The base is not a power of 2.
+ int indigits_per_limb = MPN.chars_per_word (base);
+ int str_pos = 0;
+
+ while (str_pos < str_len)
+ {
+ int chunk = str_len - str_pos;
+ if (chunk > indigits_per_limb)
+ chunk = indigits_per_limb;
+ int res_digit = str[str_pos++];
+ int big_base = base;
+
+ while (--chunk > 0)
+ {
+ res_digit = res_digit * base + str[str_pos++];
+ big_base *= base;
+ }
+
+ int cy_limb;
+ if (size == 0)
+ cy_limb = res_digit;
+ else
+ {
+ cy_limb = MPN.mul_1 (dest, dest, size, big_base);
+ cy_limb += MPN.add_1 (dest, dest, size, res_digit);
+ }
+ if (cy_limb != 0)
+ dest[size++] = cy_limb;
+ }
+ }
+ return size;
+ }
+
+ /** Compare x[0:size-1] with y[0:size-1], treating them as unsigned integers.
+ * @result -1, 0, or 1 depending on if x<y, x==y, or x>y.
+ * This is basically the same as gmp's mpn_cmp function.
+ */
+ public static int cmp (int[] x, int[] y, int size)
+ {
+ while (--size >= 0)
+ {
+ int x_word = x[size];
+ int y_word = y[size];
+ if (x_word != y_word)
+ {
+ // Invert the high-order bit, because:
+ // (unsigned) X > (unsigned) Y iff
+ // (int) (X^0x80000000) > (int) (Y^0x80000000).
+ return (x_word ^ 0x80000000) > (y_word ^0x80000000) ? 1 : -1;
+ }
+ }
+ return 0;
+ }
+
+ /**
+ * Compare x[0:xlen-1] with y[0:ylen-1], treating them as unsigned integers.
+ *
+ * @return -1, 0, or 1 depending on if x<y, x==y, or x>y.
+ */
+ public static int cmp (int[] x, int xlen, int[] y, int ylen)
+ {
+ return xlen > ylen ? 1 : xlen < ylen ? -1 : cmp (x, y, xlen);
+ }
+
+ /**
+ * Shift x[x_start:x_start+len-1] count bits to the "right"
+ * (i.e. divide by 2**count).
+ * Store the len least significant words of the result at dest.
+ * The bits shifted out to the right are returned.
+ * OK if dest==x.
+ * Assumes: 0 < count < 32
+ */
+ public static int rshift (int[] dest, int[] x, int x_start,
+ int len, int count)
+ {
+ int count_2 = 32 - count;
+ int low_word = x[x_start];
+ int retval = low_word << count_2;
+ int i = 1;
+ for (; i < len; i++)
+ {
+ int high_word = x[x_start+i];
+ dest[i-1] = (low_word >>> count) | (high_word << count_2);
+ low_word = high_word;
+ }
+ dest[i-1] = low_word >>> count;
+ return retval;
+ }
+
+ /**
+ * Shift x[x_start:x_start+len-1] count bits to the "right"
+ * (i.e. divide by 2**count).
+ * Store the len least significant words of the result at dest.
+ * OK if dest==x.
+ * Assumes: 0 <= count < 32
+ * Same as rshift, but handles count==0 (and has no return value).
+ */
+ public static void rshift0 (int[] dest, int[] x, int x_start,
+ int len, int count)
+ {
+ if (count > 0)
+ rshift(dest, x, x_start, len, count);
+ else
+ for (int i = 0; i < len; i++)
+ dest[i] = x[i + x_start];
+ }
+
+ /** Return the long-truncated value of right shifting.
+ * @param x a two's-complement "bignum"
+ * @param len the number of significant words in x
+ * @param count the shift count
+ * @return (long)(x[0..len-1] >> count).
+ */
+ public static long rshift_long (int[] x, int len, int count)
+ {
+ int wordno = count >> 5;
+ count &= 31;
+ int sign = x[len-1] < 0 ? -1 : 0;
+ int w0 = wordno >= len ? sign : x[wordno];
+ wordno++;
+ int w1 = wordno >= len ? sign : x[wordno];
+ if (count != 0)
+ {
+ wordno++;
+ int w2 = wordno >= len ? sign : x[wordno];
+ w0 = (w0 >>> count) | (w1 << (32-count));
+ w1 = (w1 >>> count) | (w2 << (32-count));
+ }
+ return ((long)w1 << 32) | ((long)w0 & 0xffffffffL);
+ }
+
+ /* Shift x[0:len-1] left by count bits, and store the len least
+ * significant words of the result in dest[d_offset:d_offset+len-1].
+ * Return the bits shifted out from the most significant digit.
+ * Assumes 0 < count < 32.
+ * OK if dest==x.
+ */
+
+ public static int lshift (int[] dest, int d_offset,
+ int[] x, int len, int count)
+ {
+ int count_2 = 32 - count;
+ int i = len - 1;
+ int high_word = x[i];
+ int retval = high_word >>> count_2;
+ d_offset++;
+ while (--i >= 0)
+ {
+ int low_word = x[i];
+ dest[d_offset+i] = (high_word << count) | (low_word >>> count_2);
+ high_word = low_word;
+ }
+ dest[d_offset+i] = high_word << count;
+ return retval;
+ }
+
+ /** Return least i such that word & (1<<i). Assumes word!=0. */
+
+ public static int findLowestBit (int word)
+ {
+ int i = 0;
+ while ((word & 0xF) == 0)
+ {
+ word >>= 4;
+ i += 4;
+ }
+ if ((word & 3) == 0)
+ {
+ word >>= 2;
+ i += 2;
+ }
+ if ((word & 1) == 0)
+ i += 1;
+ return i;
+ }
+
+ /** Return least i such that words & (1<<i). Assumes there is such an i. */
+
+ public static int findLowestBit (int[] words)
+ {
+ for (int i = 0; ; i++)
+ {
+ if (words[i] != 0)
+ return 32 * i + findLowestBit (words[i]);
+ }
+ }
+
+ /** Calculate Greatest Common Divisior of x[0:len-1] and y[0:len-1].
+ * Assumes both arguments are non-zero.
+ * Leaves result in x, and returns len of result.
+ * Also destroys y (actually sets it to a copy of the result). */
+
+ public static int gcd (int[] x, int[] y, int len)
+ {
+ int i, word;
+ // Find sh such that both x and y are divisible by 2**sh.
+ for (i = 0; ; i++)
+ {
+ word = x[i] | y[i];
+ if (word != 0)
+ {
+ // Must terminate, since x and y are non-zero.
+ break;
+ }
+ }
+ int initShiftWords = i;
+ int initShiftBits = findLowestBit (word);
+ // Logically: sh = initShiftWords * 32 + initShiftBits
+
+ // Temporarily devide both x and y by 2**sh.
+ len -= initShiftWords;
+ MPN.rshift0 (x, x, initShiftWords, len, initShiftBits);
+ MPN.rshift0 (y, y, initShiftWords, len, initShiftBits);
+
+ int[] odd_arg; /* One of x or y which is odd. */
+ int[] other_arg; /* The other one can be even or odd. */
+ if ((x[0] & 1) != 0)
+ {
+ odd_arg = x;
+ other_arg = y;
+ }
+ else
+ {
+ odd_arg = y;
+ other_arg = x;
+ }
+
+ for (;;)
+ {
+ // Shift other_arg until it is odd; this doesn't
+ // affect the gcd, since we divide by 2**k, which does not
+ // divide odd_arg.
+ for (i = 0; other_arg[i] == 0; ) i++;
+ if (i > 0)
+ {
+ int j;
+ for (j = 0; j < len-i; j++)
+ other_arg[j] = other_arg[j+i];
+ for ( ; j < len; j++)
+ other_arg[j] = 0;
+ }
+ i = findLowestBit(other_arg[0]);
+ if (i > 0)
+ MPN.rshift (other_arg, other_arg, 0, len, i);
+
+ // Now both odd_arg and other_arg are odd.
+
+ // Subtract the smaller from the larger.
+ // This does not change the result, since gcd(a-b,b)==gcd(a,b).
+ i = MPN.cmp(odd_arg, other_arg, len);
+ if (i == 0)
+ break;
+ if (i > 0)
+ { // odd_arg > other_arg
+ MPN.sub_n (odd_arg, odd_arg, other_arg, len);
+ // Now odd_arg is even, so swap with other_arg;
+ int[] tmp = odd_arg; odd_arg = other_arg; other_arg = tmp;
+ }
+ else
+ { // other_arg > odd_arg
+ MPN.sub_n (other_arg, other_arg, odd_arg, len);
+ }
+ while (odd_arg[len-1] == 0 && other_arg[len-1] == 0)
+ len--;
+ }
+ if (initShiftWords + initShiftBits > 0)
+ {
+ if (initShiftBits > 0)
+ {
+ int sh_out = MPN.lshift (x, initShiftWords, x, len, initShiftBits);
+ if (sh_out != 0)
+ x[(len++)+initShiftWords] = sh_out;
+ }
+ else
+ {
+ for (i = len; --i >= 0;)
+ x[i+initShiftWords] = x[i];
+ }
+ for (i = initShiftWords; --i >= 0; )
+ x[i] = 0;
+ len += initShiftWords;
+ }
+ return len;
+ }
+
+ public static int intLength (int i)
+ {
+ return 32 - count_leading_zeros (i < 0 ? ~i : i);
+ }
+
+ /** Calcaulte the Common Lisp "integer-length" function.
+ * Assumes input is canonicalized: len==BigInteger.wordsNeeded(words,len) */
+ public static int intLength (int[] words, int len)
+ {
+ len--;
+ return intLength (words[len]) + 32 * len;
+ }
+
+ /* DEBUGGING:
+ public static void dprint (BigInteger x)
+ {
+ if (x.words == null)
+ System.err.print(Long.toString((long) x.ival & 0xffffffffL, 16));
+ else
+ dprint (System.err, x.words, x.ival);
+ }
+ public static void dprint (int[] x) { dprint (System.err, x, x.length); }
+ public static void dprint (int[] x, int len) { dprint (System.err, x, len); }
+ public static void dprint (java.io.PrintStream ps, int[] x, int len)
+ {
+ ps.print('(');
+ for (int i = 0; i < len; i++)
+ {
+ if (i > 0)
+ ps.print (' ');
+ ps.print ("#x" + Long.toString ((long) x[i] & 0xffffffffL, 16));
+ }
+ ps.print(')');
+ }
+ */
+}
Added: llvm-gcc-4.2/trunk/libjava/classpath/gnu/java/math/package.html
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/gnu/java/math/package.html?rev=43913&view=auto
==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/gnu/java/math/package.html (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/gnu/java/math/package.html Thu Nov 8 16:56:19 2007
@@ -0,0 +1,46 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
+<!-- package.html - describes classes in gnu.java.math package.
+ Copyright (C) 2005 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. -->
+
+<html>
+<head><title>GNU Classpath - gnu.java.math</title></head>
+
+<body>
+<p></p>
+
+</body>
+</html>
Added: llvm-gcc-4.2/trunk/libjava/classpath/gnu/java/net/BASE64.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/gnu/java/net/BASE64.java?rev=43913&view=auto
==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/gnu/java/net/BASE64.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/gnu/java/net/BASE64.java Thu Nov 8 16:56:19 2007
@@ -0,0 +1,190 @@
+/* BASE.java --
+ Copyright (C) 2003, 2004, 2005 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 gnu.java.net;
+
+/**
+ * Encodes and decodes text according to the BASE64 encoding.
+ *
+ * @author Chris Burdess (dog at gnu.org)
+ */
+public final class BASE64
+{
+ private static final byte[] src = {
+ 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47, 0x48, 0x49, 0x4a,
+ 0x4b, 0x4c, 0x4d, 0x4e, 0x4f, 0x50, 0x51, 0x52, 0x53, 0x54,
+ 0x55, 0x56, 0x57, 0x58, 0x59, 0x5a, 0x61, 0x62, 0x63, 0x64,
+ 0x65, 0x66, 0x67, 0x68, 0x69, 0x6a, 0x6b, 0x6c, 0x6d, 0x6e,
+ 0x6f, 0x70, 0x71, 0x72, 0x73, 0x74, 0x75, 0x76, 0x77, 0x78,
+ 0x79, 0x7a, 0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37,
+ 0x38, 0x39, 0x2b, 0x2f
+ };
+
+ private static final byte[] dst;
+ static
+ {
+ dst = new byte[0x100];
+ for (int i = 0x0; i < 0xff; i++)
+ {
+ dst[i] = -1;
+ }
+ for (int i = 0; i < src.length; i++)
+ {
+ dst[src[i]] = (byte) i;
+ }
+ }
+
+ private BASE64()
+ {
+ }
+
+ /**
+ * Encode the specified byte array using the BASE64 algorithm.
+ *
+ * @param bs the source byte array
+ */
+ public static byte[] encode(byte[] bs)
+ {
+ int si = 0, ti = 0; // source/target array indices
+ byte[] bt = new byte[((bs.length + 2) * 4) / 3]; // target byte array
+ for (; si < bs.length; si += 3)
+ {
+ int buflen = bs.length - si;
+ if (buflen == 1)
+ {
+ byte b = bs[si];
+ int i = 0;
+ bt[ti++] = src[b >>> 2 & 0x3f];
+ bt[ti++] = src[(b << 4 & 0x30) + (i >>> 4 & 0xf)];
+ }
+ else if (buflen == 2)
+ {
+ byte b1 = bs[si], b2 = bs[si + 1];
+ int i = 0;
+ bt[ti++] = src[b1 >>> 2 & 0x3f];
+ bt[ti++] = src[(b1 << 4 & 0x30) + (b2 >>> 4 & 0xf)];
+ bt[ti++] = src[(b2 << 2 & 0x3c) + (i >>> 6 & 0x3)];
+ }
+ else
+ {
+ byte b1 = bs[si], b2 = bs[si + 1], b3 = bs[si + 2];
+ bt[ti++] = src[b1 >>> 2 & 0x3f];
+ bt[ti++] = src[(b1 << 4 & 0x30) + (b2 >>> 4 & 0xf)];
+ bt[ti++] = src[(b2 << 2 & 0x3c) + (b3 >>> 6 & 0x3)];
+ bt[ti++] = src[b3 & 0x3f];
+ }
+ }
+ if (ti < bt.length)
+ {
+ byte[] tmp = new byte[ti];
+ System.arraycopy(bt, 0, tmp, 0, ti);
+ bt = tmp;
+ }
+ /*while (ti < bt.length)
+ {
+ bt[ti++] = 0x3d;
+ }*/
+ return bt;
+ }
+
+ /**
+ * Decode the specified byte array using the BASE64 algorithm.
+ *
+ * @param bs the source byte array
+ */
+ public static byte[] decode(byte[] bs)
+ {
+ int srclen = bs.length;
+ while (srclen > 0 && bs[srclen - 1] == 0x3d)
+ {
+ srclen--; /* strip padding character */
+ }
+ byte[] buffer = new byte[srclen];
+ int buflen = 0;
+ int si = 0;
+ int len = srclen - si;
+ while (len > 0)
+ {
+ byte b0 = dst[bs[si++] & 0xff];
+ byte b2 = dst[bs[si++] & 0xff];
+ buffer[buflen++] = (byte) (b0 << 2 & 0xfc | b2 >>> 4 & 0x3);
+ if (len > 2)
+ {
+ b0 = b2;
+ b2 = dst[bs[si++] & 0xff];
+ buffer[buflen++] = (byte) (b0 << 4 & 0xf0 | b2 >>> 2 & 0xf);
+ if (len > 3)
+ {
+ b0 = b2;
+ b2 = dst[bs[si++] & 0xff];
+ buffer[buflen++] = (byte) (b0 << 6 & 0xc0 | b2 & 0x3f);
+ }
+ }
+ len = srclen - si;
+ }
+ byte[] bt = new byte[buflen];
+ System.arraycopy(buffer, 0, bt, 0, buflen);
+ return bt;
+ }
+
+ public static void main(String[] args)
+ {
+ boolean decode = false;
+ for (int i = 0; i < args.length; i++)
+ {
+ if (args[i].equals("-d"))
+ {
+ decode = true;
+ }
+ else
+ {
+ try
+ {
+ byte[] in = args[i].getBytes("US-ASCII");
+ byte[] out = decode ? decode(in) : encode(in);
+ System.out.println(args[i] + " = " +
+ new String(out, "US-ASCII"));
+ }
+ catch (java.io.UnsupportedEncodingException e)
+ {
+ e.printStackTrace(System.err);
+ }
+ }
+ }
+ }
+}
Added: llvm-gcc-4.2/trunk/libjava/classpath/gnu/java/net/CRLFInputStream.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/gnu/java/net/CRLFInputStream.java?rev=43913&view=auto
==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/gnu/java/net/CRLFInputStream.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/gnu/java/net/CRLFInputStream.java Thu Nov 8 16:56:19 2007
@@ -0,0 +1,179 @@
+/* CRLFInputStream.java --
+ Copyright (C) 2002, 2003, 2004, 2006 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 gnu.java.net;
+
+import java.io.BufferedInputStream;
+import java.io.IOException;
+import java.io.InputStream;
+
+/**
+ * An input stream that filters out CR/LF pairs into LFs.
+ *
+ * @author Chris Burdess (dog at gnu.org)
+ */
+public class CRLFInputStream
+ extends InputStream
+{
+ /**
+ * The CR octet.
+ */
+ public static final int CR = 13;
+
+ /**
+ * The LF octet.
+ */
+ public static final int LF = 10;
+
+ /**
+ * The underlying input stream.
+ */
+ protected InputStream in;
+
+ private boolean doReset;
+
+ /**
+ * Constructs a CR/LF input stream connected to the specified input
+ * stream.
+ */
+ public CRLFInputStream(InputStream in)
+ {
+ this.in = in.markSupported() ? in : new BufferedInputStream(in);
+ }
+
+ /**
+ * Reads the next byte of data from this input stream.
+ * Returns -1 if the end of the stream has been reached.
+ * @exception IOException if an I/O error occurs
+ */
+ public int read()
+ throws IOException
+ {
+ int c = in.read();
+ if (c == CR)
+ {
+ in.mark(1);
+ int d = in.read();
+ if (d == LF)
+ {
+ c = d;
+ }
+ else
+ {
+ in.reset();
+ }
+ }
+ return c;
+ }
+
+ /**
+ * Reads up to b.length bytes of data from this input stream into
+ * an array of bytes.
+ * Returns -1 if the end of the stream has been reached.
+ * @exception IOException if an I/O error occurs
+ */
+ public int read(byte[] b)
+ throws IOException
+ {
+ return read(b, 0, b.length);
+ }
+
+ /**
+ * Reads up to len bytes of data from this input stream into an
+ * array of bytes, starting at the specified offset.
+ * Returns -1 if the end of the stream has been reached.
+ * @exception IOException if an I/O error occurs
+ */
+ public int read(byte[] b, int off, int len)
+ throws IOException
+ {
+ in.mark(len + 1);
+ int l = in.read(b, off, len);
+ if (l > 0)
+ {
+ int i = indexOfCRLF(b, off, l);
+ if (doReset)
+ {
+ in.reset();
+ if (i != -1)
+ {
+ l = in.read(b, off, (i + 1) - off); // read to CR
+ in.read(); // skip LF
+ b[i] = LF; // fix CR as LF
+ }
+ else
+ {
+ l = in.read(b, off, len); // CR(s) but no LF
+ }
+ }
+ }
+ return l;
+ }
+
+ private int indexOfCRLF(byte[] b, int off, int len)
+ throws IOException
+ {
+ doReset = false;
+ int end = off + len;
+ int em1 = end - 1;
+ for (int i = off; i < end; i++)
+ {
+ if (b[i] == CR)
+ {
+ int d;
+ if (i == em1)
+ {
+ d = in.read();
+ doReset = true;
+ }
+ else
+ {
+ d = b[i + 1];
+ }
+ if (d == LF)
+ {
+ doReset = true;
+ return i;
+ }
+ }
+ }
+ return -1;
+ }
+
+}
+
Added: llvm-gcc-4.2/trunk/libjava/classpath/gnu/java/net/CRLFOutputStream.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/gnu/java/net/CRLFOutputStream.java?rev=43913&view=auto
==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/gnu/java/net/CRLFOutputStream.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/gnu/java/net/CRLFOutputStream.java Thu Nov 8 16:56:19 2007
@@ -0,0 +1,183 @@
+/* CRLFOutputStream.java --
+ Copyright (C) 2002, 2003, 2004 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 gnu.java.net;
+
+import java.io.FilterOutputStream;
+import java.io.IOException;
+import java.io.OutputStream;
+import java.io.UnsupportedEncodingException;
+
+/**
+ * An output stream that filters LFs into CR/LF pairs.
+ *
+ * @author Chris Burdess (dog at gnu.org)
+ */
+public class CRLFOutputStream
+ extends FilterOutputStream
+{
+ static final String US_ASCII = "US-ASCII";
+
+ /**
+ * The CR octet.
+ */
+ public static final int CR = 13;
+
+ /**
+ * The LF octet.
+ */
+ public static final int LF = 10;
+
+ /**
+ * The CR/LF pair.
+ */
+ public static final byte[] CRLF = { CR, LF };
+
+ /**
+ * The last byte read.
+ */
+ protected int last;
+
+ /**
+ * Constructs a CR/LF output stream connected to the specified output stream.
+ */
+ public CRLFOutputStream(OutputStream out)
+ {
+ super(out);
+ last = -1;
+ }
+
+ /**
+ * Writes a character to the underlying stream.
+ * @exception IOException if an I/O error occurred
+ */
+ public void write(int ch) throws IOException
+ {
+ if (ch == CR)
+ {
+ out.write(CRLF);
+ }
+ else if (ch == LF)
+ {
+ if (last != CR)
+ {
+ out.write(CRLF);
+ }
+ }
+ else
+ {
+ out.write(ch);
+ }
+ last = ch;
+ }
+
+ /**
+ * Writes a byte array to the underlying stream.
+ * @exception IOException if an I/O error occurred
+ */
+ public void write(byte[] b)
+ throws IOException
+ {
+ write(b, 0, b.length);
+ }
+
+ /**
+ * Writes a portion of a byte array to the underlying stream.
+ * @exception IOException if an I/O error occurred
+ */
+ public void write(byte[] b, int off, int len)
+ throws IOException
+ {
+ int d = off;
+ len += off;
+ for (int i = off; i < len; i++)
+ {
+ switch (b[i])
+ {
+ case CR:
+ out.write (b, d, i - d);
+ out.write (CRLF, 0, 2);
+ d = i + 1;
+ break;
+ case LF:
+ if (last != CR)
+ {
+ out.write (b, d, i - d);
+ out.write (CRLF, 0, 2);
+ }
+ d = i + 1;
+ break;
+ }
+ last = b[i];
+ }
+ if (len - d > 0)
+ {
+ out.write (b, d, len - d);
+ }
+ }
+
+ /**
+ * Writes the specified ASCII string to the underlying stream.
+ * @exception IOException if an I/O error occurred
+ */
+ public void write(String text)
+ throws IOException
+ {
+ try
+ {
+ byte[] bytes = text.getBytes(US_ASCII);
+ write(bytes, 0, bytes.length);
+ }
+ catch (UnsupportedEncodingException e)
+ {
+ throw new IOException("The US-ASCII encoding is not supported " +
+ "on this system");
+ }
+ }
+
+ /**
+ * Writes a newline to the underlying stream.
+ * @exception IOException if an I/O error occurred
+ */
+ public void writeln()
+ throws IOException
+ {
+ out.write(CRLF, 0, 2);
+ }
+}
+
Added: llvm-gcc-4.2/trunk/libjava/classpath/gnu/java/net/DefaultContentHandlerFactory.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/gnu/java/net/DefaultContentHandlerFactory.java?rev=43913&view=auto
==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/gnu/java/net/DefaultContentHandlerFactory.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/gnu/java/net/DefaultContentHandlerFactory.java Thu Nov 8 16:56:19 2007
@@ -0,0 +1,94 @@
+/* DefaultContentHandlerFactory.java
+ Copyright (C) 2004 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 gnu.java.net;
+
+import java.io.IOException;
+import java.net.ContentHandler;
+import java.net.ContentHandlerFactory;
+import java.net.URLConnection;
+import java.util.Arrays;
+import java.util.HashSet;
+
+/** Content Handler for Image types, using the AWT Toolkit's image decoder. */
+class ImageHandler extends ContentHandler
+{
+ static ImageHandler instance = new ImageHandler();
+
+ public Object getContent(URLConnection urlc) throws IOException
+ {
+ // FIXME: implement using ImageIO
+ // ClasspathToolkit tk = (ClasspathToolkit) Toolkit.getDefaultToolkit();
+ // java.awt.image.ImageProducer ip = tk.createImageProducer(urlc.getURL());
+ // return ip;
+ return null;
+ }
+}
+
+/**
+ */
+public class DefaultContentHandlerFactory implements ContentHandlerFactory
+{
+ /** For now, hard code the list of types that we assume should
+ * be supported by the Toolkit. ClasspathToolkit should perhaps provide
+ * an API to express what Image MIME types the Toolkit understands.
+ */
+ private static String[] known_image_types =
+ {
+ "image/bmp",
+ "image/gif",
+ "image/jpeg",
+ "image/png",
+ "image/tiff",
+ "image/x-portable-anymap",
+ "image/x-cmu-raster",
+ "image/x-xbitmap",
+ "image/x-xpixmap"
+ };
+
+ private static HashSet imageTypes
+ = new HashSet(Arrays.asList(known_image_types));
+
+ public ContentHandler createContentHandler(String mimeType)
+ {
+ if (imageTypes.contains(mimeType))
+ return ImageHandler.instance;
+ // Currently, only image types are handled.
+ return null;
+ }
+}
Added: llvm-gcc-4.2/trunk/libjava/classpath/gnu/java/net/EmptyX509TrustManager.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/gnu/java/net/EmptyX509TrustManager.java?rev=43913&view=auto
==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/gnu/java/net/EmptyX509TrustManager.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/gnu/java/net/EmptyX509TrustManager.java Thu Nov 8 16:56:19 2007
@@ -0,0 +1,70 @@
+/* EmptyX509TrustManager.java --
+ Copyright (C) 2004 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 gnu.java.net;
+
+import java.security.cert.CertificateException;
+import java.security.cert.X509Certificate;
+
+import javax.net.ssl.X509TrustManager;
+
+/**
+ * Empty implementation of an X509 trust manager.
+ * This implementation does not check any certificates in the chain.
+ *
+ * @author Chris Burdess (dog at gnu.org)
+ */
+public class EmptyX509TrustManager
+ implements X509TrustManager
+{
+ public void checkClientTrusted(X509Certificate[] chain, String authType)
+ throws CertificateException
+ {
+ }
+
+ public void checkServerTrusted(X509Certificate[] chain, String authType)
+ throws CertificateException
+ {
+ }
+
+ public X509Certificate[] getAcceptedIssuers()
+ {
+ return new X509Certificate[0];
+ }
+}
+
Added: llvm-gcc-4.2/trunk/libjava/classpath/gnu/java/net/GetLocalHostAction.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/gnu/java/net/GetLocalHostAction.java?rev=43913&view=auto
==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/gnu/java/net/GetLocalHostAction.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/gnu/java/net/GetLocalHostAction.java Thu Nov 8 16:56:19 2007
@@ -0,0 +1,65 @@
+/* GetLocalHostAction.java --
+ Copyright (C) 2003, 2004 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 gnu.java.net;
+
+import java.net.InetAddress;
+import java.net.UnknownHostException;
+import java.security.PrivilegedAction;
+
+/**
+ * Privileged action to retrieve the local host InetAddress.
+ *
+ * @author Chris Burdess (dog at gnu.org)
+ */
+public class GetLocalHostAction
+ implements PrivilegedAction
+{
+ public Object run()
+ {
+ try
+ {
+ return InetAddress.getLocalHost();
+ }
+ catch (UnknownHostException e)
+ {
+ return null;
+ }
+ }
+}
+
Added: llvm-gcc-4.2/trunk/libjava/classpath/gnu/java/net/HeaderFieldHelper.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/gnu/java/net/HeaderFieldHelper.java?rev=43913&view=auto
==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/gnu/java/net/HeaderFieldHelper.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/gnu/java/net/HeaderFieldHelper.java Thu Nov 8 16:56:19 2007
@@ -0,0 +1,138 @@
+/* HeaderFieldHelper.java -- Helps manage headers fields
+ Copyright (C) 1998, 2003 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 gnu.java.net;
+
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Vector;
+
+/**
+ * This class manages header field keys and values.
+ *
+ * @author Aaron M. Renn (arenn at urbanophile.com)
+ */
+public class HeaderFieldHelper
+{
+ private Vector headerFieldKeys;
+ private Vector headerFieldValues;
+
+ public HeaderFieldHelper()
+ {
+ this (10);
+ }
+
+ public HeaderFieldHelper (int size)
+ {
+ headerFieldKeys = new Vector (size);
+ headerFieldValues = new Vector (size);
+ }
+
+ public void addHeaderField (String key, String value)
+ {
+ headerFieldKeys.addElement (key);
+ headerFieldValues.addElement (value);
+ }
+
+ public String getHeaderFieldKeyByIndex (int index)
+ {
+ String key = null;
+
+ try
+ {
+ key = (String) headerFieldKeys.elementAt (index);
+ }
+ catch (ArrayIndexOutOfBoundsException e)
+ {
+ }
+
+ return key;
+ }
+
+ public String getHeaderFieldValueByIndex(int index)
+ {
+ String value = null;
+
+ try
+ {
+ value = (String) headerFieldValues.elementAt (index);
+ }
+ catch (ArrayIndexOutOfBoundsException e)
+ {
+ }
+
+ return value;
+ }
+
+ public String getHeaderFieldValueByKey(String key)
+ {
+ String value = null;
+
+ try
+ {
+ value = (String) headerFieldValues.elementAt
+ (headerFieldKeys.indexOf(key));
+ }
+ catch (ArrayIndexOutOfBoundsException e)
+ {
+ }
+
+ return value;
+ }
+
+ public Map getHeaderFields()
+ {
+ HashMap headers = new HashMap();
+ int max = headerFieldKeys.size();
+
+ for (int index = 0; index < max; index++)
+ {
+ headers.put(headerFieldKeys.elementAt(index),
+ headerFieldValues.elementAt(index));
+ }
+
+ return headers;
+ }
+
+ public int getNumberOfEntries()
+ {
+ return headerFieldKeys.size();
+ }
+
+} // class HeaderFieldHelper
+
Added: llvm-gcc-4.2/trunk/libjava/classpath/gnu/java/net/IndexListParser.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/gnu/java/net/IndexListParser.java?rev=43913&view=auto
==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/gnu/java/net/IndexListParser.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/gnu/java/net/IndexListParser.java Thu Nov 8 16:56:19 2007
@@ -0,0 +1,181 @@
+/* IndexListParser.java --
+ Copyright (C) 2006 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 gnu.java.net;
+
+import java.io.BufferedReader;
+import java.io.InputStreamReader;
+import java.net.URL;
+import java.util.HashSet;
+import java.util.LinkedHashMap;
+import java.util.jar.JarFile;
+
+/**
+ * The INDEX.LIST file contains sections each separated by a blank line.
+ * Each section defines the content of a jar, with a
+ * header defining the jar file path name, followed by a list of paths.
+ * The jar file paths are relative to the codebase of the root jar.
+ *
+ Specification
+ index file : version-info blankline section*
+ version-info : JarIndex-Version: version-number
+ version-number : digit+{.digit+}*
+ section : body blankline
+ body : header name*
+ header : char+.jar newline
+ name : char+ newline
+
+ * @author langel at redhat dot com
+ */
+public class IndexListParser
+{
+ public static final String JAR_INDEX_FILE = "META-INF/INDEX.LIST";
+ public static final String JAR_INDEX_VERSION_KEY = "JarIndex-Version: ";
+
+ double versionNumber;
+ // Map each jar to the prefixes defined for the jar.
+ // This is intentionally kept in insertion order.
+ LinkedHashMap prefixes = new LinkedHashMap();
+
+ /**
+ * Parses the given jarfile's INDEX.LIST file if it exists.
+ *
+ * @param jarfile - the given jar file
+ * @param baseJarURL - the codebase of the jar file
+ * @param baseURL - the base url for the headers
+ */
+ public IndexListParser(JarFile jarfile, URL baseJarURL, URL baseURL)
+ {
+ try
+ {
+ // Parse INDEX.LIST if it exists
+ if (jarfile.getEntry(JAR_INDEX_FILE) != null)
+ {
+ BufferedReader br = new BufferedReader(new InputStreamReader(new URL(baseJarURL,
+ JAR_INDEX_FILE).openStream()));
+
+ // Must start with version info
+ String line = br.readLine();
+ if (!line.startsWith(JAR_INDEX_VERSION_KEY))
+ return;
+ versionNumber = Double.parseDouble(line.substring(JAR_INDEX_VERSION_KEY.length()).trim());
+
+ // Blank line must be next
+ line = br.readLine();
+ if (! "".equals(line))
+ {
+ clearAll();
+ return;
+ }
+
+ // May contain sections.
+ while ((line = br.readLine()) != null)
+ {
+ URL jarURL = new URL(baseURL, line);
+ HashSet values = new HashSet();
+
+ // Read the names in the section.
+ while ((line = br.readLine()) != null)
+ {
+ // Stop at section boundary.
+ if ("".equals(line))
+ break;
+ values.add(line.trim());
+ }
+ prefixes.put(jarURL, values);
+ // Might have seen an early EOF.
+ if (line == null)
+ break;
+ }
+
+ br.close();
+ }
+ else
+ {
+ // INDEX.LIST does not exist
+ clearAll();
+ }
+ }
+ catch (Exception ex)
+ {
+ clearAll();
+ }
+ }
+
+ /**
+ * Clears all the variables. This is called when parsing fails.
+ */
+ void clearAll()
+ {
+ versionNumber = 0;
+ prefixes = null;
+ }
+
+ /**
+ * Gets the version info for the file.
+ *
+ * @return the version info.
+ */
+ public String getVersionInfo()
+ {
+ return JAR_INDEX_VERSION_KEY + getVersionNumber();
+ }
+
+ /**
+ * Gets the version number of the file.
+ *
+ * @return the version number.
+ */
+ public double getVersionNumber()
+ {
+ return versionNumber;
+ }
+
+ /**
+ * Gets the map of all the headers found in the file.
+ * The keys in the map are URLs of jars. The values in the map
+ * are Sets of package prefixes (and top-level file names), as
+ * specifed in INDEX.LIST.
+ *
+ * @return an map of all the headers, or null if no INDEX.LIST was found
+ */
+ public LinkedHashMap getHeaders()
+ {
+ return prefixes;
+ }
+}
Added: llvm-gcc-4.2/trunk/libjava/classpath/gnu/java/net/LineInputStream.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/gnu/java/net/LineInputStream.java?rev=43913&view=auto
==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/gnu/java/net/LineInputStream.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/gnu/java/net/LineInputStream.java Thu Nov 8 16:56:19 2007
@@ -0,0 +1,224 @@
+/* LineInputStream.java --
+ Copyright (C) 2002, 2003, 2004, 2005, 2006 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 gnu.java.net;
+
+import java.io.BufferedInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+
+/**
+ * An input stream that can read lines of input.
+ *
+ * @author Chris Burdess (dog at gnu.org)
+ */
+public class LineInputStream
+ extends InputStream
+{
+
+ /**
+ * The underlying input stream.
+ */
+ protected InputStream in;
+
+ /*
+ * Line buffer.
+ */
+ private ByteArrayOutputStream buf;
+
+ /*
+ * Encoding to use when translating bytes to characters.
+ */
+ private String encoding;
+
+ /*
+ * End-of-stream flag.
+ */
+ private boolean eof;
+
+ /**
+ * Whether we can use block reads.
+ */
+ private final boolean blockReads;
+
+ /**
+ * Constructor using the US-ASCII character encoding.
+ * @param in the underlying input stream
+ */
+ public LineInputStream(InputStream in)
+ {
+ this(in, "US-ASCII");
+ }
+
+ /**
+ * Constructor.
+ * @param in the underlying input stream
+ * @param encoding the character encoding to use
+ */
+ public LineInputStream(InputStream in, String encoding)
+ {
+ this.in = in;
+ buf = new ByteArrayOutputStream();
+ this.encoding = encoding;
+ eof = false;
+ // If it is already buffered, additional buffering gains nothing.
+ blockReads = !(in instanceof BufferedInputStream) && in.markSupported();
+ }
+
+ public int read()
+ throws IOException
+ {
+ return in.read();
+ }
+
+ public int read(byte[] buf)
+ throws IOException
+ {
+ return in.read(buf);
+ }
+
+ public int read(byte[] buf, int off, int len)
+ throws IOException
+ {
+ return in.read(buf, off, len);
+ }
+
+ /**
+ * Read a line of input.
+ */
+ public String readLine()
+ throws IOException
+ {
+ if (eof)
+ {
+ return null;
+ }
+ do
+ {
+ if (blockReads)
+ {
+ // Use mark and reset to read chunks of bytes
+ final int MAX_LENGTH = 1024;
+ int len, pos;
+
+ len = in.available();
+ if (len == 0 || len > MAX_LENGTH)
+ len = MAX_LENGTH;
+ byte[] b = new byte[len];
+ in.mark(len);
+ // Read into buffer b
+ len = in.read(b, 0, len);
+ // Handle EOF
+ if (len == -1)
+ {
+ eof = true;
+ if (buf.size() == 0)
+ {
+ return null;
+ }
+ else
+ {
+ // We don't care about resetting buf
+ return buf.toString(encoding);
+ }
+ }
+ // Get index of LF in b
+ pos = indexOf(b, len, (byte) 0x0a);
+ if (pos != -1)
+ {
+ // Write pos bytes to buf
+ buf.write(b, 0, pos);
+ // Reset stream, and read pos + 1 bytes
+ in.reset();
+ pos += 1;
+ while (pos > 0)
+ {
+ len = in.read(b, 0, pos);
+ pos = (len == -1) ? -1 : pos - len;
+ }
+ // Return line
+ String ret = buf.toString(encoding);
+ buf.reset();
+ return ret;
+ }
+ else
+ {
+ // Append everything to buf and fall through to re-read.
+ buf.write(b, 0, len);
+ }
+ }
+ else
+ {
+ // We must use character reads in order not to read too much
+ // from the underlying stream.
+ int c = in.read();
+ switch (c)
+ {
+ case -1:
+ eof = true;
+ if (buf.size() == 0)
+ {
+ return null;
+ }
+ // Fall through and return contents of buffer.
+ case 0x0a: // LF
+ String ret = buf.toString(encoding);
+ buf.reset();
+ return ret;
+ default:
+ buf.write(c);
+ }
+ }
+ }
+ while (true);
+ }
+
+ private int indexOf(byte[] b, int len, byte c)
+ {
+ for (int pos = 0; pos < len; pos++)
+ {
+ if (b[pos] == c)
+ {
+ return pos;
+ }
+ }
+ return -1;
+ }
+}
+
Added: llvm-gcc-4.2/trunk/libjava/classpath/gnu/java/net/PlainDatagramSocketImpl.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/gnu/java/net/PlainDatagramSocketImpl.java?rev=43913&view=auto
==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/gnu/java/net/PlainDatagramSocketImpl.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/gnu/java/net/PlainDatagramSocketImpl.java Thu Nov 8 16:56:19 2007
@@ -0,0 +1,334 @@
+/* PlainDatagramSocketImpl.java -- Default DatagramSocket implementation
+ Copyright (C) 1998, 1999, 2001, 2003, 2004, 2005 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 gnu.java.net;
+
+import java.io.IOException;
+import java.net.DatagramPacket;
+import java.net.DatagramSocketImpl;
+import java.net.InetAddress;
+import java.net.NetworkInterface;
+import java.net.SocketAddress;
+import java.net.SocketException;
+
+/**
+ * Written using on-line Java Platform 1.2 API Specification, as well
+ * as "The Java Class Libraries", 2nd edition (Addison-Wesley, 1998).
+ * Status: Believed complete and correct.
+ */
+
+/**
+ * This is the default socket implementation for datagram sockets.
+ * It makes native calls to C routines that implement BSD style
+ * SOCK_DGRAM sockets in the AF_INET family.
+ *
+ * @author Aaron M. Renn (arenn at urbanophile.com)
+ * @author Warren Levy (warrenl at cygnus.com)
+ */
+public final class PlainDatagramSocketImpl extends DatagramSocketImpl
+{
+
+ /**
+ * This is the actual underlying file descriptor
+ */
+ int native_fd = -1;
+
+ /**
+ * Lock object to serialize threads wanting to receive
+ */
+ private final Object RECEIVE_LOCK = new Object();
+
+ /**
+ * Lock object to serialize threads wanting to send
+ */
+ private final Object SEND_LOCK = new Object();
+
+ /**
+ * Default do nothing constructor
+ */
+ public PlainDatagramSocketImpl()
+ {
+ // Nothing to do here.
+ }
+
+ protected void finalize() throws Throwable
+ {
+ synchronized (this)
+ {
+ if (native_fd != -1)
+ close();
+ }
+ super.finalize();
+ }
+
+ public int getNativeFD()
+ {
+ return native_fd;
+ }
+
+ /**
+ * Binds this socket to a particular port and interface
+ *
+ * @param port The port to bind to
+ * @param addr The address to bind to
+ *
+ * @exception SocketException If an error occurs
+ */
+ protected synchronized void bind(int port, InetAddress addr)
+ throws SocketException
+ {
+ VMPlainDatagramSocketImpl.bind(this, port, addr);
+ }
+
+ /**
+ * Creates a new datagram socket
+ *
+ * @exception SocketException If an error occurs
+ */
+ protected synchronized void create() throws SocketException
+ {
+ VMPlainDatagramSocketImpl.create(this);
+ }
+
+ /**
+ * Connects to the remote address and port specified as arguments.
+ *
+ * @param addr The remote address to connect to
+ * @param port The remote port to connect to
+ *
+ * @exception SocketException If an error occurs
+ */
+ protected void connect(InetAddress addr, int port) throws SocketException
+ {
+ VMPlainDatagramSocketImpl.connect(this, addr, port);
+ }
+
+ /**
+ * Disconnects the socket.
+ *
+ * @since 1.4
+ */
+ protected void disconnect()
+ {
+ synchronized (this)
+ {
+ if (native_fd != -1)
+ close();
+ }
+ }
+
+ /**
+ * Sets the Time to Live value for the socket
+ *
+ * @param ttl The new TTL value
+ *
+ * @exception IOException If an error occurs
+ */
+ protected synchronized void setTimeToLive(int ttl) throws IOException
+ {
+ setOption(VMPlainDatagramSocketImpl.IP_TTL, new Integer(ttl));
+ }
+
+ /**
+ * Gets the Time to Live value for the socket
+ *
+ * @return The TTL value
+ *
+ * @exception IOException If an error occurs
+ */
+ protected synchronized int getTimeToLive() throws IOException
+ {
+ Object obj = getOption(VMPlainDatagramSocketImpl.IP_TTL);
+
+ if (! (obj instanceof Integer))
+ throw new IOException("Internal Error");
+
+ return ((Integer) obj).intValue();
+ }
+
+
+ /**
+ * Sends a packet of data to a remote host
+ *
+ * @param packet The packet to send
+ *
+ * @exception IOException If an error occurs
+ */
+ protected void send(DatagramPacket packet) throws IOException
+ {
+ if (native_fd != -1)
+ {
+ synchronized(SEND_LOCK)
+ {
+ VMPlainDatagramSocketImpl.send(this, packet);
+ }
+ }
+ }
+
+ /**
+ * Receives a UDP packet from the network
+ *
+ * @param packet The packet to fill in with the data received
+ *
+ * @exception IOException IOException If an error occurs
+ */
+ protected void receive(DatagramPacket packet)
+ throws IOException
+ {
+ synchronized(RECEIVE_LOCK)
+ {
+ VMPlainDatagramSocketImpl.receive(this, packet);
+ }
+ }
+
+
+ /**
+ * Sets the value of an option on the socket
+ *
+ * @param option_id The identifier of the option to set
+ * @param val The value of the option to set
+ *
+ * @exception SocketException If an error occurs
+ */
+ public synchronized void setOption(int option_id, Object val)
+ throws SocketException
+ {
+ VMPlainDatagramSocketImpl.setOption(this, option_id, val);
+ }
+
+ /**
+ * Retrieves the value of an option on the socket
+ *
+ * @param option_id The identifier of the option to retrieve
+ *
+ * @return The value of the option
+ *
+ * @exception SocketException If an error occurs
+ */
+ public synchronized Object getOption(int option_id)
+ throws SocketException
+ {
+ return VMPlainDatagramSocketImpl.getOption(this, option_id);
+ }
+
+ /**
+ * Closes the socket
+ */
+ protected synchronized void close()
+ {
+ VMPlainDatagramSocketImpl.close(this);
+ }
+
+ /**
+ * Gets the Time to Live value for the socket
+ *
+ * @return The TTL value
+ *
+ * @exception IOException If an error occurs
+ *
+ * @deprecated 1.2
+ */
+ protected synchronized byte getTTL() throws IOException
+ {
+ return (byte) getTimeToLive();
+ }
+
+ /**
+ * Sets the Time to Live value for the socket
+ *
+ * @param ttl The new TTL value
+ *
+ * @exception IOException If an error occurs
+ *
+ * @deprecated 1.2
+ */
+ protected synchronized void setTTL(byte ttl) throws IOException
+ {
+ setTimeToLive(((int) ttl) & 0xFF);
+ }
+
+ /**
+ * Joins a multicast group
+ *
+ * @param addr The group to join
+ *
+ * @exception IOException If an error occurs
+ */
+ protected synchronized void join(InetAddress addr) throws IOException
+ {
+ VMPlainDatagramSocketImpl.join(this,addr);
+ }
+
+ /**
+ * Leaves a multicast group
+ *
+ * @param addr The group to leave
+ *
+ * @exception IOException If an error occurs
+ */
+ protected synchronized void leave(InetAddress addr) throws IOException
+ {
+ VMPlainDatagramSocketImpl.leave(this, addr);
+ }
+
+ /**
+ * What does this method really do?
+ */
+ protected synchronized int peek(InetAddress addr) throws IOException
+ {
+ throw new IOException("Not Implemented Yet");
+ }
+
+ public int peekData(DatagramPacket packet)
+ {
+ throw new InternalError
+ ("PlainDatagramSocketImpl::peekData is not implemented");
+ }
+
+ public void joinGroup(SocketAddress address, NetworkInterface netIf)
+ throws IOException
+ {
+ VMPlainDatagramSocketImpl.joinGroup(this, address, netIf);
+ }
+
+ public void leaveGroup(SocketAddress address, NetworkInterface netIf)
+ throws IOException
+ {
+ VMPlainDatagramSocketImpl.leaveGroup(this, address, netIf);
+ }
+}
Added: llvm-gcc-4.2/trunk/libjava/classpath/gnu/java/net/PlainSocketImpl.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/gnu/java/net/PlainSocketImpl.java?rev=43913&view=auto
==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/gnu/java/net/PlainSocketImpl.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/gnu/java/net/PlainSocketImpl.java Thu Nov 8 16:56:19 2007
@@ -0,0 +1,516 @@
+/* PlainSocketImpl.java -- Default socket implementation
+ Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005
+ 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 gnu.java.net;
+
+import java.io.InputStream;
+import java.io.IOException;
+import java.io.OutputStream;
+import java.net.InetAddress;
+import java.net.SocketAddress;
+import java.net.SocketException;
+import java.net.SocketImpl;
+
+/**
+ * Written using on-line Java Platform 1.2 API Specification, as well
+ * as "The Java Class Libraries", 2nd edition (Addison-Wesley, 1998).
+ * Status: Believed complete and correct.
+ */
+
+/**
+ * Unless the application installs its own SocketImplFactory, this is the
+ * default socket implemetation that will be used. It simply uses a
+ * combination of Java and native routines to implement standard BSD
+ * style sockets of family AF_INET and types SOCK_STREAM and SOCK_DGRAM
+ *
+ * @author Per Bothner (bothner at cygnus.com)
+ * @author Nic Ferrier (nferrier at tapsellferrier.co.uk)
+ * @author Aaron M. Renn (arenn at urbanophile.com)
+ */
+public final class PlainSocketImpl extends SocketImpl
+{
+
+ /**
+ * The OS file handle representing the socket.
+ * This is used for reads and writes to/from the socket and
+ * to close it.
+ *
+ * When the socket is closed this is reset to -1.
+ */
+ int native_fd = -1;
+
+ /**
+ * A cached copy of the in stream for reading from the socket.
+ */
+ private InputStream in;
+
+ /**
+ * A cached copy of the out stream for writing to the socket.
+ */
+ private OutputStream out;
+
+ /**
+ * Indicates whether a channel initiated whatever operation
+ * is being invoked on this socket.
+ */
+ private boolean inChannelOperation;
+
+ /**
+ * Indicates whether we should ignore whether any associated
+ * channel is set to non-blocking mode. Certain operations
+ * throw an <code>IllegalBlockingModeException</code> if the
+ * associated channel is in non-blocking mode, <i>except</i>
+ * if the operation is invoked by the channel itself.
+ */
+ public final boolean isInChannelOperation()
+ {
+ return inChannelOperation;
+ }
+
+ /**
+ * Sets our indicator of whether an I/O operation is being
+ * initiated by a channel.
+ */
+ public final void setInChannelOperation(boolean b)
+ {
+ inChannelOperation = b;
+ }
+
+ /**
+ * Default do nothing constructor.
+ */
+ public PlainSocketImpl()
+ {
+ // Nothing to do here.
+ }
+
+ protected void finalize() throws Throwable
+ {
+ synchronized (this)
+ {
+ if (native_fd != -1)
+ try
+ {
+ close();
+ }
+ catch (IOException ex)
+ {
+ // Nothing we can do about it.
+ }
+ }
+ super.finalize();
+ }
+
+ public int getNativeFD()
+ {
+ return native_fd;
+ }
+
+ /**
+ * Sets the specified option on a socket to the passed in object. For
+ * options that take an integer argument, the passed in object is an
+ * Integer. The option_id parameter is one of the defined constants in
+ * this interface.
+ *
+ * @param optionId The identifier of the option
+ * @param value The value to set the option to
+ *
+ * @throws SocketException if an error occurs
+ */
+ public void setOption(int optionId, Object value) throws SocketException
+ {
+ VMPlainSocketImpl.setOption(this, optionId, value);
+ }
+
+ /**
+ * Returns the current setting of the specified option. The Object returned
+ * will be an Integer for options that have integer values. The option_id
+ * is one of the defined constants in this interface.
+ *
+ * @param optionId the option identifier
+ *
+ * @return the current value of the option
+ *
+ * @throws SocketException if an error occurs
+ */
+ public Object getOption(int optionId) throws SocketException
+ {
+ return VMPlainSocketImpl.getOption(this, optionId);
+ }
+
+ public void shutdownInput() throws IOException
+ {
+ VMPlainSocketImpl.shutdownInput(this);
+ }
+
+ public void shutdownOutput() throws IOException
+ {
+ VMPlainSocketImpl.shutdownOutput(this);
+ }
+
+ /**
+ * Creates a new socket that is not bound to any local address/port and
+ * is not connected to any remote address/port. The stream parameter will be
+ * ignored since PlainSocketImpl always is a stream socket. Datagram sockets
+ * are handled by PlainDatagramSocketImpl.
+ *
+ * @param stream <code>true</code> for stream sockets, <code>false</code> for
+ * datagram sockets
+ */
+ protected synchronized void create(boolean stream) throws IOException
+ {
+ VMPlainSocketImpl.create(this);
+ }
+
+ /**
+ * Connects to the remote hostname and port specified as arguments.
+ *
+ * @param hostname the remote hostname to connect to
+ * @param port the remote port to connect to
+ *
+ * @throws IOException If an error occurs
+ */
+ protected synchronized void connect(String hostname, int port)
+ throws IOException
+ {
+ connect(InetAddress.getByName(hostname), port);
+ }
+
+ /**
+ * Connects to the remote address and port specified as arguments.
+ *
+ * @param addr the remote address to connect to
+ * @param port the remote port to connect to
+ *
+ * @throws IOException If an error occurs
+ */
+ protected void connect(InetAddress addr, int port) throws IOException
+ {
+ VMPlainSocketImpl.connect(this, addr, port);
+ }
+
+ /**
+ * Connects to the remote socket address with a specified timeout.
+ *
+ * @param address the remote address to connect to
+ * @param timeout the timeout to use for this connect, 0 means infinite.
+ *
+ * @throws IOException If an error occurs
+ */
+ protected synchronized void connect(SocketAddress address, int timeout)
+ throws IOException
+ {
+ VMPlainSocketImpl.connect(this, address, timeout);
+ }
+
+ /**
+ * Binds to the specified port on the specified addr. Note that this addr
+ * must represent a local IP address. **** How bind to INADDR_ANY? ****
+ *
+ * @param addr the address to bind to
+ * @param port the port number to bind to
+ *
+ * @throws IOException if an error occurs
+ */
+ protected synchronized void bind(InetAddress addr, int port)
+ throws IOException
+ {
+ VMPlainSocketImpl.bind(this, addr, port);
+ }
+
+ /**
+ * Starts listening for connections on a socket. The queuelen parameter
+ * is how many pending connections will queue up waiting to be serviced
+ * before being accept'ed. If the queue of pending requests exceeds this
+ * number, additional connections will be refused.
+ *
+ * @param queuelen The length of the pending connection queue
+ *
+ * @throws IOException If an error occurs
+ */
+ protected synchronized void listen(int queuelen)
+ throws IOException
+ {
+ VMPlainSocketImpl.listen(this, queuelen);
+ }
+
+ /**
+ * Accepts a new connection on this socket and returns in in the
+ * passed in SocketImpl.
+ *
+ * @param impl The SocketImpl object to accept this connection.
+ */
+ protected synchronized void accept(SocketImpl impl)
+ throws IOException
+ {
+ VMPlainSocketImpl.accept(this, impl);
+ }
+
+ /**
+ * Returns the number of bytes that the caller can read from this socket
+ * without blocking.
+ *
+ * @return the number of readable bytes before blocking
+ *
+ * @throws IOException if an error occurs
+ */
+ protected int available() throws IOException
+ {
+ return VMPlainSocketImpl.available(this);
+ }
+
+ /**
+ * Closes the socket. This will cause any InputStream or OutputStream
+ * objects for this Socket to be closed as well.
+ *
+ * <p>
+ * Note that if the SO_LINGER option is set on this socket, then the
+ * operation could block.
+ * </p>
+ *
+ * @throws IOException if an error occurs
+ */
+ protected void close() throws IOException
+ {
+ VMPlainSocketImpl.close(this);
+ }
+
+ public void sendUrgentData(int data)
+ {
+ VMPlainSocketImpl.sendUrgendData(this, data);
+ }
+
+ /**
+ * Internal method used by SocketInputStream for reading data from
+ * the connection. Reads up to len bytes of data into the buffer
+ * buf starting at offset bytes into the buffer.
+ *
+ * @return the actual number of bytes read or -1 if end of stream.
+ *
+ * @throws IOException if an error occurs
+ */
+ protected int read(byte[] buf, int offset, int len)
+ throws IOException
+ {
+ return VMPlainSocketImpl.read(this, buf, offset, len);
+ }
+
+ /**
+ * Internal method used by SocketInputStream for reading data from
+ * the connection. Reads and returns one byte of data.
+ *
+ * @return the read byte
+ *
+ * @throws IOException if an error occurs
+ */
+ protected int read()
+ throws IOException
+ {
+ return VMPlainSocketImpl.read(this);
+ }
+
+ /**
+ * Internal method used by SocketOuputStream for writing data to
+ * the connection. Writes up to len bytes of data from the buffer
+ * buf starting at offset bytes into the buffer.
+ *
+ * @throws IOException If an error occurs
+ */
+ protected void write(byte[] buf, int offset, int len)
+ throws IOException
+ {
+ VMPlainSocketImpl.write(this, buf, offset, len);
+ }
+
+ /**
+ * Internal method used by SocketOuputStream for writing data to
+ * the connection. Writes up one byte to the socket.
+ *
+ * @throws IOException If an error occurs
+ */
+ protected void write(int data) throws IOException
+ {
+ VMPlainSocketImpl.write(this, data);
+ }
+
+ /**
+ * Returns an InputStream object for reading from this socket. This will
+ * be an instance of SocketInputStream.
+ *
+ * @return An input stream attached to the socket.
+ *
+ * @exception IOException If an error occurs
+ */
+ protected synchronized InputStream getInputStream() throws IOException
+ {
+ if (in == null)
+ in = new SocketInputStream();
+
+ return in;
+ }
+
+ /**
+ * Returns an OutputStream object for writing to this socket. This will
+ * be an instance of SocketOutputStream.
+ *
+ * @return An output stream attached to the socket.
+ *
+ * @exception IOException If an error occurs
+ */
+ protected synchronized OutputStream getOutputStream() throws IOException
+ {
+ if (out == null)
+ out = new SocketOutputStream();
+
+ return out;
+ }
+
+ /**
+ * This class contains an implementation of <code>InputStream</code> for
+ * sockets. It in an internal only class used by <code>PlainSocketImpl</code>.
+ *
+ * @author Nic Ferrier <nferrier at tapsellferrier.co.uk>
+ */
+ final class SocketInputStream
+ extends InputStream
+ {
+ /**
+ * Returns the number of bytes available to be read before blocking
+ */
+ public int available() throws IOException
+ {
+ return PlainSocketImpl.this.available();
+ }
+
+ /**
+ * This method not only closes the stream, it closes the underlying socket
+ * (and thus any connection) and invalidates any other Input/Output streams
+ * for the underlying impl object
+ */
+ public void close() throws IOException
+ {
+ PlainSocketImpl.this.close();
+ }
+
+ /**
+ * Reads the next byte of data and returns it as an int.
+ *
+ * @return The byte read (as an int) or -1 if end of stream);
+ *
+ * @exception IOException If an error occurs.
+ */
+ public int read() throws IOException
+ {
+ return PlainSocketImpl.this.read();
+ }
+
+ /**
+ * Reads up to len bytes of data into the caller supplied buffer starting
+ * at offset bytes from the start of the buffer
+ *
+ * @param buf The buffer
+ * @param offset Offset into the buffer to start reading from
+ * @param len The number of bytes to read
+ *
+ * @return The number of bytes actually read or -1 if end of stream
+ *
+ * @exception IOException If an error occurs.
+ */
+ public int read (byte[] buf, int offset, int len) throws IOException
+ {
+ int bytes_read = PlainSocketImpl.this.read (buf, offset, len);
+
+ if (bytes_read == 0)
+ return -1;
+
+ return bytes_read;
+ }
+ }
+
+ /**
+ * This class is used internally by <code>PlainSocketImpl</code> to be the
+ * <code>OutputStream</code> subclass returned by its
+ * <code>getOutputStream method</code>. It expects only to be used in that
+ * context.
+ *
+ * @author Nic Ferrier <nferrier at tapsellferrier.co.uk>
+ */
+ final class SocketOutputStream
+ extends OutputStream
+ {
+ /**
+ * This method closes the stream and the underlying socket connection. This
+ * action also effectively closes any other InputStream or OutputStream
+ * object associated with the connection.
+ *
+ * @exception IOException If an error occurs
+ */
+ public void close() throws IOException
+ {
+ PlainSocketImpl.this.close();
+ }
+
+ /**
+ * Writes a byte (passed in as an int) to the given output stream
+ *
+ * @param b The byte to write
+ *
+ * @exception IOException If an error occurs
+ */
+ public void write(int b) throws IOException
+ {
+ PlainSocketImpl.this.write(b);
+ }
+
+ /**
+ * Writes len number of bytes from the array buf to the stream starting
+ * at offset bytes into the buffer.
+ *
+ * @param buf The buffer
+ * @param offset Offset into the buffer to start writing from
+ * @param len The number of bytes to write
+ *
+ * @exception IOException If an error occurs.
+ */
+ public void write (byte[] buf, int offset, int len) throws IOException
+ {
+ PlainSocketImpl.this.write (buf, offset, len);
+ }
+ }
+}
Added: llvm-gcc-4.2/trunk/libjava/classpath/gnu/java/net/URLParseError.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/gnu/java/net/URLParseError.java?rev=43913&view=auto
==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/gnu/java/net/URLParseError.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/gnu/java/net/URLParseError.java Thu Nov 8 16:56:19 2007
@@ -0,0 +1,57 @@
+/* URLParseError.java -- Helps bypassing the exception limitation for
+ URLStreamHandler.parseURL().
+ Copyright (C) 2003 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 gnu.java.net;
+
+/**
+ * This class helps the people writing protocols to report URL parse
+ * errors in parseUrl as this method cannot report other exceptions
+ * than Errors.
+ *
+ * The main drawback is that it uses the Error mechanism which should not
+ * be used for that type of error reporting.
+ *
+ * @author Guilhem Lavaux (guilhem at kaffe.org)
+ */
+public class URLParseError extends Error
+{
+ public URLParseError(String msg)
+ {
+ super(msg);
+ }
+}
Added: llvm-gcc-4.2/trunk/libjava/classpath/gnu/java/net/loader/FileResource.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/gnu/java/net/loader/FileResource.java?rev=43913&view=auto
==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/gnu/java/net/loader/FileResource.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/gnu/java/net/loader/FileResource.java Thu Nov 8 16:56:19 2007
@@ -0,0 +1,82 @@
+/* FileResource.java -- a Resource for file URLs
+ Copyright (C) 2006 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 gnu.java.net.loader;
+
+
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.net.MalformedURLException;
+import java.net.URL;
+
+public final class FileResource extends Resource
+{
+ final File file;
+
+ public FileResource(FileURLLoader loader, File file)
+ {
+ super(loader);
+ this.file = file;
+ }
+
+ public InputStream getInputStream() throws IOException
+ {
+ return new FileInputStream(file);
+ }
+
+ public int getLength()
+ {
+ return (int) file.length();
+ }
+
+ public URL getURL()
+ {
+ try
+ {
+ return file.toURL();
+ }
+ catch (MalformedURLException e)
+ {
+ InternalError ie = new InternalError();
+ ie.initCause(e);
+ throw ie;
+ }
+ }
+}
\ No newline at end of file
Added: llvm-gcc-4.2/trunk/libjava/classpath/gnu/java/net/loader/FileURLLoader.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/gnu/java/net/loader/FileURLLoader.java?rev=43913&view=auto
==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/gnu/java/net/loader/FileURLLoader.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/gnu/java/net/loader/FileURLLoader.java Thu Nov 8 16:56:19 2007
@@ -0,0 +1,145 @@
+/* FileURLLoader.java -- a URLLoader for file URLs
+ Copyright (C) 2006 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 gnu.java.net.loader;
+
+
+import java.io.File;
+import java.io.IOException;
+import java.net.URL;
+import java.net.URLClassLoader;
+import java.net.URLStreamHandlerFactory;
+import java.util.StringTokenizer;
+
+/**
+ * A <code>FileURLLoader</code> is a type of <code>URLLoader</code>
+ * only loading from file url.
+ */
+public final class FileURLLoader extends URLLoader
+{
+ File dir; //the file for this file url
+
+ public FileURLLoader(URLClassLoader classloader,
+ URLStreamHandlerCache cache,
+ URLStreamHandlerFactory factory,
+ URL url, URL absoluteUrl)
+ {
+ super(classloader, cache, factory, url, absoluteUrl);
+ dir = new File(absoluteUrl.getFile());
+ }
+
+ /** get resource with the name "name" in the file url */
+ public Resource getResource(String name)
+ {
+ try
+ {
+ // Make sure that all components in name are valid by walking through
+ // them
+ File file = walkPathComponents(name);
+
+ if (file == null)
+ return null;
+
+ return new FileResource(this, file);
+ }
+ catch (IOException e)
+ {
+ // Fall through...
+ }
+ return null;
+ }
+
+ /**
+ * Walk all path tokens and check them for validity. At no moment, we are
+ * allowed to reach a directory located "above" the root directory, stored
+ * in "dir" property. We are also not allowed to enter a non existing
+ * directory or a non directory component (plain file, symbolic link, ...).
+ * An empty or null path is valid. Pathnames components are separated by
+ * <code>File.separatorChar</code>
+ *
+ * @param resourceFileName the name to be checked for validity.
+ * @return the canonical file pointed by the resourceFileName or null if the
+ * walking failed
+ * @throws IOException in case of issue when creating the canonical
+ * resulting file
+ * @see File#separatorChar
+ */
+ private File walkPathComponents(String resourceFileName) throws IOException
+ {
+ StringTokenizer stringTokenizer = new StringTokenizer(resourceFileName, File.separator);
+ File currentFile = dir;
+ int tokenCount = stringTokenizer.countTokens();
+
+ for (int i = 0; i < tokenCount - 1; i++)
+ {
+ String currentToken = stringTokenizer.nextToken();
+
+ // If we are at the root directory and trying to go up, the walking is
+ // finished with an error
+ if ("..".equals(currentToken) && currentFile.equals(dir))
+ return null;
+
+ currentFile = new File(currentFile, currentToken);
+
+ // If the current file doesn't exist or is not a directory, the walking is
+ // finished with an error
+ if (! (currentFile.exists() && currentFile.isDirectory()))
+ return null;
+
+ }
+
+ // Treat the last token differently, if it exists, because it does not need
+ // to be a directory
+ if (tokenCount > 0)
+ {
+ String currentToken = stringTokenizer.nextToken();
+
+ if ("..".equals(currentToken) && currentFile.equals(dir))
+ return null;
+
+ currentFile = new File(currentFile, currentToken);
+
+ // If the current file doesn't exist, the walking is
+ // finished with an error
+ if (! currentFile.exists())
+ return null;
+ }
+
+ return currentFile.getCanonicalFile();
+ }
+}
\ No newline at end of file
Added: llvm-gcc-4.2/trunk/libjava/classpath/gnu/java/net/loader/JarURLLoader.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/gnu/java/net/loader/JarURLLoader.java?rev=43913&view=auto
==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/gnu/java/net/loader/JarURLLoader.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/gnu/java/net/loader/JarURLLoader.java Thu Nov 8 16:56:19 2007
@@ -0,0 +1,215 @@
+package gnu.java.net.loader;
+
+import gnu.java.net.IndexListParser;
+
+import java.io.IOException;
+import java.net.JarURLConnection;
+import java.net.MalformedURLException;
+import java.net.URL;
+import java.net.URLClassLoader;
+import java.net.URLStreamHandlerFactory;
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.LinkedHashMap;
+import java.util.Map;
+import java.util.Set;
+import java.util.StringTokenizer;
+import java.util.jar.Attributes;
+import java.util.jar.JarEntry;
+import java.util.jar.JarFile;
+import java.util.jar.Manifest;
+
+/**
+ * A <code>JarURLLoader</code> is a type of <code>URLLoader</code>
+ * only loading from jar url.
+ */
+public final class JarURLLoader extends URLLoader
+{
+ // True if we've initialized -- i.e., tried open the jar file.
+ boolean initialized;
+ // The jar file for this url.
+ JarFile jarfile;
+ // Base jar: url for all resources loaded from jar.
+ final URL baseJarURL;
+ // The "Class-Path" attribute of this Jar's manifest.
+ ArrayList classPath;
+ // If not null, a mapping from INDEX.LIST for this jar only.
+ // This is a set of all prefixes and top-level files that
+ // ought to be available in this jar.
+ Set indexSet;
+
+ // This constructor is used internally. It purposely does not open
+ // the jar file -- it defers this until later. This allows us to
+ // implement INDEX.LIST lazy-loading semantics.
+ private JarURLLoader(URLClassLoader classloader, URLStreamHandlerCache cache,
+ URLStreamHandlerFactory factory,
+ URL baseURL, URL absoluteUrl,
+ Set indexSet)
+ {
+ super(classloader, cache, factory, baseURL, absoluteUrl);
+
+ URL newBaseURL = null;
+ try
+ {
+ // Cache url prefix for all resources in this jar url.
+ String base = baseURL.toExternalForm() + "!/";
+ newBaseURL = new URL("jar", "", -1, base, cache.get(factory, "jar"));
+ }
+ catch (MalformedURLException ignore)
+ {
+ // Ignore.
+ }
+ this.baseJarURL = newBaseURL;
+ this.classPath = null;
+ this.indexSet = indexSet;
+ }
+
+ // This constructor is used by URLClassLoader. It will immediately
+ // try to read the jar file, in case we've found an index or a class-path
+ // setting. FIXME: it would be nice to defer this as well, but URLClassLoader
+ // makes this hard.
+ public JarURLLoader(URLClassLoader classloader, URLStreamHandlerCache cache,
+ URLStreamHandlerFactory factory,
+ URL baseURL, URL absoluteUrl)
+ {
+ this(classloader, cache, factory, baseURL, absoluteUrl, null);
+ initialize();
+ }
+
+ private void initialize()
+ {
+ JarFile jarfile = null;
+ try
+ {
+ jarfile =
+ ((JarURLConnection) baseJarURL.openConnection()).getJarFile();
+
+ Manifest manifest;
+ Attributes attributes;
+ String classPathString;
+
+ IndexListParser parser = new IndexListParser(jarfile, baseJarURL,
+ baseURL);
+ LinkedHashMap indexMap = parser.getHeaders();
+ if (indexMap != null)
+ {
+ // Note that the index also computes
+ // the resulting Class-Path -- there are jars out there
+ // where the index lists some required jars which do
+ // not appear in the Class-Path attribute in the manifest.
+ this.classPath = new ArrayList();
+ Iterator it = indexMap.entrySet().iterator();
+ while (it.hasNext())
+ {
+ Map.Entry entry = (Map.Entry) it.next();
+ URL subURL = (URL) entry.getKey();
+ Set prefixes = (Set) entry.getValue();
+ if (subURL.equals(baseURL))
+ this.indexSet = prefixes;
+ else
+ {
+ JarURLLoader subLoader = new JarURLLoader(classloader,
+ cache,
+ factory, subURL,
+ subURL,
+ prefixes);
+ // Note that we don't care if the sub-loader itself has an
+ // index or a class-path -- only the top-level jar
+ // file gets this treatment; its index should cover
+ // everything.
+ this.classPath.add(subLoader);
+ }
+ }
+ }
+ else if ((manifest = jarfile.getManifest()) != null
+ && (attributes = manifest.getMainAttributes()) != null
+ && ((classPathString
+ = attributes.getValue(Attributes.Name.CLASS_PATH))
+ != null))
+ {
+ this.classPath = new ArrayList();
+ StringTokenizer st = new StringTokenizer(classPathString, " ");
+ while (st.hasMoreElements ())
+ {
+ String e = st.nextToken ();
+ try
+ {
+ URL subURL = new URL(baseURL, e);
+ // We've seen at least one jar file whose Class-Path
+ // attribute includes the original jar. If we process
+ // that normally we end up with infinite recursion.
+ if (subURL.equals(baseURL))
+ continue;
+ JarURLLoader subLoader = new JarURLLoader(classloader,
+ cache, factory,
+ subURL, subURL);
+ this.classPath.add(subLoader);
+ ArrayList extra = subLoader.getClassPath();
+ if (extra != null)
+ this.classPath.addAll(extra);
+ }
+ catch (java.net.MalformedURLException xx)
+ {
+ // Give up
+ }
+ }
+ }
+ }
+ catch (IOException ioe)
+ {
+ /* ignored */
+ }
+
+ this.jarfile = jarfile;
+ this.initialized = true;
+ }
+
+ /** get resource with the name "name" in the jar url */
+ public Resource getResource(String name)
+ {
+ if (name.startsWith("/"))
+ name = name.substring(1);
+ if (indexSet != null)
+ {
+ // Trust the index.
+ String basename = name;
+ int offset = basename.lastIndexOf('/');
+ if (offset != -1)
+ basename = basename.substring(0, offset);
+ if (! indexSet.contains(basename))
+ return null;
+ // FIXME: if the index claim to hold the resource, and jar file
+ // doesn't have it, we're supposed to throw an exception. However,
+ // in our model this is tricky to implement, as another URLLoader from
+ // the same top-level jar may have an overlapping index entry.
+ }
+
+ if (! initialized)
+ initialize();
+ if (jarfile == null)
+ return null;
+
+ JarEntry je = jarfile.getJarEntry(name);
+ if (je != null)
+ return new JarURLResource(this, name, je);
+ else
+ return null;
+ }
+
+ public Manifest getManifest()
+ {
+ try
+ {
+ return (jarfile == null) ? null : jarfile.getManifest();
+ }
+ catch (IOException ioe)
+ {
+ return null;
+ }
+ }
+
+ public ArrayList getClassPath()
+ {
+ return classPath;
+ }
+}
Added: llvm-gcc-4.2/trunk/libjava/classpath/gnu/java/net/loader/JarURLResource.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/gnu/java/net/loader/JarURLResource.java?rev=43913&view=auto
==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/gnu/java/net/loader/JarURLResource.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/gnu/java/net/loader/JarURLResource.java Thu Nov 8 16:56:19 2007
@@ -0,0 +1,94 @@
+/* JarURLResource.java -- a Resource for jar URLs
+ Copyright (C) 2006 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 gnu.java.net.loader;
+
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.net.MalformedURLException;
+import java.net.URL;
+import java.security.cert.Certificate;
+import java.util.jar.JarEntry;
+
+public final class JarURLResource extends Resource
+{
+ private final JarEntry entry;
+ private final String name;
+
+ public JarURLResource(JarURLLoader loader, String name, JarEntry entry)
+ {
+ super(loader);
+ this.entry = entry;
+ this.name = name;
+ }
+
+ public InputStream getInputStream() throws IOException
+ {
+ return ((JarURLLoader) loader).jarfile.getInputStream(entry);
+ }
+
+ public int getLength()
+ {
+ return (int) entry.getSize();
+ }
+
+ public Certificate[] getCertificates()
+ {
+ // We have to get the entry from the jar file again, because the
+ // certificates will not be available until the entire entry has
+ // been read.
+ return ((JarEntry) ((JarURLLoader) loader).jarfile.getEntry(name))
+ .getCertificates();
+ }
+
+ public URL getURL()
+ {
+ try
+ {
+ return new URL(((JarURLLoader) loader).baseJarURL, name,
+ loader.cache.get(loader.factory, "jar"));
+ }
+ catch (MalformedURLException e)
+ {
+ InternalError ie = new InternalError();
+ ie.initCause(e);
+ throw ie;
+ }
+ }
+}
\ No newline at end of file
Added: llvm-gcc-4.2/trunk/libjava/classpath/gnu/java/net/loader/RemoteResource.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/gnu/java/net/loader/RemoteResource.java?rev=43913&view=auto
==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/gnu/java/net/loader/RemoteResource.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/gnu/java/net/loader/RemoteResource.java Thu Nov 8 16:56:19 2007
@@ -0,0 +1,78 @@
+/* Resource.java -- a Resource for "remote" URLs
+ Copyright (C) 2006 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 gnu.java.net.loader;
+
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.net.URL;
+
+/**
+ * A resource from some remote location.
+ */
+public final class RemoteResource extends Resource
+{
+ private final URL url;
+ private final InputStream stream;
+ final int length;
+
+ public RemoteResource(RemoteURLLoader loader, String name, URL url,
+ InputStream stream, int length)
+ {
+ super(loader);
+ this.url = url;
+ this.stream = stream;
+ this.length = length;
+ }
+
+ public InputStream getInputStream() throws IOException
+ {
+ return stream;
+ }
+
+ public int getLength()
+ {
+ return length;
+ }
+
+ public URL getURL()
+ {
+ return url;
+ }
+}
\ No newline at end of file
Added: llvm-gcc-4.2/trunk/libjava/classpath/gnu/java/net/loader/RemoteURLLoader.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/gnu/java/net/loader/RemoteURLLoader.java?rev=43913&view=auto
==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/gnu/java/net/loader/RemoteURLLoader.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/gnu/java/net/loader/RemoteURLLoader.java Thu Nov 8 16:56:19 2007
@@ -0,0 +1,101 @@
+/* RemoteURLLoader.java -- a URLLoader for "remote" objects
+ Copyright (C) 2006 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 gnu.java.net.loader;
+
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.net.HttpURLConnection;
+import java.net.URL;
+import java.net.URLClassLoader;
+import java.net.URLConnection;
+import java.net.URLStreamHandlerFactory;
+
+/**
+ * Loader for remote directories.
+ */
+public final class RemoteURLLoader extends URLLoader
+{
+ private final String protocol;
+
+ public RemoteURLLoader(URLClassLoader classloader,
+ URLStreamHandlerCache cache,
+ URLStreamHandlerFactory factory,
+ URL url)
+ {
+ super(classloader, cache, factory, url);
+ protocol = url.getProtocol();
+ }
+
+ /**
+ * Get a remote resource.
+ * Returns null if no such resource exists.
+ */
+ public Resource getResource(String name)
+ {
+ try
+ {
+ URL url = new URL(baseURL, name, cache.get(factory, protocol));
+ URLConnection connection = url.openConnection();
+
+ // Open the connection and check the stream
+ // just to be sure it exists.
+ int length = connection.getContentLength();
+ InputStream stream = connection.getInputStream();
+
+ // We can do some extra checking if it is a http request
+ if (connection instanceof HttpURLConnection)
+ {
+ int response =
+ ((HttpURLConnection) connection).getResponseCode();
+ if (response / 100 != 2)
+ return null;
+ }
+
+ if (stream != null)
+ return new RemoteResource(this, name, url, stream, length);
+ else
+ return null;
+ }
+ catch (IOException ioe)
+ {
+ return null;
+ }
+ }
+}
\ No newline at end of file
Added: llvm-gcc-4.2/trunk/libjava/classpath/gnu/java/net/loader/Resource.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/gnu/java/net/loader/Resource.java?rev=43913&view=auto
==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/gnu/java/net/loader/Resource.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/gnu/java/net/loader/Resource.java Thu Nov 8 16:56:19 2007
@@ -0,0 +1,110 @@
+/* Resource.java -- a resource for URLLoader
+ Copyright (C) 2006 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 gnu.java.net.loader;
+
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.net.URL;
+import java.security.CodeSource;
+import java.security.cert.Certificate;
+
+/**
+ * A <code>Resource</code> represents a resource in some
+ * <code>URLLoader</code>. It also contains all information (e.g.,
+ * <code>URL</code>, <code>CodeSource</code>, <code>Manifest</code> and
+ * <code>InputStream</code>) that is necessary for loading resources
+ * and creating classes from a <code>URL</code>.
+ */
+public abstract class Resource
+{
+ final URLLoader loader;
+
+ public Resource(URLLoader loader)
+ {
+ this.loader = loader;
+ }
+
+ /**
+ * Returns the non-null <code>CodeSource</code> associated with
+ * this resource.
+ */
+ public CodeSource getCodeSource()
+ {
+ Certificate[] certs = getCertificates();
+ if (certs == null)
+ return loader.noCertCodeSource;
+ else
+ return new CodeSource(loader.baseURL, certs);
+ }
+
+ /**
+ * Returns <code>Certificates</code> associated with this
+ * resource, or null when there are none.
+ */
+ public Certificate[] getCertificates()
+ {
+ return null;
+ }
+
+ /**
+ * Return the URLLoader for this resource.
+ */
+ public final URLLoader getLoader()
+ {
+ return loader;
+ }
+
+ /**
+ * Return a <code>URL</code> that can be used to access this resource.
+ */
+ public abstract URL getURL();
+
+ /**
+ * Returns the size of this <code>Resource</code> in bytes or
+ * <code>-1</code> when unknown.
+ */
+ public abstract int getLength();
+
+ /**
+ * Returns the non-null <code>InputStream</code> through which
+ * this resource can be loaded.
+ */
+ public abstract InputStream getInputStream() throws IOException;
+}
\ No newline at end of file
Added: llvm-gcc-4.2/trunk/libjava/classpath/gnu/java/net/loader/URLLoader.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/gnu/java/net/loader/URLLoader.java?rev=43913&view=auto
==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/gnu/java/net/loader/URLLoader.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/gnu/java/net/loader/URLLoader.java Thu Nov 8 16:56:19 2007
@@ -0,0 +1,147 @@
+/* URLLoader.java -- base helper class for URLClassLoader
+ Copyright (C) 2006 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 gnu.java.net.loader;
+
+import java.net.URL;
+import java.net.URLClassLoader;
+import java.net.URLStreamHandlerFactory;
+import java.security.CodeSource;
+import java.util.ArrayList;
+import java.util.jar.Manifest;
+
+/**
+ * A <code>URLLoader</code> contains all logic to load resources from a
+ * given base <code>URL</code>.
+ */
+public abstract class URLLoader
+{
+ /**
+ * Our classloader to get info from if needed.
+ */
+ final URLClassLoader classloader;
+
+ /**
+ * The base URL from which all resources are loaded.
+ */
+ final URL baseURL;
+
+ /**
+ * The stream handler factory.
+ */
+ final URLStreamHandlerFactory factory;
+
+ /**
+ * The source for stream handlers.
+ */
+ final URLStreamHandlerCache cache;
+
+ /**
+ * A <code>CodeSource</code> without any associated certificates.
+ * It is common for classes to not have certificates associated
+ * with them. If they come from the same <code>URLLoader</code>
+ * then it is safe to share the associated <code>CodeSource</code>
+ * between them since <code>CodeSource</code> is immutable.
+ */
+ final CodeSource noCertCodeSource;
+
+ public URLLoader(URLClassLoader classloader, URLStreamHandlerCache cache,
+ URLStreamHandlerFactory factory,
+ URL baseURL)
+ {
+ this(classloader, cache, factory, baseURL, baseURL);
+ }
+
+ public URLLoader(URLClassLoader classloader, URLStreamHandlerCache cache,
+ URLStreamHandlerFactory factory,
+ URL baseURL, URL overrideURL)
+ {
+ this.classloader = classloader;
+ this.baseURL = baseURL;
+ this.factory = factory;
+ this.cache = cache;
+ this.noCertCodeSource = new CodeSource(overrideURL, null);
+ }
+
+ /**
+ * Return the base URL of this loader.
+ */
+ public final URL getBaseURL()
+ {
+ return baseURL;
+ }
+
+ /**
+ * Returns a <code>Class</code> loaded by this
+ * <code>URLLoader</code>, or <code>null</code> when this loader
+ * either can't load the class or doesn't know how to load classes
+ * at all. Most subclasses do not need to override this; it is only
+ * useful in situations where the subclass has a more direct way of
+ * making <code>Class</code> objects.
+ */
+ public Class getClass(String className)
+ {
+ return null;
+ }
+
+ /**
+ * Returns a <code>Resource</code> loaded by this
+ * <code>URLLoader</code>, or <code>null</code> when no
+ * <code>Resource</code> with the given name exists.
+ */
+ public abstract Resource getResource(String s);
+
+ /**
+ * Returns the <code>Manifest</code> associated with the
+ * <code>Resource</code>s loaded by this <code>URLLoader</code> or
+ * <code>null</code> there is no such <code>Manifest</code>.
+ */
+ public Manifest getManifest()
+ {
+ return null;
+ }
+
+ /**
+ * Return a list of new URLLoader objects representing any
+ * class path entries added by this container.
+ */
+ public ArrayList getClassPath()
+ {
+ return null;
+ }
+}
\ No newline at end of file
Added: llvm-gcc-4.2/trunk/libjava/classpath/gnu/java/net/loader/URLStreamHandlerCache.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/gnu/java/net/loader/URLStreamHandlerCache.java?rev=43913&view=auto
==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/gnu/java/net/loader/URLStreamHandlerCache.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/gnu/java/net/loader/URLStreamHandlerCache.java Thu Nov 8 16:56:19 2007
@@ -0,0 +1,84 @@
+/* URLStreamHandlerCache.java -- a cache for URLStreamHandlers
+ Copyright (C) 2006 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 gnu.java.net.loader;
+
+import java.net.URLStreamHandler;
+import java.net.URLStreamHandlerFactory;
+import java.util.HashMap;
+
+/**
+ */
+public class URLStreamHandlerCache
+{
+ /**
+ * A cache to store mappings between handler factory and its
+ * private protocol handler cache (also a HashMap), so we can avoid
+ * creating handlers each time the same protocol comes.
+ */
+ private HashMap factoryCache = new HashMap(5);
+
+ public URLStreamHandlerCache()
+ {
+ }
+
+ public synchronized void add(URLStreamHandlerFactory factory)
+ {
+ // Since we only support three protocols so far, 5 is enough
+ // for cache initial size.
+ if (factory != null && factoryCache.get(factory) == null)
+ factoryCache.put(factory, new HashMap(5));
+ }
+
+ public synchronized URLStreamHandler get(URLStreamHandlerFactory factory,
+ String protocol)
+ {
+ if (factory == null)
+ return null;
+ // Check if there're handler for the same protocol in cache.
+ HashMap cache = (HashMap) factoryCache.get(factory);
+ URLStreamHandler handler = (URLStreamHandler) cache.get(protocol);
+ if (handler == null)
+ {
+ // Add it to cache.
+ handler = factory.createURLStreamHandler(protocol);
+ cache.put(protocol, handler);
+ }
+ return handler;
+ }
+}
Added: llvm-gcc-4.2/trunk/libjava/classpath/gnu/java/net/local/LocalServerSocket.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/gnu/java/net/local/LocalServerSocket.java?rev=43913&view=auto
==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/gnu/java/net/local/LocalServerSocket.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/gnu/java/net/local/LocalServerSocket.java Thu Nov 8 16:56:19 2007
@@ -0,0 +1,172 @@
+/* LocalServerSocket.java -- a unix domain server socket.
+ Copyright (C) 2006 Free Software Foundation, Inc.
+
+This file is a 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 of the License, 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; if not, write to the Free Software
+Foundation, Inc., 51 Franklin St, 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 gnu.java.net.local;
+
+import java.io.IOException;
+
+import java.net.InetAddress;
+import java.net.ServerSocket;
+import java.net.Socket;
+import java.net.SocketAddress;
+import java.net.SocketException;
+
+public final class LocalServerSocket extends ServerSocket
+{
+
+ // Fields.
+ // -------------------------------------------------------------------------
+
+ private LocalSocketImpl myImpl;
+ private boolean closed;
+
+ // Constructors.
+ // -------------------------------------------------------------------------
+
+ public LocalServerSocket () throws IOException
+ {
+ myImpl = new LocalSocketImpl ();
+ }
+
+ public LocalServerSocket (SocketAddress bindPoint) throws IOException
+ {
+ this ();
+ bind (bindPoint);
+ }
+
+ // Instance methods.
+ // -------------------------------------------------------------------------
+
+ public void bind (SocketAddress bindPoint) throws IOException
+ {
+ bind (bindPoint, 0);
+ }
+
+ public void bind (SocketAddress bindPoint, int backlog) throws IOException
+ {
+ myImpl.doCreate ();
+ myImpl.bind (bindPoint);
+ myImpl.listen (backlog);
+ }
+
+ public InetAddress getInetAddress ()
+ {
+ return null;
+ }
+
+ public int getLocalPort ()
+ {
+ return -1;
+ }
+
+ public SocketAddress getLocalSocketAddress ()
+ {
+ return myImpl.getLocalAddress ();
+ }
+
+ public Socket accept () throws IOException
+ {
+ LocalSocket s = new LocalSocket (true);
+ myImpl.accept (s.getLocalImpl());
+ s.localConnected = true;
+ return s;
+ }
+
+ public void close () throws IOException
+ {
+ myImpl.close ();
+ myImpl.unlink ();
+ closed = true;
+ }
+
+ public boolean isBound ()
+ {
+ return myImpl.getLocalAddress () != null;
+ }
+
+ public boolean isClosed ()
+ {
+ return closed;
+ }
+
+ public void setSoTimeout (int timeout)
+ {
+ throw new UnsupportedOperationException ("local sockets do not support timeouts");
+ }
+
+ public int getSoTimeout ()
+ {
+ throw new UnsupportedOperationException ("local sockets do not support timeouts");
+ }
+
+ public void setReuseAddress (boolean b)
+ {
+ throw new UnsupportedOperationException ("local sockets do not support reuse address");
+ }
+
+ public boolean getReuseAddress ()
+ {
+ throw new UnsupportedOperationException ("local sockets do not support reuse address");
+ }
+
+ public String toString ()
+ {
+ return LocalServerSocket.class.getName() + " [ address="
+ + myImpl.getLocalAddress() + " ]";
+ }
+
+ public void setReceiveBufferSize (int size)
+ {
+ throw new UnsupportedOperationException ("local sockets do not support buffer size");
+ }
+
+ public int getReceiveBufferSize ()
+ {
+ throw new UnsupportedOperationException ("local sockets do not support buffer size");
+ }
+
+ public void setSendBufferSize (int size)
+ {
+ throw new UnsupportedOperationException ("local sockets do not support buffer size");
+ }
+
+ public int getSendBufferSize ()
+ {
+ throw new UnsupportedOperationException ("local sockets do not support buffer size");
+ }
+}
Added: llvm-gcc-4.2/trunk/libjava/classpath/gnu/java/net/local/LocalSocket.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/gnu/java/net/local/LocalSocket.java?rev=43913&view=auto
==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/gnu/java/net/local/LocalSocket.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/gnu/java/net/local/LocalSocket.java Thu Nov 8 16:56:19 2007
@@ -0,0 +1,313 @@
+/* LocalSocket.java -- a unix domain client socket.
+ Copyright (C) 2006 Free Software Foundation, Inc.
+
+This file is a 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 of the License, 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; if not, write to the Free Software
+Foundation, Inc., 51 Franklin St, 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 gnu.java.net.local;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+
+import java.net.InetAddress;
+import java.net.Socket;
+import java.net.SocketAddress;
+import java.net.SocketException;
+import java.net.SocketImpl;
+
+import java.nio.channels.IllegalBlockingModeException;
+import java.nio.channels.SocketChannel;
+
+/**
+ * A local, or unix-domain socket. Unix domain sockets are connected on the
+ * local filesystem itself, rather than a remote address.
+ */
+public final class LocalSocket extends Socket
+{
+
+ // Fields.
+ // -------------------------------------------------------------------------
+
+ private final LocalSocketImpl localimpl;
+ boolean localClosed;
+ boolean localConnected;
+
+ // Constructors.
+ // -------------------------------------------------------------------------
+
+ public LocalSocket () throws SocketException
+ {
+ super ();
+ localimpl = new LocalSocketImpl ();
+ }
+
+ public LocalSocket (LocalSocketAddress addr) throws SocketException
+ {
+ this ();
+ try
+ {
+ connect (addr);
+ }
+ catch (IOException ioe)
+ {
+ SocketException se = new SocketException ();
+ se.initCause (ioe);
+ throw se;
+ }
+ }
+
+ LocalSocket (boolean nocreate) throws IOException
+ {
+ super ();
+ localimpl = new LocalSocketImpl (nocreate);
+ }
+
+ // Instance methods.
+ // -------------------------------------------------------------------------
+
+ public void bind (SocketAddress bindpoint) throws IOException
+ {
+ throw new SocketException ("binding local client sockets is nonsensical");
+ }
+
+ public void connect (SocketAddress endpoint, int timeout) throws IOException
+ {
+ if (isClosed ())
+ {
+ throw new SocketException ("socket is closed");
+ }
+ if (! (endpoint instanceof LocalSocketAddress))
+ {
+ throw new IllegalArgumentException ("socket address is not a local address");
+ }
+ if (getChannel() != null && !getChannel().isBlocking())
+ {
+ throw new IllegalBlockingModeException ();
+ }
+
+ try
+ {
+ localimpl.doCreate ();
+ localimpl.localConnect ((LocalSocketAddress) endpoint);
+ }
+ catch (IOException ioe)
+ {
+ close ();
+ throw ioe;
+ }
+ localConnected = true;
+ }
+
+ public InetAddress getInetAddress ()
+ {
+ return null;
+ }
+
+ public InetAddress getLocalAddress ()
+ {
+ return null;
+ }
+
+ public int getPort ()
+ {
+ return -1;
+ }
+
+ public int getLocalPort ()
+ {
+ return -1;
+ }
+
+ public SocketChannel getChannel ()
+ {
+ return null;
+ }
+
+ public SocketAddress getLocalSocketAddress ()
+ {
+ return localimpl.getLocalAddress ();
+ }
+
+ public SocketAddress getRemoteSocketAddress ()
+ {
+ return localimpl.getRemoteAddress ();
+ }
+
+ public InputStream getInputStream () throws IOException
+ {
+ return localimpl.getInputStream ();
+ }
+
+ public OutputStream getOutputStream () throws IOException
+ {
+ return localimpl.getOutputStream ();
+ }
+
+ public void sendUrgentData (int b) throws IOException
+ {
+ localimpl.sendUrgentData (b);
+ }
+
+ public synchronized void close () throws IOException
+ {
+ localimpl.close ();
+ localClosed = true;
+ }
+
+ public void shutdownInput () throws IOException
+ {
+ localimpl.shutdownInput ();
+ }
+
+ public void shutdownOutput () throws IOException
+ {
+ localimpl.shutdownOutput ();
+ }
+
+ public boolean isClosed ()
+ {
+ return localClosed;
+ }
+
+ public boolean isBound ()
+ {
+ return false;
+ }
+
+ public boolean isConnected ()
+ {
+ return localConnected;
+ }
+
+ // Unsupported methods.
+ // -------------------------------------------------------------------------
+
+ public void setTcpNoDelay (boolean b) throws SocketException
+ {
+ throw new SocketException ("local sockets do not support this option");
+ }
+
+ public boolean getTcpNoDelay() throws SocketException
+ {
+ throw new SocketException ("local sockets do not support this option");
+ }
+
+ public void setSoLinger (boolean b, int i) throws SocketException
+ {
+ throw new SocketException ("local sockets do not support this option");
+ }
+
+ public int getSoLinger () throws SocketException
+ {
+ throw new SocketException ("local sockets do not support this option");
+ }
+
+ public void setOOBInline (boolean b) throws SocketException
+ {
+ throw new SocketException ("local sockets do not support this option");
+ }
+
+ public boolean getOOBInline () throws SocketException
+ {
+ throw new SocketException ("local sockets do not support this option");
+ }
+
+ public void setSoTimeout (int i) throws SocketException
+ {
+ // Ignore.
+ }
+
+ public int getSoTimeout () throws SocketException
+ {
+ // We don't support timeout, so we return 0.
+ return 0;
+ }
+
+ public void setSendBufferSize (int i) throws SocketException
+ {
+ throw new SocketException ("local sockets do not support this option");
+ }
+
+ public int getSendBufferSize() throws SocketException
+ {
+ throw new SocketException ("local sockets do not support this option");
+ }
+
+ public void setReceiveBufferSize (int i) throws SocketException
+ {
+ throw new SocketException ("local sockets do not support this option");
+ }
+
+ public int getReceiveBufferSize () throws SocketException
+ {
+ throw new SocketException ("local sockets do not support this option");
+ }
+
+ public void setKeepAlive (boolean b) throws SocketException
+ {
+ throw new SocketException ("local sockets do not support this option");
+ }
+
+ public boolean getKeepAlive () throws SocketException
+ {
+ throw new SocketException ("local sockets do not support this option");
+ }
+
+ public void setTrafficClass (int i) throws SocketException
+ {
+ throw new SocketException ("local sockets do not support this option");
+ }
+
+ public int getTrafficClass () throws SocketException
+ {
+ throw new SocketException ("local sockets do not support this option");
+ }
+
+ public void setReuseAddress (boolean b) throws SocketException
+ {
+ throw new SocketException ("local sockets do not support this option");
+ }
+
+ public boolean getReuseAddress () throws SocketException
+ {
+ throw new SocketException ("local sockets do not support this option");
+ }
+
+ LocalSocketImpl getLocalImpl ()
+ {
+ return localimpl;
+ }
+}
Added: llvm-gcc-4.2/trunk/libjava/classpath/gnu/java/net/local/LocalSocketAddress.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/gnu/java/net/local/LocalSocketAddress.java?rev=43913&view=auto
==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/gnu/java/net/local/LocalSocketAddress.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/gnu/java/net/local/LocalSocketAddress.java Thu Nov 8 16:56:19 2007
@@ -0,0 +1,100 @@
+/* LocalSocketAddress.java -- unix-domain socket address.
+ Copyright (C) 2006 Free Software Foundation, Inc.
+
+This file is a 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 of the License, 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; if not, write to the Free Software
+Foundation, Inc., 51 Franklin St, 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 gnu.java.net.local;
+
+import java.net.SocketAddress;
+
+public final class LocalSocketAddress extends SocketAddress
+{
+
+ // Fields.
+ // -------------------------------------------------------------------------
+
+ private final String path;
+
+ // Constructor.
+ // -------------------------------------------------------------------------
+
+ /**
+ * Creates a new unix domain socket address.
+ *
+ * @param path The path to the socket.
+ * @throws NullPointerException If <i>path</i> is <tt>null</tt>.
+ */
+ public LocalSocketAddress (String path)
+ {
+ if (path == null)
+ {
+ throw new NullPointerException ();
+ }
+ this.path = path;
+ }
+
+ // Instance methods.
+ // -------------------------------------------------------------------------
+
+ /**
+ * Returns the path of the socket.
+ *
+ * @return The path.
+ */
+ public String getPath ()
+ {
+ return path;
+ }
+
+ public boolean equals (Object o)
+ {
+ if (!(o instanceof LocalSocketAddress))
+ {
+ return false;
+ }
+ return getPath ().equals (((LocalSocketAddress) o).getPath ());
+ }
+
+ public int hashCode ()
+ {
+ return path.hashCode();
+ }
+
+ public String toString ()
+ {
+ return super.toString() + " [ " + path + " ]";
+ }
+}
Added: llvm-gcc-4.2/trunk/libjava/classpath/gnu/java/net/local/LocalSocketImpl.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/gnu/java/net/local/LocalSocketImpl.java?rev=43913&view=auto
==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/gnu/java/net/local/LocalSocketImpl.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/gnu/java/net/local/LocalSocketImpl.java Thu Nov 8 16:56:19 2007
@@ -0,0 +1,329 @@
+/* LocalSocketImpl.java -- a unix domain client socket implementation.
+ Copyright (C) 2006 Free Software Foundation, Inc.
+
+This file is a 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 of the License, 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; if not, write to the Free Software
+Foundation, Inc., 51 Franklin St, 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 gnu.java.net.local;
+
+import java.io.FileDescriptor;
+import java.io.InputStream;
+import java.io.IOException;
+import java.io.OutputStream;
+
+import java.net.InetAddress;
+import java.net.SocketAddress;
+import java.net.SocketException;
+import java.net.SocketImpl;
+
+final class LocalSocketImpl extends SocketImpl
+{
+
+ // Fields.
+ // -------------------------------------------------------------------------
+
+ private boolean created;
+ private InputStream in;
+ private OutputStream out;
+ // Package private to avoid synthetic accessor method.
+ int socket_fd;
+ private LocalSocketAddress local;
+ private LocalSocketAddress remote;
+
+ static
+ {
+ try
+ {
+ System.loadLibrary ("javanet");
+ }
+ catch (Exception x)
+ {
+ x.printStackTrace ();
+ }
+ }
+
+ // Constructor.
+ // -------------------------------------------------------------------------
+
+ LocalSocketImpl ()
+ {
+ this (false);
+ }
+
+ LocalSocketImpl (boolean nocreate)
+ {
+ created = nocreate;
+ socket_fd = -1;
+ fd = new FileDescriptor ();
+ }
+
+ // Instance methods.
+ // -------------------------------------------------------------------------
+
+ public void setOption (int opt, Object value) throws SocketException
+ {
+ throw new SocketException ("local sockets do not support options");
+ }
+
+ public Object getOption (int opt) throws SocketException
+ {
+ throw new SocketException ("local sockets do not support options");
+ }
+
+ protected native void create (boolean stream) throws IOException;
+ protected native void listen (int timeout) throws IOException;
+ protected native void accept (LocalSocketImpl socket) throws IOException;
+ protected native int available (int fd) throws IOException;
+ protected native void close () throws IOException;
+ protected native void sendUrgentData (int data) throws IOException;
+ protected native void shutdownInput () throws IOException;
+ protected native void shutdownOutput () throws IOException;
+
+ native void unlink () throws IOException;
+ native void localBind (LocalSocketAddress addr) throws IOException;
+ native void localConnect (LocalSocketAddress addr) throws IOException;
+ native int read (int fd, byte[] buf, int off, int len) throws IOException;
+ native void write (int fd, byte[] buf, int off, int len) throws IOException;
+
+ protected int available()
+ throws IOException
+ {
+ return available(socket_fd);
+ }
+
+ void doCreate () throws IOException
+ {
+ if (!created)
+ {
+ create (true);
+ }
+ }
+
+ LocalSocketAddress getLocalAddress ()
+ {
+ return local;
+ }
+
+ LocalSocketAddress getRemoteAddress ()
+ {
+ return remote;
+ }
+
+ protected InputStream getInputStream()
+ {
+ if (in == null)
+ {
+ in = new LocalInputStream (this);
+ }
+
+ return in;
+ }
+
+ protected OutputStream getOutputStream()
+ {
+ if (out == null)
+ {
+ out = new LocalOutputStream (this);
+ }
+
+ return out;
+ }
+
+ protected void accept (SocketImpl impl) throws IOException
+ {
+ if (! (impl instanceof LocalSocketImpl))
+ {
+ throw new IllegalArgumentException ("not a local socket");
+ }
+ accept ((LocalSocketImpl) impl);
+ }
+
+ protected void connect (String host, int port) throws IOException
+ {
+ throw new SocketException ("this is a local socket");
+ }
+
+ protected void connect (InetAddress addr, int port) throws IOException
+ {
+ throw new SocketException ("this is a local socket");
+ }
+
+ protected void connect(SocketAddress addr, int timeout) throws IOException
+ {
+ if (! (addr instanceof LocalSocketAddress))
+ {
+ throw new SocketException ("address is not local");
+ }
+ localConnect ((LocalSocketAddress) addr);
+ }
+
+ protected void bind (InetAddress addr, int port) throws IOException
+ {
+ throw new SocketException ("this is a local socket");
+ }
+
+ protected void bind (SocketAddress addr) throws IOException
+ {
+ if (! (addr instanceof LocalSocketAddress))
+ {
+ throw new SocketException ("address is not local");
+ }
+ localBind ((LocalSocketAddress) addr);
+ }
+
+// Inner classes.
+ // -------------------------------------------------------------------------
+
+ class LocalInputStream extends InputStream
+ {
+
+ // Field.
+ // -----------------------------------------------------------------------
+
+ private final LocalSocketImpl impl;
+
+ // Constructor.
+ // -----------------------------------------------------------------------
+
+ LocalInputStream (LocalSocketImpl impl)
+ {
+ this.impl = impl;
+ }
+
+ // Instance methods.
+ // -----------------------------------------------------------------------
+
+ public int available () throws IOException
+ {
+ return impl.available();
+ }
+
+ public boolean markSupported ()
+ {
+ return false;
+ }
+
+ public void mark (int readLimit)
+ {
+ }
+
+ public void reset () throws IOException
+ {
+ throw new IOException ("mark/reset not supported");
+ }
+
+ public void close () throws IOException
+ {
+ impl.close();
+ }
+
+ public int read () throws IOException
+ {
+ byte[] buf = new byte[1];
+ int ret = read (buf);
+ if (ret != -1)
+ {
+ return buf[0] & 0xFF;
+ }
+ else
+ {
+ return -1;
+ }
+ }
+
+ public int read (byte[] buf) throws IOException
+ {
+ return read (buf, 0, buf.length);
+ }
+
+ public int read (byte[] buf, int off, int len) throws IOException
+ {
+ int ret = impl.read (socket_fd, buf, off, len);
+
+ if (ret == 0)
+ {
+ return -1;
+ }
+
+ return ret;
+ }
+ }
+
+ class LocalOutputStream extends OutputStream
+ {
+
+ // Field.
+ // -----------------------------------------------------------------------
+
+ private final LocalSocketImpl impl;
+
+ // Constructor.
+ // -----------------------------------------------------------------------
+
+ LocalOutputStream (LocalSocketImpl impl)
+ {
+ this.impl = impl;
+ }
+
+ // Instance methods.
+ // -----------------------------------------------------------------------
+
+ public void close () throws IOException
+ {
+ impl.close ();
+ }
+
+ public void flush () throws IOException
+ {
+ }
+
+ public void write (int b) throws IOException
+ {
+ byte[] buf = new byte [1];
+ buf[0] = (byte) b;
+ write (buf);
+ }
+
+ public void write (byte[] buf) throws IOException
+ {
+ write (buf, 0, buf.length);
+ }
+
+ public void write (byte[] buf, int off, int len) throws IOException
+ {
+ impl.write (socket_fd, buf, off, len);
+ }
+ }
+}
Added: llvm-gcc-4.2/trunk/libjava/classpath/gnu/java/net/package.html
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/gnu/java/net/package.html?rev=43913&view=auto
==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/gnu/java/net/package.html (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/gnu/java/net/package.html Thu Nov 8 16:56:19 2007
@@ -0,0 +1,46 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
+<!-- package.html - describes classes in gnu.java.net package.
+ Copyright (C) 2005 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. -->
+
+<html>
+<head><title>GNU Classpath - gnu.java.net</title></head>
+
+<body>
+<p></p>
+
+</body>
+</html>
Added: llvm-gcc-4.2/trunk/libjava/classpath/gnu/java/net/protocol/file/Connection.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/gnu/java/net/protocol/file/Connection.java?rev=43913&view=auto
==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/gnu/java/net/protocol/file/Connection.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/gnu/java/net/protocol/file/Connection.java Thu Nov 8 16:56:19 2007
@@ -0,0 +1,376 @@
+/* FileURLConnection.java -- URLConnection class for "file" protocol
+ Copyright (C) 1998, 1999, 2003 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 gnu.java.net.protocol.file;
+
+import gnu.classpath.SystemProperties;
+
+import java.io.BufferedInputStream;
+import java.io.BufferedOutputStream;
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileOutputStream;
+import java.io.FilePermission;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.io.OutputStreamWriter;
+import java.io.Writer;
+import java.net.ProtocolException;
+import java.net.URL;
+import java.net.URLConnection;
+import java.security.Permission;
+import java.text.SimpleDateFormat;
+import java.util.Date;
+import java.util.Locale;
+import java.net.MalformedURLException;
+
+/**
+ * This subclass of java.net.URLConnection models a URLConnection via
+ * the "file" protocol.
+ *
+ * @author Aaron M. Renn (arenn at urbanophile.com)
+ * @author Nic Ferrier (nferrier at tapsellferrier.co.uk)
+ * @author Warren Levy (warrenl at cygnus.com)
+ */
+public class Connection extends URLConnection
+{
+ /**
+ * Default permission for a file
+ */
+ private static final String DEFAULT_PERMISSION = "read";
+
+ private static class StaticData
+ {
+ /**
+ * HTTP-style DateFormat, used to format the last-modified header.
+ */
+ static SimpleDateFormat dateFormat
+ = new SimpleDateFormat("EEE, dd MMM yyyy hh:mm:ss 'GMT'",
+ new Locale ("En", "Us", "Unix"));
+
+ static String lineSeparator =
+ SystemProperties.getProperty("line.separator");
+ }
+
+
+ /**
+ * This is a File object for this connection
+ */
+ private File file;
+
+ /**
+ * If a directory, contains a list of files in the directory.
+ */
+ private byte[] directoryListing;
+
+ /**
+ * InputStream if we are reading from the file
+ */
+ private InputStream inputStream;
+
+ /**
+ * OutputStream if we are writing to the file
+ */
+ private OutputStream outputStream;
+
+ /**
+ * FilePermission to read the file
+ */
+ private FilePermission permission;
+
+ /**
+ * Calls superclass constructor to initialize.
+ */
+ public Connection(URL url)
+ {
+ super (url);
+
+ permission = new FilePermission(getURL().getFile(), DEFAULT_PERMISSION);
+ }
+
+ /**
+ * Unquote "%" + hex quotes characters
+ *
+ * @param str The string to unquote or null.
+ *
+ * @return The unquoted string or null if str was null.
+ *
+ * @exception MalformedURLException If the given string contains invalid
+ * escape sequences.
+ *
+ */
+ public static String unquote(String str) throws MalformedURLException
+ {
+ if (str == null)
+ return null;
+
+ final int MAX_BYTES_PER_UTF_8_CHAR = 3;
+ byte[] buf = new byte[str.length()*MAX_BYTES_PER_UTF_8_CHAR];
+ int pos = 0;
+ for (int i = 0; i < str.length(); i++)
+ {
+ char c = str.charAt(i);
+ if (c == '%')
+ {
+ if (i + 2 >= str.length())
+ throw new MalformedURLException(str + " : Invalid quoted character");
+ int hi = Character.digit(str.charAt(++i), 16);
+ int lo = Character.digit(str.charAt(++i), 16);
+ if (lo < 0 || hi < 0)
+ throw new MalformedURLException(str + " : Invalid quoted character");
+ buf[pos++] = (byte) (hi * 16 + lo);
+ }
+ else if (c > 127) {
+ try {
+ byte [] c_as_bytes = Character.toString(c).getBytes("utf-8");
+ final int c_length = c_as_bytes.length;
+ System.arraycopy(c_as_bytes, 0, buf, pos, c_length);
+ pos += c_length;
+ }
+ catch (java.io.UnsupportedEncodingException x2) {
+ throw (Error) new InternalError().initCause(x2);
+ }
+ }
+ else
+ buf[pos++] = (byte) c;
+ }
+ try
+ {
+ return new String(buf, 0, pos, "utf-8");
+ }
+ catch (java.io.UnsupportedEncodingException x2)
+ {
+ throw (Error) new InternalError().initCause(x2);
+ }
+ }
+
+ /**
+ * "Connects" to the file by opening it.
+ */
+ public void connect() throws IOException
+ {
+ // Call is ignored if already connected.
+ if (connected)
+ return;
+
+ // If not connected, then file needs to be openned.
+ file = new File (unquote(getURL().getFile()));
+
+ if (! file.isDirectory())
+ {
+ if (doInput)
+ inputStream = new BufferedInputStream(new FileInputStream(file));
+
+ if (doOutput)
+ outputStream = new BufferedOutputStream(new FileOutputStream(file));
+ }
+ else
+ {
+ if (doInput)
+ {
+ inputStream = new ByteArrayInputStream(getDirectoryListing());
+ }
+
+ if (doOutput)
+ throw new ProtocolException
+ ("file: protocol does not support output on directories");
+ }
+
+ connected = true;
+ }
+
+ /**
+ * Populates the <code>directoryListing</code> field with a byte array
+ * containing a representation of the directory listing.
+ */
+ byte[] getDirectoryListing()
+ throws IOException
+ {
+ if (directoryListing == null)
+ {
+ ByteArrayOutputStream sink = new ByteArrayOutputStream();
+ // NB uses default character encoding for this system
+ Writer writer = new OutputStreamWriter(sink);
+
+ String[] files = file.list();
+
+ for (int i = 0; i < files.length; i++)
+ {
+ writer.write(files[i]);
+ writer.write(StaticData.lineSeparator);
+ }
+
+ directoryListing = sink.toByteArray();
+ }
+ return directoryListing;
+ }
+
+ /**
+ * Opens the file for reading and returns a stream for it.
+ *
+ * @return An InputStream for this connection.
+ *
+ * @exception IOException If an error occurs
+ */
+ public InputStream getInputStream()
+ throws IOException
+ {
+ if (!doInput)
+ throw new ProtocolException("Can't open InputStream if doInput is false");
+
+ if (!connected)
+ connect();
+
+ return inputStream;
+ }
+
+ /**
+ * Opens the file for writing and returns a stream for it.
+ *
+ * @return An OutputStream for this connection.
+ *
+ * @exception IOException If an error occurs.
+ */
+ public OutputStream getOutputStream()
+ throws IOException
+ {
+ if (!doOutput)
+ throw new
+ ProtocolException("Can't open OutputStream if doOutput is false");
+
+ if (!connected)
+ connect();
+
+ return outputStream;
+ }
+
+ /**
+ * Get the last modified time of the resource.
+ *
+ * @return the time since epoch that the resource was modified.
+ */
+ public long getLastModified()
+ {
+ try
+ {
+ if (!connected)
+ connect();
+
+ return file.lastModified();
+ }
+ catch (IOException e)
+ {
+ return -1;
+ }
+ }
+
+ /**
+ * Get an http-style header field. Just handle a few common ones.
+ */
+ public String getHeaderField(String field)
+ {
+ try
+ {
+ if (!connected)
+ connect();
+
+ if (field.equals("content-type"))
+ return guessContentTypeFromName(file.getName());
+ else if (field.equals("content-length"))
+ {
+ if (file.isDirectory())
+ {
+ return Integer.toString(getContentLength());
+ }
+ return Long.toString(file.length());
+ }
+ else if (field.equals("last-modified"))
+ {
+ synchronized (StaticData.dateFormat)
+ {
+ return StaticData.dateFormat.format(
+ new Date(file.lastModified()));
+ }
+ }
+ }
+ catch (IOException e)
+ {
+ // Fall through.
+ }
+ return null;
+ }
+
+ /**
+ * Get the length of content.
+ *
+ * @return the length of the content.
+ */
+ public int getContentLength()
+ {
+ try
+ {
+ if (!connected)
+ connect();
+
+ if (file.isDirectory())
+ {
+ return getDirectoryListing().length;
+ }
+ return (int) file.length();
+ }
+ catch (IOException e)
+ {
+ return -1;
+ }
+ }
+
+ /**
+ * This method returns a <code>Permission</code> object representing the
+ * permissions required to access this URL. This method returns a
+ * <code>java.io.FilePermission</code> for the file's path with a read
+ * permission.
+ *
+ * @return A Permission object
+ */
+ public Permission getPermission() throws IOException
+ {
+ return permission;
+ }
+}
Added: llvm-gcc-4.2/trunk/libjava/classpath/gnu/java/net/protocol/file/Handler.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/gnu/java/net/protocol/file/Handler.java?rev=43913&view=auto
==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/gnu/java/net/protocol/file/Handler.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/gnu/java/net/protocol/file/Handler.java Thu Nov 8 16:56:19 2007
@@ -0,0 +1,91 @@
+/* Handler.java -- "file" protocol handler for java.net
+ Copyright (C) 1998, 1999, 2000, 2002, 2003, 2004 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 gnu.java.net.protocol.file;
+
+import java.io.IOException;
+import java.net.URL;
+import java.net.URLConnection;
+import java.net.URLStreamHandler;
+
+/**
+ * This is the protocol handler for the "file" protocol.
+ * It implements the abstract openConnection() method from
+ * URLStreamHandler by returning a new FileURLConnection object (from
+ * this package). All other methods are inherited
+ *
+ * @author Aaron M. Renn (arenn at urbanophile.com)
+ * @author Warren Levy (warrenl at cygnus.com)
+ */
+public class Handler extends URLStreamHandler
+{
+ /**
+ * A do nothing constructor
+ */
+ public Handler()
+ {
+ }
+
+ /**
+ * This method returs a new FileURLConnection for the specified URL
+ *
+ * @param url The URL to return a connection for
+ *
+ * @return The URLConnection
+ *
+ * @exception IOException If an error occurs
+ */
+ protected URLConnection openConnection(URL url) throws IOException
+ {
+ // If a hostname is set, then we need to switch protocols to ftp
+ // in order to transfer this from the remote host.
+ String host = url.getHost();
+ if ((host != null) && (! host.equals("")))
+ {
+ // Reset the protocol (and implicitly the handler) for this URL.
+ // Then have the URL attempt the connection again, as it will
+ // get the changed handler the next time around.
+ // If the ftp protocol handler is not installed, an
+ // exception will be thrown from the new openConnection() call.
+ setURL (url, "ftp", url.getHost(), url.getPort(), url.getFile(),
+ url.getRef());
+ return url.openConnection();
+ }
+
+ return new Connection(url);
+ }
+} // class Handler
Added: llvm-gcc-4.2/trunk/libjava/classpath/gnu/java/net/protocol/file/package.html
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/gnu/java/net/protocol/file/package.html?rev=43913&view=auto
==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/gnu/java/net/protocol/file/package.html (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/gnu/java/net/protocol/file/package.html Thu Nov 8 16:56:19 2007
@@ -0,0 +1,46 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
+<!-- package.html - describes classes in gnu.java.net.protocol.file package.
+ Copyright (C) 2005 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. -->
+
+<html>
+<head><title>GNU Classpath - gnu.java.net.protocol.file</title></head>
+
+<body>
+<p></p>
+
+</body>
+</html>
Added: llvm-gcc-4.2/trunk/libjava/classpath/gnu/java/net/protocol/ftp/ActiveModeDTP.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/gnu/java/net/protocol/ftp/ActiveModeDTP.java?rev=43913&view=auto
==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/gnu/java/net/protocol/ftp/ActiveModeDTP.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/gnu/java/net/protocol/ftp/ActiveModeDTP.java Thu Nov 8 16:56:19 2007
@@ -0,0 +1,252 @@
+/* ActiveModeDTP.java --
+ Copyright (C) 2003, 2004 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 gnu.java.net.protocol.ftp;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.net.InetAddress;
+import java.net.ServerSocket;
+import java.net.Socket;
+
+/**
+ * An active mode FTP data transfer process.
+ * This starts a server on the specified port listening for a data
+ * connection. It converts the socket input into a file stream for reading.
+ *
+ * @author Chris Burdess (dog at gnu.org)
+ */
+final class ActiveModeDTP
+ implements DTP, Runnable
+{
+
+ ServerSocket server;
+ Socket socket;
+ DTPInputStream in;
+ DTPOutputStream out;
+ boolean completed;
+ boolean inProgress;
+ int transferMode;
+ IOException exception;
+ Thread acceptThread;
+ int connectionTimeout;
+
+ ActiveModeDTP(InetAddress localhost, int port,
+ int connectionTimeout, int timeout)
+ throws IOException
+ {
+ completed = false;
+ inProgress = false;
+ server = new ServerSocket(port, 1, localhost);
+ if (timeout > 0)
+ {
+ server.setSoTimeout(timeout);
+ }
+ if (connectionTimeout <= 0)
+ {
+ connectionTimeout = 20000;
+ }
+ this.connectionTimeout = connectionTimeout;
+ acceptThread = new Thread(this, "ActiveModeDTP");
+ acceptThread.setDaemon(true);
+ acceptThread.start();
+ }
+
+ /**
+ * Start listening.
+ */
+ public void run()
+ {
+ try
+ {
+ socket = server.accept();
+ //System.err.println("Accepted connection from "+socket.getInetAddress()+":"+socket.getPort());
+ }
+ catch (IOException e)
+ {
+ exception = e;
+ }
+ }
+
+ /**
+ * Waits until a client has connected.
+ */
+ public void waitFor()
+ throws IOException
+ {
+ try
+ {
+ acceptThread.join(connectionTimeout);
+ }
+ catch (InterruptedException e)
+ {
+ }
+ if (exception != null)
+ {
+ throw exception;
+ }
+ if (socket == null)
+ {
+ server.close();
+ throw new IOException("client did not connect before timeout");
+ }
+ acceptThread = null;
+ }
+
+ /**
+ * Returns an input stream from which a remote file can be read.
+ */
+ public InputStream getInputStream()
+ throws IOException
+ {
+ if (inProgress)
+ {
+ throw new IOException("Transfer in progress");
+ }
+ if (acceptThread != null)
+ {
+ waitFor();
+ }
+ switch (transferMode)
+ {
+ case FTPConnection.MODE_STREAM:
+ in = new StreamInputStream(this, socket.getInputStream());
+ break;
+ case FTPConnection.MODE_BLOCK:
+ in = new BlockInputStream(this, socket.getInputStream());
+ break;
+ case FTPConnection.MODE_COMPRESSED:
+ in = new CompressedInputStream(this, socket.getInputStream());
+ break;
+ default:
+ throw new IllegalStateException("invalid transfer mode");
+ }
+ in.setTransferComplete(false);
+ return in;
+ }
+
+ /**
+ * Returns an output stream to which a local file can be written for
+ * upload.
+ */
+ public OutputStream getOutputStream() throws IOException
+ {
+ if (inProgress)
+ {
+ throw new IOException("Transfer in progress");
+ }
+ if (acceptThread != null)
+ {
+ waitFor();
+ }
+ switch (transferMode)
+ {
+ case FTPConnection.MODE_STREAM:
+ out = new StreamOutputStream(this, socket.getOutputStream());
+ break;
+ case FTPConnection.MODE_BLOCK:
+ out = new BlockOutputStream(this, socket.getOutputStream());
+ break;
+ case FTPConnection.MODE_COMPRESSED:
+ out = new CompressedOutputStream(this, socket.getOutputStream());
+ break;
+ default:
+ throw new IllegalStateException("invalid transfer mode");
+ }
+ out.setTransferComplete(false);
+ return out;
+ }
+
+ public void setTransferMode(int mode)
+ {
+ transferMode = mode;
+ }
+
+ public void complete()
+ {
+ completed = true;
+ if (!inProgress)
+ {
+ transferComplete();
+ }
+ }
+
+ public boolean abort()
+ {
+ completed = true;
+ transferComplete();
+ return inProgress;
+ }
+
+ public void transferComplete()
+ {
+ if (socket == null)
+ {
+ return;
+ }
+ if (in != null)
+ {
+ in.setTransferComplete(true);
+ }
+ if (out != null)
+ {
+ out.setTransferComplete(true);
+ }
+ completed = completed || (transferMode == FTPConnection.MODE_STREAM);
+ if (completed && socket != null)
+ {
+ try
+ {
+ socket.close();
+ }
+ catch (IOException e)
+ {
+ }
+ try
+ {
+ server.close();
+ }
+ catch (IOException e)
+ {
+ }
+ }
+ }
+
+}
+
Added: llvm-gcc-4.2/trunk/libjava/classpath/gnu/java/net/protocol/ftp/BlockInputStream.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/gnu/java/net/protocol/ftp/BlockInputStream.java?rev=43913&view=auto
==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/gnu/java/net/protocol/ftp/BlockInputStream.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/gnu/java/net/protocol/ftp/BlockInputStream.java Thu Nov 8 16:56:19 2007
@@ -0,0 +1,150 @@
+/* BlockInputStream.java --
+ Copyright (C) 2003, 2004 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 gnu.java.net.protocol.ftp;
+
+import java.io.IOException;
+import java.io.InputStream;
+
+/**
+ * A DTP input stream that implements the FTP block transfer mode.
+ *
+ * @author Chris Burdess (dog at gnu.org)
+ */
+class BlockInputStream
+ extends DTPInputStream
+{
+
+ static final int EOF = 64;
+
+ int descriptor;
+ int max = -1;
+ int count = -1;
+
+ BlockInputStream(DTP dtp, InputStream in)
+ {
+ super(dtp, in);
+ }
+
+ public int read()
+ throws IOException
+ {
+ if (transferComplete)
+ {
+ return -1;
+ }
+ if (count == -1)
+ {
+ readHeader();
+ }
+ if (max < 1)
+ {
+ close();
+ return -1;
+ }
+ int c = in.read();
+ if (c == -1)
+ {
+ dtp.transferComplete();
+ }
+ count++;
+ if (count >= max)
+ {
+ count = -1;
+ if (descriptor == EOF)
+ {
+ close();
+ }
+ }
+ return c;
+ }
+
+ public int read(byte[] buf)
+ throws IOException
+ {
+ return read(buf, 0, buf.length);
+ }
+
+ public int read(byte[] buf, int off, int len)
+ throws IOException
+ {
+ if (transferComplete)
+ {
+ return -1;
+ }
+ if (count == -1)
+ {
+ readHeader();
+ }
+ if (max < 1)
+ {
+ close();
+ return -1;
+ }
+ int l = in.read(buf, off, len);
+ if (l == -1)
+ {
+ dtp.transferComplete();
+ }
+ count += l;
+ if (count >= max)
+ {
+ count = -1;
+ if (descriptor == EOF)
+ {
+ close();
+ }
+ }
+ return l;
+ }
+
+ /**
+ * Reads the block header.
+ */
+ void readHeader()
+ throws IOException
+ {
+ descriptor = in.read();
+ int max_hi = in.read();
+ int max_lo = in.read();
+ max = (max_hi << 8) | max_lo;
+ count = 0;
+ }
+
+}
+
Added: llvm-gcc-4.2/trunk/libjava/classpath/gnu/java/net/protocol/ftp/BlockOutputStream.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/gnu/java/net/protocol/ftp/BlockOutputStream.java?rev=43913&view=auto
==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/gnu/java/net/protocol/ftp/BlockOutputStream.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/gnu/java/net/protocol/ftp/BlockOutputStream.java Thu Nov 8 16:56:19 2007
@@ -0,0 +1,111 @@
+/* BlockOutputStream.java --
+ Copyright (C) 2003, 2004 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 gnu.java.net.protocol.ftp;
+
+import java.io.IOException;
+import java.io.OutputStream;
+
+/**
+ * A DTP output stream that implements the FTP block transfer mode.
+ *
+ * @author Chris Burdess (dog at gnu.org)
+ */
+class BlockOutputStream
+ extends DTPOutputStream
+{
+
+ static final byte RECORD = -128; // 0x80
+ static final byte EOF = 64; // 0x40
+
+ BlockOutputStream(DTP dtp, OutputStream out)
+ {
+ super(dtp, out);
+ }
+
+ public void write(int c)
+ throws IOException
+ {
+ if (transferComplete)
+ {
+ return;
+ }
+ byte[] buf = new byte[]
+ {
+ RECORD, /* record descriptor */
+ 0x00, 0x01, /* one byte */
+ (byte) c /* the byte */
+ };
+ out.write(buf, 0, 4);
+ }
+
+ public void write(byte[] b)
+ throws IOException
+ {
+ write(b, 0, b.length);
+ }
+
+ public void write(byte[] b, int off, int len)
+ throws IOException
+ {
+ if (transferComplete)
+ {
+ return;
+ }
+ byte[] buf = new byte[len + 3];
+ buf[0] = RECORD; /* record descriptor */
+ buf[1] = (byte) ((len & 0x00ff) >> 8); /* high byte of bytecount */
+ buf[2] = (byte) (len & 0xff00); /* low byte of bytecount */
+ System.arraycopy(b, off, buf, 3, len);
+ out.write(buf, 0, len);
+ }
+
+ public void close()
+ throws IOException
+ {
+ byte[] buf = new byte[]
+ {
+ EOF, /* eof descriptor */
+ 0x00, 0x00 /* no bytes */
+ };
+ out.write(buf, 0, 3);
+ super.close();
+ }
+
+}
+
Added: llvm-gcc-4.2/trunk/libjava/classpath/gnu/java/net/protocol/ftp/CompressedInputStream.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/gnu/java/net/protocol/ftp/CompressedInputStream.java?rev=43913&view=auto
==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/gnu/java/net/protocol/ftp/CompressedInputStream.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/gnu/java/net/protocol/ftp/CompressedInputStream.java Thu Nov 8 16:56:19 2007
@@ -0,0 +1,215 @@
+/* CompressedInputStream.java --
+ Copyright (C) 2003, 2004 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 gnu.java.net.protocol.ftp;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.net.ProtocolException;
+
+/**
+ * A DTP input stream that implements the FTP compressed transfer mode.
+ *
+ * @author Chris Burdess (dog at gnu.org)
+ */
+class CompressedInputStream
+ extends DTPInputStream
+{
+
+ static final int EOF = 64;
+
+ static final int RAW = 0x00;
+ static final int COMPRESSED = 0x80;
+ static final int FILLER = 0xc0;
+
+ int descriptor;
+ int max = -1;
+ int count = -1;
+
+ int state = RAW; // RAW | STATE | FILLER
+ int rep; // the compressed byte
+ int n = 0; // the number of compressed or raw bytes
+
+ CompressedInputStream(DTP dtp, InputStream in)
+ {
+ super(dtp, in);
+ }
+
+ public int read()
+ throws IOException
+ {
+ if (transferComplete)
+ {
+ return -1;
+ }
+ if (count == -1)
+ {
+ readHeader();
+ }
+ if (max < 1)
+ {
+ close();
+ return -1;
+ }
+ if (n > 0 && (state == COMPRESSED || state == FILLER))
+ {
+ n--;
+ return rep;
+ }
+ int c = in.read();
+ if (c == -1)
+ {
+ close();
+ }
+ count++;
+ if (count >= max)
+ {
+ count = -1;
+ if (descriptor == EOF)
+ {
+ close();
+ }
+ }
+ if (c == -1)
+ {
+ return c;
+ }
+ while (n == 0) // read code header
+ {
+ state = (c & 0xc0);
+ n = (c & 0x3f);
+ c = in.read();
+ if (c == -1)
+ {
+ return -1;
+ }
+ }
+ switch (state)
+ {
+ case RAW:
+ break;
+ case COMPRESSED:
+ case FILLER:
+ rep = c;
+ break;
+ default:
+ throw new ProtocolException("Illegal state: " + state);
+ }
+ n--;
+ return c;
+ }
+
+ public int read(byte[] buf)
+ throws IOException
+ {
+ return read(buf, 0, buf.length);
+ }
+
+ public int read(byte[] buf, int off, int len)
+ throws IOException
+ {
+ if (transferComplete)
+ {
+ return -1;
+ }
+ if (count == -1)
+ {
+ readHeader();
+ }
+ if (max < 1)
+ {
+ close();
+ return -1;
+ }
+ // TODO improve performance
+ for (int i = off; i < len; i++)
+ {
+ int c = read();
+ if (c == -1)
+ {
+ close();
+ return i;
+ }
+ buf[i] = (byte) c;
+ }
+ return len;
+ /*
+ int l = in.read (buf, off, len);
+ if (l==-1)
+ {
+ close ();
+ }
+ count += l;
+ if (count>=max)
+ {
+ count = -1;
+ if (descriptor==EOF)
+ {
+ close ();
+ }
+ }
+ return l;
+ */
+ }
+
+ /**
+ * Reads the block header.
+ */
+ void readHeader()
+ throws IOException
+ {
+ descriptor = in.read();
+ int max_hi = in.read();
+ int max_lo = in.read();
+ max = (max_hi << 8) | max_lo;
+ count = 0;
+ }
+
+ /**
+ * Reads the code header.
+ */
+ void readCodeHeader()
+ throws IOException
+ {
+ int code = in.read();
+ state = (code & 0xc0);
+ n = (code & 0x3f);
+ }
+
+}
+
Added: llvm-gcc-4.2/trunk/libjava/classpath/gnu/java/net/protocol/ftp/CompressedOutputStream.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/gnu/java/net/protocol/ftp/CompressedOutputStream.java?rev=43913&view=auto
==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/gnu/java/net/protocol/ftp/CompressedOutputStream.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/gnu/java/net/protocol/ftp/CompressedOutputStream.java Thu Nov 8 16:56:19 2007
@@ -0,0 +1,228 @@
+/* CompressedOutputStream.java --
+ Copyright (C) 2003, 2004 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 gnu.java.net.protocol.ftp;
+
+import java.io.IOException;
+import java.io.OutputStream;
+
+/**
+ * A DTP output stream that implements the FTP compressed transfer mode.
+ *
+ * @author Chris Burdess (dog at gnu.org)
+ */
+class CompressedOutputStream
+ extends DTPOutputStream
+{
+
+ static final byte RECORD = -128; // 0x80
+ static final byte EOF = 64; // 0x40
+
+ CompressedOutputStream(DTP dtp, OutputStream out)
+ {
+ super(dtp, out);
+ }
+
+ /**
+ * Just one byte cannot be compressed.
+ * It takes 5 bytes to transmit - hardly very compressed!
+ */
+ public void write(int c)
+ throws IOException
+ {
+ if (transferComplete)
+ {
+ return;
+ }
+ byte[] buf = new byte[]
+ {
+ RECORD, /* record descriptor */
+ 0x00, 0x01, /* one byte */
+ 0x01, /* one uncompressed byte */
+ (byte) c /* the byte */
+ };
+ out.write(buf, 0, 5);
+ }
+
+ public void write(byte[] b)
+ throws IOException
+ {
+ write(b, 0, b.length);
+ }
+
+ /**
+ * The larger len is, the better.
+ */
+ public void write(byte[] b, int off, int len)
+ throws IOException
+ {
+ if (transferComplete)
+ {
+ return;
+ }
+ byte[] buf = compress(b, off, len);
+ len = buf.length;
+ buf[0] = RECORD; /* record descriptor */
+ buf[1] = (byte) ((len & 0x00ff) >> 8); /* high byte of bytecount */
+ buf[2] = (byte) (len & 0xff00); /* low byte of bytecount */
+ out.write(buf, 0, len);
+ }
+
+ /**
+ * Returns the compressed form of the given byte array.
+ * The first 3 bytes are left free for header information.
+ */
+ byte[] compress(byte[] b, int off, int len)
+ {
+ byte[] buf = new byte[len];
+ byte last = 0;
+ int pos = 0, raw_count = 0, rep_count = 1;
+ for (int i = off; i < len; i++)
+ {
+ byte c = b[i];
+ if (i > off && c == last) // compress
+ {
+ if (raw_count > 0) // flush raw bytes to buf
+ {
+ // need to add raw_count+1 bytes
+ if (pos + (raw_count + 1) > buf.length)
+ {
+ buf = realloc(buf, len);
+ }
+ pos = flush_raw(buf, pos, b, (i - raw_count) - 1,
+ raw_count);
+ raw_count = 0;
+ }
+ rep_count++; // keep looking for same byte
+ }
+ else
+ {
+ if (rep_count > 1) // flush compressed bytes to buf
+ {
+ // need to add 2 bytes
+ if (pos + 2 > buf.length)
+ {
+ buf = realloc(buf, len);
+ }
+ pos = flush_compressed(buf, pos, rep_count, last);
+ rep_count = 1;
+ }
+ raw_count++; // keep looking for raw bytes
+ }
+ if (rep_count == 127) // flush compressed bytes
+ {
+ // need to add 2 bytes
+ if (pos + 2 > buf.length)
+ {
+ buf = realloc(buf, len);
+ }
+ pos = flush_compressed(buf, pos, rep_count, last);
+ rep_count = 1;
+ }
+ if (raw_count == 127) // flush raw bytes
+ {
+ // need to add raw_count+1 bytes
+ if (pos + (raw_count + 1) > buf.length)
+ {
+ buf = realloc(buf, len);
+ }
+ pos = flush_raw(buf, pos, b, (i - raw_count), raw_count);
+ raw_count = 0;
+ }
+ last = c;
+ }
+ if (rep_count > 1) // flush compressed bytes
+ {
+ // need to add 2 bytes
+ if (pos + 2 > buf.length)
+ {
+ buf = realloc(buf, len);
+ }
+ pos = flush_compressed(buf, pos, rep_count, last);
+ rep_count = 1;
+ }
+ if (raw_count > 0) // flush raw bytes
+ {
+ // need to add raw_count+1 bytes
+ if (pos + (raw_count + 1) > buf.length)
+ {
+ buf = realloc(buf, len);
+ }
+ pos = flush_raw(buf, pos, b, (len - raw_count), raw_count);
+ raw_count = 0;
+ }
+ byte[] ret = new byte[pos + 3];
+ System.arraycopy(buf, 0, ret, 3, pos);
+ return ret;
+ }
+
+ int flush_compressed(byte[] buf, int pos, int count, byte c)
+ {
+ buf[pos++] = (byte) (0x80 | count);
+ buf[pos++] = c;
+ return pos;
+ }
+
+ int flush_raw(byte[] buf, int pos, byte[] src, int off, int len)
+ {
+ buf[pos++] = (byte) len;
+ System.arraycopy(src, off, buf, pos, len);
+ return pos + len;
+ }
+
+ byte[] realloc(byte[] buf, int len)
+ {
+ byte[] ret = new byte[buf.length + len];
+ System.arraycopy(buf, 0, ret, 0, buf.length);
+ return ret;
+ }
+
+ public void close()
+ throws IOException
+ {
+ byte[] buf = new byte[]
+ {
+ EOF, /* eof descriptor */
+ 0x00, 0x00 /* no bytes */
+ };
+ out.write(buf, 0, 3);
+ out.close();
+ }
+
+}
+
Added: llvm-gcc-4.2/trunk/libjava/classpath/gnu/java/net/protocol/ftp/DTP.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/gnu/java/net/protocol/ftp/DTP.java?rev=43913&view=auto
==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/gnu/java/net/protocol/ftp/DTP.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/gnu/java/net/protocol/ftp/DTP.java Thu Nov 8 16:56:19 2007
@@ -0,0 +1,92 @@
+/* DTP.java --
+ Copyright (C) 2003, 2004 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 gnu.java.net.protocol.ftp;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+
+/**
+ * An FTP data transfer process.
+ *
+ * @author Chris Burdess (dog at gnu.org)
+ */
+interface DTP
+{
+
+ /**
+ * Returns an input stream from which a remote file can be read.
+ */
+ InputStream getInputStream()
+ throws IOException;
+
+ /**
+ * Returns an output stream to which a local file can be written for
+ * upload.
+ */
+ OutputStream getOutputStream()
+ throws IOException;
+
+ /**
+ * Sets the transfer mode to be used with this DTP.
+ */
+ void setTransferMode(int mode);
+
+ /**
+ * Marks this DTP completed.
+ * When the current transfer has finished, any resources will be released.
+ */
+ void complete();
+
+ /**
+ * Aborts any current transfer and releases all resources held by this
+ * DTP.
+ * @return true if a transfer was interrupted, false otherwise
+ */
+ boolean abort();
+
+ /**
+ * Used to notify the DTP that its current transfer is complete.
+ * This occurs either when end-of-stream is reached or a 226 response is
+ * received.
+ */
+ void transferComplete();
+
+}
+
Added: llvm-gcc-4.2/trunk/libjava/classpath/gnu/java/net/protocol/ftp/DTPInputStream.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/gnu/java/net/protocol/ftp/DTPInputStream.java?rev=43913&view=auto
==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/gnu/java/net/protocol/ftp/DTPInputStream.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/gnu/java/net/protocol/ftp/DTPInputStream.java Thu Nov 8 16:56:19 2007
@@ -0,0 +1,88 @@
+/* DTPInputStream.java --
+ Copyright (C) 2003, 2004 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 gnu.java.net.protocol.ftp;
+
+import java.io.FilterInputStream;
+import java.io.IOException;
+import java.io.InputStream;
+
+/**
+ * An input stream that notifies a DTP on completion.
+ *
+ * @author Chris Burdess (dog at gnu.org)
+ */
+abstract class DTPInputStream
+ extends FilterInputStream
+{
+
+ DTP dtp;
+ boolean transferComplete;
+
+ /**
+ * Constructor.
+ * @param dtp the controlling data transfer process
+ * @param in the underlying socket stream
+ */
+ DTPInputStream (DTP dtp, InputStream in)
+ {
+ super(in);
+ this.dtp = dtp;
+ transferComplete = false;
+ }
+
+ /**
+ * Marks this input stream complete.
+ * This is called by the DTP.
+ */
+ void setTransferComplete(boolean flag)
+ {
+ transferComplete = flag;
+ }
+
+ /**
+ * Notifies the controlling DTP that this stream has completed transfer.
+ */
+ public void close()
+ throws IOException
+ {
+ dtp.transferComplete();
+ }
+
+}
+
Added: llvm-gcc-4.2/trunk/libjava/classpath/gnu/java/net/protocol/ftp/DTPOutputStream.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/gnu/java/net/protocol/ftp/DTPOutputStream.java?rev=43913&view=auto
==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/gnu/java/net/protocol/ftp/DTPOutputStream.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/gnu/java/net/protocol/ftp/DTPOutputStream.java Thu Nov 8 16:56:19 2007
@@ -0,0 +1,85 @@
+/* DTPOutputStream.java --
+ Copyright (C) 2003, 2004 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 gnu.java.net.protocol.ftp;
+
+import java.io.FilterOutputStream;
+import java.io.IOException;
+import java.io.OutputStream;
+
+/**
+ * An output stream that notifies a DTP on end of stream.
+ *
+ * @author Chris Burdess (dog at gnu.org)
+ */
+abstract class DTPOutputStream extends FilterOutputStream
+{
+
+ DTP dtp;
+ boolean transferComplete;
+
+ /**
+ * Constructor.
+ * @param dtp the controlling data transfer process
+ * @param out the socket output stream
+ */
+ DTPOutputStream (DTP dtp, OutputStream out)
+ {
+ super (out);
+ this.dtp = dtp;
+ transferComplete = false;
+ }
+
+ /**
+ * Tells this stream whether transfer has completed or not.
+ * @param flag true if the process has completed, false otherwise
+ */
+ void setTransferComplete (boolean flag)
+ {
+ transferComplete = flag;
+ }
+
+ /**
+ * Notifies the controlling DTP that this stream has been terminated.
+ */
+ public void close () throws IOException
+ {
+ dtp.transferComplete ();
+ }
+
+}
Added: llvm-gcc-4.2/trunk/libjava/classpath/gnu/java/net/protocol/ftp/FTPConnection.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/gnu/java/net/protocol/ftp/FTPConnection.java?rev=43913&view=auto
==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/gnu/java/net/protocol/ftp/FTPConnection.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/gnu/java/net/protocol/ftp/FTPConnection.java Thu Nov 8 16:56:19 2007
@@ -0,0 +1,1351 @@
+/* FTPConnection.java --
+ Copyright (C) 2003, 2004 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 gnu.java.net.protocol.ftp;
+
+import gnu.java.net.CRLFInputStream;
+import gnu.java.net.CRLFOutputStream;
+import gnu.java.net.EmptyX509TrustManager;
+import gnu.java.net.LineInputStream;
+
+import java.io.BufferedInputStream;
+import java.io.BufferedOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.net.BindException;
+import java.net.InetAddress;
+import java.net.InetSocketAddress;
+import java.net.ProtocolException;
+import java.net.Socket;
+import java.net.UnknownHostException;
+import java.security.GeneralSecurityException;
+import java.util.ArrayList;
+import java.util.List;
+
+import javax.net.ssl.SSLContext;
+import javax.net.ssl.SSLSocket;
+import javax.net.ssl.SSLSocketFactory;
+import javax.net.ssl.TrustManager;
+
+/**
+ * An FTP client connection, or PI.
+ * This implements RFC 959, with the following exceptions:
+ * <ul>
+ * <li>STAT, HELP, SITE, SMNT, and ACCT commands are not supported.</li>
+ * <li>the TYPE command does not allow alternatives to the default bytesize
+ * (Non-print), and local bytesize is not supported.</li>
+ * </ul>
+ *
+ * @author Chris Burdess (dog at gnu.org)
+ */
+public class FTPConnection
+{
+
+ /**
+ * The default FTP transmission control port.
+ */
+ public static final int FTP_PORT = 21;
+
+ /**
+ * The FTP data port.
+ */
+ public static final int FTP_DATA_PORT = 20;
+
+ // -- FTP vocabulary --
+ protected static final String USER = "USER";
+ protected static final String PASS = "PASS";
+ protected static final String ACCT = "ACCT";
+ protected static final String CWD = "CWD";
+ protected static final String CDUP = "CDUP";
+ protected static final String SMNT = "SMNT";
+ protected static final String REIN = "REIN";
+ protected static final String QUIT = "QUIT";
+
+ protected static final String PORT = "PORT";
+ protected static final String PASV = "PASV";
+ protected static final String TYPE = "TYPE";
+ protected static final String STRU = "STRU";
+ protected static final String MODE = "MODE";
+
+ protected static final String RETR = "RETR";
+ protected static final String STOR = "STOR";
+ protected static final String STOU = "STOU";
+ protected static final String APPE = "APPE";
+ protected static final String ALLO = "ALLO";
+ protected static final String REST = "REST";
+ protected static final String RNFR = "RNFR";
+ protected static final String RNTO = "RNTO";
+ protected static final String ABOR = "ABOR";
+ protected static final String DELE = "DELE";
+ protected static final String RMD = "RMD";
+ protected static final String MKD = "MKD";
+ protected static final String PWD = "PWD";
+ protected static final String LIST = "LIST";
+ protected static final String NLST = "NLST";
+ protected static final String SITE = "SITE";
+ protected static final String SYST = "SYST";
+ protected static final String STAT = "STAT";
+ protected static final String HELP = "HELP";
+ protected static final String NOOP = "NOOP";
+
+ protected static final String AUTH = "AUTH";
+ protected static final String PBSZ = "PBSZ";
+ protected static final String PROT = "PROT";
+ protected static final String CCC = "CCC";
+ protected static final String TLS = "TLS";
+
+ public static final int TYPE_ASCII = 1;
+ public static final int TYPE_EBCDIC = 2;
+ public static final int TYPE_BINARY = 3;
+
+ public static final int STRUCTURE_FILE = 1;
+ public static final int STRUCTURE_RECORD = 2;
+ public static final int STRUCTURE_PAGE = 3;
+
+ public static final int MODE_STREAM = 1;
+ public static final int MODE_BLOCK = 2;
+ public static final int MODE_COMPRESSED = 3;
+
+ // -- Telnet constants --
+ private static final String US_ASCII = "US-ASCII";
+
+ /**
+ * The socket used to communicate with the server.
+ */
+ protected Socket socket;
+
+ /**
+ * The socket input stream.
+ */
+ protected LineInputStream in;
+
+ /**
+ * The socket output stream.
+ */
+ protected CRLFOutputStream out;
+
+ /**
+ * The timeout when attempting to connect a socket.
+ */
+ protected int connectionTimeout;
+
+ /**
+ * The read timeout on sockets.
+ */
+ protected int timeout;
+
+ /**
+ * If true, print debugging information.
+ */
+ protected boolean debug;
+
+ /**
+ * The current data transfer process in use by this connection.
+ */
+ protected DTP dtp;
+
+ /**
+ * The current representation type.
+ */
+ protected int representationType = TYPE_ASCII;
+
+ /**
+ * The current file structure type.
+ */
+ protected int fileStructure = STRUCTURE_FILE;
+
+ /**
+ * The current transfer mode.
+ */
+ protected int transferMode = MODE_STREAM;
+
+ /**
+ * If true, use passive mode.
+ */
+ protected boolean passive = false;
+
+ /**
+ * Creates a new connection to the server using the default port.
+ * @param hostname the hostname of the server to connect to
+ */
+ public FTPConnection(String hostname)
+ throws UnknownHostException, IOException
+ {
+ this(hostname, -1, 0, 0, false);
+ }
+
+ /**
+ * Creates a new connection to the server.
+ * @param hostname the hostname of the server to connect to
+ * @param port the port to connect to(if <=0, use default port)
+ */
+ public FTPConnection(String hostname, int port)
+ throws UnknownHostException, IOException
+ {
+ this(hostname, port, 0, 0, false);
+ }
+
+ /**
+ * Creates a new connection to the server.
+ * @param hostname the hostname of the server to connect to
+ * @param port the port to connect to(if <=0, use default port)
+ * @param connectionTimeout the connection timeout, in milliseconds
+ * @param timeout the I/O timeout, in milliseconds
+ * @param debug print debugging information
+ */
+ public FTPConnection(String hostname, int port,
+ int connectionTimeout, int timeout, boolean debug)
+ throws UnknownHostException, IOException
+ {
+ this.connectionTimeout = connectionTimeout;
+ this.timeout = timeout;
+ this.debug = debug;
+ if (port <= 0)
+ {
+ port = FTP_PORT;
+ }
+
+ // Set up socket
+ socket = new Socket();
+ InetSocketAddress address = new InetSocketAddress(hostname, port);
+ if (connectionTimeout > 0)
+ {
+ socket.connect(address, connectionTimeout);
+ }
+ else
+ {
+ socket.connect(address);
+ }
+ if (timeout > 0)
+ {
+ socket.setSoTimeout(timeout);
+ }
+
+ InputStream in = socket.getInputStream();
+ in = new BufferedInputStream(in);
+ in = new CRLFInputStream(in);
+ this.in = new LineInputStream(in);
+ OutputStream out = socket.getOutputStream();
+ out = new BufferedOutputStream(out);
+ this.out = new CRLFOutputStream(out);
+
+ // Read greeting
+ FTPResponse response = getResponse();
+ switch (response.getCode())
+ {
+ case 220: // hello
+ break;
+ default:
+ throw new FTPException(response);
+ }
+ }
+
+ /**
+ * Authenticate using the specified username and password.
+ * If the username suffices for the server, the password will not be used
+ * and may be null.
+ * @param username the username
+ * @param password the optional password
+ * @return true on success, false otherwise
+ */
+ public boolean authenticate(String username, String password)
+ throws IOException
+ {
+ String cmd = USER + ' ' + username;
+ send(cmd);
+ FTPResponse response = getResponse();
+ switch (response.getCode())
+ {
+ case 230: // User logged in
+ return true;
+ case 331: // User name okay, need password
+ break;
+ case 332: // Need account for login
+ case 530: // No such user
+ return false;
+ default:
+ throw new FTPException(response);
+ }
+ cmd = PASS + ' ' + password;
+ send(cmd);
+ response = getResponse();
+ switch (response.getCode())
+ {
+ case 230: // User logged in
+ case 202: // Superfluous
+ return true;
+ case 332: // Need account for login
+ case 530: // Bad password
+ return false;
+ default:
+ throw new FTPException(response);
+ }
+ }
+
+ /**
+ * Negotiates TLS over the current connection.
+ * See IETF draft-murray-auth-ftp-ssl-15.txt for details.
+ * @param confidential whether to provide confidentiality for the
+ * connection
+ */
+ public boolean starttls(boolean confidential)
+ throws IOException
+ {
+ return starttls(confidential, new EmptyX509TrustManager());
+ }
+
+ /**
+ * Negotiates TLS over the current connection.
+ * See IETF draft-murray-auth-ftp-ssl-15.txt for details.
+ * @param confidential whether to provide confidentiality for the
+ * connection
+ * @param tm the trust manager used to validate the server certificate.
+ */
+ public boolean starttls(boolean confidential, TrustManager tm)
+ throws IOException
+ {
+ try
+ {
+ // Use SSLSocketFactory to negotiate a TLS session and wrap the
+ // current socket.
+ SSLContext context = SSLContext.getInstance("TLS");
+ // We don't require strong validation of the server certificate
+ TrustManager[] trust = new TrustManager[] { tm };
+ context.init(null, trust, null);
+ SSLSocketFactory factory = context.getSocketFactory();
+
+ send(AUTH + ' ' + TLS);
+ FTPResponse response = getResponse();
+ switch (response.getCode())
+ {
+ case 500:
+ case 502:
+ case 504:
+ case 534:
+ case 431:
+ return false;
+ case 234:
+ break;
+ default:
+ throw new FTPException(response);
+ }
+
+ String hostname = socket.getInetAddress().getHostName();
+ int port = socket.getPort();
+ SSLSocket ss =
+ (SSLSocket) factory.createSocket(socket, hostname, port, true);
+ String[] protocols = { "TLSv1", "SSLv3" };
+ ss.setEnabledProtocols(protocols);
+ ss.setUseClientMode(true);
+ ss.startHandshake();
+
+ // PBSZ:PROT sequence
+ send(PBSZ + ' ' + Integer.MAX_VALUE);
+ response = getResponse();
+ switch (response.getCode())
+ {
+ case 501: // syntax error
+ case 503: // not authenticated
+ return false;
+ case 200:
+ break;
+ default:
+ throw new FTPException(response);
+ }
+ send(PROT + ' ' +(confidential ? 'P' : 'C'));
+ response = getResponse();
+ switch (response.getCode())
+ {
+ case 503: // not authenticated
+ case 504: // invalid level
+ case 536: // level not supported
+ return false;
+ case 200:
+ break;
+ default:
+ throw new FTPException(response);
+ }
+
+ if (confidential)
+ {
+ // Set up streams
+ InputStream in = ss.getInputStream();
+ in = new BufferedInputStream(in);
+ in = new CRLFInputStream(in);
+ this.in = new LineInputStream(in);
+ OutputStream out = ss.getOutputStream();
+ out = new BufferedOutputStream(out);
+ this.out = new CRLFOutputStream(out);
+ }
+ return true;
+ }
+ catch (GeneralSecurityException e)
+ {
+ return false;
+ }
+ }
+
+ /**
+ * Changes directory to the specified path.
+ * @param path an absolute or relative pathname
+ * @return true on success, false if the specified path does not exist
+ */
+ public boolean changeWorkingDirectory(String path)
+ throws IOException
+ {
+ // Do nothing if the path is empty.
+ if (path.length() == 0)
+ return true;
+ String cmd = CWD + ' ' + path;
+ send(cmd);
+ FTPResponse response = getResponse();
+ switch (response.getCode())
+ {
+ case 250:
+ return true;
+ case 550:
+ return false;
+ default:
+ throw new FTPException(response);
+ }
+ }
+
+ /**
+ * Changes directory to the parent of the current working directory.
+ * @return true on success, false otherwise
+ */
+ public boolean changeToParentDirectory()
+ throws IOException
+ {
+ send(CDUP);
+ FTPResponse response = getResponse();
+ switch (response.getCode())
+ {
+ case 250:
+ return true;
+ case 550:
+ return false;
+ default:
+ throw new FTPException(response);
+ }
+ }
+
+ /**
+ * Terminates an authenticated login.
+ * If file transfer is in progress, it remains active for result response
+ * only.
+ */
+ public void reinitialize()
+ throws IOException
+ {
+ send(REIN);
+ FTPResponse response = getResponse();
+ switch (response.getCode())
+ {
+ case 220:
+ if (dtp != null)
+ {
+ dtp.complete();
+ dtp = null;
+ }
+ break;
+ default:
+ throw new FTPException(response);
+ }
+ }
+
+ /**
+ * Terminates the control connection.
+ * The file transfer connection remains open for result response only.
+ * This connection is invalid and no further commands may be issued.
+ */
+ public void logout()
+ throws IOException
+ {
+ send(QUIT);
+ try
+ {
+ getResponse(); // not required
+ }
+ catch (IOException e)
+ {
+ }
+ if (dtp != null)
+ {
+ dtp.complete();
+ dtp = null;
+ }
+ try
+ {
+ socket.close();
+ }
+ catch (IOException e)
+ {
+ }
+ }
+
+ /**
+ * Initialise the data transfer process.
+ */
+ protected void initialiseDTP()
+ throws IOException
+ {
+ if (dtp != null)
+ {
+ dtp.complete();
+ dtp = null;
+ }
+
+ InetAddress localhost = socket.getLocalAddress();
+ if (passive)
+ {
+ send(PASV);
+ FTPResponse response = getResponse();
+ switch (response.getCode())
+ {
+ case 227:
+ String message = response.getMessage();
+ try
+ {
+ int start = message.indexOf(',');
+ char c = message.charAt(start - 1);
+ while (c >= 0x30 && c <= 0x39)
+ {
+ c = message.charAt((--start) - 1);
+ }
+ int mid1 = start;
+ for (int i = 0; i < 4; i++)
+ {
+ mid1 = message.indexOf(',', mid1 + 1);
+ }
+ int mid2 = message.indexOf(',', mid1 + 1);
+ if (mid1 == -1 || mid2 < mid1)
+ {
+ throw new ProtocolException("Malformed 227: " +
+ message);
+ }
+ int end = mid2;
+ c = message.charAt(end + 1);
+ while (c >= 0x30 && c <= 0x39)
+ {
+ c = message.charAt((++end) + 1);
+ }
+
+ String address =
+ message.substring(start, mid1).replace(',', '.');
+ int port_hi =
+ Integer.parseInt(message.substring(mid1 + 1, mid2));
+ int port_lo =
+ Integer.parseInt(message.substring(mid2 + 1, end + 1));
+ int port = (port_hi << 8) | port_lo;
+
+ /*System.out.println("Entering passive mode: " + address +
+ ":" + port);*/
+ dtp = new PassiveModeDTP(address, port, localhost,
+ connectionTimeout, timeout);
+ break;
+ }
+ catch (ArrayIndexOutOfBoundsException e)
+ {
+ throw new ProtocolException(e.getMessage() + ": " +
+ message);
+ }
+ catch (NumberFormatException e)
+ {
+ throw new ProtocolException(e.getMessage() + ": " +
+ message);
+ }
+ default:
+ throw new FTPException(response);
+ }
+ }
+ else
+ {
+ // Get the local port
+ int port = socket.getLocalPort() + 1;
+ int tries = 0;
+ // Bind the active mode DTP
+ while (dtp == null)
+ {
+ try
+ {
+ dtp = new ActiveModeDTP(localhost, port,
+ connectionTimeout, timeout);
+ /*System.out.println("Listening on: " + port);*/
+ }
+ catch (BindException e)
+ {
+ port++;
+ tries++;
+ if (tries > 9)
+ {
+ throw e;
+ }
+ }
+ }
+
+ // Send PORT command
+ StringBuffer buf = new StringBuffer(PORT);
+ buf.append(' ');
+ // Construct the address/port string form
+ byte[] address = localhost.getAddress();
+ for (int i = 0; i < address.length; i++)
+ {
+ int a =(int) address[i];
+ if (a < 0)
+ {
+ a += 0x100;
+ }
+ buf.append(a);
+ buf.append(',');
+ }
+ int port_hi =(port & 0xff00) >> 8;
+ int port_lo =(port & 0x00ff);
+ buf.append(port_hi);
+ buf.append(',');
+ buf.append(port_lo);
+ send(buf.toString());
+ // Get response
+ FTPResponse response = getResponse();
+ switch (response.getCode())
+ {
+ case 200: // OK
+ break;
+ default:
+ dtp.abort();
+ dtp = null;
+ throw new FTPException(response);
+ }
+ }
+ dtp.setTransferMode(transferMode);
+ }
+
+ /**
+ * Set passive mode.
+ * @param flag true if we should use passive mode, false otherwise
+ */
+ public void setPassive(boolean flag)
+ throws IOException
+ {
+ if (passive != flag)
+ {
+ passive = flag;
+ initialiseDTP();
+ }
+ }
+
+ /**
+ * Returns the current representation type of the transfer data.
+ * @return TYPE_ASCII, TYPE_EBCDIC, or TYPE_BINARY
+ */
+ public int getRepresentationType()
+ {
+ return representationType;
+ }
+
+ /**
+ * Sets the desired representation type of the transfer data.
+ * @param type TYPE_ASCII, TYPE_EBCDIC, or TYPE_BINARY
+ */
+ public void setRepresentationType(int type)
+ throws IOException
+ {
+ StringBuffer buf = new StringBuffer(TYPE);
+ buf.append(' ');
+ switch (type)
+ {
+ case TYPE_ASCII:
+ buf.append('A');
+ break;
+ case TYPE_EBCDIC:
+ buf.append('E');
+ break;
+ case TYPE_BINARY:
+ buf.append('I');
+ break;
+ default:
+ throw new IllegalArgumentException(Integer.toString(type));
+ }
+ //buf.append(' ');
+ //buf.append('N');
+ send(buf.toString());
+ FTPResponse response = getResponse();
+ switch (response.getCode())
+ {
+ case 200:
+ representationType = type;
+ break;
+ default:
+ throw new FTPException(response);
+ }
+ }
+
+ /**
+ * Returns the current file structure type.
+ * @return STRUCTURE_FILE, STRUCTURE_RECORD, or STRUCTURE_PAGE
+ */
+ public int getFileStructure()
+ {
+ return fileStructure;
+ }
+
+ /**
+ * Sets the desired file structure type.
+ * @param structure STRUCTURE_FILE, STRUCTURE_RECORD, or STRUCTURE_PAGE
+ */
+ public void setFileStructure(int structure)
+ throws IOException
+ {
+ StringBuffer buf = new StringBuffer(STRU);
+ buf.append(' ');
+ switch (structure)
+ {
+ case STRUCTURE_FILE:
+ buf.append('F');
+ break;
+ case STRUCTURE_RECORD:
+ buf.append('R');
+ break;
+ case STRUCTURE_PAGE:
+ buf.append('P');
+ break;
+ default:
+ throw new IllegalArgumentException(Integer.toString(structure));
+ }
+ send(buf.toString());
+ FTPResponse response = getResponse();
+ switch (response.getCode())
+ {
+ case 200:
+ fileStructure = structure;
+ break;
+ default:
+ throw new FTPException(response);
+ }
+ }
+
+ /**
+ * Returns the current transfer mode.
+ * @return MODE_STREAM, MODE_BLOCK, or MODE_COMPRESSED
+ */
+ public int getTransferMode()
+ {
+ return transferMode;
+ }
+
+ /**
+ * Sets the desired transfer mode.
+ * @param mode MODE_STREAM, MODE_BLOCK, or MODE_COMPRESSED
+ */
+ public void setTransferMode(int mode)
+ throws IOException
+ {
+ StringBuffer buf = new StringBuffer(MODE);
+ buf.append(' ');
+ switch (mode)
+ {
+ case MODE_STREAM:
+ buf.append('S');
+ break;
+ case MODE_BLOCK:
+ buf.append('B');
+ break;
+ case MODE_COMPRESSED:
+ buf.append('C');
+ break;
+ default:
+ throw new IllegalArgumentException(Integer.toString(mode));
+ }
+ send(buf.toString());
+ FTPResponse response = getResponse();
+ switch (response.getCode())
+ {
+ case 200:
+ transferMode = mode;
+ if (dtp != null)
+ {
+ dtp.setTransferMode(mode);
+ }
+ break;
+ default:
+ throw new FTPException(response);
+ }
+ }
+
+ /**
+ * Retrieves the specified file.
+ * @param filename the filename of the file to retrieve
+ * @return an InputStream containing the file content
+ */
+ public InputStream retrieve(String filename)
+ throws IOException
+ {
+ if (dtp == null || transferMode == MODE_STREAM)
+ {
+ initialiseDTP();
+ }
+ /*
+ int size = -1;
+ String cmd = SIZE + ' ' + filename;
+ send(cmd);
+ FTPResponse response = getResponse();
+ switch (response.getCode())
+ {
+ case 213:
+ size = Integer.parseInt(response.getMessage());
+ break;
+ case 550: // File not found
+ default:
+ throw new FTPException(response);
+ }
+ */
+ String cmd = RETR + ' ' + filename;
+ send(cmd);
+ FTPResponse response = getResponse();
+ switch (response.getCode())
+ {
+ case 125: // Data connection already open; transfer starting
+ case 150: // File status okay; about to open data connection
+ return dtp.getInputStream();
+ default:
+ throw new FTPException(response);
+ }
+ }
+
+ /**
+ * Returns a stream for uploading a file.
+ * If a file with the same filename already exists on the server, it will
+ * be overwritten.
+ * @param filename the name of the file to save the content as
+ * @return an OutputStream to write the file data to
+ */
+ public OutputStream store(String filename)
+ throws IOException
+ {
+ if (dtp == null || transferMode == MODE_STREAM)
+ {
+ initialiseDTP();
+ }
+ String cmd = STOR + ' ' + filename;
+ send(cmd);
+ FTPResponse response = getResponse();
+ switch (response.getCode())
+ {
+ case 125: // Data connection already open; transfer starting
+ case 150: // File status okay; about to open data connection
+ return dtp.getOutputStream();
+ default:
+ throw new FTPException(response);
+ }
+ }
+
+ /**
+ * Returns a stream for uploading a file.
+ * If a file with the same filename already exists on the server, the
+ * content specified will be appended to the existing file.
+ * @param filename the name of the file to save the content as
+ * @return an OutputStream to write the file data to
+ */
+ public OutputStream append(String filename)
+ throws IOException
+ {
+ if (dtp == null || transferMode == MODE_STREAM)
+ {
+ initialiseDTP();
+ }
+ String cmd = APPE + ' ' + filename;
+ send(cmd);
+ FTPResponse response = getResponse();
+ switch (response.getCode())
+ {
+ case 125: // Data connection already open; transfer starting
+ case 150: // File status okay; about to open data connection
+ return dtp.getOutputStream();
+ default:
+ throw new FTPException(response);
+ }
+ }
+
+ /**
+ * This command may be required by some servers to reserve sufficient
+ * storage to accommodate the new file to be transferred.
+ * It should be immediately followed by a <code>store</code> or
+ * <code>append</code>.
+ * @param size the number of bytes of storage to allocate
+ */
+ public void allocate(long size)
+ throws IOException
+ {
+ String cmd = ALLO + ' ' + size;
+ send(cmd);
+ FTPResponse response = getResponse();
+ switch (response.getCode())
+ {
+ case 200: // OK
+ case 202: // Superfluous
+ break;
+ default:
+ throw new FTPException(response);
+ }
+ }
+
+ /**
+ * Renames a file.
+ * @param oldName the current name of the file
+ * @param newName the new name
+ * @return true if successful, false otherwise
+ */
+ public boolean rename(String oldName, String newName)
+ throws IOException
+ {
+ String cmd = RNFR + ' ' + oldName;
+ send(cmd);
+ FTPResponse response = getResponse();
+ switch (response.getCode())
+ {
+ case 450: // File unavailable
+ case 550: // File not found
+ return false;
+ case 350: // Pending
+ break;
+ default:
+ throw new FTPException(response);
+ }
+ cmd = RNTO + ' ' + newName;
+ send(cmd);
+ response = getResponse();
+ switch (response.getCode())
+ {
+ case 250: // OK
+ return true;
+ case 450:
+ case 550:
+ return false;
+ default:
+ throw new FTPException(response);
+ }
+ }
+
+ /**
+ * Aborts the transfer in progress.
+ * @return true if a transfer was in progress, false otherwise
+ */
+ public boolean abort()
+ throws IOException
+ {
+ send(ABOR);
+ FTPResponse response = getResponse();
+ // Abort client DTP
+ if (dtp != null)
+ {
+ dtp.abort();
+ }
+ switch (response.getCode())
+ {
+ case 226: // successful abort
+ return false;
+ case 426: // interrupted
+ response = getResponse();
+ if (response.getCode() == 226)
+ {
+ return true;
+ }
+ // Otherwise fall through to throw exception
+ default:
+ throw new FTPException(response);
+ }
+ }
+
+ /**
+ * Causes the file specified to be deleted at the server site.
+ * @param filename the file to delete
+ */
+ public boolean delete(String filename)
+ throws IOException
+ {
+ String cmd = DELE + ' ' + filename;
+ send(cmd);
+ FTPResponse response = getResponse();
+ switch (response.getCode())
+ {
+ case 250: // OK
+ return true;
+ case 450: // File unavailable
+ case 550: // File not found
+ return false;
+ default:
+ throw new FTPException(response);
+ }
+ }
+
+ /**
+ * Causes the directory specified to be deleted.
+ * This may be an absolute or relative pathname.
+ * @param pathname the directory to delete
+ */
+ public boolean removeDirectory(String pathname)
+ throws IOException
+ {
+ String cmd = RMD + ' ' + pathname;
+ send(cmd);
+ FTPResponse response = getResponse();
+ switch (response.getCode())
+ {
+ case 250: // OK
+ return true;
+ case 550: // File not found
+ return false;
+ default:
+ throw new FTPException(response);
+ }
+ }
+
+ /**
+ * Causes the directory specified to be created at the server site.
+ * This may be an absolute or relative pathname.
+ * @param pathname the directory to create
+ */
+ public boolean makeDirectory(String pathname)
+ throws IOException
+ {
+ String cmd = MKD + ' ' + pathname;
+ send(cmd);
+ FTPResponse response = getResponse();
+ switch (response.getCode())
+ {
+ case 257: // Directory created
+ return true;
+ case 550: // File not found
+ return false;
+ default:
+ throw new FTPException(response);
+ }
+ }
+
+ /**
+ * Returns the current working directory.
+ */
+ public String getWorkingDirectory()
+ throws IOException
+ {
+ send(PWD);
+ FTPResponse response = getResponse();
+ switch (response.getCode())
+ {
+ case 257:
+ String message = response.getMessage();
+ if (message.charAt(0) == '"')
+ {
+ int end = message.indexOf('"', 1);
+ if (end == -1)
+ {
+ throw new ProtocolException(message);
+ }
+ return message.substring(1, end);
+ }
+ else
+ {
+ int end = message.indexOf(' ');
+ if (end == -1)
+ {
+ return message;
+ }
+ else
+ {
+ return message.substring(0, end);
+ }
+ }
+ default:
+ throw new FTPException(response);
+ }
+ }
+
+ /**
+ * Returns a listing of information about the specified pathname.
+ * If the pathname specifies a directory or other group of files, the
+ * server should transfer a list of files in the specified directory.
+ * If the pathname specifies a file then the server should send current
+ * information on the file. A null argument implies the user's
+ * current working or default directory.
+ * @param pathname the context pathname, or null
+ */
+ public InputStream list(String pathname)
+ throws IOException
+ {
+ if (dtp == null || transferMode == MODE_STREAM)
+ {
+ initialiseDTP();
+ }
+ if (pathname == null)
+ {
+ send(LIST);
+ }
+ else
+ {
+ String cmd = LIST + ' ' + pathname;
+ send(cmd);
+ }
+ FTPResponse response = getResponse();
+ switch (response.getCode())
+ {
+ case 125: // Data connection already open; transfer starting
+ case 150: // File status okay; about to open data connection
+ return dtp.getInputStream();
+ default:
+ throw new FTPException(response);
+ }
+ }
+
+ /**
+ * Returns a directory listing. The pathname should specify a
+ * directory or other system-specific file group descriptor; a null
+ * argument implies the user's current working or default directory.
+ * @param pathname the directory pathname, or null
+ * @return a list of filenames(strings)
+ */
+ public List nameList(String pathname)
+ throws IOException
+ {
+ if (dtp == null || transferMode == MODE_STREAM)
+ {
+ initialiseDTP();
+ }
+ if (pathname == null)
+ {
+ send(NLST);
+ }
+ else
+ {
+ String cmd = NLST + ' ' + pathname;
+ send(cmd);
+ }
+ FTPResponse response = getResponse();
+ switch (response.getCode())
+ {
+ case 125: // Data connection already open; transfer starting
+ case 150: // File status okay; about to open data connection
+ InputStream in = dtp.getInputStream();
+ in = new BufferedInputStream(in);
+ in = new CRLFInputStream(in); // TODO ensure that TYPE is correct
+ LineInputStream li = new LineInputStream(in);
+ List ret = new ArrayList();
+ for (String line = li.readLine();
+ line != null;
+ line = li.readLine())
+ {
+ ret.add(line);
+ }
+ li.close();
+ return ret;
+ default:
+ throw new FTPException(response);
+ }
+ }
+
+ /**
+ * Returns the type of operating system at the server.
+ */
+ public String system()
+ throws IOException
+ {
+ send(SYST);
+ FTPResponse response = getResponse();
+ switch (response.getCode())
+ {
+ case 215:
+ String message = response.getMessage();
+ int end = message.indexOf(' ');
+ if (end == -1)
+ {
+ return message;
+ }
+ else
+ {
+ return message.substring(0, end);
+ }
+ default:
+ throw new FTPException(response);
+ }
+ }
+
+ /**
+ * Does nothing.
+ * This method can be used to ensure that the connection does not time
+ * out.
+ */
+ public void noop()
+ throws IOException
+ {
+ send(NOOP);
+ FTPResponse response = getResponse();
+ switch (response.getCode())
+ {
+ case 200:
+ break;
+ default:
+ throw new FTPException(response);
+ }
+ }
+
+ // -- I/O --
+
+ /**
+ * Sends the specified command line to the server.
+ * The CRLF sequence is automatically appended.
+ * @param cmd the command line to send
+ */
+ protected void send(String cmd)
+ throws IOException
+ {
+ byte[] data = cmd.getBytes(US_ASCII);
+ out.write(data);
+ out.writeln();
+ out.flush();
+ }
+
+ /**
+ * Reads the next response from the server.
+ * If the server sends the "transfer complete" code, this is handled here,
+ * and the next response is passed to the caller.
+ */
+ protected FTPResponse getResponse()
+ throws IOException
+ {
+ FTPResponse response = readResponse();
+ if (response.getCode() == 226)
+ {
+ if (dtp != null)
+ {
+ dtp.transferComplete();
+ }
+ response = readResponse();
+ }
+ return response;
+ }
+
+ /**
+ * Reads and parses the next response from the server.
+ */
+ protected FTPResponse readResponse()
+ throws IOException
+ {
+ String line = in.readLine();
+ if (line == null)
+ {
+ throw new ProtocolException( "EOF");
+ }
+ if (line.length() < 4)
+ {
+ throw new ProtocolException(line);
+ }
+ int code = parseCode(line);
+ if (code == -1)
+ {
+ throw new ProtocolException(line);
+ }
+ char c = line.charAt(3);
+ if (c == ' ')
+ {
+ return new FTPResponse(code, line.substring(4));
+ }
+ else if (c == '-')
+ {
+ StringBuffer buf = new StringBuffer(line.substring(4));
+ buf.append('\n');
+ while(true)
+ {
+ line = in.readLine();
+ if (line == null)
+ {
+ throw new ProtocolException("EOF");
+ }
+ if (line.length() >= 4 &&
+ line.charAt(3) == ' ' &&
+ parseCode(line) == code)
+ {
+ return new FTPResponse(code, line.substring(4),
+ buf.toString());
+ }
+ else
+ {
+ buf.append(line);
+ buf.append('\n');
+ }
+ }
+ }
+ else
+ {
+ throw new ProtocolException(line);
+ }
+ }
+
+ /*
+ * Parses the 3-digit numeric code at the beginning of the given line.
+ * Returns -1 on failure.
+ */
+ static final int parseCode(String line)
+ {
+ char[] c = { line.charAt(0), line.charAt(1), line.charAt(2) };
+ int ret = 0;
+ for (int i = 0; i < 3; i++)
+ {
+ int digit =((int) c[i]) - 0x30;
+ if (digit < 0 || digit > 9)
+ {
+ return -1;
+ }
+ // Computing integer powers is way too expensive in Java!
+ switch (i)
+ {
+ case 0:
+ ret +=(100 * digit);
+ break;
+ case 1:
+ ret +=(10 * digit);
+ break;
+ case 2:
+ ret += digit;
+ break;
+ }
+ }
+ return ret;
+ }
+
+}
+
Added: llvm-gcc-4.2/trunk/libjava/classpath/gnu/java/net/protocol/ftp/FTPException.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/gnu/java/net/protocol/ftp/FTPException.java?rev=43913&view=auto
==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/gnu/java/net/protocol/ftp/FTPException.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/gnu/java/net/protocol/ftp/FTPException.java Thu Nov 8 16:56:19 2007
@@ -0,0 +1,76 @@
+/* FTPException.java --
+ Copyright (C) 2003. 2004 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 gnu.java.net.protocol.ftp;
+
+import java.io.IOException;
+
+/**
+ * An FTP control exception.
+ *
+ * @author Chris Burdess (dog at gnu.org)
+ */
+public class FTPException
+ extends IOException
+{
+
+ /**
+ * The response that provoked this exception.
+ */
+ protected final FTPResponse response;
+
+ /**
+ * Constructs a new FTP exception.
+ * @param response the response that provoked this exception
+ */
+ public FTPException(FTPResponse response)
+ {
+ super(response.getMessage());
+ this.response = response;
+ }
+
+ /**
+ * Returns the response that provoked this exception.
+ */
+ public FTPResponse getResponse()
+ {
+ return response;
+ }
+
+}
+
Added: llvm-gcc-4.2/trunk/libjava/classpath/gnu/java/net/protocol/ftp/FTPResponse.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/gnu/java/net/protocol/ftp/FTPResponse.java?rev=43913&view=auto
==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/gnu/java/net/protocol/ftp/FTPResponse.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/gnu/java/net/protocol/ftp/FTPResponse.java Thu Nov 8 16:56:19 2007
@@ -0,0 +1,112 @@
+/* FTPResponse.java --
+ Copyright (C) 2003, 2004 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 gnu.java.net.protocol.ftp;
+
+/**
+ * An FTP control response.
+ *
+ * @author Chris Burdess (dog at gnu.org)
+ */
+public final class FTPResponse
+{
+
+ /**
+ * The 3-digit status code.
+ */
+ protected final int code;
+
+ /**
+ * The human-readable message.
+ */
+ protected final String message;
+
+ /**
+ * Multiline data, if present.
+ */
+ protected final String data;
+
+ /**
+ * Constructs a new FTP response.
+ * @param code the status code
+ * @param message the message
+ */
+ public FTPResponse(int code, String message)
+ {
+ this(code, message, null);
+ }
+
+ /**
+ * Constructs a new multiline FTP response.
+ * @param code the status code
+ * @param message the message
+ * @param data multiline data
+ */
+ public FTPResponse(int code, String message, String data)
+ {
+ this.code = code;
+ this.message = message;
+ this.data = data;
+ }
+
+ /**
+ * Returns the 3-digit status code.
+ */
+ public int getCode()
+ {
+ return code;
+ }
+
+ /**
+ * Returns the human-readable message.
+ */
+ public String getMessage()
+ {
+ return message;
+ }
+
+ /**
+ * Returns the multiline data, or null if there was no such data.
+ */
+ public String getData()
+ {
+ return data;
+ }
+
+}
+
Added: llvm-gcc-4.2/trunk/libjava/classpath/gnu/java/net/protocol/ftp/FTPURLConnection.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/gnu/java/net/protocol/ftp/FTPURLConnection.java?rev=43913&view=auto
==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/gnu/java/net/protocol/ftp/FTPURLConnection.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/gnu/java/net/protocol/ftp/FTPURLConnection.java Thu Nov 8 16:56:19 2007
@@ -0,0 +1,371 @@
+/* FTPURLConnection.java --
+ Copyright (C) 2003, 2004, 2006 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 gnu.java.net.protocol.ftp;
+
+import gnu.classpath.SystemProperties;
+import gnu.java.net.GetLocalHostAction;
+
+import java.io.FilterInputStream;
+import java.io.FilterOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.net.InetAddress;
+import java.net.URL;
+import java.net.URLConnection;
+import java.security.AccessController;
+import java.util.HashMap;
+import java.util.Map;
+
+/**
+ * An FTP URL connection.
+ *
+ * @author Chris Burdess (dog at gnu.org)
+ */
+public class FTPURLConnection
+ extends URLConnection
+{
+
+ /**
+ * The connection managing the protocol exchange.
+ */
+ protected FTPConnection connection;
+
+ protected boolean passive;
+ protected int representationType;
+ protected int fileStructure;
+ protected int transferMode;
+
+ /**
+ * Constructs an FTP connection to the specified URL.
+ * @param url the URL
+ */
+ public FTPURLConnection(URL url)
+ {
+ super(url);
+ passive = true;
+ representationType = FTPConnection.TYPE_BINARY;
+ fileStructure = -1;
+ transferMode = -1;
+ }
+
+ /**
+ * Establishes the connection.
+ */
+ public void connect()
+ throws IOException
+ {
+ if (connected)
+ {
+ return;
+ }
+ String host = url.getHost();
+ int port = url.getPort();
+ String username = url.getUserInfo();
+ String password = null;
+ if (username != null)
+ {
+ int ci = username.indexOf(':');
+ if (ci != -1)
+ {
+ password = username.substring(ci + 1);
+ username = username.substring(0, ci);
+ }
+ }
+ else
+ {
+ username = "anonymous";
+ GetLocalHostAction a = new GetLocalHostAction();
+ InetAddress localhost =(InetAddress) AccessController.doPrivileged(a);
+ password = SystemProperties.getProperty("user.name") + "@" +
+ ((localhost == null) ? "localhost" : localhost.getHostName());
+ }
+ connection = new FTPConnection(host, port);
+ if (!connection.authenticate(username, password))
+ {
+ throw new SecurityException("Authentication failed");
+ }
+ connection.setPassive(passive);
+ if (representationType != -1)
+ {
+ connection.setRepresentationType(representationType);
+ }
+ if (fileStructure != -1)
+ {
+ connection.setFileStructure(fileStructure);
+ }
+ if (transferMode != -1)
+ {
+ connection.setTransferMode(transferMode);
+ }
+ }
+
+ /**
+ * This connection supports doInput.
+ */
+ public void setDoInput(boolean doinput)
+ {
+ doInput = doinput;
+ }
+
+ /**
+ * This connection supports doOutput.
+ */
+ public void setDoOutput(boolean dooutput)
+ {
+ doOutput = dooutput;
+ }
+
+ /**
+ * Returns an input stream that reads from this open connection.
+ */
+ public InputStream getInputStream()
+ throws IOException
+ {
+ if (!connected)
+ {
+ connect();
+ }
+ String path = url.getPath();
+ if (connection.changeWorkingDirectory(path))
+ {
+ return this.new ClosingInputStream(connection.list(null));
+ }
+ else
+ {
+ return this.new ClosingInputStream(connection.retrieve(path));
+ }
+ }
+
+ /**
+ * Returns an output stream that writes to this connection.
+ */
+ public OutputStream getOutputStream()
+ throws IOException
+ {
+ if (!connected)
+ {
+ connect();
+ }
+ String path = url.getPath();
+ return this.new ClosingOutputStream(connection.store(path));
+ }
+
+ public String getRequestProperty(String key)
+ {
+ if ("passive".equals(key))
+ {
+ return Boolean.toString(passive);
+ }
+ else if ("representationType".equals(key))
+ {
+ switch (representationType)
+ {
+ case FTPConnection.TYPE_ASCII:
+ return "ASCII";
+ case FTPConnection.TYPE_EBCDIC:
+ return "EBCDIC";
+ case FTPConnection.TYPE_BINARY:
+ return "BINARY";
+ }
+ }
+ else if ("fileStructure".equals(key))
+ {
+ switch (fileStructure)
+ {
+ case FTPConnection.STRUCTURE_FILE:
+ return "FILE";
+ case FTPConnection.STRUCTURE_RECORD:
+ return "RECORD";
+ case FTPConnection.STRUCTURE_PAGE:
+ return "PAGE";
+ }
+ }
+ else if ("transferMode".equals(key))
+ {
+ switch (transferMode)
+ {
+ case FTPConnection.MODE_STREAM:
+ return "STREAM";
+ case FTPConnection.MODE_BLOCK:
+ return "BLOCK";
+ case FTPConnection.MODE_COMPRESSED:
+ return "COMPRESSED";
+ }
+ }
+ return null;
+ }
+
+ public Map getRequestProperties()
+ {
+ Map map = new HashMap();
+ addRequestPropertyValue(map, "passive");
+ addRequestPropertyValue(map, "representationType");
+ addRequestPropertyValue(map, "fileStructure");
+ addRequestPropertyValue(map, "transferMode");
+ return map;
+ }
+
+ private void addRequestPropertyValue(Map map, String key)
+ {
+ String value = getRequestProperty(key);
+ map.put(key, value);
+ }
+
+ public void setRequestProperty(String key, String value)
+ {
+ if (connected)
+ {
+ throw new IllegalStateException();
+ }
+ if ("passive".equals(key))
+ {
+ passive = Boolean.valueOf(value).booleanValue();
+ }
+ else if ("representationType".equals(key))
+ {
+ if ("A".equalsIgnoreCase(value) ||
+ "ASCII".equalsIgnoreCase(value))
+ {
+ representationType = FTPConnection.TYPE_ASCII;
+ }
+ else if ("E".equalsIgnoreCase(value) ||
+ "EBCDIC".equalsIgnoreCase(value))
+ {
+ representationType = FTPConnection.TYPE_EBCDIC;
+ }
+ else if ("I".equalsIgnoreCase(value) ||
+ "BINARY".equalsIgnoreCase(value))
+ {
+ representationType = FTPConnection.TYPE_BINARY;
+ }
+ else
+ {
+ throw new IllegalArgumentException(value);
+ }
+ }
+ else if ("fileStructure".equals(key))
+ {
+ if ("F".equalsIgnoreCase(value) ||
+ "FILE".equalsIgnoreCase(value))
+ {
+ fileStructure = FTPConnection.STRUCTURE_FILE;
+ }
+ else if ("R".equalsIgnoreCase(value) ||
+ "RECORD".equalsIgnoreCase(value))
+ {
+ fileStructure = FTPConnection.STRUCTURE_RECORD;
+ }
+ else if ("P".equalsIgnoreCase(value) ||
+ "PAGE".equalsIgnoreCase(value))
+ {
+ fileStructure = FTPConnection.STRUCTURE_PAGE;
+ }
+ else
+ {
+ throw new IllegalArgumentException(value);
+ }
+ }
+ else if ("transferMode".equals(key))
+ {
+ if ("S".equalsIgnoreCase(value) ||
+ "STREAM".equalsIgnoreCase(value))
+ {
+ transferMode = FTPConnection.MODE_STREAM;
+ }
+ else if ("B".equalsIgnoreCase(value) ||
+ "BLOCK".equalsIgnoreCase(value))
+ {
+ transferMode = FTPConnection.MODE_BLOCK;
+ }
+ else if ("C".equalsIgnoreCase(value) ||
+ "COMPRESSED".equalsIgnoreCase(value))
+ {
+ transferMode = FTPConnection.MODE_COMPRESSED;
+ }
+ else
+ {
+ throw new IllegalArgumentException(value);
+ }
+ }
+ }
+
+ public void addRequestProperty(String key, String value)
+ {
+ setRequestProperty(key, value);
+ }
+
+ class ClosingInputStream
+ extends FilterInputStream
+ {
+
+ ClosingInputStream(InputStream in)
+ {
+ super(in);
+ }
+
+ public void close()
+ throws IOException
+ {
+ super.close();
+ connection.logout();
+ }
+
+ }
+
+ class ClosingOutputStream
+ extends FilterOutputStream
+ {
+
+ ClosingOutputStream(OutputStream out)
+ {
+ super(out);
+ }
+
+ public void close()
+ throws IOException
+ {
+ super.close();
+ connection.logout();
+ }
+
+ }
+
+}
+
Added: llvm-gcc-4.2/trunk/libjava/classpath/gnu/java/net/protocol/ftp/Handler.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/gnu/java/net/protocol/ftp/Handler.java?rev=43913&view=auto
==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/gnu/java/net/protocol/ftp/Handler.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/gnu/java/net/protocol/ftp/Handler.java Thu Nov 8 16:56:19 2007
@@ -0,0 +1,70 @@
+/* Handler.java --
+ Copyright (C) 2003, 2004 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 gnu.java.net.protocol.ftp;
+
+import java.io.IOException;
+import java.net.URL;
+import java.net.URLConnection;
+import java.net.URLStreamHandler;
+
+/**
+ * An FTP URL stream handler.
+ *
+ * @author Chris Burdess (dog at gnu.org)
+ */
+public class Handler
+ extends URLStreamHandler
+{
+
+ protected int getDefaultPort()
+ {
+ return FTPConnection.FTP_PORT;
+ }
+
+ /**
+ * Returns an FTPURLConnection for the given URL.
+ */
+ public URLConnection openConnection(URL url)
+ throws IOException
+ {
+ return new FTPURLConnection(url);
+ }
+
+}
+
Added: llvm-gcc-4.2/trunk/libjava/classpath/gnu/java/net/protocol/ftp/PassiveModeDTP.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/gnu/java/net/protocol/ftp/PassiveModeDTP.java?rev=43913&view=auto
==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/gnu/java/net/protocol/ftp/PassiveModeDTP.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/gnu/java/net/protocol/ftp/PassiveModeDTP.java Thu Nov 8 16:56:19 2007
@@ -0,0 +1,201 @@
+/* PassiveModeDTP.java --
+ Copyright (C) 2003, 2004 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 gnu.java.net.protocol.ftp;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.net.InetAddress;
+import java.net.InetSocketAddress;
+import java.net.Socket;
+
+/**
+ * A passive mode FTP data transfer process.
+ * This connects to the host specified and proxies the resulting socket's
+ * input and output streams.
+ *
+ * @author Chris Burdess (dog at gnu.org)
+ */
+final class PassiveModeDTP
+ implements DTP
+{
+
+ final String address;
+ final int port;
+ Socket socket;
+ DTPInputStream in;
+ DTPOutputStream out;
+ boolean completed;
+ boolean inProgress;
+ int transferMode;
+
+ PassiveModeDTP(String address, int port, InetAddress localhost,
+ int connectionTimeout, int timeout)
+ throws IOException
+ {
+ this.address = address;
+ this.port = port;
+ completed = false;
+ inProgress = false;
+ socket = new Socket();
+ InetSocketAddress remote = new InetSocketAddress(address, port);
+ InetSocketAddress local = new InetSocketAddress(localhost, port + 1);
+ socket.bind(local);
+ if (connectionTimeout > 0)
+ {
+ socket.connect(remote, connectionTimeout);
+ }
+ else
+ {
+ socket.connect(remote);
+ }
+ if (timeout > 0)
+ {
+ socket.setSoTimeout(timeout);
+ }
+ }
+
+ /**
+ * Returns an input stream from which a remote file can be read.
+ */
+ public InputStream getInputStream()
+ throws IOException
+ {
+ if (inProgress)
+ {
+ throw new IOException("Transfer in progress");
+ }
+ switch (transferMode)
+ {
+ case FTPConnection.MODE_STREAM:
+ in = new StreamInputStream(this, socket.getInputStream());
+ break;
+ case FTPConnection.MODE_BLOCK:
+ in = new BlockInputStream(this, socket.getInputStream());
+ break;
+ case FTPConnection.MODE_COMPRESSED:
+ in = new CompressedInputStream(this, socket.getInputStream());
+ break;
+ default:
+ throw new IllegalStateException("Invalid transfer mode");
+ }
+ in.setTransferComplete(false);
+ return in;
+ }
+
+ /**
+ * Returns an output stream to which a local file can be written for
+ * upload.
+ */
+ public OutputStream getOutputStream()
+ throws IOException
+ {
+ if (inProgress)
+ {
+ throw new IOException("Transfer in progress");
+ }
+ switch (transferMode)
+ {
+ case FTPConnection.MODE_STREAM:
+ out = new StreamOutputStream(this, socket.getOutputStream());
+ break;
+ case FTPConnection.MODE_BLOCK:
+ out = new BlockOutputStream(this, socket.getOutputStream());
+ break;
+ case FTPConnection.MODE_COMPRESSED:
+ out = new CompressedOutputStream(this, socket.getOutputStream());
+ break;
+ default:
+ throw new IllegalStateException("Invalid transfer mode");
+ }
+ out.setTransferComplete(false);
+ return out;
+ }
+
+ public void setTransferMode(int mode)
+ {
+ transferMode = mode;
+ }
+
+ public void complete()
+ {
+ completed = true;
+ if (!inProgress)
+ {
+ transferComplete();
+ }
+ }
+
+ public boolean abort()
+ {
+ completed = true;
+ transferComplete();
+ return inProgress;
+ }
+
+ /*
+ * Called by DTPInputStream or DTPOutputStream when end of
+ * stream is reached.
+ */
+ public void transferComplete()
+ {
+ if (in != null)
+ {
+ in.setTransferComplete(true);
+ }
+ if (out != null)
+ {
+ out.setTransferComplete(true);
+ }
+ inProgress = false;
+ completed = completed ||(transferMode == FTPConnection.MODE_STREAM);
+ if (completed && socket != null)
+ {
+ try
+ {
+ socket.close();
+ }
+ catch (IOException e)
+ {
+ }
+ }
+ }
+
+}
+
Added: llvm-gcc-4.2/trunk/libjava/classpath/gnu/java/net/protocol/ftp/StreamInputStream.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/gnu/java/net/protocol/ftp/StreamInputStream.java?rev=43913&view=auto
==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/gnu/java/net/protocol/ftp/StreamInputStream.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/gnu/java/net/protocol/ftp/StreamInputStream.java Thu Nov 8 16:56:19 2007
@@ -0,0 +1,95 @@
+/* StreamInputStream.java --
+ Copyright (C) 2003, 2004 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 gnu.java.net.protocol.ftp;
+
+import java.io.IOException;
+import java.io.InputStream;
+
+/**
+ * A DTP input stream that implements the FTP stream data transfer mode.
+ *
+ * @author Chris Burdess (dog at gnu.org)
+ */
+class StreamInputStream
+ extends DTPInputStream
+{
+
+ StreamInputStream(DTP dtp, InputStream in)
+ {
+ super(dtp, in);
+ }
+
+ public int read()
+ throws IOException
+ {
+ if (transferComplete)
+ {
+ return -1;
+ }
+ int c = in.read();
+ if (c == -1)
+ {
+ close();
+ }
+ return c;
+ }
+
+ public int read(byte[] buf)
+ throws IOException
+ {
+ return read(buf, 0, buf.length);
+ }
+
+ public int read(byte[] buf, int off, int len)
+ throws IOException
+ {
+ if (transferComplete)
+ {
+ return -1;
+ }
+ int l = in.read(buf, off, len);
+ if (l == -1)
+ {
+ close();
+ }
+ return l;
+ }
+
+}
+
Added: llvm-gcc-4.2/trunk/libjava/classpath/gnu/java/net/protocol/ftp/StreamOutputStream.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/gnu/java/net/protocol/ftp/StreamOutputStream.java?rev=43913&view=auto
==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/gnu/java/net/protocol/ftp/StreamOutputStream.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/gnu/java/net/protocol/ftp/StreamOutputStream.java Thu Nov 8 16:56:19 2007
@@ -0,0 +1,85 @@
+/* StreamOutputStream.java --
+ Copyright (C) 2003, 2004 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 gnu.java.net.protocol.ftp;
+
+import java.io.IOException;
+import java.io.OutputStream;
+
+/**
+ * A DTP output stream that implements the FTP stream transfer mode.
+ *
+ * @author Chris Burdess (dog at gnu.org)
+ */
+class StreamOutputStream
+ extends DTPOutputStream
+{
+
+ StreamOutputStream(DTP dtp, OutputStream out)
+ {
+ super(dtp, out);
+ }
+
+ public void write(int c)
+ throws IOException
+ {
+ if (transferComplete)
+ {
+ return;
+ }
+ out.write(c);
+ }
+
+ public void write(byte[] b)
+ throws IOException
+ {
+ write(b, 0, b.length);
+ }
+
+ public void write(byte[] b, int off, int len)
+ throws IOException
+ {
+ if (transferComplete)
+ {
+ return;
+ }
+ out.write(b, off, len);
+ }
+
+}
+
Added: llvm-gcc-4.2/trunk/libjava/classpath/gnu/java/net/protocol/ftp/package.html
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/gnu/java/net/protocol/ftp/package.html?rev=43913&view=auto
==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/gnu/java/net/protocol/ftp/package.html (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/gnu/java/net/protocol/ftp/package.html Thu Nov 8 16:56:19 2007
@@ -0,0 +1,60 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
+<!-- package.html - describes classes in gnu.java.net.protocol.ftp package.
+ Copyright (C) 2004 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. -->
+
+<html>
+<head><title>GNU Classpath - gnu.java.net.protocol.ftp</title></head>
+
+<body>
+
+<p>
+This package contains an FTP client. It can handle both active and passive
+mode connections and the various transfer modes and representation types.
+</p>
+
+<p>
+Interaction with the server is via a simple stream interface. Only one
+concurrent stream (input or output) is supported.
+</p>
+
+<p>
+The control connection to the server can be protected using TLS
+(the starttls method).
+</p>
+
+</body>
+</html>
Added: llvm-gcc-4.2/trunk/libjava/classpath/gnu/java/net/protocol/http/Authenticator.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/gnu/java/net/protocol/http/Authenticator.java?rev=43913&view=auto
==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/gnu/java/net/protocol/http/Authenticator.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/gnu/java/net/protocol/http/Authenticator.java Thu Nov 8 16:56:19 2007
@@ -0,0 +1,59 @@
+/* Authenticator.java --
+ Copyright (C) 2004 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 gnu.java.net.protocol.http;
+
+/**
+ * Callback interface for managing authentication.
+ * @see Request#setAuthenticator
+ *
+ * @author Chris Burdess (dog at gnu.org)
+ */
+public interface Authenticator
+{
+
+ /**
+ * Returns the credentials to supply for the given realm.
+ * @param realm the authentication realm
+ * @param attempt zero on first authentication attempt, increments on each
+ * unsuccessful attempt
+ */
+ Credentials getCredentials(String realm, int attempt);
+
+}
+
Added: llvm-gcc-4.2/trunk/libjava/classpath/gnu/java/net/protocol/http/ByteArrayRequestBodyWriter.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/gnu/java/net/protocol/http/ByteArrayRequestBodyWriter.java?rev=43913&view=auto
==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/gnu/java/net/protocol/http/ByteArrayRequestBodyWriter.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/gnu/java/net/protocol/http/ByteArrayRequestBodyWriter.java Thu Nov 8 16:56:19 2007
@@ -0,0 +1,107 @@
+/* ByteArrayRequestBodyWriter.java --
+ Copyright (C) 2004 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 gnu.java.net.protocol.http;
+
+/**
+ * A simple request body writer using a byte array.
+ *
+ * @author Chris Burdess (dog at gnu.org)
+ */
+public class ByteArrayRequestBodyWriter
+ implements RequestBodyWriter
+{
+
+ /**
+ * The content.
+ */
+ protected byte[] content;
+
+ /**
+ * The position within the content at which the next read will occur.
+ */
+ protected int pos;
+
+ /**
+ * Constructs a new byte array request body writer with the specified
+ * content.
+ * @param content the content buffer
+ */
+ public ByteArrayRequestBodyWriter(byte[] content)
+ {
+ this.content = content;
+ pos = 0;
+ }
+
+ /**
+ * Returns the total number of bytes that will be written in a single pass
+ * by this writer.
+ */
+ public int getContentLength()
+ {
+ return content.length;
+ }
+
+ /**
+ * Initialises the writer.
+ * This will be called before each pass.
+ */
+ public void reset()
+ {
+ pos = 0;
+ }
+
+ /**
+ * Writes body content to the supplied buffer.
+ * @param buffer the content buffer
+ * @return the number of bytes written
+ */
+ public int write(byte[] buffer)
+ {
+ int len = content.length - pos;
+ len = (buffer.length < len) ? buffer.length : len;
+ if (len > -1)
+ {
+ System.arraycopy(content, pos, buffer, 0, len);
+ pos += len;
+ }
+ return len;
+ }
+
+}
+
Added: llvm-gcc-4.2/trunk/libjava/classpath/gnu/java/net/protocol/http/ChunkedInputStream.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/gnu/java/net/protocol/http/ChunkedInputStream.java?rev=43913&view=auto
==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/gnu/java/net/protocol/http/ChunkedInputStream.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/gnu/java/net/protocol/http/ChunkedInputStream.java Thu Nov 8 16:56:19 2007
@@ -0,0 +1,226 @@
+/* ChunkedInputStream.java --
+ Copyright (C) 2004, 2006 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 gnu.java.net.protocol.http;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.net.ProtocolException;
+
+
+//
+// Note that we rely on the implemtation of skip() in the super class
+// (InputStream) calling our read methods to account for chunk headers
+// while skipping.
+//
+
+
+/**
+ * Input stream wrapper for the "chunked" transfer-coding.
+ *
+ * @author Chris Burdess (dog at gnu.org)
+ */
+public class ChunkedInputStream
+ extends InputStream
+{
+
+ private static final byte CR = 0x0d;
+ private static final byte LF = 0x0a;
+
+ Headers headers;
+
+ /** The underlying stream. */
+ private InputStream in;
+
+ /** Size of the chunk we're reading. */
+ int size;
+ /** Number of bytes we've read in this chunk. */
+ int count;
+ /**
+ * True when we should read meta-information, false when we should
+ * read data.
+ */
+ boolean meta;
+ /** True when we've hit EOF. */
+ boolean eof;
+
+ /**
+ * Constructor.
+ * @param in the response socket input stream
+ * @param headers the headers to receive additional header lines
+ */
+ public ChunkedInputStream(InputStream in, Headers headers)
+ {
+ this.in = in;
+ this.headers = headers;
+ size = -1;
+ count = 0;
+ meta = true;
+ }
+
+ public int read()
+ throws IOException
+ {
+ byte[] buf = new byte[1];
+ int len = read(buf, 0, 1);
+ if (len == -1)
+ {
+ return -1;
+ }
+ return 0xff & buf[0];
+ }
+
+ public synchronized int read(byte[] buffer, int offset, int length)
+ throws IOException
+ {
+ if (eof)
+ {
+ return -1;
+ }
+ if (meta)
+ {
+ // Read chunk header
+ int c, last = 0;
+ boolean seenSemi = false;
+ StringBuilder buf = new StringBuilder();
+ do
+ {
+ c = in.read();
+ if (c == 0x3b) // ;
+ {
+ seenSemi = true;
+ }
+ else if (c == 0x0a && last == 0x0d) // CRLF
+ {
+ try
+ {
+ size = Integer.parseInt(buf.toString(), 16);
+ }
+ catch (NumberFormatException nfe)
+ {
+ IOException ioe = new IOException("Bad chunk header");
+ ioe.initCause(nfe);
+ // Unrecoverable. Don't try to read more.
+ in.close();
+ throw ioe;
+ }
+ break;
+ }
+ else if (!seenSemi && c >= 0x30)
+ {
+ buf.append ((char) c);
+ }
+ last = c;
+ }
+ while(c != -1);
+ count = 0;
+ meta = false;
+ }
+ if (size == 0)
+ {
+ // Read trailer
+ headers.parse(in);
+ eof = true;
+ return -1;
+ }
+ else
+ {
+ int canRead = Math.min(size - count, length);
+ int len = in.read(buffer, offset, canRead);
+ if (len == -1)
+ {
+ // This is an error condition but it isn't clear what we
+ // should do with it.
+ eof = true;
+ return -1;
+ }
+ count += len;
+ if (count == size)
+ {
+ // Read CRLF
+ int c1 = in.read();
+ int c2 = in.read();
+ if (c1 == -1 || c2 == -1)
+ {
+ // EOF before CRLF: bad, but ignore
+ eof = true;
+ return -1;
+ }
+ if (c1 != 0x0d || c2 != 0x0a)
+ {
+ throw new ProtocolException("expecting CRLF: " + c1 + "," + c2);
+ }
+ meta = true;
+ }
+ return len;
+ }
+ }
+
+ /**
+ * This method returns the number of bytes that can be read from
+ * this stream before a read might block. Even if the underlying
+ * InputStream has data available past the end of the current chunk,
+ * we have no way of knowing how large the next chunk header will
+ * be. So we cannot report available data past the current chunk.
+ *
+ * @return The number of bytes that can be read before a read might
+ * block
+ *
+ * @exception IOException If an error occurs
+ */
+ public int available() throws IOException
+ {
+ if (meta)
+ return 0;
+
+ return Math.min(in.available(), size - count);
+ }
+
+ /**
+ * This method closes the ChunkedInputStream by closing the underlying
+ * InputStream.
+ *
+ * @exception IOException If an error occurs
+ */
+ public void close() throws IOException
+ {
+ in.close();
+ }
+
+}
+
Added: llvm-gcc-4.2/trunk/libjava/classpath/gnu/java/net/protocol/http/Cookie.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/gnu/java/net/protocol/http/Cookie.java?rev=43913&view=auto
==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/gnu/java/net/protocol/http/Cookie.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/gnu/java/net/protocol/http/Cookie.java Thu Nov 8 16:56:19 2007
@@ -0,0 +1,160 @@
+/* Cookie.java --
+ Copyright (C) 2004 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 gnu.java.net.protocol.http;
+
+import java.util.Date;
+
+/**
+ * An HTTP cookie, as specified in RFC 2109.
+ *
+ * @author Chris Burdess (dog at gnu.org)
+ */
+public class Cookie
+{
+
+ /**
+ * The name of the cookie.
+ */
+ protected final String name;
+
+ /**
+ * The value of the cookie.
+ */
+ protected final String value;
+
+ /**
+ * Optional documentation of the intended use of the cookie.
+ */
+ protected final String comment;
+
+ /**
+ * The domain for which the cookie is valid.
+ */
+ protected final String domain;
+
+ /**
+ * Optional subset of URL paths within the domain for which the cookie is
+ * valid.
+ */
+ protected final String path;
+
+ /**
+ * Indicates that the user-agent should only use secure means to transmit
+ * this cookie to the server.
+ */
+ protected final boolean secure;
+
+ /**
+ * The date at which this cookie expires.
+ */
+ protected final Date expires;
+
+ public Cookie(String name, String value, String comment, String domain,
+ String path, boolean secure, Date expires)
+ {
+ this.name = name;
+ this.value = value;
+ this.comment = comment;
+ this.domain = domain;
+ this.path = path;
+ this.secure = secure;
+ this.expires = expires;
+ }
+
+ public String getName()
+ {
+ return name;
+ }
+
+ public String getValue()
+ {
+ return value;
+ }
+
+ public String getComment()
+ {
+ return comment;
+ }
+
+ public String getDomain()
+ {
+ return domain;
+ }
+
+ public String getPath()
+ {
+ return path;
+ }
+
+ public boolean isSecure()
+ {
+ return secure;
+ }
+
+ public Date getExpiryDate()
+ {
+ return expires;
+ }
+
+ public String toString()
+ {
+ return toString(true, true);
+ }
+
+ public String toString(boolean showPath, boolean showDomain)
+ {
+ StringBuilder buf = new StringBuilder();
+ buf.append(name);
+ buf.append('=');
+ buf.append(value);
+ if (showPath)
+ {
+ buf.append("; $Path=");
+ buf.append(path);
+ }
+ if (showDomain)
+ {
+ buf.append("; $Domain=");
+ buf.append(domain);
+ }
+ return buf.toString();
+ }
+
+}
+
Added: llvm-gcc-4.2/trunk/libjava/classpath/gnu/java/net/protocol/http/CookieManager.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/gnu/java/net/protocol/http/CookieManager.java?rev=43913&view=auto
==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/gnu/java/net/protocol/http/CookieManager.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/gnu/java/net/protocol/http/CookieManager.java Thu Nov 8 16:56:19 2007
@@ -0,0 +1,65 @@
+/* CookieManager.java --
+ Copyright (C) 2004 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 gnu.java.net.protocol.http;
+
+/**
+ * Cookie manager interface.
+ * If an application wants to handle cookies, they should implement this
+ * interface and register the instance with each HTTPConnection they use.
+ *
+ * @author Chris Burdess (dog at gnu.org)
+ */
+public interface CookieManager
+{
+
+ /**
+ * Stores a cookie in the cookie manager.
+ * @param cookie the cookie to store
+ */
+ void setCookie(Cookie cookie);
+
+ /**
+ * Retrieves the cookies matching the specified criteria.
+ * @param host the host name
+ * @param secure whether the connection is secure
+ * @param path the path to access
+ */
+ Cookie[] getCookies(String host, boolean secure, String path);
+
+}
Added: llvm-gcc-4.2/trunk/libjava/classpath/gnu/java/net/protocol/http/Credentials.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/gnu/java/net/protocol/http/Credentials.java?rev=43913&view=auto
==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/gnu/java/net/protocol/http/Credentials.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/gnu/java/net/protocol/http/Credentials.java Thu Nov 8 16:56:19 2007
@@ -0,0 +1,88 @@
+/* Credentials.java --
+ Copyright (C) 2004 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 gnu.java.net.protocol.http;
+
+/**
+ * Represents a username/password combination that can be used to
+ * authenticate to an HTTP server.
+ *
+ * @author Chris Burdess (dog at gnu.org)
+ */
+public class Credentials
+{
+
+ /**
+ * The username.
+ */
+ private String username;
+
+ /**
+ * The password.
+ */
+ private String password;
+
+ /**
+ * Constructor.
+ * @param username the username
+ * @param password the password
+ */
+ public Credentials(String username, String password)
+ {
+ this.username = username;
+ this.password = password;
+ }
+
+ /**
+ * Returns the username.
+ */
+ public String getUsername()
+ {
+ return username;
+ }
+
+ /**
+ * Returns the password.
+ */
+ public String getPassword()
+ {
+ return password;
+ }
+
+}
+
Added: llvm-gcc-4.2/trunk/libjava/classpath/gnu/java/net/protocol/http/HTTPConnection.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/gnu/java/net/protocol/http/HTTPConnection.java?rev=43913&view=auto
==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/gnu/java/net/protocol/http/HTTPConnection.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/gnu/java/net/protocol/http/HTTPConnection.java Thu Nov 8 16:56:19 2007
@@ -0,0 +1,858 @@
+/* HTTPConnection.java --
+ Copyright (C) 2004, 2005, 2006 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 gnu.java.net.protocol.http;
+
+import gnu.classpath.SystemProperties;
+import gnu.java.net.EmptyX509TrustManager;
+
+import java.io.BufferedInputStream;
+import java.io.BufferedOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.net.InetSocketAddress;
+import java.net.Socket;
+import java.security.GeneralSecurityException;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.LinkedList;
+import java.util.List;
+import java.util.ListIterator;
+import java.util.Map;
+
+import javax.net.ssl.HandshakeCompletedListener;
+import javax.net.ssl.SSLContext;
+import javax.net.ssl.SSLSocket;
+import javax.net.ssl.SSLSocketFactory;
+import javax.net.ssl.TrustManager;
+
+/**
+ * A connection to an HTTP server.
+ *
+ * @author Chris Burdess (dog at gnu.org)
+ */
+public class HTTPConnection
+{
+
+ /**
+ * The default HTTP port.
+ */
+ public static final int HTTP_PORT = 80;
+
+ /**
+ * The default HTTPS port.
+ */
+ public static final int HTTPS_PORT = 443;
+
+ private static final String userAgent = SystemProperties.getProperty("http.agent");
+
+ /**
+ * The host name of the server to connect to.
+ */
+ protected final String hostname;
+
+ /**
+ * The port to connect to.
+ */
+ protected final int port;
+
+ /**
+ * Whether the connection should use transport level security (HTTPS).
+ */
+ protected final boolean secure;
+
+ /**
+ * The connection timeout for connecting the underlying socket.
+ */
+ protected final int connectionTimeout;
+
+ /**
+ * The read timeout for reads on the underlying socket.
+ */
+ protected final int timeout;
+
+ /**
+ * The host name of the proxy to connect to.
+ */
+ protected String proxyHostname;
+
+ /**
+ * The port on the proxy to connect to.
+ */
+ protected int proxyPort;
+
+ /**
+ * The major version of HTTP supported by this client.
+ */
+ protected int majorVersion;
+
+ /**
+ * The minor version of HTTP supported by this client.
+ */
+ protected int minorVersion;
+
+ private final List handshakeCompletedListeners;
+
+ /**
+ * The socket this connection communicates on.
+ */
+ protected Socket socket;
+
+ /**
+ * The SSL socket factory to use.
+ */
+ private SSLSocketFactory sslSocketFactory;
+
+ /**
+ * The socket input stream.
+ */
+ protected InputStream in;
+
+ /**
+ * The socket output stream.
+ */
+ protected OutputStream out;
+
+ /**
+ * Nonce values seen by this connection.
+ */
+ private Map nonceCounts;
+
+ /**
+ * The cookie manager for this connection.
+ */
+ protected CookieManager cookieManager;
+
+
+ /**
+ * The pool that this connection is a member of (if any).
+ */
+ private Pool pool;
+
+ /**
+ * Creates a new HTTP connection.
+ * @param hostname the name of the host to connect to
+ */
+ public HTTPConnection(String hostname)
+ {
+ this(hostname, HTTP_PORT, false, 0, 0);
+ }
+
+ /**
+ * Creates a new HTTP or HTTPS connection.
+ * @param hostname the name of the host to connect to
+ * @param secure whether to use a secure connection
+ */
+ public HTTPConnection(String hostname, boolean secure)
+ {
+ this(hostname, secure ? HTTPS_PORT : HTTP_PORT, secure, 0, 0);
+ }
+
+ /**
+ * Creates a new HTTP or HTTPS connection on the specified port.
+ * @param hostname the name of the host to connect to
+ * @param secure whether to use a secure connection
+ * @param connectionTimeout the connection timeout
+ * @param timeout the socket read timeout
+ */
+ public HTTPConnection(String hostname, boolean secure,
+ int connectionTimeout, int timeout)
+ {
+ this(hostname, secure ? HTTPS_PORT : HTTP_PORT, secure,
+ connectionTimeout, timeout);
+ }
+
+ /**
+ * Creates a new HTTP connection on the specified port.
+ * @param hostname the name of the host to connect to
+ * @param port the port on the host to connect to
+ */
+ public HTTPConnection(String hostname, int port)
+ {
+ this(hostname, port, false, 0, 0);
+ }
+
+ /**
+ * Creates a new HTTP or HTTPS connection on the specified port.
+ * @param hostname the name of the host to connect to
+ * @param port the port on the host to connect to
+ * @param secure whether to use a secure connection
+ */
+ public HTTPConnection(String hostname, int port, boolean secure)
+ {
+ this(hostname, port, secure, 0, 0);
+ }
+
+ /**
+ * Creates a new HTTP or HTTPS connection on the specified port.
+ * @param hostname the name of the host to connect to
+ * @param port the port on the host to connect to
+ * @param secure whether to use a secure connection
+ * @param connectionTimeout the connection timeout
+ * @param timeout the socket read timeout
+ */
+ public HTTPConnection(String hostname, int port, boolean secure,
+ int connectionTimeout, int timeout)
+ {
+ this.hostname = hostname;
+ this.port = port;
+ this.secure = secure;
+ this.connectionTimeout = connectionTimeout;
+ this.timeout = timeout;
+ majorVersion = minorVersion = 1;
+ handshakeCompletedListeners = new ArrayList(2);
+ }
+
+ /**
+ * Returns the name of the host to connect to.
+ */
+ public String getHostName()
+ {
+ return hostname;
+ }
+
+ /**
+ * Returns the port on the host to connect to.
+ */
+ public int getPort()
+ {
+ return port;
+ }
+
+ /**
+ * Indicates whether to use a secure connection or not.
+ */
+ public boolean isSecure()
+ {
+ return secure;
+ }
+
+ /**
+ * Returns the HTTP version string supported by this connection.
+ * @see #majorVersion
+ * @see #minorVersion
+ */
+ public String getVersion()
+ {
+ return "HTTP/" + majorVersion + '.' + minorVersion;
+ }
+
+ /**
+ * Sets the HTTP version supported by this connection.
+ * @param majorVersion the major version
+ * @param minorVersion the minor version
+ */
+ public void setVersion(int majorVersion, int minorVersion)
+ {
+ if (majorVersion != 1)
+ {
+ throw new IllegalArgumentException("major version not supported: " +
+ majorVersion);
+ }
+ if (minorVersion < 0 || minorVersion > 1)
+ {
+ throw new IllegalArgumentException("minor version not supported: " +
+ minorVersion);
+ }
+ this.majorVersion = majorVersion;
+ this.minorVersion = minorVersion;
+ }
+
+ /**
+ * Directs this connection to use the specified proxy.
+ * @param hostname the proxy host name
+ * @param port the port on the proxy to connect to
+ */
+ public void setProxy(String hostname, int port)
+ {
+ proxyHostname = hostname;
+ proxyPort = port;
+ }
+
+ /**
+ * Indicates whether this connection is using an HTTP proxy.
+ */
+ public boolean isUsingProxy()
+ {
+ return (proxyHostname != null && proxyPort > 0);
+ }
+
+ /**
+ * Sets the cookie manager to use for this connection.
+ * @param cookieManager the cookie manager
+ */
+ public void setCookieManager(CookieManager cookieManager)
+ {
+ this.cookieManager = cookieManager;
+ }
+
+ /**
+ * Returns the cookie manager in use for this connection.
+ */
+ public CookieManager getCookieManager()
+ {
+ return cookieManager;
+ }
+
+ /**
+ * Manages a pool of HTTPConections. The pool will have a maximum
+ * size determined by the value of the maxConn parameter passed to
+ * the {@link #get} method. This value inevitably comes from the
+ * http.maxConnections system property. If the
+ * classpath.net.http.keepAliveTTL system property is set, that will
+ * be the maximum time (in seconds) that an idle connection will be
+ * maintained.
+ */
+ static class Pool
+ {
+ /**
+ * Singleton instance of the pool.
+ */
+ static Pool instance = new Pool();
+
+ /**
+ * The pool
+ */
+ final LinkedList connectionPool = new LinkedList();
+
+ /**
+ * Maximum size of the pool.
+ */
+ int maxConnections;
+
+ /**
+ * If greater than zero, the maximum time a connection will remain
+ * int the pool.
+ */
+ int connectionTTL;
+
+ /**
+ * A thread that removes connections older than connectionTTL.
+ */
+ class Reaper
+ implements Runnable
+ {
+ public void run()
+ {
+ synchronized (Pool.this)
+ {
+ try
+ {
+ do
+ {
+ while (connectionPool.size() > 0)
+ {
+ long currentTime = System.currentTimeMillis();
+
+ HTTPConnection c =
+ (HTTPConnection)connectionPool.getFirst();
+
+ long waitTime = c.timeLastUsed
+ + connectionTTL - currentTime;
+
+ if (waitTime <= 0)
+ removeOldest();
+ else
+ try
+ {
+ Pool.this.wait(waitTime);
+ }
+ catch (InterruptedException _)
+ {
+ // Ignore the interrupt.
+ }
+ }
+ // After the pool is empty, wait TTL to see if it
+ // is used again. This is because in the
+ // situation where a single thread is making HTTP
+ // requests to the same server it can remove the
+ // connection from the pool before the Reaper has
+ // a chance to start. This would cause the Reaper
+ // to exit if it were not for this extra delay.
+ // The result would be starting a Reaper thread
+ // for each HTTP request. With the delay we get
+ // at most one Reaper created each TTL.
+ try
+ {
+ Pool.this.wait(connectionTTL);
+ }
+ catch (InterruptedException _)
+ {
+ // Ignore the interrupt.
+ }
+ }
+ while (connectionPool.size() > 0);
+ }
+ finally
+ {
+ reaper = null;
+ }
+ }
+ }
+ }
+
+ Reaper reaper;
+
+ /**
+ * Private constructor to ensure singleton.
+ */
+ private Pool()
+ {
+ }
+
+ /**
+ * Tests for a matching connection.
+ *
+ * @param c connection to match.
+ * @param h the host name.
+ * @param p the port.
+ * @param sec true if using https.
+ *
+ * @return true if c matches h, p, and sec.
+ */
+ private static boolean matches(HTTPConnection c,
+ String h, int p, boolean sec)
+ {
+ return h.equals(c.hostname) && (p == c.port) && (sec == c.secure);
+ }
+
+ /**
+ * Get a pooled HTTPConnection. If there is an existing idle
+ * connection to the requested server it is returned. Otherwise a
+ * new connection is created.
+ *
+ * @param host the name of the host to connect to
+ * @param port the port on the host to connect to
+ * @param secure whether to use a secure connection
+ *
+ * @return the HTTPConnection.
+ */
+ synchronized HTTPConnection get(String host,
+ int port,
+ boolean secure,
+ int connectionTimeout, int timeout)
+ {
+ String ttl =
+ SystemProperties.getProperty("classpath.net.http.keepAliveTTL");
+ connectionTTL = (ttl != null && ttl.length() > 0) ?
+ 1000 * Math.max(1, Integer.parseInt(ttl)) : 10000;
+
+ String mc = SystemProperties.getProperty("http.maxConnections");
+ maxConnections = (mc != null && mc.length() > 0) ?
+ Math.max(Integer.parseInt(mc), 1) : 5;
+ if (maxConnections < 1)
+ maxConnections = 1;
+
+ HTTPConnection c = null;
+
+ ListIterator it = connectionPool.listIterator(0);
+ while (it.hasNext())
+ {
+ HTTPConnection cc = (HTTPConnection)it.next();
+ if (matches(cc, host, port, secure))
+ {
+ c = cc;
+ it.remove();
+ break;
+ }
+ }
+ if (c == null)
+ {
+ c = new HTTPConnection(host, port, secure, connectionTimeout, timeout);
+ c.setPool(this);
+ }
+ return c;
+ }
+
+ /**
+ * Put an idle HTTPConnection back into the pool. If this causes
+ * the pool to be come too large, the oldest connection is removed
+ * and closed.
+ *
+ */
+ synchronized void put(HTTPConnection c)
+ {
+ c.timeLastUsed = System.currentTimeMillis();
+ connectionPool.addLast(c);
+
+ // maxConnections must always be >= 1
+ while (connectionPool.size() >= maxConnections)
+ removeOldest();
+
+ if (connectionTTL > 0 && null == reaper) {
+ // If there is a connectionTTL, then the reaper has removed
+ // any stale connections, so we don't have to check for stale
+ // now. We do have to start a reaper though, as there is not
+ // one running now.
+ reaper = new Reaper();
+ Thread t = new Thread(reaper, "HTTPConnection.Reaper");
+ t.setDaemon(true);
+ t.start();
+ }
+ }
+
+ /**
+ * Remove the oldest connection from the pool and close it.
+ */
+ void removeOldest()
+ {
+ HTTPConnection cx = (HTTPConnection)connectionPool.removeFirst();
+ try
+ {
+ cx.closeConnection();
+ }
+ catch (IOException ioe)
+ {
+ // Ignore it. We are just cleaning up.
+ }
+ }
+ }
+
+ /**
+ * The number of times this HTTPConnection has be used via keep-alive.
+ */
+ int useCount;
+
+ /**
+ * If this HTTPConnection is in the pool, the time it was put there.
+ */
+ long timeLastUsed;
+
+ /**
+ * Set the connection pool that this HTTPConnection is a member of.
+ * If left unset or set to null, it will not be a member of any pool
+ * and will not be a candidate for reuse.
+ *
+ * @param p the pool.
+ */
+ void setPool(Pool p)
+ {
+ pool = p;
+ }
+
+ /**
+ * Signal that this HTTPConnection is no longer needed and can be
+ * returned to the connection pool.
+ *
+ */
+ void release()
+ {
+ if (pool != null)
+ {
+ useCount++;
+ pool.put(this);
+
+ }
+ else
+ {
+ // If there is no pool, just close.
+ try
+ {
+ closeConnection();
+ }
+ catch (IOException ioe)
+ {
+ // Ignore it. We are just cleaning up.
+ }
+ }
+ }
+
+ /**
+ * Creates a new request using this connection.
+ * @param method the HTTP method to invoke
+ * @param path the URI-escaped RFC2396 <code>abs_path</code> with
+ * optional query part
+ */
+ public Request newRequest(String method, String path)
+ {
+ if (method == null || method.length() == 0)
+ {
+ throw new IllegalArgumentException("method must have non-zero length");
+ }
+ if (path == null || path.length() == 0)
+ {
+ path = "/";
+ }
+ Request ret = new Request(this, method, path);
+ if ((secure && port != HTTPS_PORT) ||
+ (!secure && port != HTTP_PORT))
+ {
+ ret.setHeader("Host", hostname + ":" + port);
+ }
+ else
+ {
+ ret.setHeader("Host", hostname);
+ }
+ ret.setHeader("User-Agent", userAgent);
+ ret.setHeader("Connection", "keep-alive");
+ ret.setHeader("Accept-Encoding",
+ "chunked;q=1.0, gzip;q=0.9, deflate;q=0.8, " +
+ "identity;q=0.6, *;q=0");
+ if (cookieManager != null)
+ {
+ Cookie[] cookies = cookieManager.getCookies(hostname, secure, path);
+ if (cookies != null && cookies.length > 0)
+ {
+ StringBuilder buf = new StringBuilder();
+ buf.append("$Version=1");
+ for (int i = 0; i < cookies.length; i++)
+ {
+ buf.append(',');
+ buf.append(' ');
+ buf.append(cookies[i].toString());
+ }
+ ret.setHeader("Cookie", buf.toString());
+ }
+ }
+ return ret;
+ }
+
+ /**
+ * Closes this connection.
+ */
+ public void close()
+ throws IOException
+ {
+ closeConnection();
+ }
+
+ /**
+ * Retrieves the socket associated with this connection.
+ * This creates the socket if necessary.
+ */
+ protected synchronized Socket getSocket()
+ throws IOException
+ {
+ if (socket == null)
+ {
+ String connectHostname = hostname;
+ int connectPort = port;
+ if (isUsingProxy())
+ {
+ connectHostname = proxyHostname;
+ connectPort = proxyPort;
+ }
+ socket = new Socket();
+ InetSocketAddress address =
+ new InetSocketAddress(connectHostname, connectPort);
+ if (connectionTimeout > 0)
+ {
+ socket.connect(address, connectionTimeout);
+ }
+ else
+ {
+ socket.connect(address);
+ }
+ if (timeout > 0)
+ {
+ socket.setSoTimeout(timeout);
+ }
+ if (secure)
+ {
+ try
+ {
+ SSLSocketFactory factory = getSSLSocketFactory();
+ SSLSocket ss =
+ (SSLSocket) factory.createSocket(socket, connectHostname,
+ connectPort, true);
+ String[] protocols = { "TLSv1", "SSLv3" };
+ ss.setEnabledProtocols(protocols);
+ ss.setUseClientMode(true);
+ synchronized (handshakeCompletedListeners)
+ {
+ if (!handshakeCompletedListeners.isEmpty())
+ {
+ for (Iterator i =
+ handshakeCompletedListeners.iterator();
+ i.hasNext(); )
+ {
+ HandshakeCompletedListener l =
+ (HandshakeCompletedListener) i.next();
+ ss.addHandshakeCompletedListener(l);
+ }
+ }
+ }
+ ss.startHandshake();
+ socket = ss;
+ }
+ catch (GeneralSecurityException e)
+ {
+ throw new IOException(e.getMessage());
+ }
+ }
+ in = socket.getInputStream();
+ in = new BufferedInputStream(in);
+ out = socket.getOutputStream();
+ out = new BufferedOutputStream(out);
+ }
+ return socket;
+ }
+
+ SSLSocketFactory getSSLSocketFactory()
+ throws GeneralSecurityException
+ {
+ if (sslSocketFactory == null)
+ {
+ TrustManager tm = new EmptyX509TrustManager();
+ SSLContext context = SSLContext.getInstance("SSL");
+ TrustManager[] trust = new TrustManager[] { tm };
+ context.init(null, trust, null);
+ sslSocketFactory = context.getSocketFactory();
+ }
+ return sslSocketFactory;
+ }
+
+ void setSSLSocketFactory(SSLSocketFactory factory)
+ {
+ sslSocketFactory = factory;
+ }
+
+ protected synchronized InputStream getInputStream()
+ throws IOException
+ {
+ if (socket == null)
+ {
+ getSocket();
+ }
+ return in;
+ }
+
+ protected synchronized OutputStream getOutputStream()
+ throws IOException
+ {
+ if (socket == null)
+ {
+ getSocket();
+ }
+ return out;
+ }
+
+ /**
+ * Closes the underlying socket, if any.
+ */
+ protected synchronized void closeConnection()
+ throws IOException
+ {
+ if (socket != null)
+ {
+ try
+ {
+ socket.close();
+ }
+ finally
+ {
+ socket = null;
+ }
+ }
+ }
+
+ /**
+ * Returns a URI representing the connection.
+ * This does not include any request path component.
+ */
+ protected String getURI()
+ {
+ StringBuilder buf = new StringBuilder();
+ buf.append(secure ? "https://" : "http://");
+ buf.append(hostname);
+ if (secure)
+ {
+ if (port != HTTPConnection.HTTPS_PORT)
+ {
+ buf.append(':');
+ buf.append(port);
+ }
+ }
+ else
+ {
+ if (port != HTTPConnection.HTTP_PORT)
+ {
+ buf.append(':');
+ buf.append(port);
+ }
+ }
+ return buf.toString();
+ }
+
+ /**
+ * Get the number of times the specified nonce has been seen by this
+ * connection.
+ */
+ int getNonceCount(String nonce)
+ {
+ if (nonceCounts == null)
+ {
+ return 0;
+ }
+ return((Integer) nonceCounts.get(nonce)).intValue();
+ }
+
+ /**
+ * Increment the number of times the specified nonce has been seen.
+ */
+ void incrementNonce(String nonce)
+ {
+ int current = getNonceCount(nonce);
+ if (nonceCounts == null)
+ {
+ nonceCounts = new HashMap();
+ }
+ nonceCounts.put(nonce, new Integer(current + 1));
+ }
+
+ // -- Events --
+
+ void addHandshakeCompletedListener(HandshakeCompletedListener l)
+ {
+ synchronized (handshakeCompletedListeners)
+ {
+ handshakeCompletedListeners.add(l);
+ }
+ }
+ void removeHandshakeCompletedListener(HandshakeCompletedListener l)
+ {
+ synchronized (handshakeCompletedListeners)
+ {
+ handshakeCompletedListeners.remove(l);
+ }
+ }
+
+}
+
Added: llvm-gcc-4.2/trunk/libjava/classpath/gnu/java/net/protocol/http/HTTPDateFormat.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/gnu/java/net/protocol/http/HTTPDateFormat.java?rev=43913&view=auto
==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/gnu/java/net/protocol/http/HTTPDateFormat.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/gnu/java/net/protocol/http/HTTPDateFormat.java Thu Nov 8 16:56:19 2007
@@ -0,0 +1,441 @@
+/* HTTPDateFormat.java --
+ Copyright (C) 2004 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 gnu.java.net.protocol.http;
+
+import java.text.DateFormat;
+import java.text.DecimalFormat;
+import java.text.FieldPosition;
+import java.text.NumberFormat;
+import java.text.ParsePosition;
+import java.util.Calendar;
+import java.util.Date;
+import java.util.GregorianCalendar;
+import java.util.TimeZone;
+
+/**
+ * HTTP date formatter and parser.
+ * Formats dates according to RFC 822 (updated by RFC 1123).
+ * Parses dates according to the above, <i>or</i> RFC 1036, <i>or</i> the
+ * ANSI C <code>asctime()</code> format.
+ *
+ * @author Chris Burdess (dog at gnu.org)
+ */
+public class HTTPDateFormat
+ extends DateFormat
+{
+
+ static final String[] DAYS_OF_WEEK = {
+ null, "Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"
+ };
+
+ static final String[] MONTHS = {
+ "Jan", "Feb", "Mar", "Apr", "May", "Jun",
+ "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"
+ };
+
+ public HTTPDateFormat()
+ {
+ calendar = new GregorianCalendar(TimeZone.getTimeZone ("GMT"));
+ numberFormat = new DecimalFormat();
+ }
+
+ /**
+ * Appends the textual value for the specified field to the given string
+ * buffer. This method should be avoided, use <code>format(Date)</code>
+ * instead.
+ * @param date the Date object
+ * @param buf the buffer to append to
+ * @param field the current field position
+ * @return the modified buffer
+ */
+ public StringBuffer format(Date date, StringBuffer buf,
+ FieldPosition field)
+ {
+ calendar.clear();
+ calendar.setTime(date);
+ buf.setLength(0);
+
+ // Day of week
+ buf.append(DAYS_OF_WEEK[calendar.get(Calendar.DAY_OF_WEEK)]);
+ buf.append(',');
+ buf.append(' ');
+
+ // Day of month
+ int day = calendar.get(Calendar.DAY_OF_MONTH);
+ buf.append(Character.forDigit(day / 10, 10));
+ buf.append(Character.forDigit(day % 10, 10));
+ buf.append(' ');
+
+ // Month
+ buf.append(MONTHS[calendar.get(Calendar.MONTH)]);
+ buf.append(' ');
+
+ // Year
+ int year = calendar.get(Calendar.YEAR);
+ if (year < 1000)
+ {
+ buf.append('0');
+ if (year < 100)
+ {
+ buf.append('0');
+ if (year < 10)
+ {
+ buf.append('0');
+ }
+ }
+ }
+ buf.append(Integer.toString(year));
+ buf.append(' ');
+
+ // Hour
+ int hour = calendar.get(Calendar.HOUR_OF_DAY);
+ buf.append(Character.forDigit(hour / 10, 10));
+ buf.append(Character.forDigit(hour % 10, 10));
+ buf.append(':');
+
+ // Minute
+ int minute = calendar.get(Calendar.MINUTE);
+ buf.append(Character.forDigit(minute / 10, 10));
+ buf.append(Character.forDigit(minute % 10, 10));
+ buf.append(':');
+
+ // Second
+ int second = calendar.get(Calendar.SECOND);
+ buf.append(Character.forDigit(second / 10, 10));
+ buf.append(Character.forDigit(second % 10, 10));
+ buf.append(' ');
+
+ // Timezone
+ // Get time offset in minutes
+ int zoneOffset =(calendar.get(Calendar.ZONE_OFFSET) +
+ calendar.get(Calendar.DST_OFFSET)) / 60000;
+
+ // Apply + or - appropriately
+ if (zoneOffset < 0)
+ {
+ zoneOffset = -zoneOffset;
+ buf.append('-');
+ }
+ else
+ {
+ buf.append('+');
+ }
+
+ // Set the 2 2-char fields as specified above
+ int tzhours = zoneOffset / 60;
+ buf.append(Character.forDigit(tzhours / 10, 10));
+ buf.append(Character.forDigit(tzhours % 10, 10));
+ int tzminutes = zoneOffset % 60;
+ buf.append(Character.forDigit(tzminutes / 10, 10));
+ buf.append(Character.forDigit(tzminutes % 10, 10));
+
+ field.setBeginIndex(0);
+ field.setEndIndex(buf.length());
+ return buf;
+ }
+
+ /**
+ * Parses the given date in the current TimeZone.
+ * @param text the formatted date to be parsed
+ * @param pos the current parse position
+ */
+ public Date parse(String text, ParsePosition pos)
+ {
+ int date, month, year, hour, minute, second;
+ String monthText;
+ int start = 0, end = -1;
+ int len = text.length();
+ calendar.clear();
+ pos.setIndex(start);
+ try
+ {
+ // Advance to date
+ if (Character.isLetter(text.charAt(start)))
+ {
+ start = skipNonWhitespace(text, start);
+ }
+ // Determine mode
+ switch(start)
+ {
+ case 3:
+ // asctime
+ start = skipWhitespace(text, start);
+ pos.setIndex(start);
+ end = skipNonWhitespace(text, start + 1);
+ monthText = text.substring(start, end);
+ month = -1;
+ for (int i = 0; i < 12; i++)
+ {
+ if (MONTHS[i].equals(monthText))
+ {
+ month = i;
+ break;
+ }
+ }
+ if (month == -1)
+ {
+ pos.setErrorIndex(end);
+ return null;
+ }
+ // Advance to date
+ start = skipWhitespace(text, end + 1);
+ pos.setIndex(start);
+ end = skipNonWhitespace(text, start + 1);
+ date = Integer.parseInt(text.substring(start, end));
+ // Advance to hour
+ start = skipWhitespace(text, end + 1);
+ pos.setIndex(start);
+ end = skipTo(text, start + 1, ':');
+ hour = Integer.parseInt(text.substring(start, end));
+ // Advance to minute
+ start = end + 1;
+ pos.setIndex(start);
+ end = skipTo(text, start + 1, ':');
+ minute = Integer.parseInt(text.substring(start, end));
+ // Advance to second
+ start = end + 1;
+ pos.setIndex(start);
+ end = skipNonWhitespace(text, start + 1);
+ second = Integer.parseInt(text.substring(start, end));
+ // Advance to year
+ start = skipWhitespace(text, end + 1);
+ pos.setIndex(start);
+ end = skipNonWhitespace(text, start + 1);
+ year = Integer.parseInt(text.substring(start, end));
+ break;
+ case 0:
+ case 4:
+ // rfc822
+ start = skipWhitespace(text, start);
+ pos.setIndex(start);
+ end = skipNonWhitespace(text, start + 1);
+ date = Integer.parseInt(text.substring(start, end));
+ // Advance to month
+ start = skipWhitespace(text, end + 1);
+ pos.setIndex(start);
+ end = skipNonWhitespace(text, start + 1);
+ monthText = text.substring(start, end);
+ month = -1;
+ for (int i = 0; i < 12; i++)
+ {
+ if (MONTHS[i].equals(monthText))
+ {
+ month = i;
+ break;
+ }
+ }
+ if (month == -1)
+ {
+ pos.setErrorIndex(end);
+ return null;
+ }
+ // Advance to year
+ start = skipWhitespace(text, end + 1);
+ pos.setIndex(start);
+ end = skipNonWhitespace(text, start + 1);
+ year = Integer.parseInt(text.substring(start, end));
+ // Advance to hour
+ start = skipWhitespace(text, end + 1);
+ pos.setIndex(start);
+ end = skipTo(text, start + 1, ':');
+ hour = Integer.parseInt(text.substring(start, end));
+ // Advance to minute
+ start = end + 1;
+ pos.setIndex(start);
+ end = skipTo(text, start + 1, ':');
+ minute = Integer.parseInt(text.substring(start, end));
+ // Advance to second
+ start = end + 1;
+ pos.setIndex(start);
+ end = start + 1;
+ while (end < len && !Character.isWhitespace(text.charAt(end)))
+ {
+ end++;
+ }
+ second = Integer.parseInt(text.substring(start, end));
+ break;
+ default:
+ // rfc850(obsolete)
+ start = skipWhitespace(text, start);
+ pos.setIndex(start);
+ end = skipTo(text, start + 1, '-');
+ date = Integer.parseInt(text.substring(start, end));
+ // Advance to month
+ start = end + 1;
+ pos.setIndex(start);
+ end = skipTo(text, start + 1, '-');
+ monthText = text.substring(start, end);
+ month = -1;
+ for (int i = 0; i < 12; i++)
+ {
+ if (MONTHS[i].equals(monthText))
+ {
+ month = i;
+ break;
+ }
+ }
+ if (month == -1)
+ {
+ pos.setErrorIndex(end);
+ return null;
+ }
+ // Advance to year
+ start = end + 1;
+ pos.setIndex(start);
+ end = skipNonWhitespace(text, start + 1);
+ year = 1900 + Integer.parseInt(text.substring(start, end));
+ // Advance to hour
+ start = skipWhitespace(text, end + 1);
+ pos.setIndex(start);
+ end = skipTo(text, start + 1, ':');
+ hour = Integer.parseInt(text.substring(start, end));
+ // Advance to minute
+ start = end + 1;
+ pos.setIndex(start);
+ end = skipTo(text, start + 1, ':');
+ minute = Integer.parseInt(text.substring(start, end));
+ // Advance to second
+ start = end + 1;
+ pos.setIndex(start);
+ end = start + 1;
+ while (end < len && !Character.isWhitespace(text.charAt(end)))
+ {
+ end++;
+ }
+ second = Integer.parseInt(text.substring(start, end));
+ }
+
+ calendar.set(Calendar.YEAR, year);
+ calendar.set(Calendar.MONTH, month);
+ calendar.set(Calendar.DAY_OF_MONTH, date);
+ calendar.set(Calendar.HOUR, hour);
+ calendar.set(Calendar.MINUTE, minute);
+ calendar.set(Calendar.SECOND, second);
+
+ if (end != len)
+ {
+ // Timezone
+ start = skipWhitespace(text, end + 1);
+ end = start + 1;
+ while (end < len && !Character.isWhitespace(text.charAt(end)))
+ {
+ end++;
+ }
+ char pm = text.charAt(start);
+ if (Character.isLetter(pm))
+ {
+ TimeZone tz =
+ TimeZone.getTimeZone(text.substring(start, end));
+ calendar.set(Calendar.ZONE_OFFSET, tz.getRawOffset());
+ }
+ else
+ {
+ int zoneOffset = 0;
+ zoneOffset += 600 * Character.digit(text.charAt(++start), 10);
+ zoneOffset += 60 * Character.digit(text.charAt(++start), 10);
+ zoneOffset += 10 * Character.digit(text.charAt(++start), 10);
+ zoneOffset += Character.digit(text.charAt(++start), 10);
+ zoneOffset *= 60000; // minutes -> ms
+ if ('-' == pm)
+ {
+ zoneOffset = -zoneOffset;
+ }
+ calendar.set(Calendar.ZONE_OFFSET, zoneOffset);
+ }
+ }
+ pos.setIndex(end);
+
+ return calendar.getTime();
+ }
+ catch (NumberFormatException e)
+ {
+ pos.setErrorIndex(Math.max(start, end));
+ }
+ catch (StringIndexOutOfBoundsException e)
+ {
+ pos.setErrorIndex(Math.max(start, end));
+ }
+ return null;
+ }
+
+ private int skipWhitespace(String text, int pos)
+ {
+ while(Character.isWhitespace(text.charAt(pos)))
+ {
+ pos++;
+ }
+ return pos;
+ }
+
+ private int skipNonWhitespace(String text, int pos)
+ {
+ while(!Character.isWhitespace(text.charAt(pos)))
+ {
+ pos++;
+ }
+ return pos;
+ }
+
+ private int skipTo(String text, int pos, char c)
+ {
+ while(text.charAt(pos) != c)
+ {
+ pos++;
+ }
+ return pos;
+ }
+
+ /**
+ * Don't allow setting the calendar.
+ */
+ public void setCalendar(Calendar newCalendar)
+ {
+ throw new UnsupportedOperationException();
+ }
+
+ /**
+ * Don't allow setting the NumberFormat.
+ */
+ public void setNumberFormat(NumberFormat newNumberFormat)
+ {
+ throw new UnsupportedOperationException();
+ }
+
+}
+
Added: llvm-gcc-4.2/trunk/libjava/classpath/gnu/java/net/protocol/http/HTTPURLConnection.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/gnu/java/net/protocol/http/HTTPURLConnection.java?rev=43913&view=auto
==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/gnu/java/net/protocol/http/HTTPURLConnection.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/gnu/java/net/protocol/http/HTTPURLConnection.java Thu Nov 8 16:56:19 2007
@@ -0,0 +1,687 @@
+/* HTTPURLConnection.java --
+ Copyright (C) 2004, 2005, 2006 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 gnu.java.net.protocol.http;
+
+import gnu.classpath.SystemProperties;
+
+import java.io.ByteArrayOutputStream;
+import java.io.FileNotFoundException;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.net.ProtocolException;
+import java.net.URL;
+import java.security.cert.Certificate;
+import java.util.Collections;
+import java.util.Date;
+import java.util.Map;
+
+import javax.net.ssl.HandshakeCompletedEvent;
+import javax.net.ssl.HandshakeCompletedListener;
+import javax.net.ssl.HostnameVerifier;
+import javax.net.ssl.HttpsURLConnection;
+import javax.net.ssl.SSLPeerUnverifiedException;
+import javax.net.ssl.SSLSocketFactory;
+
+/**
+ * A URLConnection that uses the HTTPConnection class.
+ *
+ * @author Chris Burdess (dog at gnu.org)
+ */
+public class HTTPURLConnection
+ extends HttpsURLConnection
+ implements HandshakeCompletedListener
+{
+ /*
+ * The underlying connection.
+ */
+ private HTTPConnection connection;
+
+ // These are package private for use in anonymous inner classes.
+ String proxyHostname;
+ int proxyPort;
+ String agent;
+ boolean keepAlive;
+
+ private Request request;
+ private Headers requestHeaders;
+ private ByteArrayOutputStream requestSink;
+ private boolean requestMethodSetExplicitly;
+
+ private Response response;
+ private InputStream responseSink;
+ private InputStream errorSink;
+
+ private HandshakeCompletedEvent handshakeEvent;
+
+ /**
+ * Constructor.
+ * @param url the URL
+ */
+ public HTTPURLConnection(URL url)
+ throws IOException
+ {
+ super(url);
+ requestHeaders = new Headers();
+ proxyHostname = SystemProperties.getProperty("http.proxyHost");
+ if (proxyHostname != null && proxyHostname.length() > 0)
+ {
+ String port = SystemProperties.getProperty("http.proxyPort");
+ if (port != null && port.length() > 0)
+ {
+ proxyPort = Integer.parseInt(port);
+ }
+ else
+ {
+ proxyHostname = null;
+ proxyPort = -1;
+ }
+ }
+ agent = SystemProperties.getProperty("http.agent");
+ String ka = SystemProperties.getProperty("http.keepAlive");
+ keepAlive = !(ka != null && "false".equals(ka));
+ }
+
+ public void connect()
+ throws IOException
+ {
+ if (connected)
+ {
+ return;
+ }
+ String protocol = url.getProtocol();
+ boolean secure = "https".equals(protocol);
+ String host = url.getHost();
+ int port = url.getPort();
+ if (port < 0)
+ {
+ port = secure ? HTTPConnection.HTTPS_PORT :
+ HTTPConnection.HTTP_PORT;
+ }
+ String file = url.getFile();
+ String username = url.getUserInfo();
+ String password = null;
+ if (username != null)
+ {
+ int ci = username.indexOf(':');
+ if (ci != -1)
+ {
+ password = username.substring(ci + 1);
+ username = username.substring(0, ci);
+ }
+ }
+ final Credentials creds = (username == null) ? null :
+ new Credentials (username, password);
+
+ if ("POST".equals(method))
+ {
+ String contentType = requestHeaders.getValue("Content-Type");
+ if (null == contentType)
+ requestHeaders.addValue("Content-Type",
+ "application/x-www-form-urlencoded");
+ }
+
+ boolean retry;
+ do
+ {
+ retry = false;
+ if (connection == null)
+ {
+ connection = getConnection(host, port, secure);
+ if (secure)
+ {
+ SSLSocketFactory factory = getSSLSocketFactory();
+ HostnameVerifier verifier = getHostnameVerifier();
+ if (factory != null)
+ {
+ connection.setSSLSocketFactory(factory);
+ }
+ connection.addHandshakeCompletedListener(this);
+ // TODO verifier
+ }
+ }
+ if (proxyHostname != null)
+ {
+ if (proxyPort < 0)
+ {
+ proxyPort = secure ? HTTPConnection.HTTPS_PORT :
+ HTTPConnection.HTTP_PORT;
+ }
+ connection.setProxy(proxyHostname, proxyPort);
+ }
+ try
+ {
+ request = connection.newRequest(method, file);
+ if (!keepAlive)
+ {
+ request.setHeader("Connection", "close");
+ }
+ if (agent != null)
+ {
+ request.setHeader("User-Agent", agent);
+ }
+ request.getHeaders().putAll(requestHeaders);
+ if (requestSink != null)
+ {
+ byte[] content = requestSink.toByteArray();
+ RequestBodyWriter writer = new ByteArrayRequestBodyWriter(content);
+ request.setRequestBodyWriter(writer);
+ }
+ if (creds != null)
+ {
+ request.setAuthenticator(new Authenticator() {
+ public Credentials getCredentials(String realm, int attempts)
+ {
+ return (attempts < 2) ? creds : null;
+ }
+ });
+ }
+ response = request.dispatch();
+ }
+ catch (IOException ioe)
+ {
+ if (connection.useCount > 0)
+ {
+ // Connection re-use failed: Try a new connection.
+ try
+ {
+ connection.close();
+ }
+ catch (IOException _)
+ {
+ // Ignore.
+ }
+ connection = null;
+ retry = true;
+ continue;
+ }
+ else
+ {
+ // First time the connection was used: Hard failure.
+ throw ioe;
+ }
+ }
+
+ if (response.isRedirect() && getInstanceFollowRedirects())
+ {
+ // Read the response body, if there is one. If the
+ // redirect points us back at the same server, we will use
+ // the cached connection, so we must make sure there is no
+ // pending data in it.
+ InputStream body = response.getBody();
+ if (body != null)
+ {
+ byte[] ignore = new byte[1024];
+ while (true)
+ {
+ int n = body.read(ignore, 0, ignore.length);
+ if (n == -1)
+ break;
+ }
+ }
+
+ // Follow redirect
+ String location = response.getHeader("Location");
+ if (location != null)
+ {
+ String connectionUri = connection.getURI();
+ int start = connectionUri.length();
+ if (location.startsWith(connectionUri) &&
+ location.charAt(start) == '/')
+ {
+ file = location.substring(start);
+ retry = true;
+ }
+ else if (location.startsWith("http:"))
+ {
+ connection.close();
+ connection = null;
+ secure = false;
+ start = 7;
+ int end = location.indexOf('/', start);
+ if (end == -1)
+ end = location.length();
+ host = location.substring(start, end);
+ int ci = host.lastIndexOf(':');
+ if (ci != -1)
+ {
+ port = Integer.parseInt(host.substring (ci + 1));
+ host = host.substring(0, ci);
+ }
+ else
+ {
+ port = HTTPConnection.HTTP_PORT;
+ }
+ file = location.substring(end);
+ retry = true;
+ }
+ else if (location.startsWith("https:"))
+ {
+ connection.close();
+ connection = null;
+ secure = true;
+ start = 8;
+ int end = location.indexOf('/', start);
+ if (end == -1)
+ end = location.length();
+ host = location.substring(start, end);
+ int ci = host.lastIndexOf(':');
+ if (ci != -1)
+ {
+ port = Integer.parseInt(host.substring (ci + 1));
+ host = host.substring(0, ci);
+ }
+ else
+ {
+ port = HTTPConnection.HTTPS_PORT;
+ }
+ file = location.substring(end);
+ retry = true;
+ }
+ else if (location.length() > 0)
+ {
+ // Malformed absolute URI, treat as file part of URI
+ if (location.charAt(0) == '/')
+ {
+ // Absolute path
+ file = location;
+ }
+ else
+ {
+ // Relative path
+ int lsi = file.lastIndexOf('/');
+ file = (lsi == -1) ? "/" : file.substring(0, lsi + 1);
+ file += location;
+ }
+ retry = true;
+ }
+ }
+ }
+ else
+ {
+ responseSink = response.getBody();
+
+ if (response.isError())
+ errorSink = responseSink;
+ }
+ }
+ while (retry);
+ connected = true;
+ }
+
+ /**
+ * Returns a connection, from the pool if necessary.
+ */
+ HTTPConnection getConnection(String host, int port, boolean secure)
+ throws IOException
+ {
+ HTTPConnection connection;
+ if (keepAlive)
+ {
+ connection = HTTPConnection.Pool.instance.get(host, port, secure, getConnectTimeout(), 0);
+ }
+ else
+ {
+ connection = new HTTPConnection(host, port, secure, 0, getConnectTimeout());
+ }
+ return connection;
+ }
+
+ public void disconnect()
+ {
+ if (connection != null)
+ {
+ try
+ {
+ connection.close();
+ }
+ catch (IOException e)
+ {
+ }
+ }
+ }
+
+ public boolean usingProxy()
+ {
+ return (proxyHostname != null);
+ }
+
+ /**
+ * Overrides the corresponding method in HttpURLConnection to permit
+ * arbitrary methods, as long as they're valid ASCII alphabetic
+ * characters. This is to permit WebDAV and other HTTP extensions to
+ * function.
+ * @param method the method
+ */
+ public void setRequestMethod(String method)
+ throws ProtocolException
+ {
+ if (connected)
+ {
+ throw new ProtocolException("Already connected");
+ }
+ // Validate
+ method = method.toUpperCase();
+ int len = method.length();
+ if (len == 0)
+ {
+ throw new ProtocolException("Empty method name");
+ }
+ for (int i = 0; i < len; i++)
+ {
+ char c = method.charAt(i);
+ if (c < 0x41 || c > 0x5a)
+ {
+ throw new ProtocolException("Illegal character '" + c +
+ "' at index " + i);
+ }
+ }
+ // OK
+ this.method = method;
+ requestMethodSetExplicitly = true;
+ }
+
+ public String getRequestProperty(String key)
+ {
+ return requestHeaders.getValue(key);
+ }
+
+ public Map getRequestProperties()
+ {
+ if (connected)
+ throw new IllegalStateException("Already connected");
+
+ Map m = requestHeaders.getAsMap();
+ return Collections.unmodifiableMap(m);
+ }
+
+ public void setRequestProperty(String key, String value)
+ {
+ super.setRequestProperty(key, value);
+
+ requestHeaders.put(key, value);
+ }
+
+ public void addRequestProperty(String key, String value)
+ {
+ super.addRequestProperty(key, value);
+ requestHeaders.addValue(key, value);
+ }
+
+ public OutputStream getOutputStream()
+ throws IOException
+ {
+ if (connected)
+ {
+ throw new ProtocolException("Already connected");
+ }
+ if (!doOutput)
+ {
+ throw new ProtocolException("doOutput is false");
+ }
+ else if (!requestMethodSetExplicitly)
+ {
+ /*
+ * Silently change the method to POST if no method was set
+ * explicitly. This is due to broken applications depending on this
+ * behaviour (Apache XMLRPC for one).
+ */
+ method = "POST";
+ }
+ if (requestSink == null)
+ {
+ requestSink = new ByteArrayOutputStream();
+ }
+ return requestSink;
+ }
+
+ // -- Response --
+
+ public InputStream getInputStream()
+ throws IOException
+ {
+ if (!connected)
+ {
+ connect();
+ }
+ if (!doInput)
+ {
+ throw new ProtocolException("doInput is false");
+ }
+
+ if (response.isError())
+ {
+ int code = response.getCode();
+ if (code == 404 || code == 410)
+ throw new FileNotFoundException(url.toString());
+
+ throw new IOException("Server returned HTTP response code " + code
+ + " for URL " + url.toString());
+ }
+
+ return responseSink;
+ }
+
+ public InputStream getErrorStream()
+ {
+ return errorSink;
+ }
+
+ public Map getHeaderFields()
+ {
+ if (!connected)
+ {
+ try
+ {
+ connect();
+ }
+ catch (IOException e)
+ {
+ return null;
+ }
+ }
+ Map m = response.getHeaders().getAsMap();
+ m.put(null, Collections.singletonList(getStatusLine(response)));
+ return Collections.unmodifiableMap(m);
+ }
+
+ String getStatusLine(Response response)
+ {
+ return "HTTP/" + response.getMajorVersion() +
+ "." + response.getMinorVersion() +
+ " " + response.getCode() +
+ " " + response.getMessage();
+ }
+
+ public String getHeaderField(int index)
+ {
+ if (!connected)
+ {
+ try
+ {
+ connect();
+ }
+ catch (IOException e)
+ {
+ return null;
+ }
+ }
+ if (index == 0)
+ {
+ return getStatusLine(response);
+ }
+ return response.getHeaders().getHeaderValue(index - 1);
+ }
+
+ public String getHeaderFieldKey(int index)
+ {
+ if (!connected)
+ {
+ try
+ {
+ connect();
+ }
+ catch (IOException e)
+ {
+ return null;
+ }
+ }
+ // index of zero is the status line.
+ return response.getHeaders().getHeaderName(index - 1);
+ }
+
+ public String getHeaderField(String name)
+ {
+ if (!connected)
+ {
+ try
+ {
+ connect();
+ }
+ catch (IOException e)
+ {
+ return null;
+ }
+ }
+ return response.getHeader(name);
+ }
+
+ public long getHeaderFieldDate(String name, long def)
+ {
+ if (!connected)
+ {
+ try
+ {
+ connect();
+ }
+ catch (IOException e)
+ {
+ return def;
+ }
+ }
+ Date date = response.getDateHeader(name);
+ return (date == null) ? def : date.getTime();
+ }
+
+ public String getContentType()
+ {
+ return getHeaderField("Content-Type");
+ }
+
+ public int getResponseCode()
+ throws IOException
+ {
+ if (!connected)
+ {
+ connect();
+ }
+ return response.getCode();
+ }
+
+ public String getResponseMessage()
+ throws IOException
+ {
+ if (!connected)
+ {
+ connect();
+ }
+ return response.getMessage();
+ }
+
+ // -- HTTPS specific --
+
+ public String getCipherSuite()
+ {
+ if (!connected)
+ {
+ throw new IllegalStateException("not connected");
+ }
+ return handshakeEvent.getCipherSuite();
+ }
+
+ public Certificate[] getLocalCertificates()
+ {
+ if (!connected)
+ {
+ throw new IllegalStateException("not connected");
+ }
+ return handshakeEvent.getLocalCertificates();
+ }
+
+ public Certificate[] getServerCertificates()
+ throws SSLPeerUnverifiedException
+ {
+ if (!connected)
+ {
+ throw new IllegalStateException("not connected");
+ }
+ return handshakeEvent.getPeerCertificates();
+ }
+
+ // HandshakeCompletedListener
+
+ public void handshakeCompleted(HandshakeCompletedEvent event)
+ {
+ handshakeEvent = event;
+ }
+
+ /**
+ * Set the connection timeout speed, in milliseconds, or zero if the timeout
+ * is to be considered infinite.
+ *
+ * Overloaded.
+ *
+ */
+ public void setConnectTimeout(int timeout)
+ throws IllegalArgumentException
+ {
+ super.setConnectTimeout( timeout );
+ if( connection == null )
+ return;
+ try
+ {
+ connection.getSocket().setSoTimeout( timeout );
+ }
+ catch(IOException se)
+ {
+ // Ignore socket exceptions.
+ }
+ }
+}
+
Added: llvm-gcc-4.2/trunk/libjava/classpath/gnu/java/net/protocol/http/Handler.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/gnu/java/net/protocol/http/Handler.java?rev=43913&view=auto
==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/gnu/java/net/protocol/http/Handler.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/gnu/java/net/protocol/http/Handler.java Thu Nov 8 16:56:19 2007
@@ -0,0 +1,73 @@
+/* Handler.java --
+ Copyright (C) 2004 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 gnu.java.net.protocol.http;
+
+import java.io.IOException;
+import java.net.URL;
+import java.net.URLConnection;
+import java.net.URLStreamHandler;
+
+/**
+ * An HTTP URL stream handler.
+ *
+ * @author Chris Burdess (dog at gnu.org)
+ */
+public class Handler
+ extends URLStreamHandler
+{
+
+ /**
+ * Returns the default HTTP port (80).
+ */
+ protected int getDefaultPort()
+ {
+ return HTTPConnection.HTTP_PORT;
+ }
+
+ /**
+ * Returns an HTTPURLConnection for the given URL.
+ */
+ public URLConnection openConnection(URL url)
+ throws IOException
+ {
+ return new HTTPURLConnection(url);
+ }
+
+}
+
Added: llvm-gcc-4.2/trunk/libjava/classpath/gnu/java/net/protocol/http/Headers.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/gnu/java/net/protocol/http/Headers.java?rev=43913&view=auto
==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/gnu/java/net/protocol/http/Headers.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/gnu/java/net/protocol/http/Headers.java Thu Nov 8 16:56:19 2007
@@ -0,0 +1,421 @@
+/* Headers.java --
+ Copyright (C) 2004, 2006 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 gnu.java.net.protocol.http;
+
+import gnu.java.net.LineInputStream;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.text.DateFormat;
+import java.text.ParseException;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.Date;
+import java.util.Iterator;
+import java.util.LinkedHashMap;
+import java.util.Map;
+
+/**
+ * A collection of HTTP header names and associated values. The
+ * values are {@link ArrayList ArrayLists} of Strings. Retrieval of
+ * values is case insensitive. An iteration over the collection
+ * returns the header names in the order they were received.
+ *
+ * @author Chris Burdess (dog at gnu.org)
+ * @author David Daney (ddaney at avtrex.com)
+ */
+class Headers
+{
+ /**
+ * A list of HeaderElements
+ */
+ private final ArrayList headers = new ArrayList();
+
+ /**
+ * The HTTP dateformat used to parse date header fields.
+ */
+ private static final DateFormat dateFormat = new HTTPDateFormat();
+
+ /**
+ * Class for a Header element consisting of
+ * a name and value String.
+ */
+ static class HeaderElement
+ {
+ String name;
+ String value;
+
+ HeaderElement(String name, String value)
+ {
+ this.name = name;
+ this.value = value;
+ }
+ }
+
+ /**
+ * Default constructor.
+ */
+ public Headers()
+ {
+ // nothing to do
+ }
+
+ /**
+ * Return an Iterator over this collection of headers.
+ * Iterator.getNext() returns objects of type {@link HeaderElement}.
+ *
+ * @return the Iterator.
+ */
+ Iterator iterator()
+ {
+ return headers.iterator();
+ }
+
+ /**
+ * Returns the value of the specified header as a string. If
+ * multiple values are present, the last one is returned.
+ *
+ * @param header the header name (case insensitive search)
+ * @return The header value or <code>null</code> if not found.
+ */
+ public String getValue(String header)
+ {
+ for (int i = headers.size() - 1; i >= 0; i--)
+ {
+ HeaderElement e = (HeaderElement)headers.get(i);
+ if (e.name.equalsIgnoreCase(header))
+ {
+ return e.value;
+ }
+ }
+ return null;
+ }
+
+ /**
+ * Returns the value of the specified header as an integer. If
+ * multiple values are present, the last one is returned.
+ *
+ * @param header the header name (case insensitive search)
+ * @return The header value or <code>-1</code> if not present or
+ * not an integer value.
+ */
+ public int getIntValue(String header)
+ {
+ String val = getValue(header);
+ if (val == null)
+ {
+ return -1;
+ }
+ try
+ {
+ return Integer.parseInt(val);
+ }
+ catch (NumberFormatException e)
+ {
+ // fall through
+ }
+ return -1;
+ }
+
+ /**
+ * Returns the value of the specified header as a long. If
+ * multiple values are present, the last one is returned.
+ *
+ * @param header the header name (case insensitive search)
+ * @return The header value or <code>-1</code> if not present or
+ * not a long value.
+ */
+ public long getLongValue(String header)
+ {
+ String val = getValue(header);
+ if (val == null)
+ {
+ return -1;
+ }
+ try
+ {
+ return Long.parseLong(val);
+ }
+ catch (NumberFormatException e)
+ {
+ // fall through
+ }
+ return -1;
+ }
+
+ /**
+ * Returns the value of the specified header as a date. If
+ * multiple values are present, the last one is returned.
+ *
+ * @param header the header name (case insensitive search)
+ * @return The header value or <code>null</code> if not present or
+ * not a date value.
+ */
+ public Date getDateValue(String header)
+ {
+ String val = getValue(header);
+ if (val == null)
+ {
+ return null;
+ }
+ try
+ {
+ return dateFormat.parse(val);
+ }
+ catch (ParseException e)
+ {
+ return null;
+ }
+ }
+
+ /**
+ * Add a header to this set of headers. If there is an existing
+ * header with the same name it's value is replaced with the new value.
+ * If multiple headers of the same name exist only the last one's value
+ * is replaced.
+ *
+ * @param name the header name
+ * @param value the header value
+ *
+ * @see #addValue(String, String)
+ */
+ public void put(String name, String value)
+ {
+ for (int i = headers.size() - 1; i >= 0; i--)
+ {
+ HeaderElement e = (HeaderElement)headers.get(i);
+ if (e.name.equalsIgnoreCase(name))
+ {
+ e.value = value;
+ return;
+ }
+ }
+
+ // nothing was replaced so add it as new HeaderElement
+ addValue(name, value);
+ }
+
+ /**
+ * Add all headers from a set of headers to this set. Any existing header
+ * with the same (case insensitive) name as one of the new headers will
+ * be overridden.
+ *
+ * @param o the headers to be added
+ */
+ public void putAll(Headers o)
+ {
+ for (Iterator it = o.iterator(); it.hasNext(); )
+ {
+ HeaderElement e = (HeaderElement)it.next();
+ remove(e.name);
+ addValue(e.name, e.value);
+ }
+ }
+
+ /**
+ * Remove a header from this set of headers. If there is more than
+ * one instance of a header of the given name, they are all removed.
+ *
+ * @param name the header name
+ */
+ public void remove(String name)
+ {
+ for (Iterator it = headers.iterator(); it.hasNext(); )
+ {
+ HeaderElement e = (HeaderElement)it.next();
+ if (e.name.equalsIgnoreCase(name))
+ it.remove();
+ }
+ }
+
+ /**
+ * Parse the specified InputStream, adding headers to this collection.
+ *
+ * @param in the InputStream.
+ * @throws IOException if I/O error occured.
+ */
+ public void parse(InputStream in)
+ throws IOException
+ {
+ LineInputStream lin = (in instanceof LineInputStream) ?
+ (LineInputStream) in : new LineInputStream(in);
+
+ String name = null;
+ StringBuilder value = new StringBuilder();
+ while (true)
+ {
+ String line = lin.readLine();
+ if (line == null)
+ {
+ if (name != null)
+ {
+ addValue(name, value.toString());
+ }
+ break;
+ }
+ int len = line.length();
+ if (len < 2)
+ {
+ if (name != null)
+ {
+ addValue(name, value.toString());
+ }
+ break;
+ }
+ char c1 = line.charAt(0);
+ if (c1 == ' ' || c1 == '\t')
+ {
+ // Continuation
+ int last = len - 1;
+ if (line.charAt(last) != '\r')
+ ++last;
+ value.append(line.substring(0, last));
+ }
+ else
+ {
+ if (name != null)
+ {
+ addValue(name, value.toString());
+ }
+
+ int di = line.indexOf(':');
+ name = line.substring(0, di);
+ value.setLength(0);
+ do
+ {
+ di++;
+ }
+ while (di < len && line.charAt(di) == ' ');
+ int last = len - 1;
+ if (line.charAt(last) != '\r')
+ ++last;
+ value.append(line.substring(di, last));
+ }
+ }
+ }
+
+
+ /**
+ * Add a header to this set of headers. If there is an existing
+ * header with the same name, it is not effected.
+ *
+ * @param name the header name
+ * @param value the header value
+ *
+ * @see #put(String, String)
+ */
+ public void addValue(String name, String value)
+ {
+ headers.add(headers.size(), new HeaderElement(name, value));
+ }
+
+ /**
+ * Get a new Map containing all the headers. The keys of the Map
+ * are Strings (the header names). The headers will be included
+ * case-sensitive in the map so that querying must be done with the
+ * correct case of the needed header name. The values of the Map are
+ * unmodifiable Lists containing Strings (the header values).
+ *
+ * <p>
+ * The returned map is modifiable. Changing it will not effect this
+ * collection of Headers in any way.</p>
+ *
+ * @return a Map containing all the headers.
+ */
+ public Map getAsMap()
+ {
+ LinkedHashMap m = new LinkedHashMap();
+ for (Iterator it = headers.iterator(); it.hasNext(); )
+ {
+ HeaderElement e = (HeaderElement)it.next();
+ ArrayList l = (ArrayList)m.get(e.name);
+ if (l == null)
+ {
+ l = new ArrayList(1);
+ l.add(e.value);
+ m.put(e.name, l);
+ }
+ else
+ l.add(0, e.value);
+ }
+ for (Iterator it = m.entrySet().iterator(); it.hasNext(); )
+ {
+ Map.Entry me = (Map.Entry)it.next();
+ ArrayList l = (ArrayList)me.getValue();
+ me.setValue(Collections.unmodifiableList(l));
+ }
+ return m;
+ }
+
+ /**
+ * Get the name of the Nth header.
+ *
+ * @param i the header index.
+ *
+ * @return The header name, or <code>null</code> if index outside of range.
+ *
+ * @see #getHeaderValue(int)
+ */
+ public String getHeaderName(int i)
+ {
+ if (i >= headers.size() || i < 0)
+ return null;
+
+ return ((HeaderElement)headers.get(i)).name;
+ }
+
+ /**
+ * Get the value of the Nth header.
+ *
+ * @param i the header index.
+ *
+ * @return the header value, or <code>null</code> if index outside of range.
+ *
+ * @see #getHeaderName(int)
+ */
+ public String getHeaderValue(int i)
+ {
+ if (i >= headers.size() || i < 0)
+ return null;
+
+ return ((HeaderElement)headers.get(i)).value;
+ }
+
+}
+
Added: llvm-gcc-4.2/trunk/libjava/classpath/gnu/java/net/protocol/http/LimitedLengthInputStream.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/gnu/java/net/protocol/http/LimitedLengthInputStream.java?rev=43913&view=auto
==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/gnu/java/net/protocol/http/LimitedLengthInputStream.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/gnu/java/net/protocol/http/LimitedLengthInputStream.java Thu Nov 8 16:56:19 2007
@@ -0,0 +1,220 @@
+/* LimitedLengthInputStream.java --
+ Copyright (C) 2005 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 gnu.java.net.protocol.http;
+
+import java.io.IOException;
+import java.io.InputStream;
+
+/**
+ * InputStream that limits the total number of bytes that can be read
+ * from an underlying stream. In addition to limiting the number of
+ * bytes read, close() is not propagated to the underlying stream.
+ *
+ * @author David Daney (ddaney at avtrex.com)
+ */
+class LimitedLengthInputStream
+ extends InputStream
+{
+ private long remainingLen;
+ private boolean restrictLen;
+ private HTTPConnection connection;
+ private boolean eof;
+ private InputStream in;
+ private boolean doClose;
+
+
+ private void handleClose()
+ throws IOException
+ {
+ eof = true;
+ if (doClose)
+ {
+ in.close();
+ }
+ else
+ {
+ connection.release();
+ }
+ in = null;
+ connection = null;
+ }
+
+ /**
+ * Constructor.
+ *
+ * @param in the underlying stream
+ *
+ * @param maxLen the maximum number of bytes to read
+ *
+ * @param restrictLen if true the number of bytes that can be read
+ * from this stream will be limited to maxLen, otherwise the number
+ * of bytes is not restricted.
+ *
+ * @param con the HTTPConnection associated with this stream
+ *
+ * @param doClose if true con will be closed when finished reading,
+ * else it will be placed back in the connection pool.
+ *
+ */
+ LimitedLengthInputStream(InputStream in,
+ long maxLen,
+ boolean restrictLen,
+ HTTPConnection con,
+ boolean doClose)
+ throws IOException
+
+ {
+ this.in = in;
+ this.remainingLen = maxLen;
+ this.restrictLen = restrictLen;
+ this.connection = con;
+ this.doClose = doClose;
+
+ if (restrictLen)
+ {
+ if (maxLen < 0)
+ throw new IllegalArgumentException();
+ else if (maxLen == 0)
+ handleClose(); // Nothing to do, release the connection.
+ }
+ }
+
+ public synchronized int read()
+ throws IOException
+ {
+ if (eof)
+ return -1; // EOF
+
+ int r;
+
+ if (restrictLen)
+ {
+ r = in.read();
+ if (-1 != r)
+ remainingLen--;
+
+ if (0 == remainingLen)
+ handleClose();
+ }
+ else
+ {
+ r = in.read();
+ if (r == -1)
+ handleClose();
+ }
+
+ return r;
+ }
+
+ public int read(byte[] buffer)
+ throws IOException
+ {
+ return read(buffer, 0, buffer.length);
+ }
+
+ public synchronized int read(byte[] buffer, int offset, int length)
+ throws IOException
+ {
+ if (eof)
+ return -1; // EOF
+
+ if (restrictLen && length > remainingLen)
+ length = (int) remainingLen;
+
+ int r = in.read(buffer, offset, length);
+
+ if (-1 == r)
+ handleClose();
+
+ if (restrictLen && r > 0)
+ {
+ remainingLen -= r;
+ if (0 == remainingLen)
+ handleClose();
+ }
+ return r;
+ }
+
+ public synchronized long skip(long n)
+ throws IOException
+ {
+
+ if (eof)
+ return 0;
+
+ if (restrictLen && n > remainingLen)
+ n = remainingLen;
+
+ long r = in.skip(n);
+
+ if (restrictLen)
+ {
+ remainingLen -= r;
+ if (0 == remainingLen)
+ handleClose();
+ }
+ return r;
+ }
+
+ public synchronized int available()
+ throws IOException
+ {
+ if (eof)
+ return 0;
+
+ int a = in.available();
+ if (restrictLen && a > remainingLen)
+ a = (int)remainingLen;
+ return a;
+ }
+
+ public synchronized void close()
+ throws IOException
+ {
+ if (eof)
+ return;
+
+ // If we get to here, the stream was not fully read. Just throw
+ // it away.
+
+ doClose = true;
+
+ handleClose();
+ }
+}
Added: llvm-gcc-4.2/trunk/libjava/classpath/gnu/java/net/protocol/http/Request.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/gnu/java/net/protocol/http/Request.java?rev=43913&view=auto
==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/gnu/java/net/protocol/http/Request.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/gnu/java/net/protocol/http/Request.java Thu Nov 8 16:56:19 2007
@@ -0,0 +1,861 @@
+/* Request.java --
+ Copyright (C) 2004, 2005, 2006 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 gnu.java.net.protocol.http;
+
+import gnu.java.net.BASE64;
+import gnu.java.net.LineInputStream;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.net.ProtocolException;
+import java.security.MessageDigest;
+import java.security.NoSuchAlgorithmException;
+import java.text.DateFormat;
+import java.text.ParseException;
+import java.util.Calendar;
+import java.util.Date;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.Map;
+import java.util.Properties;
+import java.util.zip.GZIPInputStream;
+import java.util.zip.InflaterInputStream;
+
+/**
+ * A single HTTP request.
+ *
+ * @author Chris Burdess (dog at gnu.org)
+ */
+public class Request
+{
+
+ /**
+ * The connection context in which this request is invoked.
+ */
+ protected final HTTPConnection connection;
+
+ /**
+ * The HTTP method to invoke.
+ */
+ protected final String method;
+
+ /**
+ * The path identifying the resource.
+ * This string must conform to the abs_path definition given in RFC2396,
+ * with an optional "?query" part, and must be URI-escaped by the caller.
+ */
+ protected final String path;
+
+ /**
+ * The headers in this request.
+ */
+ protected final Headers requestHeaders;
+
+ /**
+ * The request body provider.
+ */
+ protected RequestBodyWriter requestBodyWriter;
+
+ /**
+ * Map of response header handlers.
+ */
+ protected Map responseHeaderHandlers;
+
+ /**
+ * The authenticator.
+ */
+ protected Authenticator authenticator;
+
+ /**
+ * Whether this request has been dispatched yet.
+ */
+ private boolean dispatched;
+
+ /**
+ * Constructor for a new request.
+ * @param connection the connection context
+ * @param method the HTTP method
+ * @param path the resource path including query part
+ */
+ protected Request(HTTPConnection connection, String method,
+ String path)
+ {
+ this.connection = connection;
+ this.method = method;
+ this.path = path;
+ requestHeaders = new Headers();
+ responseHeaderHandlers = new HashMap();
+ }
+
+ /**
+ * Returns the connection associated with this request.
+ * @see #connection
+ */
+ public HTTPConnection getConnection()
+ {
+ return connection;
+ }
+
+ /**
+ * Returns the HTTP method to invoke.
+ * @see #method
+ */
+ public String getMethod()
+ {
+ return method;
+ }
+
+ /**
+ * Returns the resource path.
+ * @see #path
+ */
+ public String getPath()
+ {
+ return path;
+ }
+
+ /**
+ * Returns the full request-URI represented by this request, as specified
+ * by HTTP/1.1.
+ */
+ public String getRequestURI()
+ {
+ return connection.getURI() + path;
+ }
+
+ /**
+ * Returns the headers in this request.
+ */
+ public Headers getHeaders()
+ {
+ return requestHeaders;
+ }
+
+ /**
+ * Returns the value of the specified header in this request.
+ * @param name the header name
+ */
+ public String getHeader(String name)
+ {
+ return requestHeaders.getValue(name);
+ }
+
+ /**
+ * Returns the value of the specified header in this request as an integer.
+ * @param name the header name
+ */
+ public int getIntHeader(String name)
+ {
+ return requestHeaders.getIntValue(name);
+ }
+
+ /**
+ * Returns the value of the specified header in this request as a date.
+ * @param name the header name
+ */
+ public Date getDateHeader(String name)
+ {
+ return requestHeaders.getDateValue(name);
+ }
+
+ /**
+ * Sets the specified header in this request.
+ * @param name the header name
+ * @param value the header value
+ */
+ public void setHeader(String name, String value)
+ {
+ requestHeaders.put(name, value);
+ }
+
+ /**
+ * Convenience method to set the entire request body.
+ * @param requestBody the request body content
+ */
+ public void setRequestBody(byte[] requestBody)
+ {
+ setRequestBodyWriter(new ByteArrayRequestBodyWriter(requestBody));
+ }
+
+ /**
+ * Sets the request body provider.
+ * @param requestBodyWriter the handler used to obtain the request body
+ */
+ public void setRequestBodyWriter(RequestBodyWriter requestBodyWriter)
+ {
+ this.requestBodyWriter = requestBodyWriter;
+ }
+
+ /**
+ * Sets a callback handler to be invoked for the specified header name.
+ * @param name the header name
+ * @param handler the handler to receive the value for the header
+ */
+ public void setResponseHeaderHandler(String name,
+ ResponseHeaderHandler handler)
+ {
+ responseHeaderHandlers.put(name, handler);
+ }
+
+ /**
+ * Sets an authenticator that can be used to handle authentication
+ * automatically.
+ * @param authenticator the authenticator
+ */
+ public void setAuthenticator(Authenticator authenticator)
+ {
+ this.authenticator = authenticator;
+ }
+
+ /**
+ * Dispatches this request.
+ * A request can only be dispatched once; calling this method a second
+ * time results in a protocol exception.
+ * @exception IOException if an I/O error occurred
+ * @return an HTTP response object representing the result of the operation
+ */
+ public Response dispatch()
+ throws IOException
+ {
+ if (dispatched)
+ {
+ throw new ProtocolException("request already dispatched");
+ }
+ final String CRLF = "\r\n";
+ final String HEADER_SEP = ": ";
+ final String US_ASCII = "US-ASCII";
+ final String version = connection.getVersion();
+ Response response;
+ int contentLength = -1;
+ boolean retry = false;
+ int attempts = 0;
+ boolean expectingContinue = false;
+ if (requestBodyWriter != null)
+ {
+ contentLength = requestBodyWriter.getContentLength();
+ String expect = getHeader("Expect");
+ if (expect != null && expect.equals("100-continue"))
+ {
+ expectingContinue = true;
+ }
+ else
+ {
+ setHeader("Content-Length", Integer.toString(contentLength));
+ }
+ }
+
+ try
+ {
+ // Loop while authentication fails or continue
+ do
+ {
+ retry = false;
+
+ // Get socket output and input streams
+ OutputStream out = connection.getOutputStream();
+
+ // Request line
+ String requestUri = path;
+ if (connection.isUsingProxy() &&
+ !"*".equals(requestUri) &&
+ !"CONNECT".equals(method))
+ {
+ requestUri = getRequestURI();
+ }
+ String line = method + ' ' + requestUri + ' ' + version + CRLF;
+ out.write(line.getBytes(US_ASCII));
+ // Request headers
+ for (Iterator i = requestHeaders.iterator(); i.hasNext(); )
+ {
+ Headers.HeaderElement elt = (Headers.HeaderElement)i.next();
+ line = elt.name + HEADER_SEP + elt.value + CRLF;
+ out.write(line.getBytes(US_ASCII));
+ }
+ out.write(CRLF.getBytes(US_ASCII));
+ // Request body
+ if (requestBodyWriter != null && !expectingContinue)
+ {
+ byte[] buffer = new byte[4096];
+ int len;
+ int count = 0;
+
+ requestBodyWriter.reset();
+ do
+ {
+ len = requestBodyWriter.write(buffer);
+ if (len > 0)
+ {
+ out.write(buffer, 0, len);
+ }
+ count += len;
+ }
+ while (len > -1 && count < contentLength);
+ }
+ out.flush();
+ // Get response
+ while(true)
+ {
+ response = readResponse(connection.getInputStream());
+ int sc = response.getCode();
+ if (sc == 401 && authenticator != null)
+ {
+ if (authenticate(response, attempts++))
+ {
+ retry = true;
+ }
+ }
+ else if (sc == 100)
+ {
+ if (expectingContinue)
+ {
+ requestHeaders.remove("Expect");
+ setHeader("Content-Length",
+ Integer.toString(contentLength));
+ expectingContinue = false;
+ retry = true;
+ }
+ else
+ {
+ // A conforming server can send an unsoliceted
+ // Continue response but *should* not (RFC 2616
+ // sec 8.2.3). Ignore the bogus Continue
+ // response and get the real response that
+ // should follow
+ continue;
+ }
+ }
+ break;
+ }
+ }
+ while (retry);
+ }
+ catch (IOException e)
+ {
+ connection.close();
+ throw e;
+ }
+ return response;
+ }
+
+ Response readResponse(InputStream in)
+ throws IOException
+ {
+ String line;
+ int len;
+
+ // Read response status line
+ LineInputStream lis = new LineInputStream(in);
+
+ line = lis.readLine();
+ if (line == null)
+ {
+ throw new ProtocolException("Peer closed connection");
+ }
+ if (!line.startsWith("HTTP/"))
+ {
+ throw new ProtocolException(line);
+ }
+ len = line.length();
+ int start = 5, end = 6;
+ while (line.charAt(end) != '.')
+ {
+ end++;
+ }
+ int majorVersion = Integer.parseInt(line.substring(start, end));
+ start = end + 1;
+ end = start + 1;
+ while (line.charAt(end) != ' ')
+ {
+ end++;
+ }
+ int minorVersion = Integer.parseInt(line.substring(start, end));
+ start = end + 1;
+ end = start + 3;
+ int code = Integer.parseInt(line.substring(start, end));
+ String message = line.substring(end + 1, len - 1);
+ // Read response headers
+ Headers responseHeaders = new Headers();
+ responseHeaders.parse(lis);
+ notifyHeaderHandlers(responseHeaders);
+ InputStream body = null;
+
+ switch (code)
+ {
+ case 100:
+ break;
+ case 204:
+ case 205:
+ case 304:
+ body = createResponseBodyStream(responseHeaders, majorVersion,
+ minorVersion, in, false);
+ break;
+ default:
+ body = createResponseBodyStream(responseHeaders, majorVersion,
+ minorVersion, in, true);
+ }
+
+ // Construct response
+ Response ret = new Response(majorVersion, minorVersion, code,
+ message, responseHeaders, body);
+ return ret;
+ }
+
+ void notifyHeaderHandlers(Headers headers)
+ {
+ for (Iterator i = headers.iterator(); i.hasNext(); )
+ {
+ Headers.HeaderElement entry = (Headers.HeaderElement) i.next();
+ // Handle Set-Cookie
+ if ("Set-Cookie".equalsIgnoreCase(entry.name))
+ handleSetCookie(entry.value);
+
+ ResponseHeaderHandler handler =
+ (ResponseHeaderHandler) responseHeaderHandlers.get(entry.name);
+ if (handler != null)
+ handler.setValue(entry.value);
+ }
+ }
+
+ private InputStream createResponseBodyStream(Headers responseHeaders,
+ int majorVersion,
+ int minorVersion,
+ InputStream in,
+ boolean mayHaveBody)
+ throws IOException
+ {
+ long contentLength = -1;
+ Headers trailer = null;
+
+ // Persistent connections are the default in HTTP/1.1
+ boolean doClose = "close".equalsIgnoreCase(getHeader("Connection")) ||
+ "close".equalsIgnoreCase(responseHeaders.getValue("Connection")) ||
+ (connection.majorVersion == 1 && connection.minorVersion == 0) ||
+ (majorVersion == 1 && minorVersion == 0);
+
+ String transferCoding = responseHeaders.getValue("Transfer-Encoding");
+ if ("HEAD".equals(method) || !mayHaveBody)
+ {
+ // Special case no body.
+ in = new LimitedLengthInputStream(in, 0, true, connection, doClose);
+ }
+ else if ("chunked".equalsIgnoreCase(transferCoding))
+ {
+ in = new LimitedLengthInputStream(in, -1, false, connection, doClose);
+
+ in = new ChunkedInputStream(in, responseHeaders);
+ }
+ else
+ {
+ contentLength = responseHeaders.getLongValue("Content-Length");
+
+ if (contentLength < 0)
+ doClose = true; // No Content-Length, must close.
+
+ in = new LimitedLengthInputStream(in, contentLength,
+ contentLength >= 0,
+ connection, doClose);
+ }
+ String contentCoding = responseHeaders.getValue("Content-Encoding");
+ if (contentCoding != null && !"identity".equals(contentCoding))
+ {
+ if ("gzip".equals(contentCoding))
+ {
+ in = new GZIPInputStream(in);
+ }
+ else if ("deflate".equals(contentCoding))
+ {
+ in = new InflaterInputStream(in);
+ }
+ else
+ {
+ throw new ProtocolException("Unsupported Content-Encoding: " +
+ contentCoding);
+ }
+ // Remove the Content-Encoding header because the content is
+ // no longer compressed.
+ responseHeaders.remove("Content-Encoding");
+ }
+ return in;
+ }
+
+ boolean authenticate(Response response, int attempts)
+ throws IOException
+ {
+ String challenge = response.getHeader("WWW-Authenticate");
+ if (challenge == null)
+ {
+ challenge = response.getHeader("Proxy-Authenticate");
+ }
+ int si = challenge.indexOf(' ');
+ String scheme = (si == -1) ? challenge : challenge.substring(0, si);
+ if ("Basic".equalsIgnoreCase(scheme))
+ {
+ Properties params = parseAuthParams(challenge.substring(si + 1));
+ String realm = params.getProperty("realm");
+ Credentials creds = authenticator.getCredentials(realm, attempts);
+ String userPass = creds.getUsername() + ':' + creds.getPassword();
+ byte[] b_userPass = userPass.getBytes("US-ASCII");
+ byte[] b_encoded = BASE64.encode(b_userPass);
+ String authorization =
+ scheme + " " + new String(b_encoded, "US-ASCII");
+ setHeader("Authorization", authorization);
+ return true;
+ }
+ else if ("Digest".equalsIgnoreCase(scheme))
+ {
+ Properties params = parseAuthParams(challenge.substring(si + 1));
+ String realm = params.getProperty("realm");
+ String nonce = params.getProperty("nonce");
+ String qop = params.getProperty("qop");
+ String algorithm = params.getProperty("algorithm");
+ String digestUri = getRequestURI();
+ Credentials creds = authenticator.getCredentials(realm, attempts);
+ String username = creds.getUsername();
+ String password = creds.getPassword();
+ connection.incrementNonce(nonce);
+ try
+ {
+ MessageDigest md5 = MessageDigest.getInstance("MD5");
+ final byte[] COLON = { 0x3a };
+
+ // Calculate H(A1)
+ md5.reset();
+ md5.update(username.getBytes("US-ASCII"));
+ md5.update(COLON);
+ md5.update(realm.getBytes("US-ASCII"));
+ md5.update(COLON);
+ md5.update(password.getBytes("US-ASCII"));
+ byte[] ha1 = md5.digest();
+ if ("md5-sess".equals(algorithm))
+ {
+ byte[] cnonce = generateNonce();
+ md5.reset();
+ md5.update(ha1);
+ md5.update(COLON);
+ md5.update(nonce.getBytes("US-ASCII"));
+ md5.update(COLON);
+ md5.update(cnonce);
+ ha1 = md5.digest();
+ }
+ String ha1Hex = toHexString(ha1);
+
+ // Calculate H(A2)
+ md5.reset();
+ md5.update(method.getBytes("US-ASCII"));
+ md5.update(COLON);
+ md5.update(digestUri.getBytes("US-ASCII"));
+ if ("auth-int".equals(qop))
+ {
+ byte[] hEntity = null; // TODO hash of entity body
+ md5.update(COLON);
+ md5.update(hEntity);
+ }
+ byte[] ha2 = md5.digest();
+ String ha2Hex = toHexString(ha2);
+
+ // Calculate response
+ md5.reset();
+ md5.update(ha1Hex.getBytes("US-ASCII"));
+ md5.update(COLON);
+ md5.update(nonce.getBytes("US-ASCII"));
+ if ("auth".equals(qop) || "auth-int".equals(qop))
+ {
+ String nc = getNonceCount(nonce);
+ byte[] cnonce = generateNonce();
+ md5.update(COLON);
+ md5.update(nc.getBytes("US-ASCII"));
+ md5.update(COLON);
+ md5.update(cnonce);
+ md5.update(COLON);
+ md5.update(qop.getBytes("US-ASCII"));
+ }
+ md5.update(COLON);
+ md5.update(ha2Hex.getBytes("US-ASCII"));
+ String digestResponse = toHexString(md5.digest());
+
+ String authorization = scheme +
+ " username=\"" + username + "\"" +
+ " realm=\"" + realm + "\"" +
+ " nonce=\"" + nonce + "\"" +
+ " uri=\"" + digestUri + "\"" +
+ " response=\"" + digestResponse + "\"";
+ setHeader("Authorization", authorization);
+ return true;
+ }
+ catch (NoSuchAlgorithmException e)
+ {
+ return false;
+ }
+ }
+ // Scheme not recognised
+ return false;
+ }
+
+ Properties parseAuthParams(String text)
+ {
+ int len = text.length();
+ String key = null;
+ StringBuilder buf = new StringBuilder();
+ Properties ret = new Properties();
+ boolean inQuote = false;
+ for (int i = 0; i < len; i++)
+ {
+ char c = text.charAt(i);
+ if (c == '"')
+ {
+ inQuote = !inQuote;
+ }
+ else if (c == '=' && key == null)
+ {
+ key = buf.toString().trim();
+ buf.setLength(0);
+ }
+ else if (c == ' ' && !inQuote)
+ {
+ String value = unquote(buf.toString().trim());
+ ret.put(key, value);
+ key = null;
+ buf.setLength(0);
+ }
+ else if (c != ',' || (i <(len - 1) && text.charAt(i + 1) != ' '))
+ {
+ buf.append(c);
+ }
+ }
+ if (key != null)
+ {
+ String value = unquote(buf.toString().trim());
+ ret.put(key, value);
+ }
+ return ret;
+ }
+
+ String unquote(String text)
+ {
+ int len = text.length();
+ if (len > 0 && text.charAt(0) == '"' && text.charAt(len - 1) == '"')
+ {
+ return text.substring(1, len - 1);
+ }
+ return text;
+ }
+
+ /**
+ * Returns the number of times the specified nonce value has been seen.
+ * This always returns an 8-byte 0-padded hexadecimal string.
+ */
+ String getNonceCount(String nonce)
+ {
+ int nc = connection.getNonceCount(nonce);
+ String hex = Integer.toHexString(nc);
+ StringBuilder buf = new StringBuilder();
+ for (int i = 8 - hex.length(); i > 0; i--)
+ {
+ buf.append('0');
+ }
+ buf.append(hex);
+ return buf.toString();
+ }
+
+ /**
+ * Client nonce value.
+ */
+ byte[] nonce;
+
+ /**
+ * Generates a new client nonce value.
+ */
+ byte[] generateNonce()
+ throws IOException, NoSuchAlgorithmException
+ {
+ if (nonce == null)
+ {
+ long time = System.currentTimeMillis();
+ MessageDigest md5 = MessageDigest.getInstance("MD5");
+ md5.update(Long.toString(time).getBytes("US-ASCII"));
+ nonce = md5.digest();
+ }
+ return nonce;
+ }
+
+ String toHexString(byte[] bytes)
+ {
+ char[] ret = new char[bytes.length * 2];
+ for (int i = 0, j = 0; i < bytes.length; i++)
+ {
+ int c =(int) bytes[i];
+ if (c < 0)
+ {
+ c += 0x100;
+ }
+ ret[j++] = Character.forDigit(c / 0x10, 0x10);
+ ret[j++] = Character.forDigit(c % 0x10, 0x10);
+ }
+ return new String(ret);
+ }
+
+ /**
+ * Parse the specified cookie list and notify the cookie manager.
+ */
+ void handleSetCookie(String text)
+ {
+ CookieManager cookieManager = connection.getCookieManager();
+ if (cookieManager == null)
+ {
+ return;
+ }
+ String name = null;
+ String value = null;
+ String comment = null;
+ String domain = connection.getHostName();
+ String path = this.path;
+ int lsi = path.lastIndexOf('/');
+ if (lsi != -1)
+ {
+ path = path.substring(0, lsi);
+ }
+ boolean secure = false;
+ Date expires = null;
+
+ int len = text.length();
+ String attr = null;
+ StringBuilder buf = new StringBuilder();
+ boolean inQuote = false;
+ for (int i = 0; i <= len; i++)
+ {
+ char c =(i == len) ? '\u0000' : text.charAt(i);
+ if (c == '"')
+ {
+ inQuote = !inQuote;
+ }
+ else if (!inQuote)
+ {
+ if (c == '=' && attr == null)
+ {
+ attr = buf.toString().trim();
+ buf.setLength(0);
+ }
+ else if (c == ';' || i == len || c == ',')
+ {
+ String val = unquote(buf.toString().trim());
+ if (name == null)
+ {
+ name = attr;
+ value = val;
+ }
+ else if ("Comment".equalsIgnoreCase(attr))
+ {
+ comment = val;
+ }
+ else if ("Domain".equalsIgnoreCase(attr))
+ {
+ domain = val;
+ }
+ else if ("Path".equalsIgnoreCase(attr))
+ {
+ path = val;
+ }
+ else if ("Secure".equalsIgnoreCase(val))
+ {
+ secure = true;
+ }
+ else if ("Max-Age".equalsIgnoreCase(attr))
+ {
+ int delta = Integer.parseInt(val);
+ Calendar cal = Calendar.getInstance();
+ cal.setTimeInMillis(System.currentTimeMillis());
+ cal.add(Calendar.SECOND, delta);
+ expires = cal.getTime();
+ }
+ else if ("Expires".equalsIgnoreCase(attr))
+ {
+ DateFormat dateFormat = new HTTPDateFormat();
+ try
+ {
+ expires = dateFormat.parse(val);
+ }
+ catch (ParseException e)
+ {
+ // if this isn't a valid date, it may be that
+ // the value was returned unquoted; in that case, we
+ // want to continue buffering the value
+ buf.append(c);
+ continue;
+ }
+ }
+ attr = null;
+ buf.setLength(0);
+ // case EOL
+ if (i == len || c == ',')
+ {
+ Cookie cookie = new Cookie(name, value, comment, domain,
+ path, secure, expires);
+ cookieManager.setCookie(cookie);
+ }
+ if (c == ',')
+ {
+ // Reset cookie fields
+ name = null;
+ value = null;
+ comment = null;
+ domain = connection.getHostName();
+ path = this.path;
+ if (lsi != -1)
+ {
+ path = path.substring(0, lsi);
+ }
+ secure = false;
+ expires = null;
+ }
+ }
+ else
+ {
+ buf.append(c);
+ }
+ }
+ else
+ {
+ buf.append(c);
+ }
+ }
+ }
+
+}
+
Added: llvm-gcc-4.2/trunk/libjava/classpath/gnu/java/net/protocol/http/RequestBodyWriter.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/gnu/java/net/protocol/http/RequestBodyWriter.java?rev=43913&view=auto
==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/gnu/java/net/protocol/http/RequestBodyWriter.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/gnu/java/net/protocol/http/RequestBodyWriter.java Thu Nov 8 16:56:19 2007
@@ -0,0 +1,69 @@
+/* RequestBodyWriter.java --
+ Copyright (C) 2004 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 gnu.java.net.protocol.http;
+
+/**
+ * Callback interface for writing request body content.
+ *
+ * @author Chris Burdess (dog at gnu.org)
+ */
+public interface RequestBodyWriter
+{
+
+ /**
+ * Returns the total number of bytes that will be written in a single pass
+ * by this writer.
+ */
+ int getContentLength();
+
+ /**
+ * Initialises the writer.
+ * This will be called before each pass.
+ */
+ void reset();
+
+ /**
+ * Writes body content to the supplied buffer.
+ * @param buffer the content buffer
+ * @return the number of bytes written
+ */
+ int write(byte[] buffer);
+
+}
+
Added: llvm-gcc-4.2/trunk/libjava/classpath/gnu/java/net/protocol/http/Response.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/gnu/java/net/protocol/http/Response.java?rev=43913&view=auto
==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/gnu/java/net/protocol/http/Response.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/gnu/java/net/protocol/http/Response.java Thu Nov 8 16:56:19 2007
@@ -0,0 +1,224 @@
+/* Response.java --
+ Copyright (C) 2004, 2006 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 gnu.java.net.protocol.http;
+
+import java.io.InputStream;
+import java.util.Date;
+
+/**
+ * An HTTP response.
+ *
+ * @author Chris Burdess (dog at gnu.org)
+ */
+public class Response
+{
+
+ /**
+ * The HTTP major version of the server issuing the response.
+ */
+ protected final int majorVersion;
+
+ /**
+ * The HTTP minor version of the server issuing the response.
+ */
+ protected final int minorVersion;
+
+ /**
+ * The HTTP status code of the response.
+ */
+ protected final int code;
+
+ /**
+ * Human-readable text of the response.
+ */
+ protected final String message;
+
+ /**
+ * The response headers.
+ */
+ protected final Headers headers;
+
+ /**
+ * An InputStream that returns the body of the response.
+ */
+ protected final InputStream body;
+
+ /**
+ * Constructs a new response with the specified parameters.
+ */
+ protected Response(int majorVersion, int minorVersion, int code,
+ String message, Headers headers, InputStream body)
+ {
+ this.majorVersion = majorVersion;
+ this.minorVersion = minorVersion;
+ this.code = code;
+ this.message = message;
+ this.headers = headers;
+ this.body = body;
+ }
+
+ /**
+ * Returns the HTTP major version of the server issuing the response.
+ * @see #majorVersion
+ */
+ public int getMajorVersion()
+ {
+ return majorVersion;
+ }
+
+ /**
+ * Returns the HTTP minor version of the server issuing the response.
+ * @see #minorVersion
+ */
+ public int getMinorVersion()
+ {
+ return minorVersion;
+ }
+
+ /**
+ * Returns the HTTP status code of the response.
+ * @see #code
+ */
+ public int getCode()
+ {
+ return code;
+ }
+
+ /**
+ * Returns the class of the response. This is the most significant
+ * digit of the status code.
+ * <dl>
+ * <dt><code>1xx</code></dt> <dd>Informational response</dd>
+ * <dt><code>2xx</code></dt> <dd>Success</dd>
+ * <dt><code>3xx</code></dt> <dd>Redirection</dd>
+ * <dt><code>4xx</code></dt> <dd>Client error</dd>
+ * <dt><code>5xx</code></dt> <dd>Server error</dd>
+ * </dl>
+ */
+ public int getCodeClass()
+ {
+ return code / 100;
+ }
+
+ /**
+ * Returns the human-readable text of the response.
+ * @see #message
+ */
+ public String getMessage()
+ {
+ return message;
+ }
+
+ /**
+ * Returns the headers in the response.
+ */
+ public Headers getHeaders()
+ {
+ return headers;
+ }
+
+ /**
+ * Returns the header value for the specified name.
+ * @param name the header name
+ */
+ public String getHeader(String name)
+ {
+ return headers.getValue(name);
+ }
+
+ /**
+ * Returns the header value for the specified name as an integer.
+ * @param name the header name
+ */
+ public int getIntHeader(String name)
+ {
+ return headers.getIntValue(name);
+ }
+
+ /**
+ * Returns the header value for the specified name as a long.
+ * @param name the header name
+ */
+ public long getLongHeader(String name)
+ {
+ return headers.getLongValue(name);
+ }
+
+ /**
+ * Returns the header value for the specified name as a date.
+ * @param name the header name
+ */
+ public Date getDateHeader(String name)
+ {
+ return headers.getDateValue(name);
+ }
+
+ /**
+ * Tests whether this response indicates a redirection.
+ *
+ * @return <code>true</code> if, <code>false</code> otherwise.
+ */
+ public boolean isRedirect()
+ {
+ return (code != 304 && getCodeClass() == 3);
+ }
+
+ /**
+ * Tests whether this response indicates an error.
+ * Errors are the response codes <code>4xx</code> - Client error and
+ * <code>5xx</code> - Server error.
+ *
+ * @return <code>true</code> if, <code>false</code> otherwise.
+ */
+ public boolean isError()
+ {
+ return (getCodeClass() == 4 || getCodeClass() == 5);
+ }
+
+ /**
+ * Returns an InputStream that returns the body of the response.
+ *
+ * @return the body of the response
+ */
+ public InputStream getBody()
+ {
+ return body;
+ }
+}
+
Added: llvm-gcc-4.2/trunk/libjava/classpath/gnu/java/net/protocol/http/ResponseHeaderHandler.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/gnu/java/net/protocol/http/ResponseHeaderHandler.java?rev=43913&view=auto
==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/gnu/java/net/protocol/http/ResponseHeaderHandler.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/gnu/java/net/protocol/http/ResponseHeaderHandler.java Thu Nov 8 16:56:19 2007
@@ -0,0 +1,57 @@
+/* ResponseHeaderHandler.java --
+ Copyright (C) 2004 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 gnu.java.net.protocol.http;
+
+/**
+ * Callback interface for objects that wish to be notified of response
+ * header values.
+ * @see Request#setResponseHeaderHandler(String, ResponseHeaderHandler)
+ *
+ * @author Chris Burdess (dog at gnu.org)
+ */
+public interface ResponseHeaderHandler
+{
+
+ /**
+ * Sets the value for the header associated with this handler.
+ */
+ void setValue(String value);
+
+}
+
Added: llvm-gcc-4.2/trunk/libjava/classpath/gnu/java/net/protocol/http/SimpleCookieManager.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/gnu/java/net/protocol/http/SimpleCookieManager.java?rev=43913&view=auto
==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/gnu/java/net/protocol/http/SimpleCookieManager.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/gnu/java/net/protocol/http/SimpleCookieManager.java Thu Nov 8 16:56:19 2007
@@ -0,0 +1,140 @@
+/* CookieManager.java --
+ Copyright (C) 2004 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 gnu.java.net.protocol.http;
+
+import java.util.ArrayList;
+import java.util.Date;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+
+/**
+ * A simple non-persistent cookie manager. This class can be extended to
+ * provide cookie persistence.
+ *
+ * @author Chris Burdess (dog at gnu.org)
+ */
+public class SimpleCookieManager
+ implements CookieManager
+{
+
+ /**
+ * The cookie cache.
+ * This is a dictionary mapping domains to maps of cookies by name.
+ */
+ protected Map cookies;
+
+ /**
+ * Constructor.
+ */
+ public SimpleCookieManager()
+ {
+ cookies = new HashMap();
+ }
+
+ public void setCookie(Cookie cookie)
+ {
+ String domain = cookie.getDomain();
+ Map map =(Map) cookies.get(domain);
+ if (map == null)
+ {
+ map = new HashMap();
+ cookies.put(domain, map);
+ }
+ String name = cookie.getName();
+ map.put(name, cookie); // will replace a cookie of the same name
+ }
+
+ public Cookie[] getCookies(String host, boolean secure, String path)
+ {
+ List matches = new ArrayList();
+ Date now = new Date();
+ if (Character.isLetter(host.charAt(0)))
+ {
+ int di = host.indexOf('.');
+ while (di != -1)
+ {
+ addCookies(matches, host, secure, path, now);
+ host = host.substring(di);
+ di = host.indexOf('.', 1);
+ }
+ }
+ addCookies(matches, host, secure, path, now);
+ Cookie[] ret = new Cookie[matches.size()];
+ matches.toArray(ret);
+ return ret;
+ }
+
+ private void addCookies(List matches, String domain, boolean secure,
+ String path, Date now)
+ {
+ Map map = (Map) cookies.get(domain);
+ if (map != null)
+ {
+ List expired = new ArrayList();
+ for (Iterator i = map.entrySet().iterator(); i.hasNext(); )
+ {
+ Map.Entry entry = (Map.Entry) i.next();
+ Cookie cookie = (Cookie) entry.getValue();
+ Date expires = cookie.getExpiryDate();
+ if (expires != null && expires.before(now))
+ {
+ expired.add(entry.getKey());
+ continue;
+ }
+ if (secure && !cookie.isSecure())
+ {
+ continue;
+ }
+ if (path.startsWith(cookie.getPath()))
+ {
+ matches.add(cookie);
+ }
+ }
+ // Good housekeeping
+ for (Iterator i = expired.iterator(); i.hasNext(); )
+ {
+ map.remove(i.next());
+ }
+ }
+ }
+
+}
+
Added: llvm-gcc-4.2/trunk/libjava/classpath/gnu/java/net/protocol/http/package.html
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/gnu/java/net/protocol/http/package.html?rev=43913&view=auto
==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/gnu/java/net/protocol/http/package.html (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/gnu/java/net/protocol/http/package.html Thu Nov 8 16:56:19 2007
@@ -0,0 +1,76 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
+<!-- package.html - describes classes in gnu.java.net.protocol.http package.
+ Copyright (C) 2004 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. -->
+
+<html>
+<head><title>GNU Classpath - gnu.java.net.protocol.http</title></head>
+
+<body>
+
+<p>
+This package contains an HTTP/1.1 client, as described in RFC 2616.
+It supports the following features:
+<ul>
+<li>Persistent connections</li>
+<li>Basic and Digest authentication (RFC 2617)</li>
+<li>HTTPS</li>
+<li>HTTP proxies</li>
+<li>HTTP/1.0 compatibility</li>
+<li>Support for WebDAV methods and other HTTP extensions</li>
+<li>Automatic decoding of the chunked transfer-coding</li>
+<li>Parsing of HTTP date headers</li>
+<li>Support for the 100-continue expectation</li>
+</ul>
+</p>
+
+<p>
+The API is similar to the <a href='http://www.webdav.org/neon/'>neon</a>
+WebDAV/HTTP library. A logical connection to the server is instantiated,
+and multiple requests can be issued for this connection. Each request
+has an atomic <code>dispatch</code> method which returns the response.
+All I/O, authentication, etc is handled by registering callback objects
+with the request prior to dispatch, which are notified during the dispatch
+procedure as necessary. Simple byte-array content callbacks are supplied
+which can manage any request/response content that fits in available memory.
+</p>
+
+<p>
+An URL stream handler is provided, supporting the full HttpURLConnection
+specification.
+</p>
+
+</body>
Added: llvm-gcc-4.2/trunk/libjava/classpath/gnu/java/net/protocol/https/Handler.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/gnu/java/net/protocol/https/Handler.java?rev=43913&view=auto
==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/gnu/java/net/protocol/https/Handler.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/gnu/java/net/protocol/https/Handler.java Thu Nov 8 16:56:19 2007
@@ -0,0 +1,76 @@
+/* Handler.java --
+ Copyright (C) 2004, 2005 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 gnu.java.net.protocol.https;
+
+import gnu.java.net.protocol.http.HTTPConnection;
+import gnu.java.net.protocol.http.HTTPURLConnection;
+
+import java.io.IOException;
+import java.net.URL;
+import java.net.URLConnection;
+import java.net.URLStreamHandler;
+
+/**
+ * An HTTPS URL stream handler.
+ *
+ * @author Chris Burdess (dog at gnu.org)
+ */
+public class Handler
+ extends URLStreamHandler
+{
+
+ /**
+ * Returns the default HTTPS port (443).
+ */
+ protected int getDefaultPort()
+ {
+ return HTTPConnection.HTTPS_PORT;
+ }
+
+ /**
+ * Returns an HTTPURLConnection for the given URL.
+ */
+ public URLConnection openConnection(URL url)
+ throws IOException
+ {
+ return new HTTPURLConnection(url);
+ }
+
+}
+
Added: llvm-gcc-4.2/trunk/libjava/classpath/gnu/java/net/protocol/jar/Connection.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/gnu/java/net/protocol/jar/Connection.java?rev=43913&view=auto
==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/gnu/java/net/protocol/jar/Connection.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/gnu/java/net/protocol/jar/Connection.java Thu Nov 8 16:56:19 2007
@@ -0,0 +1,231 @@
+/* Connection - jar url connection for java.net
+ Copyright (C) 1999, 2002, 2003, 2005, 2006 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 gnu.java.net.protocol.jar;
+
+import java.io.File;
+import java.io.FileNotFoundException;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.net.JarURLConnection;
+import java.net.MalformedURLException;
+import java.net.ProtocolException;
+import java.net.URL;
+import java.net.URLConnection;
+import java.text.SimpleDateFormat;
+import java.util.Date;
+import java.util.Hashtable;
+import java.util.Locale;
+import java.util.jar.JarEntry;
+import java.util.jar.JarFile;
+import java.util.zip.ZipFile;
+
+/**
+ * This subclass of java.net.JarURLConnection models a URLConnection via
+ * the "jar" protocol.
+ *
+ * @author Kresten Krab Thorup (krab at gnu.org)
+ */
+public final class Connection extends JarURLConnection
+{
+ /**
+ * HTTP-style DateFormat, used to format the last-modified header.
+ * Lazy initialized since jar files are used during bootstrapping.
+ */
+ private static SimpleDateFormat dateFormat;
+
+ private JarFile jar_file;
+ private JarEntry jar_entry;
+ private URL jar_url;
+
+ public static class JarFileCache
+ {
+ private static Hashtable cache = new Hashtable();
+ private static final int READBUFSIZE = 4*1024;
+
+ public static synchronized JarFile get (URL url, boolean useCaches)
+ throws IOException
+ {
+ JarFile jf;
+ if (useCaches)
+ {
+ jf = (JarFile) cache.get (url);
+ if (jf != null)
+ return jf;
+ }
+
+ if ("file".equals (url.getProtocol()))
+ {
+ String fn = url.getFile();
+ fn = gnu.java.net.protocol.file.Connection.unquote(fn);
+ File f = new File (fn);
+ jf = new JarFile (f, true, ZipFile.OPEN_READ);
+ }
+ else
+ {
+ URLConnection urlconn = url.openConnection();
+ InputStream is = urlconn.getInputStream();
+ byte[] buf = new byte [READBUFSIZE];
+ File f = File.createTempFile ("cache", "jar");
+ FileOutputStream fos = new FileOutputStream (f);
+ int len = 0;
+
+ while ((len = is.read (buf)) != -1)
+ {
+ fos.write (buf, 0, len);
+ }
+
+ fos.close();
+ // Always verify the Manifest, open read only and delete when done.
+ jf = new JarFile (f, true,
+ ZipFile.OPEN_READ | ZipFile.OPEN_DELETE);
+ }
+
+ if (useCaches)
+ cache.put (url, jf);
+
+ return jf;
+ }
+ }
+
+ protected Connection(URL url)
+ throws MalformedURLException
+ {
+ super(url);
+ }
+
+ public synchronized void connect() throws IOException
+ {
+ // Call is ignored if already connected.
+ if (connected)
+ return;
+
+ jar_url = getJarFileURL();
+ jar_file = JarFileCache.get (jar_url, useCaches);
+ String entry_name = getEntryName();
+
+ if (entry_name != null
+ && !entry_name.equals (""))
+ {
+ jar_entry = (JarEntry) jar_file.getEntry (entry_name);
+
+ if(jar_entry == null)
+ throw new FileNotFoundException("No entry for " + entry_name + " exists.");
+ }
+
+ connected = true;
+ }
+
+ public InputStream getInputStream() throws IOException
+ {
+ if (!connected)
+ connect();
+
+ if (! doInput)
+ throw new ProtocolException("Can't open InputStream if doInput is false");
+
+ return jar_file.getInputStream (jar_entry);
+ }
+
+ public synchronized JarFile getJarFile() throws IOException
+ {
+ if (!connected)
+ connect();
+
+ if (! doInput)
+ throw new ProtocolException("Can't open JarFile if doInput is false");
+
+ return jar_file;
+ }
+
+ public String getHeaderField(String field)
+ {
+ try
+ {
+ if (!connected)
+ connect();
+
+ if (field.equals("content-type"))
+ return guessContentTypeFromName(getJarEntry().getName());
+ else if (field.equals("content-length"))
+ return Long.toString(getJarEntry().getSize());
+ else if (field.equals("last-modified"))
+ {
+ // Both creating and manipulating dateFormat need synchronization.
+ synchronized (Connection.class)
+ {
+ if (dateFormat == null)
+ dateFormat = new SimpleDateFormat
+ ("EEE, dd MMM yyyy hh:mm:ss 'GMT'",
+ new Locale ("En", "Us", "Unix"));
+
+ return dateFormat.format(new Date(getJarEntry().getTime()));
+ }
+ }
+ }
+ catch (IOException e)
+ {
+ // Fall through.
+ }
+ return null;
+ }
+
+ public int getContentLength()
+ {
+ if (!connected)
+ return -1;
+
+ return (int) jar_entry.getSize();
+ }
+
+ public long getLastModified()
+ {
+ if (!connected)
+ return -1;
+
+ try
+ {
+ return getJarEntry().getTime();
+ }
+ catch (IOException e)
+ {
+ return -1;
+ }
+ }
+}
Added: llvm-gcc-4.2/trunk/libjava/classpath/gnu/java/net/protocol/jar/Handler.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/gnu/java/net/protocol/jar/Handler.java?rev=43913&view=auto
==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/gnu/java/net/protocol/jar/Handler.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/gnu/java/net/protocol/jar/Handler.java Thu Nov 8 16:56:19 2007
@@ -0,0 +1,173 @@
+/* gnu.java.net.protocol.jar.Handler - jar protocol handler for java.net
+ Copyright (C) 1999, 2002, 2003, 2005 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 gnu.java.net.protocol.jar;
+
+import gnu.java.net.URLParseError;
+
+import java.io.IOException;
+import java.net.MalformedURLException;
+import java.net.URL;
+import java.net.URLConnection;
+import java.net.URLStreamHandler;
+
+/**
+ * @author Kresten Krab Thorup (krab at gnu.org)
+ */
+public class Handler extends URLStreamHandler
+{
+ /**
+ * A do nothing constructor
+ */
+ public Handler()
+ {
+ }
+
+ /**
+ * This method returs a new JarURLConnection for the specified URL
+ *
+ * @param url The URL to return a connection for
+ *
+ * @return The URLConnection
+ *
+ * @exception IOException If an error occurs
+ */
+ protected URLConnection openConnection(URL url) throws IOException
+ {
+ return new Connection(url);
+ }
+
+ /**
+ * This method overrides URLStreamHandler's for parsing url of protocol "jar"
+ *
+ * @param url The URL object in which to store the results
+ * @param url_string The String-ized URL to parse
+ * @param start The position in the string to start scanning from
+ * @param end The position in the string to stop scanning
+ */
+ protected void parseURL (URL url, String url_string, int start, int end)
+ {
+ // This method does not throw an exception or return a value. Thus our
+ // strategy when we encounter an error in parsing is to return without
+ // doing anything.
+ String file = url.getFile();
+
+ if (!file.equals(""))
+ { //has context url
+ url_string = url_string.substring (start, end);
+ if (url_string.startsWith("/"))
+ { //url string is an absolute path
+ int idx = file.lastIndexOf ("!/");
+
+ if (idx < 0)
+ throw new URLParseError("no !/ in spec");
+
+ file = file.substring (0, idx + 1) + url_string;
+ }
+ else if (url_string.length() > 0)
+ {
+ int idx = file.lastIndexOf ("/");
+ if (idx == -1) //context path is weird
+ file = "/" + url_string;
+ else if (idx == (file.length() - 1))
+ //just concatenate two parts
+ file = file + url_string;
+ else
+ // according to Java API Documentation, here is a little different
+ // with URLStreamHandler.parseURL
+ // but JDK seems doesn't handle it well
+ file = file.substring(0, idx + 1) + url_string;
+ }
+
+ setURL (url, "jar", url.getHost(), url.getPort(), file, null);
+ return;
+ }
+
+ // Bunches of things should be true. Make sure.
+ if (end < start)
+ return;
+ if (end - start < 2)
+ return;
+ if (start > url_string.length())
+ return;
+
+ // Skip remains of protocol
+ url_string = url_string.substring (start, end);
+
+ int jar_stop;
+ if ((jar_stop = url_string.indexOf("!/")) < 0)
+ throw new URLParseError("no !/ in spec");
+
+ try
+ {
+ new URL(url_string.substring (0, jar_stop));
+ }
+ catch (MalformedURLException e)
+ {
+ throw new URLParseError("invalid inner URL: " + e.getMessage());
+ }
+
+ if (!url.getProtocol().equals ("jar") )
+ throw new URLParseError("unexpected protocol " + url.getProtocol());
+
+ setURL (url, "jar", url.getHost(), url.getPort(), url_string, null);
+ }
+
+ /**
+ * This method converts a Jar URL object into a String.
+ *
+ * @param url The URL object to convert
+ */
+ protected String toExternalForm (URL url)
+ {
+ String file = url.getFile();
+ String ref = url.getRef();
+
+ // return "jar:" + file;
+ // Performance!!:
+ // Do the concatenation manually to avoid resize StringBuffer's
+ // internal buffer. The length of ref is not taken into consideration
+ // as it's a rare path.
+ StringBuffer sb = new StringBuffer (file.length() + 5);
+ sb.append ("jar:");
+ sb.append (file);
+ if (ref != null)
+ sb.append('#').append(ref);
+ return sb.toString();
+ }
+}
Added: llvm-gcc-4.2/trunk/libjava/classpath/gnu/java/net/protocol/jar/package.html
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/gnu/java/net/protocol/jar/package.html?rev=43913&view=auto
==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/gnu/java/net/protocol/jar/package.html (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/gnu/java/net/protocol/jar/package.html Thu Nov 8 16:56:19 2007
@@ -0,0 +1,46 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
+<!-- package.html - describes classes in gnu.java.net.protocol.jar package.
+ Copyright (C) 2005 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. -->
+
+<html>
+<head><title>GNU Classpath - gnu.java.net.protocol.jar</title></head>
+
+<body>
+<p></p>
+
+</body>
+</html>
Added: llvm-gcc-4.2/trunk/libjava/classpath/gnu/java/nio/ChannelInputStream.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/gnu/java/nio/ChannelInputStream.java?rev=43913&view=auto
==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/gnu/java/nio/ChannelInputStream.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/gnu/java/nio/ChannelInputStream.java Thu Nov 8 16:56:19 2007
@@ -0,0 +1,79 @@
+/* ChannelInputStream.java --
+ Copyright (C) 2003 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 gnu.java.nio;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.nio.ByteBuffer;
+import java.nio.channels.IllegalBlockingModeException;
+import java.nio.channels.ReadableByteChannel;
+import java.nio.channels.SelectableChannel;
+
+/**
+ * @author Michael Koch
+ */
+public final class ChannelInputStream extends InputStream
+{
+ private ReadableByteChannel ch;
+
+ public ChannelInputStream (ReadableByteChannel ch)
+ {
+ super();
+
+ this.ch = ch;
+ }
+
+ public int read() throws IOException
+ {
+ if (ch instanceof SelectableChannel
+ && (! ((SelectableChannel) ch).isBlocking()))
+ throw new IllegalBlockingModeException();
+
+ ByteBuffer buffer = ByteBuffer.allocate(1);
+ int result = ch.read(buffer);
+
+ if (result == -1)
+ return -1;
+
+ if (result == 0)
+ throw new IOException("Could not read from channel");
+
+ return buffer.get(0);
+ }
+}
Added: llvm-gcc-4.2/trunk/libjava/classpath/gnu/java/nio/ChannelOutputStream.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/gnu/java/nio/ChannelOutputStream.java?rev=43913&view=auto
==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/gnu/java/nio/ChannelOutputStream.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/gnu/java/nio/ChannelOutputStream.java Thu Nov 8 16:56:19 2007
@@ -0,0 +1,67 @@
+/* ChannelOutputStream.java --
+ Copyright (C) 2003 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 gnu.java.nio;
+
+import java.io.IOException;
+import java.io.OutputStream;
+import java.nio.ByteBuffer;
+import java.nio.channels.WritableByteChannel;
+
+/**
+ * @author Michael Koch
+ */
+public final class ChannelOutputStream extends OutputStream
+{
+ private WritableByteChannel ch;
+
+ public ChannelOutputStream (WritableByteChannel ch)
+ {
+ super();
+
+ this.ch = ch;
+ }
+
+ public void write (int value) throws IOException
+ {
+ ByteBuffer buffer = ByteBuffer.allocate (1);
+ buffer.put ((byte) (value & 0xff));
+ buffer.flip();
+ ch.write (buffer);
+ }
+}
Added: llvm-gcc-4.2/trunk/libjava/classpath/gnu/java/nio/ChannelReader.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/gnu/java/nio/ChannelReader.java?rev=43913&view=auto
==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/gnu/java/nio/ChannelReader.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/gnu/java/nio/ChannelReader.java Thu Nov 8 16:56:19 2007
@@ -0,0 +1,217 @@
+/* ChannelReader.java --
+ Copyright (C) 2005 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 gnu.java.nio;
+
+import java.io.IOException;
+import java.io.Reader;
+import java.nio.ByteBuffer;
+import java.nio.CharBuffer;
+import java.nio.channels.ReadableByteChannel;
+import java.nio.charset.CharsetDecoder;
+import java.nio.charset.CoderResult;
+import java.nio.charset.CodingErrorAction;
+
+/**
+ * A Reader implementation that works using a ReadableByteChannel and a
+ * CharsetDecoder.
+ *
+ * <p>
+ * This is a bridge between NIO <-> IO character decoding.
+ * </p>
+ *
+ * @author Robert Schuster
+ */
+public class ChannelReader extends Reader
+{
+
+ private static final int DEFAULT_BUFFER_CAP = 8192;
+
+ private ReadableByteChannel channel;
+
+ private CharsetDecoder decoder;
+
+ private ByteBuffer byteBuffer;
+
+ private CharBuffer charBuffer;
+
+ public ChannelReader(ReadableByteChannel channel, CharsetDecoder decoder,
+ int minBufferCap)
+ {
+ this.channel = channel;
+ this.decoder = decoder;
+
+ // JDK reports errors, so we do the same.
+ decoder.onMalformedInput(CodingErrorAction.REPORT);
+ decoder.onUnmappableCharacter(CodingErrorAction.REPORT);
+ decoder.reset();
+
+ int size = (minBufferCap == -1) ? DEFAULT_BUFFER_CAP : minBufferCap;
+
+ // Allocates the buffers and prepares them for reading, because that is the
+ // first operation being done on them.
+ byteBuffer = ByteBuffer.allocate(size);
+ byteBuffer.flip();
+ charBuffer = CharBuffer.allocate((int) (size * decoder.averageCharsPerByte()));
+ }
+
+ public int read(char[] buf, int offset, int count) throws IOException
+ {
+ synchronized (lock)
+ {
+ // I declared channel being null meaning that the reader is closed.
+ if (!channel.isOpen())
+ throw new IOException("Reader was already closed.");
+
+ // I declared decoder being null meaning that there is no more data to read
+ // and convert.
+ if (decoder == null)
+ return -1;
+
+ // Stores the amount of character being read. It -1 so that if no conversion
+ // occured the caller will see this as an 'end of file'.
+ int sum = -1;
+
+ // Copies any characters which may be left from the last invocation into the
+ // destination array.
+ if (charBuffer.remaining() > 0)
+ {
+ sum = Math.min(count, charBuffer.remaining());
+ charBuffer.get(buf, offset, sum);
+
+ // Updates the control variables according to the latest copy operation.
+ offset += sum;
+ count -= sum;
+ }
+
+ // Copies the character which have not been put in the destination array to
+ // the beginning. If data is actually copied count will be 0. If no data is
+ // copied count is >0 and we can now convert some more characters.
+ charBuffer.compact();
+
+ int converted = 0;
+ boolean last = false;
+
+ while (count != 0)
+ {
+ // Tries to convert some bytes (Which will intentionally fail in the
+ // first place because we have not read any bytes yet.)
+ CoderResult result = decoder.decode(byteBuffer, charBuffer, last);
+ if (result.isMalformed() || result.isUnmappable())
+ {
+ // JDK throws exception when bytes are malformed for sure.
+ // FIXME: Unsure what happens when a character is simply
+ // unmappable.
+ result.throwException();
+ }
+
+ // Marks that we should end this loop regardless whether the caller
+ // wants more chars or not, when this was the last conversion.
+ if (last)
+ {
+ decoder = null;
+ }
+ else if (result.isUnderflow())
+ {
+ // We need more bytes to do the conversion.
+
+ // Copies the not yet converted bytes to the beginning making it
+ // being able to receive more bytes.
+ byteBuffer.compact();
+
+ // Reads in another bunch of bytes for being converted.
+ if (channel.read(byteBuffer) == -1)
+ {
+ // If there is no more data available in the channel we mark
+ // that state for the final character conversion run which is
+ // done in the next loop iteration.
+ last = true;
+ }
+
+ // Prepares the byteBuffer for the next character conversion run.
+ byteBuffer.flip();
+ }
+
+ // Prepares the charBuffer for being drained.
+ charBuffer.flip();
+
+ converted = Math.min(count, charBuffer.remaining());
+ charBuffer.get(buf, offset, converted);
+
+ // Copies characters which have not yet being copied into the char-Array
+ // to the beginning making it possible to read them later (If data is
+ // really copied here, then the caller has received enough characters so
+ // far.).
+ charBuffer.compact();
+
+ // Updates the control variables according to the latest copy operation.
+ offset += converted;
+ count -= converted;
+
+ // Updates the amount of transferred characters.
+ sum += converted;
+
+ if (decoder == null)
+ {
+ break;
+ }
+
+ // Now that more characters have been transfered we let the loop decide
+ // what to do next.
+ }
+
+ // Makes the charBuffer ready for reading on the next invocation.
+ charBuffer.flip();
+
+ return sum;
+ }
+ }
+
+ public void close() throws IOException
+ {
+ synchronized (lock)
+ {
+ channel.close();
+
+ // Makes sure all intermediate data is released by the decoder.
+ if (decoder != null)
+ decoder.reset();
+ }
+ }
+
+}
Added: llvm-gcc-4.2/trunk/libjava/classpath/gnu/java/nio/ChannelWriter.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/gnu/java/nio/ChannelWriter.java?rev=43913&view=auto
==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/gnu/java/nio/ChannelWriter.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/gnu/java/nio/ChannelWriter.java Thu Nov 8 16:56:19 2007
@@ -0,0 +1,190 @@
+/* ChannelWriter.java -- nio / writer bridge
+ Copyright (C) 2006 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 gnu.java.nio;
+
+import java.io.IOException;
+import java.io.Writer;
+import java.nio.ByteBuffer;
+import java.nio.CharBuffer;
+import java.nio.channels.WritableByteChannel;
+import java.nio.charset.CharsetEncoder;
+import java.nio.charset.CoderResult;
+
+/**
+ * A Writer implementation that works by wrapping an NIO channel.
+ */
+public class ChannelWriter
+ extends Writer
+{
+ private static final int DEFAULT_BUFFER_CAP = 8192;
+
+ /**
+ * The output channel.
+ */
+ private WritableByteChannel byteChannel;
+
+ /**
+ * The encoder to use.
+ */
+ private CharsetEncoder enc;
+
+ /**
+ * The byte buffer. Translated characters are stored here on their way out.
+ */
+ private ByteBuffer byteBuffer;
+
+ /**
+ * The character buffer. Characters are stored here on their way into
+ * the encoder.
+ */
+ private CharBuffer charBuffer;
+
+ private void writeBuffer() throws IOException
+ {
+ byteBuffer.flip();
+ byteChannel.write(byteBuffer);
+ }
+
+ /**
+ * Create a new instance, given the output byte channel, the encoder
+ * to use, and the minimum buffer capacity.
+ */
+ public ChannelWriter(WritableByteChannel ch, CharsetEncoder enc,
+ int minBufferCap)
+ {
+ this.byteChannel = ch;
+ this.enc = enc;
+ if (minBufferCap == -1)
+ minBufferCap = DEFAULT_BUFFER_CAP;
+ this.byteBuffer
+ = ByteBuffer.allocate((int) (minBufferCap * enc.maxBytesPerChar()));
+ this.charBuffer = CharBuffer.allocate(minBufferCap);
+ this.charBuffer.clear();
+ }
+
+ /* (non-Javadoc)
+ * @see java.io.Writer#flush()
+ */
+ public void flush() throws IOException
+ {
+ // Presumably if we have characters in our buffer, it is
+ // due to an underflow. So we don't bother trying to flush
+ // that here.
+ }
+
+ /* (non-Javadoc)
+ * @see java.io.Writer#close()
+ */
+ public void close() throws IOException
+ {
+ synchronized (lock)
+ {
+ if (enc == null)
+ throw new IOException("writer already closed");
+
+ byteBuffer.clear();
+ charBuffer.flip();
+ CoderResult res = enc.encode(charBuffer, byteBuffer, true);
+ if (res.isError() || res.isMalformed() || res.isUnmappable())
+ res.throwException();
+ writeBuffer();
+
+ byteBuffer.clear();
+ res = enc.flush(byteBuffer);
+ if (res.isError() || res.isMalformed() || res.isUnmappable())
+ res.throwException();
+ writeBuffer();
+ enc = null;
+ }
+ }
+
+ /* (non-Javadoc)
+ * @see java.io.Writer#write(char[], int, int)
+ */
+ public void write(char[] buf, int offset, int len) throws IOException
+ {
+ synchronized (lock)
+ {
+ if (enc == null)
+ throw new IOException("writer already closed");
+ int lastLen = -1;
+ while (len > 0)
+ {
+ // Copy data into our character buffer.
+ int allowed = Math.min(charBuffer.remaining(), len);
+ charBuffer.put(buf, offset, allowed);
+ // Update for the next pass through the loop.
+ offset += allowed;
+ len -= allowed;
+ charBuffer.flip();
+ // If we didn't make any progress, we want to clean up
+ // and save our state for the next write().
+ if (len == lastLen)
+ {
+ if (len <= charBuffer.remaining())
+ {
+ charBuffer.put(buf, offset, len);
+ charBuffer.flip();
+ }
+ else
+ {
+ CharBuffer ncb = CharBuffer.allocate(charBuffer.length()
+ + len);
+ ncb.put(charBuffer);
+ ncb.put(buf, offset, len);
+ charBuffer = ncb;
+ }
+ break;
+ }
+ lastLen = len;
+
+ // Convert.
+ byteBuffer.clear();
+ CoderResult res = enc.encode(charBuffer, byteBuffer, false);
+ // Compact here, as we want to leave the buffer in the
+ // right state for any future put()s.
+ charBuffer.compact();
+ if (res.isError() || res.isMalformed() || res.isUnmappable())
+ res.throwException();
+ // Write the byte buffer to the output channel.
+ writeBuffer();
+ }
+ }
+ }
+}
Added: llvm-gcc-4.2/trunk/libjava/classpath/gnu/java/nio/DatagramChannelImpl.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/gnu/java/nio/DatagramChannelImpl.java?rev=43913&view=auto
==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/gnu/java/nio/DatagramChannelImpl.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/gnu/java/nio/DatagramChannelImpl.java Thu Nov 8 16:56:19 2007
@@ -0,0 +1,297 @@
+/* DatagramChannelImpl.java --
+ Copyright (C) 2002, 2003, 2004 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 gnu.java.nio;
+
+import gnu.java.net.PlainDatagramSocketImpl;
+import java.io.IOException;
+import java.net.DatagramPacket;
+import java.net.DatagramSocket;
+import java.net.InetSocketAddress;
+import java.net.SocketAddress;
+import java.net.SocketTimeoutException;
+import java.nio.ByteBuffer;
+import java.nio.channels.ClosedChannelException;
+import java.nio.channels.DatagramChannel;
+import java.nio.channels.NotYetConnectedException;
+import java.nio.channels.spi.SelectorProvider;
+
+/**
+ * @author Michael Koch
+ */
+public final class DatagramChannelImpl extends DatagramChannel
+{
+ private NIODatagramSocket socket;
+
+ /**
+ * Indicates whether this channel initiated whatever operation
+ * is being invoked on our datagram socket.
+ */
+ private boolean inChannelOperation;
+
+ /**
+ * Indicates whether our datagram socket should ignore whether
+ * we are set to non-blocking mode. Certain operations on our
+ * socket throw an <code>IllegalBlockingModeException</code> if
+ * we are in non-blocking mode, <i>except</i> if the operation
+ * is initiated by us.
+ */
+ public final boolean isInChannelOperation()
+ {
+ return inChannelOperation;
+ }
+
+ /**
+ * Sets our indicator of whether we are initiating an I/O operation
+ * on our socket.
+ */
+ public final void setInChannelOperation(boolean b)
+ {
+ inChannelOperation = b;
+ }
+
+ protected DatagramChannelImpl (SelectorProvider provider)
+ throws IOException
+ {
+ super (provider);
+ socket = new NIODatagramSocket (new PlainDatagramSocketImpl(), this);
+ configureBlocking(true);
+ }
+
+ public DatagramSocket socket ()
+ {
+ return socket;
+ }
+
+ protected void implCloseSelectableChannel ()
+ throws IOException
+ {
+ socket.close ();
+ }
+
+ protected void implConfigureBlocking (boolean blocking)
+ throws IOException
+ {
+ socket.setSoTimeout (blocking ? 0 : NIOConstants.DEFAULT_TIMEOUT);
+ }
+
+ public DatagramChannel connect (SocketAddress remote)
+ throws IOException
+ {
+ if (!isOpen())
+ throw new ClosedChannelException();
+
+ socket.connect (remote);
+ return this;
+ }
+
+ public DatagramChannel disconnect ()
+ throws IOException
+ {
+ socket.disconnect ();
+ return this;
+ }
+
+ public boolean isConnected ()
+ {
+ return socket.isConnected ();
+ }
+
+ public int write (ByteBuffer src)
+ throws IOException
+ {
+ if (!isConnected ())
+ throw new NotYetConnectedException ();
+
+ return send (src, socket.getRemoteSocketAddress());
+ }
+
+ public long write (ByteBuffer[] srcs, int offset, int length)
+ throws IOException
+ {
+ if (!isConnected())
+ throw new NotYetConnectedException();
+
+ if ((offset < 0)
+ || (offset > srcs.length)
+ || (length < 0)
+ || (length > (srcs.length - offset)))
+ throw new IndexOutOfBoundsException();
+
+ long result = 0;
+
+ for (int index = offset; index < offset + length; index++)
+ result += write (srcs [index]);
+
+ return result;
+ }
+
+ public int read (ByteBuffer dst)
+ throws IOException
+ {
+ if (!isConnected ())
+ throw new NotYetConnectedException ();
+
+ int remaining = dst.remaining();
+ receive (dst);
+ return remaining - dst.remaining();
+ }
+
+ public long read (ByteBuffer[] dsts, int offset, int length)
+ throws IOException
+ {
+ if (!isConnected())
+ throw new NotYetConnectedException();
+
+ if ((offset < 0)
+ || (offset > dsts.length)
+ || (length < 0)
+ || (length > (dsts.length - offset)))
+ throw new IndexOutOfBoundsException();
+
+ long result = 0;
+
+ for (int index = offset; index < offset + length; index++)
+ result += read (dsts [index]);
+
+ return result;
+ }
+
+ public SocketAddress receive (ByteBuffer dst)
+ throws IOException
+ {
+ if (!isOpen())
+ throw new ClosedChannelException();
+
+ try
+ {
+ DatagramPacket packet;
+ int len = dst.remaining();
+
+ if (dst.hasArray())
+ {
+ packet = new DatagramPacket (dst.array(),
+ dst.arrayOffset() + dst.position(),
+ len);
+ }
+ else
+ {
+ packet = new DatagramPacket (new byte [len], len);
+ }
+
+ boolean completed = false;
+
+ try
+ {
+ begin();
+ setInChannelOperation(true);
+ socket.receive (packet);
+ completed = true;
+ }
+ finally
+ {
+ end (completed);
+ setInChannelOperation(false);
+ }
+
+ if (!dst.hasArray())
+ {
+ dst.put (packet.getData(), packet.getOffset(), packet.getLength());
+ }
+ else
+ {
+ dst.position (dst.position() + packet.getLength());
+ }
+
+ return packet.getSocketAddress();
+ }
+ catch (SocketTimeoutException e)
+ {
+ return null;
+ }
+ }
+
+ public int send (ByteBuffer src, SocketAddress target)
+ throws IOException
+ {
+ if (!isOpen())
+ throw new ClosedChannelException();
+
+ if (target instanceof InetSocketAddress
+ && ((InetSocketAddress) target).isUnresolved())
+ throw new IOException("Target address not resolved");
+
+ byte[] buffer;
+ int offset = 0;
+ int len = src.remaining();
+
+ if (src.hasArray())
+ {
+ buffer = src.array();
+ offset = src.arrayOffset() + src.position();
+ }
+ else
+ {
+ buffer = new byte [len];
+ src.get (buffer);
+ }
+
+ DatagramPacket packet = new DatagramPacket (buffer, offset, len, target);
+
+ boolean completed = false;
+ try
+ {
+ begin();
+ setInChannelOperation(true);
+ socket.send(packet);
+ completed = true;
+ }
+ finally
+ {
+ end (completed);
+ setInChannelOperation(false);
+ }
+
+ if (src.hasArray())
+ {
+ src.position (src.position() + len);
+ }
+
+ return len;
+ }
+}
Added: llvm-gcc-4.2/trunk/libjava/classpath/gnu/java/nio/DatagramChannelSelectionKey.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/gnu/java/nio/DatagramChannelSelectionKey.java?rev=43913&view=auto
==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/gnu/java/nio/DatagramChannelSelectionKey.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/gnu/java/nio/DatagramChannelSelectionKey.java Thu Nov 8 16:56:19 2007
@@ -0,0 +1,61 @@
+/* DatagramChannelSelectionKey.java --
+ Copyright (C) 2003, 2005 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 gnu.java.nio;
+
+import java.nio.channels.spi.AbstractSelectableChannel;
+
+/**
+ * @author Michael Koch
+ */
+public final class DatagramChannelSelectionKey
+ extends SelectionKeyImpl
+{
+ public DatagramChannelSelectionKey (AbstractSelectableChannel channel,
+ SelectorImpl selector)
+ {
+ super (channel, selector);
+ }
+
+ public int getNativeFD()
+ {
+ NIODatagramSocket socket =
+ (NIODatagramSocket) ((DatagramChannelImpl) ch).socket();
+ return socket.getPlainDatagramSocketImpl().getNativeFD();
+ }
+}
Added: llvm-gcc-4.2/trunk/libjava/classpath/gnu/java/nio/FileLockImpl.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/gnu/java/nio/FileLockImpl.java?rev=43913&view=auto
==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/gnu/java/nio/FileLockImpl.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/gnu/java/nio/FileLockImpl.java Thu Nov 8 16:56:19 2007
@@ -0,0 +1,104 @@
+/* FileLockImpl.java -- FileLock associated with a FileChannelImpl.
+ Copyright (C) 2002, 2004, 2005 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 gnu.java.nio;
+
+import gnu.java.nio.channels.FileChannelImpl;
+
+import java.io.IOException;
+import java.nio.channels.FileLock;
+
+/**
+ * A FileLock associated with a FileChannelImpl.
+ *
+ * @author Michael Koch
+ * @since 1.4
+ */
+public final class FileLockImpl extends FileLock
+{
+ /**
+ * Whether or not this lock is valid, false when channel is closed or
+ * release has been explicitly called.
+ */
+ private boolean valid;
+
+ public FileLockImpl (FileChannelImpl channel, long position,
+ long size, boolean shared)
+ {
+ super (channel, position, size, shared);
+ valid = true;
+ }
+
+ /**
+ * Releases this lock.
+ */
+ protected void finalize()
+ {
+ try
+ {
+ release();
+ }
+ catch (IOException e)
+ {
+ // Ignore this.
+ }
+ }
+
+ /**
+ * Whether or not this lock is valid, false when channel is closed or
+ * release has been explicitly called.
+ */
+ public boolean isValid()
+ {
+ if (valid)
+ valid = channel().isOpen();
+ return valid;
+ }
+
+ /**
+ * Releases the lock if it is still valid. Marks this lock as invalid.
+ */
+ public void release() throws IOException
+ {
+ if (isValid())
+ {
+ valid = false;
+ ((FileChannelImpl) channel()).unlock(position(), size());
+ }
+ }
+}
Added: llvm-gcc-4.2/trunk/libjava/classpath/gnu/java/nio/InputStreamChannel.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/gnu/java/nio/InputStreamChannel.java?rev=43913&view=auto
==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/gnu/java/nio/InputStreamChannel.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/gnu/java/nio/InputStreamChannel.java Thu Nov 8 16:56:19 2007
@@ -0,0 +1,88 @@
+/* InputStreamChannel.java --
+ Copyright (C) 2003 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 gnu.java.nio;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.nio.ByteBuffer;
+import java.nio.channels.ClosedChannelException;
+import java.nio.channels.ReadableByteChannel;
+
+/**
+ * @author Michael Koch
+ */
+public final class InputStreamChannel implements ReadableByteChannel
+{
+ private boolean closed = false;
+ private InputStream in;
+
+ public InputStreamChannel (InputStream in)
+ {
+ super();
+ this.in = in;
+ }
+
+ public void close() throws IOException
+ {
+ if (!closed)
+ {
+ in.close();
+ closed = true;
+ }
+ }
+
+ public boolean isOpen()
+ {
+ return !closed;
+ }
+
+ public int read (ByteBuffer dst) throws IOException
+ {
+ if (!isOpen())
+ throw new ClosedChannelException();
+
+ byte[] buffer = new byte [dst.remaining()];
+ int readBytes = in.read (buffer);
+
+ if (readBytes > 0)
+ dst.put (buffer, 0, readBytes);
+
+ return readBytes;
+ }
+}
Added: llvm-gcc-4.2/trunk/libjava/classpath/gnu/java/nio/NIOConstants.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/gnu/java/nio/NIOConstants.java?rev=43913&view=auto
==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/gnu/java/nio/NIOConstants.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/gnu/java/nio/NIOConstants.java Thu Nov 8 16:56:19 2007
@@ -0,0 +1,47 @@
+/* NIOConstants.java --
+ Copyright (C) 2003 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 gnu.java.nio;
+
+/**
+ * @author Michael Koch
+ */
+public final class NIOConstants
+{
+ public static final int DEFAULT_TIMEOUT = 50;
+}
Added: llvm-gcc-4.2/trunk/libjava/classpath/gnu/java/nio/NIODatagramSocket.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/gnu/java/nio/NIODatagramSocket.java?rev=43913&view=auto
==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/gnu/java/nio/NIODatagramSocket.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/gnu/java/nio/NIODatagramSocket.java Thu Nov 8 16:56:19 2007
@@ -0,0 +1,71 @@
+/* NIODatagramSocket.java --
+ Copyright (C) 2003 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 gnu.java.nio;
+
+import gnu.java.net.PlainDatagramSocketImpl;
+
+import java.net.DatagramSocket;
+import java.nio.channels.DatagramChannel;
+
+/**
+ * @author Michael Koch
+ */
+public final class NIODatagramSocket extends DatagramSocket
+{
+ private PlainDatagramSocketImpl impl;
+ private DatagramChannelImpl channel;
+
+ public NIODatagramSocket (PlainDatagramSocketImpl impl,
+ DatagramChannelImpl channel)
+ {
+ super (impl);
+ this.impl = impl;
+ this.channel = channel;
+ }
+
+ public final PlainDatagramSocketImpl getPlainDatagramSocketImpl()
+ {
+ return impl;
+ }
+
+ public final DatagramChannel getChannel()
+ {
+ return channel;
+ }
+}
Added: llvm-gcc-4.2/trunk/libjava/classpath/gnu/java/nio/NIOServerSocket.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/gnu/java/nio/NIOServerSocket.java?rev=43913&view=auto
==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/gnu/java/nio/NIOServerSocket.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/gnu/java/nio/NIOServerSocket.java Thu Nov 8 16:56:19 2007
@@ -0,0 +1,106 @@
+/* NIOServerSocket.java --
+ Copyright (C) 2003, 2004 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 gnu.java.nio;
+
+import gnu.java.net.PlainSocketImpl;
+
+import java.io.IOException;
+import java.lang.reflect.Method;
+import java.net.ServerSocket;
+import java.net.Socket;
+import java.nio.channels.ServerSocketChannel;
+import java.nio.channels.SocketChannel;
+import java.security.AccessController;
+import java.security.PrivilegedExceptionAction;
+
+/**
+ * @author Michael Koch (konqueror at gmx.de)
+ */
+public final class NIOServerSocket extends ServerSocket
+{
+ private ServerSocketChannelImpl channel;
+
+ protected NIOServerSocket (ServerSocketChannelImpl channel)
+ throws IOException
+ {
+ super();
+ this.channel = channel;
+ }
+
+ public PlainSocketImpl getPlainSocketImpl()
+ {
+ try
+ {
+ final Object t = this;
+ final Method method = ServerSocket.class.getDeclaredMethod("getImpl", new Class[0]);
+ method.setAccessible(true);
+ PrivilegedExceptionAction action = new PrivilegedExceptionAction()
+ {
+ public Object run() throws Exception
+ {
+ return method.invoke(t, new Object[0]);
+ }
+ };
+ return (PlainSocketImpl) AccessController.doPrivileged(action);
+ }
+ catch (Exception e)
+ {
+ // This should never happen.
+ Error error = new InternalError("unable to invoke method ServerSocket.getImpl()");
+ error.initCause(e);
+ throw error;
+ }
+ }
+
+ public ServerSocketChannel getChannel()
+ {
+ return channel;
+ }
+
+ public Socket accept() throws IOException
+ {
+ SecurityManager sm = System.getSecurityManager();
+ if (sm != null)
+ sm.checkListen (getLocalPort());
+
+ SocketChannel socketChannel = channel.provider().openSocketChannel();
+ implAccept (socketChannel.socket());
+ return socketChannel.socket();
+ }
+}
Added: llvm-gcc-4.2/trunk/libjava/classpath/gnu/java/nio/NIOSocket.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/gnu/java/nio/NIOSocket.java?rev=43913&view=auto
==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/gnu/java/nio/NIOSocket.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/gnu/java/nio/NIOSocket.java Thu Nov 8 16:56:19 2007
@@ -0,0 +1,77 @@
+/* NIOSocket.java --
+ Copyright (C) 2003 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 gnu.java.nio;
+
+import gnu.java.net.PlainSocketImpl;
+import java.io.IOException;
+import java.net.Socket;
+import java.nio.channels.SocketChannel;
+
+/**
+ * @author Michael Koch
+ */
+public final class NIOSocket extends Socket
+{
+ private PlainSocketImpl impl;
+ private SocketChannelImpl channel;
+
+ protected NIOSocket (PlainSocketImpl impl, SocketChannelImpl channel)
+ throws IOException
+ {
+ super (impl);
+ this.impl = impl;
+ this.channel = channel;
+ }
+
+ public final PlainSocketImpl getPlainSocketImpl()
+ {
+ return impl;
+ }
+
+ final void setChannel (SocketChannelImpl channel)
+ {
+ this.impl = channel.getPlainSocketImpl();
+ this.channel = channel;
+ }
+
+ public final SocketChannel getChannel()
+ {
+ return channel;
+ }
+}
Added: llvm-gcc-4.2/trunk/libjava/classpath/gnu/java/nio/OutputStreamChannel.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/gnu/java/nio/OutputStreamChannel.java?rev=43913&view=auto
==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/gnu/java/nio/OutputStreamChannel.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/gnu/java/nio/OutputStreamChannel.java Thu Nov 8 16:56:19 2007
@@ -0,0 +1,87 @@
+/* OutputStreamChannel.java --
+ Copyright (C) 2003 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 gnu.java.nio;
+
+import java.io.IOException;
+import java.io.OutputStream;
+import java.nio.ByteBuffer;
+import java.nio.channels.ClosedChannelException;
+import java.nio.channels.WritableByteChannel;
+
+/**
+ * @author Michael Koch
+ */
+public final class OutputStreamChannel implements WritableByteChannel
+{
+ private boolean closed = false;
+ private OutputStream out;
+
+ public OutputStreamChannel (OutputStream out)
+ {
+ super();
+
+ this.out = out;
+ }
+
+ public void close() throws IOException
+ {
+ if (!closed)
+ {
+ out.close();
+ closed = true;
+ }
+ }
+
+ public boolean isOpen()
+ {
+ return !closed;
+ }
+
+ public int write (ByteBuffer src) throws IOException
+ {
+ if (!isOpen())
+ throw new ClosedChannelException();
+
+ int len = src.remaining();
+ byte[] buffer = new byte [len];
+ src.get (buffer);
+ out.write (buffer);
+ return len;
+ }
+}
Added: llvm-gcc-4.2/trunk/libjava/classpath/gnu/java/nio/PipeImpl.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/gnu/java/nio/PipeImpl.java?rev=43913&view=auto
==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/gnu/java/nio/PipeImpl.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/gnu/java/nio/PipeImpl.java Thu Nov 8 16:56:19 2007
@@ -0,0 +1,178 @@
+/* PipeImpl.java --
+ Copyright (C) 2002, 2003, 2004, 2005 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 gnu.java.nio;
+
+
+import java.io.IOException;
+import java.nio.ByteBuffer;
+import java.nio.channels.Pipe;
+import java.nio.channels.spi.SelectorProvider;
+
+class PipeImpl extends Pipe
+{
+ public static final class SourceChannelImpl extends Pipe.SourceChannel
+ {
+ private int native_fd;
+ private VMChannel vmch;
+
+ public SourceChannelImpl (SelectorProvider selectorProvider,
+ int native_fd)
+ {
+ super (selectorProvider);
+ this.native_fd = native_fd;
+ vmch = VMChannel.getVMChannel(this);
+ }
+
+ protected final void implCloseSelectableChannel()
+ throws IOException
+ {
+ throw new Error ("Not implemented");
+ }
+
+ protected void implConfigureBlocking (boolean blocking)
+ throws IOException
+ {
+ vmch.setBlocking(blocking);
+ }
+
+ public final int read (ByteBuffer src)
+ throws IOException
+ {
+ return vmch.read(src);
+ }
+
+ public final long read (ByteBuffer[] srcs)
+ throws IOException
+ {
+ return vmch.readScattering(srcs, 0, srcs.length);
+ }
+
+ public final synchronized long read (ByteBuffer[] srcs, int offset,
+ int len)
+ throws IOException
+ {
+ if (offset < 0
+ || offset > srcs.length
+ || len < 0
+ || len > srcs.length - offset)
+ throw new IndexOutOfBoundsException();
+
+ return vmch.readScattering(srcs, offset, len);
+ }
+
+ public final int getNativeFD()
+ {
+ return native_fd;
+ }
+ }
+
+ public static final class SinkChannelImpl extends Pipe.SinkChannel
+ {
+ private int native_fd;
+ private VMChannel vmch;
+
+ public SinkChannelImpl (SelectorProvider selectorProvider,
+ int native_fd)
+ {
+ super (selectorProvider);
+ this.native_fd = native_fd;
+ vmch = VMChannel.getVMChannel(this);
+ }
+
+ protected final void implCloseSelectableChannel()
+ throws IOException
+ {
+ throw new Error ("Not implemented");
+ }
+
+ protected final void implConfigureBlocking (boolean blocking)
+ throws IOException
+ {
+ vmch.setBlocking(blocking);
+ }
+
+ public final int write (ByteBuffer dst)
+ throws IOException
+ {
+ return vmch.write(dst);
+ }
+
+ public final long write (ByteBuffer[] srcs)
+ throws IOException
+ {
+ return vmch.writeGathering(srcs, 0, srcs.length);
+ }
+
+ public final synchronized long write (ByteBuffer[] srcs, int offset, int len)
+ throws IOException
+ {
+ if (offset < 0
+ || offset > srcs.length
+ || len < 0
+ || len > srcs.length - offset)
+ throw new IndexOutOfBoundsException();
+
+ return vmch.writeGathering(srcs, offset, len);
+ }
+
+ public final int getNativeFD()
+ {
+ return native_fd;
+ }
+ }
+
+ private SinkChannelImpl sink;
+ private SourceChannelImpl source;
+
+ public PipeImpl (SelectorProvider provider)
+ throws IOException
+ {
+ super();
+ VMPipe.init (this, provider);
+ }
+
+ public Pipe.SinkChannel sink()
+ {
+ return sink;
+ }
+
+ public Pipe.SourceChannel source()
+ {
+ return source;
+ }
+}
Added: llvm-gcc-4.2/trunk/libjava/classpath/gnu/java/nio/SelectionKeyImpl.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/gnu/java/nio/SelectionKeyImpl.java?rev=43913&view=auto
==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/gnu/java/nio/SelectionKeyImpl.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/gnu/java/nio/SelectionKeyImpl.java Thu Nov 8 16:56:19 2007
@@ -0,0 +1,110 @@
+/* SelectionKeyImpl.java --
+ Copyright (C) 2002, 2003, 2006 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 gnu.java.nio;
+
+import java.nio.channels.CancelledKeyException;
+import java.nio.channels.SelectableChannel;
+import java.nio.channels.SelectionKey;
+import java.nio.channels.Selector;
+import java.nio.channels.spi.AbstractSelectionKey;
+
+public abstract class SelectionKeyImpl extends AbstractSelectionKey
+{
+ private int readyOps;
+ private int interestOps;
+ private final SelectorImpl impl;
+ final SelectableChannel ch;
+
+ public SelectionKeyImpl (SelectableChannel ch, SelectorImpl impl)
+ {
+ this.ch = ch;
+ this.impl = impl;
+ }
+
+ public SelectableChannel channel ()
+ {
+ return ch;
+ }
+
+ public synchronized int readyOps ()
+ {
+ if (!isValid())
+ throw new CancelledKeyException();
+
+ return readyOps;
+ }
+
+ public synchronized SelectionKey readyOps (int ops)
+ {
+ if (!isValid())
+ throw new CancelledKeyException();
+
+ readyOps = ops;
+ return this;
+ }
+
+ public int interestOps ()
+ {
+ if (!isValid())
+ throw new CancelledKeyException();
+
+ synchronized (impl.selectedKeys())
+ {
+ return interestOps;
+ }
+ }
+
+ public SelectionKey interestOps (int ops)
+ {
+ if (!isValid())
+ throw new CancelledKeyException();
+
+ synchronized (impl.selectedKeys())
+ {
+ interestOps = ops;
+ }
+ return this;
+ }
+
+ public Selector selector ()
+ {
+ return impl;
+ }
+
+ public abstract int getNativeFD();
+}
Added: llvm-gcc-4.2/trunk/libjava/classpath/gnu/java/nio/SelectorImpl.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/gnu/java/nio/SelectorImpl.java?rev=43913&view=auto
==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/gnu/java/nio/SelectorImpl.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/gnu/java/nio/SelectorImpl.java Thu Nov 8 16:56:19 2007
@@ -0,0 +1,397 @@
+/* SelectorImpl.java --
+ Copyright (C) 2002, 2003, 2004, 2006 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 gnu.java.nio;
+
+import java.io.IOException;
+import java.nio.channels.ClosedSelectorException;
+import java.nio.channels.SelectableChannel;
+import java.nio.channels.SelectionKey;
+import java.nio.channels.Selector;
+import java.nio.channels.SocketChannel;
+import java.nio.channels.spi.AbstractSelectableChannel;
+import java.nio.channels.spi.AbstractSelector;
+import java.nio.channels.spi.SelectorProvider;
+import java.util.Collections;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.Set;
+
+public class SelectorImpl extends AbstractSelector
+{
+ private Set keys;
+ private Set selected;
+
+ /**
+ * A dummy object whose monitor regulates access to both our
+ * selectThread and unhandledWakeup fields.
+ */
+ private Object selectThreadMutex = new Object ();
+
+ /**
+ * Any thread that's currently blocked in a select operation.
+ */
+ private Thread selectThread;
+
+ /**
+ * Indicates whether we have an unhandled wakeup call. This can
+ * be due to either wakeup() triggering a thread interruption while
+ * a thread was blocked in a select operation (in which case we need
+ * to reset this thread's interrupt status after interrupting the
+ * select), or else that no thread was on a select operation at the
+ * time that wakeup() was called, in which case the following select()
+ * operation should return immediately with nothing selected.
+ */
+ private boolean unhandledWakeup;
+
+ public SelectorImpl (SelectorProvider provider)
+ {
+ super (provider);
+
+ keys = new HashSet ();
+ selected = new HashSet ();
+ }
+
+ protected void finalize() throws Throwable
+ {
+ close();
+ }
+
+ protected final void implCloseSelector()
+ throws IOException
+ {
+ // Cancel any pending select operation.
+ wakeup();
+
+ synchronized (keys)
+ {
+ synchronized (selected)
+ {
+ synchronized (cancelledKeys ())
+ {
+ // FIXME: Release resources here.
+ }
+ }
+ }
+ }
+
+ public final Set keys()
+ {
+ if (!isOpen())
+ throw new ClosedSelectorException();
+
+ return Collections.unmodifiableSet (keys);
+ }
+
+ public final int selectNow()
+ throws IOException
+ {
+ // FIXME: We're simulating an immediate select
+ // via a select with a timeout of one millisecond.
+ return select (1);
+ }
+
+ public final int select()
+ throws IOException
+ {
+ return select (0);
+ }
+
+ private final int[] getFDsAsArray (int ops)
+ {
+ int[] result;
+ int counter = 0;
+ Iterator it = keys.iterator ();
+
+ // Count the number of file descriptors needed
+ while (it.hasNext ())
+ {
+ SelectionKeyImpl key = (SelectionKeyImpl) it.next ();
+
+ if ((key.interestOps () & ops) != 0)
+ {
+ counter++;
+ }
+ }
+
+ result = new int[counter];
+
+ counter = 0;
+ it = keys.iterator ();
+
+ // Fill the array with the file descriptors
+ while (it.hasNext ())
+ {
+ SelectionKeyImpl key = (SelectionKeyImpl) it.next ();
+
+ if ((key.interestOps () & ops) != 0)
+ {
+ result[counter] = key.getNativeFD();
+ counter++;
+ }
+ }
+
+ return result;
+ }
+
+ public synchronized int select (long timeout)
+ throws IOException
+ {
+ if (!isOpen())
+ throw new ClosedSelectorException();
+
+ synchronized (keys)
+ {
+ synchronized (selected)
+ {
+ deregisterCancelledKeys();
+
+ // Set only keys with the needed interest ops into the arrays.
+ int[] read = getFDsAsArray (SelectionKey.OP_READ
+ | SelectionKey.OP_ACCEPT);
+ int[] write = getFDsAsArray (SelectionKey.OP_WRITE
+ | SelectionKey.OP_CONNECT);
+
+ // FIXME: We dont need to check this yet
+ int[] except = new int [0];
+
+ // Test to see if we've got an unhandled wakeup call,
+ // in which case we return immediately. Otherwise,
+ // remember our current thread and jump into the select.
+ // The monitor for dummy object selectThreadMutex regulates
+ // access to these fields.
+
+ // FIXME: Not sure from the spec at what point we should
+ // return "immediately". Is it here or immediately upon
+ // entry to this function?
+
+ // NOTE: There's a possibility of another thread calling
+ // wakeup() immediately after our thread releases
+ // selectThreadMutex's monitor here, in which case we'll
+ // do the select anyway. Since calls to wakeup() and select()
+ // among different threads happen in non-deterministic order,
+ // I don't think this is an issue.
+ synchronized (selectThreadMutex)
+ {
+ if (unhandledWakeup)
+ {
+ unhandledWakeup = false;
+ return 0;
+ }
+ else
+ {
+ selectThread = Thread.currentThread ();
+ }
+ }
+
+ // Call the native select() on all file descriptors.
+ int result = 0;
+ try
+ {
+ begin();
+ result = VMSelector.select (read, write, except, timeout);
+ }
+ finally
+ {
+ end();
+ }
+
+ // If our unhandled wakeup flag is set at this point,
+ // reset our thread's interrupt flag because we were
+ // awakened by wakeup() instead of an external thread
+ // interruption.
+ //
+ // NOTE: If we were blocked in a select() and one thread
+ // called Thread.interrupt() on the blocked thread followed
+ // by another thread calling Selector.wakeup(), then race
+ // conditions could make it so that the thread's interrupt
+ // flag is reset even though the Thread.interrupt() call
+ // "was there first". I don't think we need to care about
+ // this scenario.
+ synchronized (selectThreadMutex)
+ {
+ if (unhandledWakeup)
+ {
+ unhandledWakeup = false;
+ Thread.interrupted ();
+ }
+ selectThread = null;
+ }
+
+ Iterator it = keys.iterator ();
+
+ while (it.hasNext ())
+ {
+ int ops = 0;
+ SelectionKeyImpl key = (SelectionKeyImpl) it.next ();
+
+ // If key is already selected retrieve old ready ops.
+ if (selected.contains (key))
+ {
+ ops = key.readyOps ();
+ }
+
+ // Set new ready read/accept ops
+ for (int i = 0; i < read.length; i++)
+ {
+ if (key.getNativeFD() == read[i])
+ {
+ if (key.channel () instanceof ServerSocketChannelImpl)
+ {
+ ops = ops | SelectionKey.OP_ACCEPT;
+ }
+ else
+ {
+ ops = ops | SelectionKey.OP_READ;
+ }
+ }
+ }
+
+ // Set new ready write ops
+ for (int i = 0; i < write.length; i++)
+ {
+ if (key.getNativeFD() == write[i])
+ {
+ if (key.channel() instanceof SocketChannel)
+ {
+ if (((SocketChannel) key.channel ()).isConnected ())
+ ops = ops | SelectionKey.OP_WRITE;
+ else
+ ops = ops | SelectionKey.OP_CONNECT;
+ }
+ else
+ ops = ops | SelectionKey.OP_WRITE;
+ }
+ }
+
+ // FIXME: We dont handle exceptional file descriptors yet.
+
+ // If key is not yet selected add it.
+ if (!selected.contains (key))
+ {
+ selected.add (key);
+ }
+
+ // Set new ready ops
+ key.readyOps (key.interestOps () & ops);
+ }
+ deregisterCancelledKeys();
+
+ return result;
+ }
+ }
+ }
+
+ public final Set selectedKeys()
+ {
+ if (!isOpen())
+ throw new ClosedSelectorException();
+
+ return selected;
+ }
+
+ public final Selector wakeup()
+ {
+ // IMPLEMENTATION NOTE: Whereas the specification says that
+ // thread interruption should trigger a call to wakeup, we
+ // do the reverse under the covers: wakeup triggers a thread
+ // interrupt followed by a subsequent reset of the thread's
+ // interrupt status within select().
+
+ // First, acquire the monitor of the object regulating
+ // access to our selectThread and unhandledWakeup fields.
+ synchronized (selectThreadMutex)
+ {
+ unhandledWakeup = true;
+
+ // Interrupt any thread which is currently blocked in
+ // a select operation.
+ if (selectThread != null)
+ selectThread.interrupt ();
+ }
+
+ return this;
+ }
+
+ private final void deregisterCancelledKeys()
+ {
+ Set ckeys = cancelledKeys ();
+ synchronized (ckeys)
+ {
+ Iterator it = ckeys.iterator();
+
+ while (it.hasNext ())
+ {
+ keys.remove ((SelectionKeyImpl) it.next ());
+ it.remove ();
+ }
+ }
+ }
+
+ protected SelectionKey register (SelectableChannel ch, int ops, Object att)
+ {
+ return register ((AbstractSelectableChannel) ch, ops, att);
+ }
+
+ protected final SelectionKey register (AbstractSelectableChannel ch, int ops,
+ Object att)
+ {
+ SelectionKeyImpl result;
+
+ if (ch instanceof SocketChannelImpl)
+ result = new SocketChannelSelectionKey (ch, this);
+ else if (ch instanceof DatagramChannelImpl)
+ result = new DatagramChannelSelectionKey (ch, this);
+ else if (ch instanceof ServerSocketChannelImpl)
+ result = new ServerSocketChannelSelectionKey (ch, this);
+ else if (ch instanceof gnu.java.nio.SocketChannelImpl)
+ result = new gnu.java.nio.SocketChannelSelectionKeyImpl((gnu.java.nio.SocketChannelImpl)ch, this);
+ else
+ throw new InternalError ("No known channel type");
+
+ synchronized (keys)
+ {
+ keys.add (result);
+
+ result.interestOps (ops);
+ result.attach (att);
+ }
+
+ return result;
+ }
+}
Added: llvm-gcc-4.2/trunk/libjava/classpath/gnu/java/nio/SelectorProviderImpl.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/gnu/java/nio/SelectorProviderImpl.java?rev=43913&view=auto
==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/gnu/java/nio/SelectorProviderImpl.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/gnu/java/nio/SelectorProviderImpl.java Thu Nov 8 16:56:19 2007
@@ -0,0 +1,83 @@
+/* SelectorProviderImpl.java --
+ Copyright (C) 2002, 2003 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 gnu.java.nio;
+
+import java.io.IOException;
+import java.nio.channels.DatagramChannel;
+import java.nio.channels.Pipe;
+import java.nio.channels.ServerSocketChannel;
+import java.nio.channels.SocketChannel;
+import java.nio.channels.spi.AbstractSelector;
+import java.nio.channels.spi.SelectorProvider;
+
+public class SelectorProviderImpl extends SelectorProvider
+{
+ public SelectorProviderImpl ()
+ {
+ }
+
+ public DatagramChannel openDatagramChannel ()
+ throws IOException
+ {
+ return new DatagramChannelImpl (this);
+ }
+
+ public Pipe openPipe ()
+ throws IOException
+ {
+ return new PipeImpl (this);
+ }
+
+ public AbstractSelector openSelector ()
+ throws IOException
+ {
+ return new SelectorImpl (this);
+ }
+
+ public ServerSocketChannel openServerSocketChannel ()
+ throws IOException
+ {
+ return new ServerSocketChannelImpl (this);
+ }
+
+ public SocketChannel openSocketChannel ()
+ throws IOException
+ {
+ return new SocketChannelImpl (this);
+ }
+}
Added: llvm-gcc-4.2/trunk/libjava/classpath/gnu/java/nio/ServerSocketChannelImpl.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/gnu/java/nio/ServerSocketChannelImpl.java?rev=43913&view=auto
==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/gnu/java/nio/ServerSocketChannelImpl.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/gnu/java/nio/ServerSocketChannelImpl.java Thu Nov 8 16:56:19 2007
@@ -0,0 +1,124 @@
+/* ServerSocketChannelImpl.java --
+ Copyright (C) 2002, 2003, 2004 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 gnu.java.nio;
+
+import java.io.IOException;
+import java.net.ServerSocket;
+import java.net.SocketTimeoutException;
+import java.nio.channels.ClosedChannelException;
+import java.nio.channels.NotYetBoundException;
+import java.nio.channels.ServerSocketChannel;
+import java.nio.channels.SocketChannel;
+import java.nio.channels.spi.SelectorProvider;
+
+public final class ServerSocketChannelImpl extends ServerSocketChannel
+{
+ private NIOServerSocket serverSocket;
+ private boolean connected;
+
+ protected ServerSocketChannelImpl (SelectorProvider provider)
+ throws IOException
+ {
+ super (provider);
+ serverSocket = new NIOServerSocket (this);
+ configureBlocking(true);
+ }
+
+ public void finalizer()
+ {
+ if (connected)
+ {
+ try
+ {
+ close ();
+ }
+ catch (Exception e)
+ {
+ }
+ }
+ }
+
+ protected void implCloseSelectableChannel () throws IOException
+ {
+ connected = false;
+ serverSocket.close();
+ }
+
+ protected void implConfigureBlocking (boolean blocking) throws IOException
+ {
+ serverSocket.setSoTimeout (blocking ? 0 : NIOConstants.DEFAULT_TIMEOUT);
+ }
+
+ public SocketChannel accept () throws IOException
+ {
+ if (!isOpen())
+ throw new ClosedChannelException();
+
+ if (!serverSocket.isBound())
+ throw new NotYetBoundException();
+
+ boolean completed = false;
+
+ try
+ {
+ begin();
+ serverSocket.getPlainSocketImpl().setInChannelOperation(true);
+ // indicate that a channel is initiating the accept operation
+ // so that the socket ignores the fact that we might be in
+ // non-blocking mode.
+ NIOSocket socket = (NIOSocket) serverSocket.accept();
+ completed = true;
+ return socket.getChannel();
+ }
+ catch (SocketTimeoutException e)
+ {
+ return null;
+ }
+ finally
+ {
+ serverSocket.getPlainSocketImpl().setInChannelOperation(false);
+ end (completed);
+ }
+ }
+
+ public ServerSocket socket ()
+ {
+ return serverSocket;
+ }
+}
Added: llvm-gcc-4.2/trunk/libjava/classpath/gnu/java/nio/ServerSocketChannelSelectionKey.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/gnu/java/nio/ServerSocketChannelSelectionKey.java?rev=43913&view=auto
==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/gnu/java/nio/ServerSocketChannelSelectionKey.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/gnu/java/nio/ServerSocketChannelSelectionKey.java Thu Nov 8 16:56:19 2007
@@ -0,0 +1,58 @@
+/* ServerSocketChannelSelectionKey.java --
+ Copyright (C) 2003 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 gnu.java.nio;
+
+import java.nio.channels.spi.AbstractSelectableChannel;
+
+public final class ServerSocketChannelSelectionKey
+ extends SelectionKeyImpl
+{
+ public ServerSocketChannelSelectionKey (AbstractSelectableChannel channel,
+ SelectorImpl selector)
+ {
+ super (channel, selector);
+ }
+
+ public int getNativeFD()
+ {
+ NIOServerSocket socket =
+ (NIOServerSocket) ((ServerSocketChannelImpl) ch).socket();
+ return socket.getPlainSocketImpl().getNativeFD();
+ }
+}
Added: llvm-gcc-4.2/trunk/libjava/classpath/gnu/java/nio/SocketChannelImpl.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/gnu/java/nio/SocketChannelImpl.java?rev=43913&view=auto
==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/gnu/java/nio/SocketChannelImpl.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/gnu/java/nio/SocketChannelImpl.java Thu Nov 8 16:56:19 2007
@@ -0,0 +1,351 @@
+/* SocketChannelImpl.java --
+ Copyright (C) 2002, 2003, 2004 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 gnu.java.nio;
+
+import gnu.java.net.PlainSocketImpl;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.net.InetSocketAddress;
+import java.net.Socket;
+import java.net.SocketAddress;
+import java.net.SocketTimeoutException;
+import java.nio.ByteBuffer;
+import java.nio.channels.AlreadyConnectedException;
+import java.nio.channels.ClosedChannelException;
+import java.nio.channels.ConnectionPendingException;
+import java.nio.channels.NoConnectionPendingException;
+import java.nio.channels.NotYetConnectedException;
+import java.nio.channels.SelectionKey;
+import java.nio.channels.Selector;
+import java.nio.channels.SocketChannel;
+import java.nio.channels.UnresolvedAddressException;
+import java.nio.channels.UnsupportedAddressTypeException;
+import java.nio.channels.spi.SelectorProvider;
+
+public final class SocketChannelImpl extends SocketChannel
+{
+ private PlainSocketImpl impl;
+ private NIOSocket socket;
+ private boolean connectionPending;
+
+ SocketChannelImpl (SelectorProvider provider)
+ throws IOException
+ {
+ super (provider);
+ impl = new PlainSocketImpl();
+ socket = new NIOSocket (impl, this);
+ configureBlocking(true);
+ }
+
+ SocketChannelImpl (SelectorProvider provider,
+ NIOSocket socket)
+ throws IOException
+ {
+ super (provider);
+ this.impl = socket.getPlainSocketImpl();
+ this.socket = socket;
+ }
+
+ public void finalizer()
+ {
+ if (isConnected())
+ {
+ try
+ {
+ close ();
+ }
+ catch (Exception e)
+ {
+ }
+ }
+ }
+
+ PlainSocketImpl getPlainSocketImpl()
+ {
+ return impl;
+ }
+
+ protected void implCloseSelectableChannel () throws IOException
+ {
+ socket.close();
+ }
+
+ protected void implConfigureBlocking (boolean blocking) throws IOException
+ {
+ socket.setSoTimeout (blocking ? 0 : NIOConstants.DEFAULT_TIMEOUT);
+ }
+
+ public boolean connect (SocketAddress remote) throws IOException
+ {
+ if (!isOpen())
+ throw new ClosedChannelException();
+
+ if (isConnected())
+ throw new AlreadyConnectedException();
+
+ if (connectionPending)
+ throw new ConnectionPendingException();
+
+ if (!(remote instanceof InetSocketAddress))
+ throw new UnsupportedAddressTypeException();
+
+ if (((InetSocketAddress) remote).isUnresolved())
+ throw new UnresolvedAddressException();
+
+ try
+ {
+ socket.getPlainSocketImpl().setInChannelOperation(true);
+ // indicate that a channel is initiating the accept operation
+ // so that the socket ignores the fact that we might be in
+ // non-blocking mode.
+
+ if (isBlocking())
+ {
+ // Do blocking connect.
+ socket.connect (remote);
+ return true;
+ }
+
+ // Do non-blocking connect.
+ try
+ {
+ socket.connect (remote, NIOConstants.DEFAULT_TIMEOUT);
+ return true;
+ }
+ catch (SocketTimeoutException e)
+ {
+ connectionPending = true;
+ return false;
+ }
+ }
+ finally
+ {
+ socket.getPlainSocketImpl().setInChannelOperation(false);
+ }
+ }
+
+ public boolean finishConnect ()
+ throws IOException
+ {
+ if (!isOpen())
+ throw new ClosedChannelException();
+
+ if (!isConnected() && !connectionPending)
+ throw new NoConnectionPendingException();
+
+ if (isConnected())
+ return true;
+
+ // FIXME: Handle blocking/non-blocking mode.
+
+ Selector selector = provider().openSelector();
+ register(selector, SelectionKey.OP_CONNECT);
+
+ if (isBlocking())
+ {
+ selector.select(); // blocking until channel is connected.
+ connectionPending = false;
+ return true;
+ }
+
+ int ready = selector.selectNow(); // non-blocking
+ if (ready == 1)
+ {
+ connectionPending = false;
+ return true;
+ }
+
+ return false;
+ }
+
+ public boolean isConnected ()
+ {
+ return socket.isConnected();
+ }
+
+ public boolean isConnectionPending ()
+ {
+ return connectionPending;
+ }
+
+ public Socket socket ()
+ {
+ return socket;
+ }
+
+ public int read(ByteBuffer dst) throws IOException
+ {
+ if (!isConnected())
+ throw new NotYetConnectedException();
+
+ byte[] data;
+ int offset = 0;
+ InputStream input = socket.getInputStream();
+ int available = input.available();
+ int len = dst.remaining();
+
+ if ((! isBlocking()) && available == 0)
+ return 0;
+
+ if (dst.hasArray())
+ {
+ offset = dst.arrayOffset() + dst.position();
+ data = dst.array();
+ }
+ else
+ {
+ data = new byte [len];
+ }
+
+ int readBytes = 0;
+ boolean completed = false;
+
+ try
+ {
+ begin();
+ socket.getPlainSocketImpl().setInChannelOperation(true);
+ readBytes = input.read (data, offset, len);
+ completed = true;
+ }
+ finally
+ {
+ end (completed);
+ socket.getPlainSocketImpl().setInChannelOperation(false);
+ }
+
+ if (readBytes > 0)
+ if (dst.hasArray())
+ {
+ dst.position (dst.position() + readBytes);
+ }
+ else
+ {
+ dst.put (data, offset, readBytes);
+ }
+
+ return readBytes;
+ }
+
+ public long read (ByteBuffer[] dsts, int offset, int length)
+ throws IOException
+ {
+ if (!isConnected())
+ throw new NotYetConnectedException();
+
+ if ((offset < 0)
+ || (offset > dsts.length)
+ || (length < 0)
+ || (length > (dsts.length - offset)))
+ throw new IndexOutOfBoundsException();
+
+ long readBytes = 0;
+
+ for (int index = offset; index < length; index++)
+ readBytes += read (dsts [index]);
+
+ return readBytes;
+ }
+
+ public int write (ByteBuffer src)
+ throws IOException
+ {
+ if (!isConnected())
+ throw new NotYetConnectedException();
+
+ byte[] data;
+ int offset = 0;
+ int len = src.remaining();
+
+ if (!src.hasArray())
+ {
+ data = new byte [len];
+ src.get (data, 0, len);
+ }
+ else
+ {
+ offset = src.arrayOffset() + src.position();
+ data = src.array();
+ }
+
+ OutputStream output = socket.getOutputStream();
+ boolean completed = false;
+
+ try
+ {
+ begin();
+ socket.getPlainSocketImpl().setInChannelOperation(true);
+ output.write (data, offset, len);
+ completed = true;
+ }
+ finally
+ {
+ end (completed);
+ socket.getPlainSocketImpl().setInChannelOperation(false);
+ }
+
+ if (src.hasArray())
+ {
+ src.position (src.position() + len);
+ }
+
+ return len;
+ }
+
+ public long write (ByteBuffer[] srcs, int offset, int length)
+ throws IOException
+ {
+ if (!isConnected())
+ throw new NotYetConnectedException();
+
+ if ((offset < 0)
+ || (offset > srcs.length)
+ || (length < 0)
+ || (length > (srcs.length - offset)))
+ throw new IndexOutOfBoundsException();
+
+ long writtenBytes = 0;
+
+ for (int index = offset; index < length; index++)
+ writtenBytes += write (srcs [index]);
+
+ return writtenBytes;
+ }
+}
Added: llvm-gcc-4.2/trunk/libjava/classpath/gnu/java/nio/SocketChannelSelectionKey.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/gnu/java/nio/SocketChannelSelectionKey.java?rev=43913&view=auto
==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/gnu/java/nio/SocketChannelSelectionKey.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/gnu/java/nio/SocketChannelSelectionKey.java Thu Nov 8 16:56:19 2007
@@ -0,0 +1,58 @@
+/* SocketChannelSelectionKey.java --
+ Copyright (C) 2003 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 gnu.java.nio;
+
+import java.nio.channels.spi.AbstractSelectableChannel;
+
+public final class SocketChannelSelectionKey
+ extends SelectionKeyImpl
+{
+ public SocketChannelSelectionKey (AbstractSelectableChannel channel,
+ SelectorImpl selector)
+ {
+ super (channel, selector);
+ }
+
+ public int getNativeFD()
+ {
+ NIOSocket socket =
+ (NIOSocket) ((SocketChannelImpl) ch).socket();
+ return socket.getPlainSocketImpl().getNativeFD();
+ }
+}
Added: llvm-gcc-4.2/trunk/libjava/classpath/gnu/java/nio/SocketChannelSelectionKeyImpl.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/gnu/java/nio/SocketChannelSelectionKeyImpl.java?rev=43913&view=auto
==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/gnu/java/nio/SocketChannelSelectionKeyImpl.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/gnu/java/nio/SocketChannelSelectionKeyImpl.java Thu Nov 8 16:56:19 2007
@@ -0,0 +1,69 @@
+/* SocketChannelSelectionKey.java -- Selection key for Socket Channel
+ Copyright (C) 2005 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 gnu.java.nio;
+
+
+/**
+ * @author Michael Barker <mike at middlesoft.co.uk>
+ *
+ */
+public class SocketChannelSelectionKeyImpl extends SelectionKeyImpl
+{
+
+ SocketChannelImpl ch;
+
+ /**
+ * @param ch
+ * @param impl
+ */
+ public SocketChannelSelectionKeyImpl(SocketChannelImpl ch, SelectorImpl impl)
+ {
+ super(ch, impl);
+ this.ch = (SocketChannelImpl) ch;
+ }
+
+ /**
+ * Returns the native file/socket descriptor as an int.
+ */
+ public int getNativeFD()
+ {
+ return ch.getPlainSocketImpl().getNativeFD();
+ }
+
+}
Added: llvm-gcc-4.2/trunk/libjava/classpath/gnu/java/nio/channels/FileChannelImpl.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/gnu/java/nio/channels/FileChannelImpl.java?rev=43913&view=auto
==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/gnu/java/nio/channels/FileChannelImpl.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/gnu/java/nio/channels/FileChannelImpl.java Thu Nov 8 16:56:19 2007
@@ -0,0 +1,553 @@
+/* FileChannelImpl.java --
+ Copyright (C) 2002, 2004, 2005, 2006 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 gnu.java.nio.channels;
+
+import gnu.classpath.Configuration;
+import gnu.java.nio.FileLockImpl;
+import gnu.java.nio.VMChannel;
+
+import java.io.File;
+import java.io.FileNotFoundException;
+import java.io.IOException;
+import java.nio.ByteBuffer;
+import java.nio.MappedByteBuffer;
+import java.nio.channels.ClosedChannelException;
+import java.nio.channels.FileChannel;
+import java.nio.channels.FileLock;
+import java.nio.channels.NonReadableChannelException;
+import java.nio.channels.NonWritableChannelException;
+import java.nio.channels.ReadableByteChannel;
+import java.nio.channels.WritableByteChannel;
+
+/**
+ * This file is not user visible !
+ * But alas, Java does not have a concept of friendly packages
+ * so this class is public.
+ * Instances of this class are created by invoking getChannel
+ * Upon a Input/Output/RandomAccessFile object.
+ */
+public final class FileChannelImpl extends FileChannel
+{
+ // These are mode values for open().
+ public static final int READ = 1;
+ public static final int WRITE = 2;
+ public static final int APPEND = 4;
+
+ // EXCL is used only when making a temp file.
+ public static final int EXCL = 8;
+ public static final int SYNC = 16;
+ public static final int DSYNC = 32;
+
+ public static FileChannelImpl in;
+ public static FileChannelImpl out;
+ public static FileChannelImpl err;
+
+ private static native void init();
+
+ static
+ {
+ if (Configuration.INIT_LOAD_LIBRARY)
+ {
+ System.loadLibrary("javanio");
+ }
+
+ init();
+
+ in = new FileChannelImpl(0, READ);
+ out = new FileChannelImpl(1, WRITE);
+ err = new FileChannelImpl(2, WRITE);
+ }
+
+ /**
+ * This is the actual native file descriptor value
+ */
+ // System's notion of file descriptor. It might seem redundant to
+ // initialize this given that it is reassigned in the constructors.
+ // However, this is necessary because if open() throws an exception
+ // we want to make sure this has the value -1. This is the most
+ // efficient way to accomplish that.
+ private int fd = -1;
+ private VMChannel ch;
+
+ private int mode;
+
+ final String description;
+
+ /* Open a file. MODE is a combination of the above mode flags. */
+ /* This is a static factory method, so that VM implementors can decide
+ * substitute subclasses of FileChannelImpl. */
+ public static FileChannelImpl create(File file, int mode)
+ throws FileNotFoundException
+ {
+ return new FileChannelImpl(file, mode);
+ }
+
+ private FileChannelImpl(File file, int mode)
+ throws FileNotFoundException
+ {
+ String path = file.getPath();
+ description = path;
+ fd = open (path, mode);
+ this.mode = mode;
+ this.ch = VMChannel.getVMChannel(this);
+
+ // First open the file and then check if it is a a directory
+ // to avoid race condition.
+ if (file.isDirectory())
+ {
+ try
+ {
+ close();
+ }
+ catch (IOException e)
+ {
+ /* ignore it */
+ }
+
+ throw new FileNotFoundException(description + " is a directory");
+ }
+ }
+
+ /**
+ * Constructor for default channels in, out and err.
+ *
+ * Used by init() (native code).
+ *
+ * @param fd the file descriptor (0, 1, 2 for stdin, stdout, stderr).
+ *
+ * @param mode READ or WRITE
+ */
+ FileChannelImpl (int fd, int mode)
+ {
+ this.fd = fd;
+ this.mode = mode;
+ this.description = "descriptor(" + fd + ")";
+ this.ch = VMChannel.getVMChannel(this);
+ }
+
+ private native int open (String path, int mode) throws FileNotFoundException;
+
+ public native int available () throws IOException;
+ private native long implPosition () throws IOException;
+ private native void seek (long newPosition) throws IOException;
+ private native void implTruncate (long size) throws IOException;
+
+ public native void unlock (long pos, long len) throws IOException;
+
+ public native long size () throws IOException;
+
+ protected native void implCloseChannel() throws IOException;
+
+ /**
+ * Makes sure the Channel is properly closed.
+ */
+ protected void finalize() throws IOException
+ {
+ if (fd != -1)
+ close();
+ }
+
+ public int read (ByteBuffer dst) throws IOException
+ {
+ /*
+ int result;
+ byte[] buffer = new byte [dst.remaining ()];
+
+ result = read (buffer, 0, buffer.length);
+
+ if (result > 0)
+ dst.put (buffer, 0, result);
+
+ return result;
+ */
+ return ch.read(dst);
+ }
+
+ public int read (ByteBuffer dst, long position)
+ throws IOException
+ {
+ if (position < 0)
+ throw new IllegalArgumentException ("position: " + position);
+ long oldPosition = implPosition ();
+ position (position);
+ int result = read(dst);
+ position (oldPosition);
+
+ return result;
+ }
+
+ public native int read ()
+ throws IOException;
+
+ public native int read (byte[] buffer, int offset, int length)
+ throws IOException;
+
+ public long read (ByteBuffer[] dsts, int offset, int length)
+ throws IOException
+ {
+ return ch.readScattering(dsts, offset, length);
+ }
+
+ public int write (ByteBuffer src) throws IOException
+ {
+ return ch.write(src);
+ }
+
+ public int write (ByteBuffer src, long position)
+ throws IOException
+ {
+ if (position < 0)
+ throw new IllegalArgumentException ("position: " + position);
+
+ if (!isOpen ())
+ throw new ClosedChannelException ();
+
+ if ((mode & WRITE) == 0)
+ throw new NonWritableChannelException ();
+
+ int result;
+ long oldPosition;
+
+ oldPosition = implPosition ();
+ seek (position);
+ result = write(src);
+ seek (oldPosition);
+
+ return result;
+ }
+
+ public native void write (byte[] buffer, int offset, int length)
+ throws IOException;
+
+ public native void write (int b) throws IOException;
+
+ public long write(ByteBuffer[] srcs, int offset, int length)
+ throws IOException
+ {
+ return ch.writeGathering(srcs, offset, length);
+ }
+
+ public native MappedByteBuffer mapImpl (char mode, long position, int size)
+ throws IOException;
+
+ public MappedByteBuffer map (FileChannel.MapMode mode,
+ long position, long size)
+ throws IOException
+ {
+ char nmode = 0;
+ if (mode == MapMode.READ_ONLY)
+ {
+ nmode = 'r';
+ if ((this.mode & READ) == 0)
+ throw new NonReadableChannelException();
+ }
+ else if (mode == MapMode.READ_WRITE || mode == MapMode.PRIVATE)
+ {
+ nmode = mode == MapMode.READ_WRITE ? '+' : 'c';
+ if ((this.mode & WRITE) != WRITE)
+ throw new NonWritableChannelException();
+ if ((this.mode & READ) != READ)
+ throw new NonReadableChannelException();
+ }
+ else
+ throw new IllegalArgumentException ("mode: " + mode);
+
+ if (position < 0 || size < 0 || size > Integer.MAX_VALUE)
+ throw new IllegalArgumentException ("position: " + position
+ + ", size: " + size);
+ return mapImpl(nmode, position, (int) size);
+ }
+
+ /**
+ * msync with the disk
+ */
+ public void force (boolean metaData) throws IOException
+ {
+ if (!isOpen ())
+ throw new ClosedChannelException ();
+
+ force ();
+ }
+
+ private native void force ();
+
+ // like transferTo, but with a count of less than 2Gbytes
+ private int smallTransferTo (long position, int count,
+ WritableByteChannel target)
+ throws IOException
+ {
+ ByteBuffer buffer;
+ try
+ {
+ // Try to use a mapped buffer if we can. If this fails for
+ // any reason we'll fall back to using a ByteBuffer.
+ buffer = map (MapMode.READ_ONLY, position, count);
+ }
+ catch (IOException e)
+ {
+ buffer = ByteBuffer.allocate (count);
+ read (buffer, position);
+ buffer.flip();
+ }
+
+ return target.write (buffer);
+ }
+
+ public long transferTo (long position, long count,
+ WritableByteChannel target)
+ throws IOException
+ {
+ if (position < 0
+ || count < 0)
+ throw new IllegalArgumentException ("position: " + position
+ + ", count: " + count);
+
+ if (!isOpen ())
+ throw new ClosedChannelException ();
+
+ if ((mode & READ) == 0)
+ throw new NonReadableChannelException ();
+
+ final int pageSize = 65536;
+ long total = 0;
+
+ while (count > 0)
+ {
+ int transferred
+ = smallTransferTo (position, (int)Math.min (count, pageSize),
+ target);
+ if (transferred < 0)
+ break;
+ total += transferred;
+ position += transferred;
+ count -= transferred;
+ }
+
+ return total;
+ }
+
+ // like transferFrom, but with a count of less than 2Gbytes
+ private int smallTransferFrom (ReadableByteChannel src, long position,
+ int count)
+ throws IOException
+ {
+ ByteBuffer buffer = null;
+
+ if (src instanceof FileChannel)
+ {
+ try
+ {
+ // Try to use a mapped buffer if we can. If this fails
+ // for any reason we'll fall back to using a ByteBuffer.
+ buffer = ((FileChannel)src).map (MapMode.READ_ONLY, position,
+ count);
+ }
+ catch (IOException e)
+ {
+ }
+ }
+
+ if (buffer == null)
+ {
+ buffer = ByteBuffer.allocate ((int) count);
+ src.read (buffer);
+ buffer.flip();
+ }
+
+ return write (buffer, position);
+ }
+
+ public long transferFrom (ReadableByteChannel src, long position,
+ long count)
+ throws IOException
+ {
+ if (position < 0
+ || count < 0)
+ throw new IllegalArgumentException ("position: " + position
+ + ", count: " + count);
+
+ if (!isOpen ())
+ throw new ClosedChannelException ();
+
+ if ((mode & WRITE) == 0)
+ throw new NonWritableChannelException ();
+
+ final int pageSize = 65536;
+ long total = 0;
+
+ while (count > 0)
+ {
+ int transferred = smallTransferFrom (src, position,
+ (int)Math.min (count, pageSize));
+ if (transferred < 0)
+ break;
+ total += transferred;
+ position += transferred;
+ count -= transferred;
+ }
+
+ return total;
+ }
+
+ // Shared sanity checks between lock and tryLock methods.
+ private void lockCheck(long position, long size, boolean shared)
+ throws IOException
+ {
+ if (position < 0
+ || size < 0)
+ throw new IllegalArgumentException ("position: " + position
+ + ", size: " + size);
+
+ if (!isOpen ())
+ throw new ClosedChannelException();
+
+ if (shared && ((mode & READ) == 0))
+ throw new NonReadableChannelException();
+
+ if (!shared && ((mode & WRITE) == 0))
+ throw new NonWritableChannelException();
+ }
+
+ public FileLock tryLock (long position, long size, boolean shared)
+ throws IOException
+ {
+ lockCheck(position, size, shared);
+
+ boolean completed = false;
+ try
+ {
+ begin();
+ boolean lockable = lock(position, size, shared, false);
+ completed = true;
+ return (lockable
+ ? new FileLockImpl(this, position, size, shared)
+ : null);
+ }
+ finally
+ {
+ end(completed);
+ }
+ }
+
+ /** Try to acquire a lock at the given position and size.
+ * On success return true.
+ * If wait as specified, block until we can get it.
+ * Otherwise return false.
+ */
+ private native boolean lock(long position, long size,
+ boolean shared, boolean wait) throws IOException;
+
+ public FileLock lock (long position, long size, boolean shared)
+ throws IOException
+ {
+ lockCheck(position, size, shared);
+
+ boolean completed = false;
+ try
+ {
+ boolean lockable = lock(position, size, shared, true);
+ completed = true;
+ return (lockable
+ ? new FileLockImpl(this, position, size, shared)
+ : null);
+ }
+ finally
+ {
+ end(completed);
+ }
+ }
+
+ public long position ()
+ throws IOException
+ {
+ if (!isOpen ())
+ throw new ClosedChannelException ();
+
+ return implPosition ();
+ }
+
+ public FileChannel position (long newPosition)
+ throws IOException
+ {
+ if (newPosition < 0)
+ throw new IllegalArgumentException ("newPosition: " + newPosition);
+
+ if (!isOpen ())
+ throw new ClosedChannelException ();
+
+ // FIXME note semantics if seeking beyond eof.
+ // We should seek lazily - only on a write.
+ seek (newPosition);
+ return this;
+ }
+
+ public FileChannel truncate (long size)
+ throws IOException
+ {
+ if (size < 0)
+ throw new IllegalArgumentException ("size: " + size);
+
+ if (!isOpen ())
+ throw new ClosedChannelException ();
+
+ if ((mode & WRITE) == 0)
+ throw new NonWritableChannelException ();
+
+ if (size < size ())
+ implTruncate (size);
+
+ return this;
+ }
+
+ public String toString()
+ {
+ return (this.getClass()
+ + "[fd=" + fd
+ + ",mode=" + mode + ","
+ + description + "]");
+ }
+
+ /**
+ * @return The native file descriptor.
+ */
+ public int getNativeFD()
+ {
+ return fd;
+ }
+}
Added: llvm-gcc-4.2/trunk/libjava/classpath/gnu/java/nio/channels/package.html
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/gnu/java/nio/channels/package.html?rev=43913&view=auto
==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/gnu/java/nio/channels/package.html (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/gnu/java/nio/channels/package.html Thu Nov 8 16:56:19 2007
@@ -0,0 +1,46 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
+<!-- package.html - describes classes in gnu.java.nio.channels package.
+ Copyright (C) 2005 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. -->
+
+<html>
+<head><title>GNU Classpath - gnu.java.nio.channels</title></head>
+
+<body>
+<p></p>
+
+</body>
+</html>
Added: llvm-gcc-4.2/trunk/libjava/classpath/gnu/java/nio/charset/ByteCharset.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/gnu/java/nio/charset/ByteCharset.java?rev=43913&view=auto
==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/gnu/java/nio/charset/ByteCharset.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/gnu/java/nio/charset/ByteCharset.java Thu Nov 8 16:56:19 2007
@@ -0,0 +1,203 @@
+/* ByteCharset.java -- Abstract class for generic 1-byte encodings.
+ Copyright (C) 2005 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 gnu.java.nio.charset;
+
+import java.nio.ByteBuffer;
+import java.nio.CharBuffer;
+import java.nio.charset.Charset;
+import java.nio.charset.CharsetDecoder;
+import java.nio.charset.CharsetEncoder;
+import java.nio.charset.CoderResult;
+
+/**
+ * A generic encoding framework for single-byte encodings,
+ * utilizing a look-up table.
+ *
+ * This replaces the gnu.java.io.EncoderEightBitLookup class,
+ * created by Aron Renn.
+ *
+ * @author Sven de Marothy
+ */
+abstract class ByteCharset extends Charset
+{
+ protected char[] lookupTable;
+ /**
+ * Char to signify the character in the table is undefined
+ */
+ protected static final char NONE = (char)0xFFFD;
+
+ ByteCharset (String canonicalName, String[] aliases)
+ {
+ super (canonicalName, aliases);
+ }
+
+ /**
+ * Most western charsets include ASCII, but this should
+ * be overloaded for others.
+ */
+ public boolean contains (Charset cs)
+ {
+ return cs instanceof US_ASCII || (cs.getClass() == getClass());
+ }
+
+ char[] getLookupTable()
+ {
+ return lookupTable;
+ }
+
+ public CharsetDecoder newDecoder ()
+ {
+ return new Decoder (this);
+ }
+
+ public CharsetEncoder newEncoder ()
+ {
+ return new Encoder (this);
+ }
+
+ private static final class Decoder extends CharsetDecoder
+ {
+ private char[] lookup;
+
+ // Package-private to avoid a trampoline constructor.
+ Decoder (ByteCharset cs)
+ {
+ super (cs, 1.0f, 1.0f);
+ lookup = cs.getLookupTable();
+ }
+
+ protected CoderResult decodeLoop (ByteBuffer in, CharBuffer out)
+ {
+ // TODO: Optimize this in the case in.hasArray() / out.hasArray()
+ while (in.hasRemaining ())
+ {
+ byte b = in.get ();
+ char c;
+
+ if (!out.hasRemaining ())
+ {
+ in.position (in.position () - 1);
+ return CoderResult.OVERFLOW;
+ }
+
+ if((c = lookup[(int) (b & 0xFF)]) == NONE);
+ // return CoderResult.unmappableForLength (1);
+ out.put (c);
+ }
+
+ return CoderResult.UNDERFLOW;
+ }
+ }
+
+ private static final class Encoder extends CharsetEncoder
+ {
+ private byte[] lookup;
+
+ // Package-private to avoid a trampoline constructor.
+ Encoder (ByteCharset cs)
+ {
+ super (cs, 1.0f, 1.0f);
+
+ char[] lookup_table = cs.getLookupTable();
+
+ // Create the inverse look-up table.
+ // determine required size of encoding_table:
+ int max = 0;
+ for (int i = 0; i < lookup_table.length; i++)
+ {
+ int c = (int)lookup_table[i];
+ max = (c > max && c < NONE) ? c : max;
+ }
+
+ lookup = new byte[max+1];
+
+ for (int i = 0; i < lookup_table.length; i++)
+ {
+ int c = (int)lookup_table[i];
+ if (c != 0 && c < NONE)
+ {
+ lookup[c] = (byte)i;
+ }
+ }
+ }
+
+ public boolean canEncode(char c)
+ {
+ byte b = (c < lookup.length) ? lookup[c] : 0;
+ return b != 0 || c == 0;
+ }
+
+ public boolean canEncode(CharSequence cs)
+ {
+ for (int i = 0; i < cs.length(); ++i)
+ {
+ if (! canEncode(cs.charAt(i)))
+ return false;
+ }
+ return true;
+ }
+
+ protected CoderResult encodeLoop (CharBuffer in, ByteBuffer out)
+ {
+ // TODO: Optimize this in the case in.hasArray() / out.hasArray()
+ while (in.hasRemaining ())
+ {
+ int c = (int)in.get ();
+
+ if (!out.hasRemaining ())
+ {
+ in.position (in.position () - 1);
+ return CoderResult.OVERFLOW;
+ }
+
+ // lookup byte encoding
+ byte b = (c < lookup.length) ? lookup[c] : (byte)0;
+
+ if ((int)b != 0 || (int)c == 0)
+ {
+ out.put (b);
+ } else {
+ in.position (in.position () - 1);
+ return CoderResult.unmappableForLength (1);
+ }
+ }
+
+ return CoderResult.UNDERFLOW;
+ }
+ }
+}
Added: llvm-gcc-4.2/trunk/libjava/classpath/gnu/java/nio/charset/Cp424.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/gnu/java/nio/charset/Cp424.java?rev=43913&view=auto
==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/gnu/java/nio/charset/Cp424.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/gnu/java/nio/charset/Cp424.java Thu Nov 8 16:56:19 2007
@@ -0,0 +1,89 @@
+/* Cp424.java -- Charset implementation for the Cp424 character set.
+ Copyright (C) 2005 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 gnu.java.nio.charset;
+
+public class Cp424 extends ByteCharset
+{
+
+ /**
+ * This is the lookup table for this encoding
+ */
+ private static final char[] lookup =
+ {
+ 0x0000, 0x0001, 0x0002, 0x0003, 0x009C, 0x0009, 0x0086, 0x007F,
+ 0x0097, 0x008D, 0x008E, 0x000B, 0x000C, 0x000D, 0x000E, 0x000F,
+ 0x0010, 0x0011, 0x0012, 0x0013, 0x009D, 0x0085, 0x0008, 0x0087,
+ 0x0018, 0x0019, 0x0092, 0x008F, 0x001C, 0x001D, 0x001E, 0x001F,
+ 0x0080, 0x0081, 0x0082, 0x0083, 0x0084, 0x000A, 0x0017, 0x001B,
+ 0x0088, 0x0089, 0x008A, 0x008B, 0x008C, 0x0005, 0x0006, 0x0007,
+ 0x0090, 0x0091, 0x0016, 0x0093, 0x0094, 0x0095, 0x0096, 0x0004,
+ 0x0098, 0x0099, 0x009A, 0x009B, 0x0014, 0x0015, 0x009E, 0x001A,
+ 0x0020, 0x05D0, 0x05D1, 0x05D2, 0x05D3, 0x05D4, 0x05D5, 0x05D6,
+ 0x05D7, 0x05D8, 0x00A2, 0x002E, 0x003C, 0x0028, 0x002B, 0x007C,
+ 0x0026, 0x05D9, 0x05DA, 0x05DB, 0x05DC, 0x05DD, 0x05DE, 0x05DF,
+ 0x05E0, 0x05E1, 0x0021, 0x0024, 0x002A, 0x0029, 0x003B, 0x00AC,
+ 0x002D, 0x002F, 0x05E2, 0x05E3, 0x05E4, 0x05E5, 0x05E6, 0x05E7,
+ 0x05E8, 0x05E9, 0x00A6, 0x002C, 0x0025, 0x005F, 0x003E, 0x003F,
+ NONE, 0x05EA, NONE, NONE, 0x00A0, NONE, NONE, NONE,
+ 0x2017, 0x0060, 0x003A, 0x0023, 0x0040, 0x0027, 0x003D, 0x0022,
+ NONE, 0x0061, 0x0062, 0x0063, 0x0064, 0x0065, 0x0066, 0x0067,
+ 0x0068, 0x0069, 0x00AB, 0x00BB, NONE, NONE, NONE, 0x00B1,
+ 0x00B0, 0x006A, 0x006B, 0x006C, 0x006D, 0x006E, 0x006F, 0x0070,
+ 0x0071, 0x0072, NONE, NONE, NONE, 0x00B8, NONE, 0x00A4,
+ 0x00B5, 0x007E, 0x0073, 0x0074, 0x0075, 0x0076, 0x0077, 0x0078,
+ 0x0079, 0x007A, NONE, NONE, NONE, NONE, NONE, 0x00AE,
+ 0x005E, 0x00A3, 0x00A5, 0x00B7, 0x00A9, 0x00A7, 0x00B6, 0x00BC,
+ 0x00BD, 0x00BE, 0x005B, 0x005D, 0x00AF, 0x00A8, 0x00B4, 0x00D7,
+ 0x007B, 0x0041, 0x0042, 0x0043, 0x0044, 0x0045, 0x0046, 0x0047,
+ 0x0048, 0x0049, 0x00AD, NONE, NONE, NONE, NONE, NONE,
+ 0x007D, 0x004A, 0x004B, 0x004C, 0x004D, 0x004E, 0x004F, 0x0050,
+ 0x0051, 0x0052, 0x00B9, NONE, NONE, NONE, NONE, NONE,
+ 0x005C, 0x00F7, 0x0053, 0x0054, 0x0055, 0x0056, 0x0057, 0x0058,
+ 0x0059, 0x005A, 0x00B2, NONE, NONE, NONE, NONE, NONE,
+ 0x0030, 0x0031, 0x0032, 0x0033, 0x0034, 0x0035, 0x0036, 0x0037,
+ 0x0038, 0x0039, 0x00B3, NONE, NONE, NONE, NONE, 0x009F
+ };
+
+ public Cp424()
+ {
+ super("Cp424", new String[] {
+ });
+ lookupTable = lookup;
+ }
+
+} // class Cp424
Added: llvm-gcc-4.2/trunk/libjava/classpath/gnu/java/nio/charset/Cp437.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/gnu/java/nio/charset/Cp437.java?rev=43913&view=auto
==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/gnu/java/nio/charset/Cp437.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/gnu/java/nio/charset/Cp437.java Thu Nov 8 16:56:19 2007
@@ -0,0 +1,89 @@
+/* Cp437.java -- Charset implementation for the Cp437 character set.
+ Copyright (C) 2005 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 gnu.java.nio.charset;
+
+public class Cp437 extends ByteCharset
+{
+
+ /**
+ * This is the lookup table for this encoding
+ */
+ private static final char[] lookup =
+ {
+ 0x0000, 0x0001, 0x0002, 0x0003, 0x0004, 0x0005, 0x0006, 0x0007,
+ 0x0008, 0x0009, 0x000A, 0x000B, 0x000C, 0x000D, 0x000E, 0x000F,
+ 0x0010, 0x0011, 0x0012, 0x0013, 0x0014, 0x0015, 0x0016, 0x0017,
+ 0x0018, 0x0019, 0x001A, 0x001B, 0x001C, 0x001D, 0x001E, 0x001F,
+ 0x0020, 0x0021, 0x0022, 0x0023, 0x0024, 0x0025, 0x0026, 0x0027,
+ 0x0028, 0x0029, 0x002A, 0x002B, 0x002C, 0x002D, 0x002E, 0x002F,
+ 0x0030, 0x0031, 0x0032, 0x0033, 0x0034, 0x0035, 0x0036, 0x0037,
+ 0x0038, 0x0039, 0x003A, 0x003B, 0x003C, 0x003D, 0x003E, 0x003F,
+ 0x0040, 0x0041, 0x0042, 0x0043, 0x0044, 0x0045, 0x0046, 0x0047,
+ 0x0048, 0x0049, 0x004A, 0x004B, 0x004C, 0x004D, 0x004E, 0x004F,
+ 0x0050, 0x0051, 0x0052, 0x0053, 0x0054, 0x0055, 0x0056, 0x0057,
+ 0x0058, 0x0059, 0x005A, 0x005B, 0x005C, 0x005D, 0x005E, 0x005F,
+ 0x0060, 0x0061, 0x0062, 0x0063, 0x0064, 0x0065, 0x0066, 0x0067,
+ 0x0068, 0x0069, 0x006A, 0x006B, 0x006C, 0x006D, 0x006E, 0x006F,
+ 0x0070, 0x0071, 0x0072, 0x0073, 0x0074, 0x0075, 0x0076, 0x0077,
+ 0x0078, 0x0079, 0x007A, 0x007B, 0x007C, 0x007D, 0x007E, 0x007F,
+ 0x00C7, 0x00FC, 0x00E9, 0x00E2, 0x00E4, 0x00E0, 0x00E5, 0x00E7,
+ 0x00EA, 0x00EB, 0x00E8, 0x00EF, 0x00EE, 0x00EC, 0x00C4, 0x00C5,
+ 0x00C9, 0x00E6, 0x00C6, 0x00F4, 0x00F6, 0x00F2, 0x00FB, 0x00F9,
+ 0x00FF, 0x00D6, 0x00DC, 0x00A2, 0x00A3, 0x00A5, 0x20A7, 0x0192,
+ 0x00E1, 0x00ED, 0x00F3, 0x00FA, 0x00F1, 0x00D1, 0x00AA, 0x00BA,
+ 0x00BF, 0x2310, 0x00AC, 0x00BD, 0x00BC, 0x00A1, 0x00AB, 0x00BB,
+ 0x2591, 0x2592, 0x2593, 0x2502, 0x2524, 0x2561, 0x2562, 0x2556,
+ 0x2555, 0x2563, 0x2551, 0x2557, 0x255D, 0x255C, 0x255B, 0x2510,
+ 0x2514, 0x2534, 0x252C, 0x251C, 0x2500, 0x253C, 0x255E, 0x255F,
+ 0x255A, 0x2554, 0x2569, 0x2566, 0x2560, 0x2550, 0x256C, 0x2567,
+ 0x2568, 0x2564, 0x2565, 0x2559, 0x2558, 0x2552, 0x2553, 0x256B,
+ 0x256A, 0x2518, 0x250C, 0x2588, 0x2584, 0x258C, 0x2590, 0x2580,
+ 0x03B1, 0x00DF, 0x0393, 0x03C0, 0x03A3, 0x03C3, 0x00B5, 0x03C4,
+ 0x03A6, 0x0398, 0x03A9, 0x03B4, 0x221E, 0x03C6, 0x03B5, 0x2229,
+ 0x2261, 0x00B1, 0x2265, 0x2264, 0x2320, 0x2321, 0x00F7, 0x2248,
+ 0x00B0, 0x2219, 0x00B7, 0x221A, 0x207F, 0x00B2, 0x25A0, 0x00A0
+ };
+
+ public Cp437()
+ {
+ super("Cp437", new String[] {
+ });
+ lookupTable = lookup;
+ }
+
+} // class Cp437
Added: llvm-gcc-4.2/trunk/libjava/classpath/gnu/java/nio/charset/Cp737.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/gnu/java/nio/charset/Cp737.java?rev=43913&view=auto
==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/gnu/java/nio/charset/Cp737.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/gnu/java/nio/charset/Cp737.java Thu Nov 8 16:56:19 2007
@@ -0,0 +1,89 @@
+/* Cp737.java -- Charset implementation for the Cp737 character set.
+ Copyright (C) 2005 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 gnu.java.nio.charset;
+
+public class Cp737 extends ByteCharset
+{
+
+ /**
+ * This is the lookup table for this encoding
+ */
+ private static final char[] lookup =
+ {
+ 0x0000, 0x0001, 0x0002, 0x0003, 0x0004, 0x0005, 0x0006, 0x0007,
+ 0x0008, 0x0009, 0x000A, 0x000B, 0x000C, 0x000D, 0x000E, 0x000F,
+ 0x0010, 0x0011, 0x0012, 0x0013, 0x0014, 0x0015, 0x0016, 0x0017,
+ 0x0018, 0x0019, 0x001A, 0x001B, 0x001C, 0x001D, 0x001E, 0x001F,
+ 0x0020, 0x0021, 0x0022, 0x0023, 0x0024, 0x0025, 0x0026, 0x0027,
+ 0x0028, 0x0029, 0x002A, 0x002B, 0x002C, 0x002D, 0x002E, 0x002F,
+ 0x0030, 0x0031, 0x0032, 0x0033, 0x0034, 0x0035, 0x0036, 0x0037,
+ 0x0038, 0x0039, 0x003A, 0x003B, 0x003C, 0x003D, 0x003E, 0x003F,
+ 0x0040, 0x0041, 0x0042, 0x0043, 0x0044, 0x0045, 0x0046, 0x0047,
+ 0x0048, 0x0049, 0x004A, 0x004B, 0x004C, 0x004D, 0x004E, 0x004F,
+ 0x0050, 0x0051, 0x0052, 0x0053, 0x0054, 0x0055, 0x0056, 0x0057,
+ 0x0058, 0x0059, 0x005A, 0x005B, 0x005C, 0x005D, 0x005E, 0x005F,
+ 0x0060, 0x0061, 0x0062, 0x0063, 0x0064, 0x0065, 0x0066, 0x0067,
+ 0x0068, 0x0069, 0x006A, 0x006B, 0x006C, 0x006D, 0x006E, 0x006F,
+ 0x0070, 0x0071, 0x0072, 0x0073, 0x0074, 0x0075, 0x0076, 0x0077,
+ 0x0078, 0x0079, 0x007A, 0x007B, 0x007C, 0x007D, 0x007E, 0x007F,
+ 0x0391, 0x0392, 0x0393, 0x0394, 0x0395, 0x0396, 0x0397, 0x0398,
+ 0x0399, 0x039A, 0x039B, 0x039C, 0x039D, 0x039E, 0x039F, 0x03A0,
+ 0x03A1, 0x03A3, 0x03A4, 0x03A5, 0x03A6, 0x03A7, 0x03A8, 0x03A9,
+ 0x03B1, 0x03B2, 0x03B3, 0x03B4, 0x03B5, 0x03B6, 0x03B7, 0x03B8,
+ 0x03B9, 0x03BA, 0x03BB, 0x03BC, 0x03BD, 0x03BE, 0x03BF, 0x03C0,
+ 0x03C1, 0x03C3, 0x03C2, 0x03C4, 0x03C5, 0x03C6, 0x03C7, 0x03C8,
+ 0x2591, 0x2592, 0x2593, 0x2502, 0x2524, 0x2561, 0x2562, 0x2556,
+ 0x2555, 0x2563, 0x2551, 0x2557, 0x255D, 0x255C, 0x255B, 0x2510,
+ 0x2514, 0x2534, 0x252C, 0x251C, 0x2500, 0x253C, 0x255E, 0x255F,
+ 0x255A, 0x2554, 0x2569, 0x2566, 0x2560, 0x2550, 0x256C, 0x2567,
+ 0x2568, 0x2564, 0x2565, 0x2559, 0x2558, 0x2552, 0x2553, 0x256B,
+ 0x256A, 0x2518, 0x250C, 0x2588, 0x2584, 0x258C, 0x2590, 0x2580,
+ 0x03C9, 0x03AC, 0x03AD, 0x03AE, 0x03CA, 0x03AF, 0x03CC, 0x03CD,
+ 0x03CB, 0x03CE, 0x0386, 0x0388, 0x0389, 0x038A, 0x038C, 0x038E,
+ 0x038F, 0x00B1, 0x2265, 0x2264, 0x03AA, 0x03AB, 0x00F7, 0x2248,
+ 0x00B0, 0x2219, 0x00B7, 0x221A, 0x207F, 0x00B2, 0x25A0, 0x00A0
+ };
+
+ public Cp737()
+ {
+ super("Cp737", new String[] {
+ });
+ lookupTable = lookup;
+ }
+
+} // class Cp737
Added: llvm-gcc-4.2/trunk/libjava/classpath/gnu/java/nio/charset/Cp775.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/gnu/java/nio/charset/Cp775.java?rev=43913&view=auto
==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/gnu/java/nio/charset/Cp775.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/gnu/java/nio/charset/Cp775.java Thu Nov 8 16:56:19 2007
@@ -0,0 +1,89 @@
+/* Cp775.java -- Charset implementation for the Cp775 character set.
+ Copyright (C) 2005 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 gnu.java.nio.charset;
+
+public class Cp775 extends ByteCharset
+{
+
+ /**
+ * This is the lookup table for this encoding
+ */
+ private static final char[] lookup =
+ {
+ 0x0000, 0x0001, 0x0002, 0x0003, 0x0004, 0x0005, 0x0006, 0x0007,
+ 0x0008, 0x0009, 0x000A, 0x000B, 0x000C, 0x000D, 0x000E, 0x000F,
+ 0x0010, 0x0011, 0x0012, 0x0013, 0x0014, 0x0015, 0x0016, 0x0017,
+ 0x0018, 0x0019, 0x001A, 0x001B, 0x001C, 0x001D, 0x001E, 0x001F,
+ 0x0020, 0x0021, 0x0022, 0x0023, 0x0024, 0x0025, 0x0026, 0x0027,
+ 0x0028, 0x0029, 0x002A, 0x002B, 0x002C, 0x002D, 0x002E, 0x002F,
+ 0x0030, 0x0031, 0x0032, 0x0033, 0x0034, 0x0035, 0x0036, 0x0037,
+ 0x0038, 0x0039, 0x003A, 0x003B, 0x003C, 0x003D, 0x003E, 0x003F,
+ 0x0040, 0x0041, 0x0042, 0x0043, 0x0044, 0x0045, 0x0046, 0x0047,
+ 0x0048, 0x0049, 0x004A, 0x004B, 0x004C, 0x004D, 0x004E, 0x004F,
+ 0x0050, 0x0051, 0x0052, 0x0053, 0x0054, 0x0055, 0x0056, 0x0057,
+ 0x0058, 0x0059, 0x005A, 0x005B, 0x005C, 0x005D, 0x005E, 0x005F,
+ 0x0060, 0x0061, 0x0062, 0x0063, 0x0064, 0x0065, 0x0066, 0x0067,
+ 0x0068, 0x0069, 0x006A, 0x006B, 0x006C, 0x006D, 0x006E, 0x006F,
+ 0x0070, 0x0071, 0x0072, 0x0073, 0x0074, 0x0075, 0x0076, 0x0077,
+ 0x0078, 0x0079, 0x007A, 0x007B, 0x007C, 0x007D, 0x007E, 0x007F,
+ 0x0106, 0x00FC, 0x00E9, 0x0101, 0x00E4, 0x0123, 0x00E5, 0x0107,
+ 0x0142, 0x0113, 0x0156, 0x0157, 0x012B, 0x0179, 0x00C4, 0x00C5,
+ 0x00C9, 0x00E6, 0x00C6, 0x014D, 0x00F6, 0x0122, 0x00A2, 0x015A,
+ 0x015B, 0x00D6, 0x00DC, 0x00F8, 0x00A3, 0x00D8, 0x00D7, 0x00A4,
+ 0x0100, 0x012A, 0x00F3, 0x017B, 0x017C, 0x017A, 0x201D, 0x00A6,
+ 0x00A9, 0x00AE, 0x00AC, 0x00BD, 0x00BC, 0x0141, 0x00AB, 0x00BB,
+ 0x2591, 0x2592, 0x2593, 0x2502, 0x2524, 0x0104, 0x010C, 0x0118,
+ 0x0116, 0x2563, 0x2551, 0x2557, 0x255D, 0x012E, 0x0160, 0x2510,
+ 0x2514, 0x2534, 0x252C, 0x251C, 0x2500, 0x253C, 0x0172, 0x016A,
+ 0x255A, 0x2554, 0x2569, 0x2566, 0x2560, 0x2550, 0x256C, 0x017D,
+ 0x0105, 0x010D, 0x0119, 0x0117, 0x012F, 0x0161, 0x0173, 0x016B,
+ 0x017E, 0x2518, 0x250C, 0x2588, 0x2584, 0x258C, 0x2590, 0x2580,
+ 0x00D3, 0x00DF, 0x014C, 0x0143, 0x00F5, 0x00D5, 0x00B5, 0x0144,
+ 0x0136, 0x0137, 0x013B, 0x013C, 0x0146, 0x0112, 0x0145, 0x2019,
+ 0x00AD, 0x00B1, 0x201C, 0x00BE, 0x00B6, 0x00A7, 0x00F7, 0x201E,
+ 0x00B0, 0x2219, 0x00B7, 0x00B9, 0x00B3, 0x00B2, 0x25A0, 0x00A0
+ };
+
+ public Cp775()
+ {
+ super("Cp775", new String[] {
+ });
+ lookupTable = lookup;
+ }
+
+} // class Cp775
Added: llvm-gcc-4.2/trunk/libjava/classpath/gnu/java/nio/charset/Cp850.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/gnu/java/nio/charset/Cp850.java?rev=43913&view=auto
==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/gnu/java/nio/charset/Cp850.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/gnu/java/nio/charset/Cp850.java Thu Nov 8 16:56:19 2007
@@ -0,0 +1,89 @@
+/* Cp850.java -- Charset implementation for the Cp850 character set.
+ Copyright (C) 2005 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 gnu.java.nio.charset;
+
+public class Cp850 extends ByteCharset
+{
+
+ /**
+ * This is the lookup table for this encoding
+ */
+ private static final char[] lookup =
+ {
+ 0x0000, 0x0001, 0x0002, 0x0003, 0x0004, 0x0005, 0x0006, 0x0007,
+ 0x0008, 0x0009, 0x000A, 0x000B, 0x000C, 0x000D, 0x000E, 0x000F,
+ 0x0010, 0x0011, 0x0012, 0x0013, 0x0014, 0x0015, 0x0016, 0x0017,
+ 0x0018, 0x0019, 0x001A, 0x001B, 0x001C, 0x001D, 0x001E, 0x001F,
+ 0x0020, 0x0021, 0x0022, 0x0023, 0x0024, 0x0025, 0x0026, 0x0027,
+ 0x0028, 0x0029, 0x002A, 0x002B, 0x002C, 0x002D, 0x002E, 0x002F,
+ 0x0030, 0x0031, 0x0032, 0x0033, 0x0034, 0x0035, 0x0036, 0x0037,
+ 0x0038, 0x0039, 0x003A, 0x003B, 0x003C, 0x003D, 0x003E, 0x003F,
+ 0x0040, 0x0041, 0x0042, 0x0043, 0x0044, 0x0045, 0x0046, 0x0047,
+ 0x0048, 0x0049, 0x004A, 0x004B, 0x004C, 0x004D, 0x004E, 0x004F,
+ 0x0050, 0x0051, 0x0052, 0x0053, 0x0054, 0x0055, 0x0056, 0x0057,
+ 0x0058, 0x0059, 0x005A, 0x005B, 0x005C, 0x005D, 0x005E, 0x005F,
+ 0x0060, 0x0061, 0x0062, 0x0063, 0x0064, 0x0065, 0x0066, 0x0067,
+ 0x0068, 0x0069, 0x006A, 0x006B, 0x006C, 0x006D, 0x006E, 0x006F,
+ 0x0070, 0x0071, 0x0072, 0x0073, 0x0074, 0x0075, 0x0076, 0x0077,
+ 0x0078, 0x0079, 0x007A, 0x007B, 0x007C, 0x007D, 0x007E, 0x007F,
+ 0x00C7, 0x00FC, 0x00E9, 0x00E2, 0x00E4, 0x00E0, 0x00E5, 0x00E7,
+ 0x00EA, 0x00EB, 0x00E8, 0x00EF, 0x00EE, 0x00EC, 0x00C4, 0x00C5,
+ 0x00C9, 0x00E6, 0x00C6, 0x00F4, 0x00F6, 0x00F2, 0x00FB, 0x00F9,
+ 0x00FF, 0x00D6, 0x00DC, 0x00F8, 0x00A3, 0x00D8, 0x00D7, 0x0192,
+ 0x00E1, 0x00ED, 0x00F3, 0x00FA, 0x00F1, 0x00D1, 0x00AA, 0x00BA,
+ 0x00BF, 0x00AE, 0x00AC, 0x00BD, 0x00BC, 0x00A1, 0x00AB, 0x00BB,
+ 0x2591, 0x2592, 0x2593, 0x2502, 0x2524, 0x00C1, 0x00C2, 0x00C0,
+ 0x00A9, 0x2563, 0x2551, 0x2557, 0x255D, 0x00A2, 0x00A5, 0x2510,
+ 0x2514, 0x2534, 0x252C, 0x251C, 0x2500, 0x253C, 0x00E3, 0x00C3,
+ 0x255A, 0x2554, 0x2569, 0x2566, 0x2560, 0x2550, 0x256C, 0x00A4,
+ 0x00F0, 0x00D0, 0x00CA, 0x00CB, 0x00C8, 0x0131, 0x00CD, 0x00CE,
+ 0x00CF, 0x2518, 0x250C, 0x2588, 0x2584, 0x00A6, 0x00CC, 0x2580,
+ 0x00D3, 0x00DF, 0x00D4, 0x00D2, 0x00F5, 0x00D5, 0x00B5, 0x00FE,
+ 0x00DE, 0x00DA, 0x00DB, 0x00D9, 0x00FD, 0x00DD, 0x00AF, 0x00B4,
+ 0x00AD, 0x00B1, 0x2017, 0x00BE, 0x00B6, 0x00A7, 0x00F7, 0x00B8,
+ 0x00B0, 0x00A8, 0x00B7, 0x00B9, 0x00B3, 0x00B2, 0x25A0, 0x00A0
+ };
+
+ public Cp850()
+ {
+ super("Cp850", new String[] {
+ });
+ lookupTable = lookup;
+ }
+
+} // class Cp850
Added: llvm-gcc-4.2/trunk/libjava/classpath/gnu/java/nio/charset/Cp852.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/gnu/java/nio/charset/Cp852.java?rev=43913&view=auto
==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/gnu/java/nio/charset/Cp852.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/gnu/java/nio/charset/Cp852.java Thu Nov 8 16:56:19 2007
@@ -0,0 +1,89 @@
+/* Cp852.java -- Charset implementation for the Cp852 character set.
+ Copyright (C) 2005 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 gnu.java.nio.charset;
+
+public class Cp852 extends ByteCharset
+{
+
+ /**
+ * This is the lookup table for this encoding
+ */
+ private static final char[] lookup =
+ {
+ 0x0000, 0x0001, 0x0002, 0x0003, 0x0004, 0x0005, 0x0006, 0x0007,
+ 0x0008, 0x0009, 0x000A, 0x000B, 0x000C, 0x000D, 0x000E, 0x000F,
+ 0x0010, 0x0011, 0x0012, 0x0013, 0x0014, 0x0015, 0x0016, 0x0017,
+ 0x0018, 0x0019, 0x001A, 0x001B, 0x001C, 0x001D, 0x001E, 0x001F,
+ 0x0020, 0x0021, 0x0022, 0x0023, 0x0024, 0x0025, 0x0026, 0x0027,
+ 0x0028, 0x0029, 0x002A, 0x002B, 0x002C, 0x002D, 0x002E, 0x002F,
+ 0x0030, 0x0031, 0x0032, 0x0033, 0x0034, 0x0035, 0x0036, 0x0037,
+ 0x0038, 0x0039, 0x003A, 0x003B, 0x003C, 0x003D, 0x003E, 0x003F,
+ 0x0040, 0x0041, 0x0042, 0x0043, 0x0044, 0x0045, 0x0046, 0x0047,
+ 0x0048, 0x0049, 0x004A, 0x004B, 0x004C, 0x004D, 0x004E, 0x004F,
+ 0x0050, 0x0051, 0x0052, 0x0053, 0x0054, 0x0055, 0x0056, 0x0057,
+ 0x0058, 0x0059, 0x005A, 0x005B, 0x005C, 0x005D, 0x005E, 0x005F,
+ 0x0060, 0x0061, 0x0062, 0x0063, 0x0064, 0x0065, 0x0066, 0x0067,
+ 0x0068, 0x0069, 0x006A, 0x006B, 0x006C, 0x006D, 0x006E, 0x006F,
+ 0x0070, 0x0071, 0x0072, 0x0073, 0x0074, 0x0075, 0x0076, 0x0077,
+ 0x0078, 0x0079, 0x007A, 0x007B, 0x007C, 0x007D, 0x007E, 0x007F,
+ 0x00C7, 0x00FC, 0x00E9, 0x00E2, 0x00E4, 0x016F, 0x0107, 0x00E7,
+ 0x0142, 0x00EB, 0x0150, 0x0151, 0x00EE, 0x0179, 0x00C4, 0x0106,
+ 0x00C9, 0x0139, 0x013A, 0x00F4, 0x00F6, 0x013D, 0x013E, 0x015A,
+ 0x015B, 0x00D6, 0x00DC, 0x0164, 0x0165, 0x0141, 0x00D7, 0x010D,
+ 0x00E1, 0x00ED, 0x00F3, 0x00FA, 0x0104, 0x0105, 0x017D, 0x017E,
+ 0x0118, 0x0119, 0x00AC, 0x017A, 0x010C, 0x015F, 0x00AB, 0x00BB,
+ 0x2591, 0x2592, 0x2593, 0x2502, 0x2524, 0x00C1, 0x00C2, 0x011A,
+ 0x015E, 0x2563, 0x2551, 0x2557, 0x255D, 0x017B, 0x017C, 0x2510,
+ 0x2514, 0x2534, 0x252C, 0x251C, 0x2500, 0x253C, 0x0102, 0x0103,
+ 0x255A, 0x2554, 0x2569, 0x2566, 0x2560, 0x2550, 0x256C, 0x00A4,
+ 0x0111, 0x0110, 0x010E, 0x00CB, 0x010F, 0x0147, 0x00CD, 0x00CE,
+ 0x011B, 0x2518, 0x250C, 0x2588, 0x2584, 0x0162, 0x016E, 0x2580,
+ 0x00D3, 0x00DF, 0x00D4, 0x0143, 0x0144, 0x0148, 0x0160, 0x0161,
+ 0x0154, 0x00DA, 0x0155, 0x0170, 0x00FD, 0x00DD, 0x0163, 0x00B4,
+ 0x00AD, 0x02DD, 0x02DB, 0x02C7, 0x02D8, 0x00A7, 0x00F7, 0x00B8,
+ 0x00B0, 0x00A8, 0x02D9, 0x0171, 0x0158, 0x0159, 0x25A0, 0x00A0
+ };
+
+ public Cp852()
+ {
+ super("Cp852", new String[] {
+ });
+ lookupTable = lookup;
+ }
+
+} // class Cp852
Added: llvm-gcc-4.2/trunk/libjava/classpath/gnu/java/nio/charset/Cp855.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/gnu/java/nio/charset/Cp855.java?rev=43913&view=auto
==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/gnu/java/nio/charset/Cp855.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/gnu/java/nio/charset/Cp855.java Thu Nov 8 16:56:19 2007
@@ -0,0 +1,90 @@
+/* Cp855.java -- Charset implementation for the Cp855 character set.
+ Copyright (C) 2005 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 gnu.java.nio.charset;
+
+public class Cp855 extends ByteCharset
+{
+
+ /**
+ * This is the lookup table for this encoding
+ */
+ private static final char[] lookup =
+ {
+ 0x0000, 0x0001, 0x0002, 0x0003, 0x0004, 0x0005, 0x0006, 0x0007,
+ 0x0008, 0x0009, 0x000A, 0x000B, 0x000C, 0x000D, 0x000E, 0x000F,
+ 0x0010, 0x0011, 0x0012, 0x0013, 0x0014, 0x0015, 0x0016, 0x0017,
+ 0x0018, 0x0019, 0x001A, 0x001B, 0x001C, 0x001D, 0x001E, 0x001F,
+ 0x0020, 0x0021, 0x0022, 0x0023, 0x0024, 0x0025, 0x0026, 0x0027,
+ 0x0028, 0x0029, 0x002A, 0x002B, 0x002C, 0x002D, 0x002E, 0x002F,
+ 0x0030, 0x0031, 0x0032, 0x0033, 0x0034, 0x0035, 0x0036, 0x0037,
+ 0x0038, 0x0039, 0x003A, 0x003B, 0x003C, 0x003D, 0x003E, 0x003F,
+ 0x0040, 0x0041, 0x0042, 0x0043, 0x0044, 0x0045, 0x0046, 0x0047,
+ 0x0048, 0x0049, 0x004A, 0x004B, 0x004C, 0x004D, 0x004E, 0x004F,
+ 0x0050, 0x0051, 0x0052, 0x0053, 0x0054, 0x0055, 0x0056, 0x0057,
+ 0x0058, 0x0059, 0x005A, 0x005B, 0x005C, 0x005D, 0x005E, 0x005F,
+ 0x0060, 0x0061, 0x0062, 0x0063, 0x0064, 0x0065, 0x0066, 0x0067,
+ 0x0068, 0x0069, 0x006A, 0x006B, 0x006C, 0x006D, 0x006E, 0x006F,
+ 0x0070, 0x0071, 0x0072, 0x0073, 0x0074, 0x0075, 0x0076, 0x0077,
+ 0x0078, 0x0079, 0x007A, 0x007B, 0x007C, 0x007D, 0x007E, 0x007F,
+ 0x0452, 0x0402, 0x0453, 0x0403, 0x0451, 0x0401, 0x0454, 0x0404,
+ 0x0455, 0x0405, 0x0456, 0x0406, 0x0457, 0x0407, 0x0458, 0x0408,
+ 0x0459, 0x0409, 0x045A, 0x040A, 0x045B, 0x040B, 0x045C, 0x040C,
+ 0x045E, 0x040E, 0x045F, 0x040F, 0x044E, 0x042E, 0x044A, 0x042A,
+ 0x0430, 0x0410, 0x0431, 0x0411, 0x0446, 0x0426, 0x0434, 0x0414,
+ 0x0435, 0x0415, 0x0444, 0x0424, 0x0433, 0x0413, 0x00AB, 0x00BB,
+ 0x2591, 0x2592, 0x2593, 0x2502, 0x2524, 0x0445, 0x0425, 0x0438,
+ 0x0418, 0x2563, 0x2551, 0x2557, 0x255D, 0x0439, 0x0419, 0x2510,
+ 0x2514, 0x2534, 0x252C, 0x251C, 0x2500, 0x253C, 0x043A, 0x041A,
+ 0x255A, 0x2554, 0x2569, 0x2566, 0x2560, 0x2550, 0x256C, 0x00A4,
+ 0x043B, 0x041B, 0x043C, 0x041C, 0x043D, 0x041D, 0x043E, 0x041E,
+ 0x043F, 0x2518, 0x250C, 0x2588, 0x2584, 0x041F, 0x044F, 0x2580,
+ 0x042F, 0x0440, 0x0420, 0x0441, 0x0421, 0x0442, 0x0422, 0x0443,
+ 0x0423, 0x0436, 0x0416, 0x0432, 0x0412, 0x044C, 0x042C, 0x2116,
+ 0x00AD, 0x044B, 0x042B, 0x0437, 0x0417, 0x0448, 0x0428, 0x044D,
+ 0x042D, 0x0449, 0x0429, 0x0447, 0x0427, 0x00A7, 0x25A0, 0x00A0
+ };
+
+ public Cp855()
+ {
+ super("Cp855", new String[] {
+ "cp-855",
+ });
+ lookupTable = lookup;
+ }
+
+} // class Cp855
Added: llvm-gcc-4.2/trunk/libjava/classpath/gnu/java/nio/charset/Cp857.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/gnu/java/nio/charset/Cp857.java?rev=43913&view=auto
==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/gnu/java/nio/charset/Cp857.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/gnu/java/nio/charset/Cp857.java Thu Nov 8 16:56:19 2007
@@ -0,0 +1,91 @@
+/* Cp857.java -- Charset implementation for the Cp857 character set.
+ Copyright (C) 2005 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 gnu.java.nio.charset;
+
+public class Cp857 extends ByteCharset
+{
+
+ /**
+ * This is the lookup table for this encoding
+ */
+ private static final char[] lookup =
+ {
+ 0x0000, 0x0001, 0x0002, 0x0003, 0x0004, 0x0005, 0x0006, 0x0007,
+ 0x0008, 0x0009, 0x000A, 0x000B, 0x000C, 0x000D, 0x000E, 0x000F,
+ 0x0010, 0x0011, 0x0012, 0x0013, 0x0014, 0x0015, 0x0016, 0x0017,
+ 0x0018, 0x0019, 0x001A, 0x001B, 0x001C, 0x001D, 0x001E, 0x001F,
+ 0x0020, 0x0021, 0x0022, 0x0023, 0x0024, 0x0025, 0x0026, 0x0027,
+ 0x0028, 0x0029, 0x002A, 0x002B, 0x002C, 0x002D, 0x002E, 0x002F,
+ 0x0030, 0x0031, 0x0032, 0x0033, 0x0034, 0x0035, 0x0036, 0x0037,
+ 0x0038, 0x0039, 0x003A, 0x003B, 0x003C, 0x003D, 0x003E, 0x003F,
+ 0x0040, 0x0041, 0x0042, 0x0043, 0x0044, 0x0045, 0x0046, 0x0047,
+ 0x0048, 0x0049, 0x004A, 0x004B, 0x004C, 0x004D, 0x004E, 0x004F,
+ 0x0050, 0x0051, 0x0052, 0x0053, 0x0054, 0x0055, 0x0056, 0x0057,
+ 0x0058, 0x0059, 0x005A, 0x005B, 0x005C, 0x005D, 0x005E, 0x005F,
+ 0x0060, 0x0061, 0x0062, 0x0063, 0x0064, 0x0065, 0x0066, 0x0067,
+ 0x0068, 0x0069, 0x006A, 0x006B, 0x006C, 0x006D, 0x006E, 0x006F,
+ 0x0070, 0x0071, 0x0072, 0x0073, 0x0074, 0x0075, 0x0076, 0x0077,
+ 0x0078, 0x0079, 0x007A, 0x007B, 0x007C, 0x007D, 0x007E, 0x007F,
+ 0x00C7, 0x00FC, 0x00E9, 0x00E2, 0x00E4, 0x00E0, 0x00E5, 0x00E7,
+ 0x00EA, 0x00EB, 0x00E8, 0x00EF, 0x00EE, 0x0131, 0x00C4, 0x00C5,
+ 0x00C9, 0x00E6, 0x00C6, 0x00F4, 0x00F6, 0x00F2, 0x00FB, 0x00F9,
+ 0x0130, 0x00D6, 0x00DC, 0x00F8, 0x00A3, 0x00D8, 0x015E, 0x015F,
+ 0x00E1, 0x00ED, 0x00F3, 0x00FA, 0x00F1, 0x00D1, 0x011E, 0x011F,
+ 0x00BF, 0x00AE, 0x00AC, 0x00BD, 0x00BC, 0x00A1, 0x00AB, 0x00BB,
+ 0x2591, 0x2592, 0x2593, 0x2502, 0x2524, 0x00C1, 0x00C2, 0x00C0,
+ 0x00A9, 0x2563, 0x2551, 0x2557, 0x255D, 0x00A2, 0x00A5, 0x2510,
+ 0x2514, 0x2534, 0x252C, 0x251C, 0x2500, 0x253C, 0x00E3, 0x00C3,
+ 0x255A, 0x2554, 0x2569, 0x2566, 0x2560, 0x2550, 0x256C, 0x00A4,
+ 0x00BA, 0x00AA, 0x00CA, 0x00CB, 0x00C8, NONE, 0x00CD, 0x00CE,
+ 0x00CF, 0x2518, 0x250C, 0x2588, 0x2584, 0x00A6, 0x00CC, 0x2580,
+ 0x00D3, 0x00DF, 0x00D4, 0x00D2, 0x00F5, 0x00D5, 0x00B5, NONE,
+ 0x00D7, 0x00DA, 0x00DB, 0x00D9, 0x00EC, 0x00FF, 0x00AF, 0x00B4,
+ 0x00AD, 0x00B1, NONE, 0x00BE, 0x00B6, 0x00A7, 0x00F7, 0x00B8,
+ 0x00B0, 0x00A8, 0x00B7, 0x00B9, 0x00B3, 0x00B2, 0x25A0, 0x00A0
+ };
+
+ public Cp857()
+ {
+ super("Cp857", new String[] {
+ "cp-857"
+ });
+ lookupTable = lookup;
+ }
+
+} // class Cp857
Added: llvm-gcc-4.2/trunk/libjava/classpath/gnu/java/nio/charset/Cp860.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/gnu/java/nio/charset/Cp860.java?rev=43913&view=auto
==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/gnu/java/nio/charset/Cp860.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/gnu/java/nio/charset/Cp860.java Thu Nov 8 16:56:19 2007
@@ -0,0 +1,91 @@
+/* Cp860.java -- Charset implementation for the Cp860 character set.
+ Copyright (C) 2005 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 gnu.java.nio.charset;
+
+public class Cp860 extends ByteCharset
+{
+
+ /**
+ * This is the lookup table for this encoding
+ */
+ private static final char[] lookup =
+ {
+ 0x0000, 0x0001, 0x0002, 0x0003, 0x0004, 0x0005, 0x0006, 0x0007,
+ 0x0008, 0x0009, 0x000A, 0x000B, 0x000C, 0x000D, 0x000E, 0x000F,
+ 0x0010, 0x0011, 0x0012, 0x0013, 0x0014, 0x0015, 0x0016, 0x0017,
+ 0x0018, 0x0019, 0x001A, 0x001B, 0x001C, 0x001D, 0x001E, 0x001F,
+ 0x0020, 0x0021, 0x0022, 0x0023, 0x0024, 0x0025, 0x0026, 0x0027,
+ 0x0028, 0x0029, 0x002A, 0x002B, 0x002C, 0x002D, 0x002E, 0x002F,
+ 0x0030, 0x0031, 0x0032, 0x0033, 0x0034, 0x0035, 0x0036, 0x0037,
+ 0x0038, 0x0039, 0x003A, 0x003B, 0x003C, 0x003D, 0x003E, 0x003F,
+ 0x0040, 0x0041, 0x0042, 0x0043, 0x0044, 0x0045, 0x0046, 0x0047,
+ 0x0048, 0x0049, 0x004A, 0x004B, 0x004C, 0x004D, 0x004E, 0x004F,
+ 0x0050, 0x0051, 0x0052, 0x0053, 0x0054, 0x0055, 0x0056, 0x0057,
+ 0x0058, 0x0059, 0x005A, 0x005B, 0x005C, 0x005D, 0x005E, 0x005F,
+ 0x0060, 0x0061, 0x0062, 0x0063, 0x0064, 0x0065, 0x0066, 0x0067,
+ 0x0068, 0x0069, 0x006A, 0x006B, 0x006C, 0x006D, 0x006E, 0x006F,
+ 0x0070, 0x0071, 0x0072, 0x0073, 0x0074, 0x0075, 0x0076, 0x0077,
+ 0x0078, 0x0079, 0x007A, 0x007B, 0x007C, 0x007D, 0x007E, 0x007F,
+ 0x00C7, 0x00FC, 0x00E9, 0x00E2, 0x00E3, 0x00E0, 0x00C1, 0x00E7,
+ 0x00EA, 0x00CA, 0x00E8, 0x00CD, 0x00D4, 0x00EC, 0x00C3, 0x00C2,
+ 0x00C9, 0x00C0, 0x00C8, 0x00F4, 0x00F5, 0x00F2, 0x00DA, 0x00F9,
+ 0x00CC, 0x00D5, 0x00DC, 0x00A2, 0x00A3, 0x00D9, 0x20A7, 0x00D3,
+ 0x00E1, 0x00ED, 0x00F3, 0x00FA, 0x00F1, 0x00D1, 0x00AA, 0x00BA,
+ 0x00BF, 0x00D2, 0x00AC, 0x00BD, 0x00BC, 0x00A1, 0x00AB, 0x00BB,
+ 0x2591, 0x2592, 0x2593, 0x2502, 0x2524, 0x2561, 0x2562, 0x2556,
+ 0x2555, 0x2563, 0x2551, 0x2557, 0x255D, 0x255C, 0x255B, 0x2510,
+ 0x2514, 0x2534, 0x252C, 0x251C, 0x2500, 0x253C, 0x255E, 0x255F,
+ 0x255A, 0x2554, 0x2569, 0x2566, 0x2560, 0x2550, 0x256C, 0x2567,
+ 0x2568, 0x2564, 0x2565, 0x2559, 0x2558, 0x2552, 0x2553, 0x256B,
+ 0x256A, 0x2518, 0x250C, 0x2588, 0x2584, 0x258C, 0x2590, 0x2580,
+ 0x03B1, 0x00DF, 0x0393, 0x03C0, 0x03A3, 0x03C3, 0x00B5, 0x03C4,
+ 0x03A6, 0x0398, 0x03A9, 0x03B4, 0x221E, 0x03C6, 0x03B5, 0x2229,
+ 0x2261, 0x00B1, 0x2265, 0x2264, 0x2320, 0x2321, 0x00F7, 0x2248,
+ 0x00B0, 0x2219, 0x00B7, 0x221A, 0x207F, 0x00B2, 0x25A0, 0x00A0
+ };
+
+ public Cp860()
+ {
+ super("Cp860", new String[] {
+ "cp-860"
+ });
+ lookupTable = lookup;
+ }
+
+} // class Cp860
Added: llvm-gcc-4.2/trunk/libjava/classpath/gnu/java/nio/charset/Cp861.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/gnu/java/nio/charset/Cp861.java?rev=43913&view=auto
==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/gnu/java/nio/charset/Cp861.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/gnu/java/nio/charset/Cp861.java Thu Nov 8 16:56:19 2007
@@ -0,0 +1,91 @@
+/* Cp861.java -- Charset implementation for the Cp861 character set.
+ Copyright (C) 2005 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 gnu.java.nio.charset;
+
+public class Cp861 extends ByteCharset
+{
+
+ /**
+ * This is the lookup table for this encoding
+ */
+ private static final char[] lookup =
+ {
+ 0x0000, 0x0001, 0x0002, 0x0003, 0x0004, 0x0005, 0x0006, 0x0007,
+ 0x0008, 0x0009, 0x000A, 0x000B, 0x000C, 0x000D, 0x000E, 0x000F,
+ 0x0010, 0x0011, 0x0012, 0x0013, 0x0014, 0x0015, 0x0016, 0x0017,
+ 0x0018, 0x0019, 0x001A, 0x001B, 0x001C, 0x001D, 0x001E, 0x001F,
+ 0x0020, 0x0021, 0x0022, 0x0023, 0x0024, 0x0025, 0x0026, 0x0027,
+ 0x0028, 0x0029, 0x002A, 0x002B, 0x002C, 0x002D, 0x002E, 0x002F,
+ 0x0030, 0x0031, 0x0032, 0x0033, 0x0034, 0x0035, 0x0036, 0x0037,
+ 0x0038, 0x0039, 0x003A, 0x003B, 0x003C, 0x003D, 0x003E, 0x003F,
+ 0x0040, 0x0041, 0x0042, 0x0043, 0x0044, 0x0045, 0x0046, 0x0047,
+ 0x0048, 0x0049, 0x004A, 0x004B, 0x004C, 0x004D, 0x004E, 0x004F,
+ 0x0050, 0x0051, 0x0052, 0x0053, 0x0054, 0x0055, 0x0056, 0x0057,
+ 0x0058, 0x0059, 0x005A, 0x005B, 0x005C, 0x005D, 0x005E, 0x005F,
+ 0x0060, 0x0061, 0x0062, 0x0063, 0x0064, 0x0065, 0x0066, 0x0067,
+ 0x0068, 0x0069, 0x006A, 0x006B, 0x006C, 0x006D, 0x006E, 0x006F,
+ 0x0070, 0x0071, 0x0072, 0x0073, 0x0074, 0x0075, 0x0076, 0x0077,
+ 0x0078, 0x0079, 0x007A, 0x007B, 0x007C, 0x007D, 0x007E, 0x007F,
+ 0x00C7, 0x00FC, 0x00E9, 0x00E2, 0x00E4, 0x00E0, 0x00E5, 0x00E7,
+ 0x00EA, 0x00EB, 0x00E8, 0x00D0, 0x00F0, 0x00DE, 0x00C4, 0x00C5,
+ 0x00C9, 0x00E6, 0x00C6, 0x00F4, 0x00F6, 0x00FE, 0x00FB, 0x00DD,
+ 0x00FD, 0x00D6, 0x00DC, 0x00F8, 0x00A3, 0x00D8, 0x20A7, 0x0192,
+ 0x00E1, 0x00ED, 0x00F3, 0x00FA, 0x00C1, 0x00CD, 0x00D3, 0x00DA,
+ 0x00BF, 0x2310, 0x00AC, 0x00BD, 0x00BC, 0x00A1, 0x00AB, 0x00BB,
+ 0x2591, 0x2592, 0x2593, 0x2502, 0x2524, 0x2561, 0x2562, 0x2556,
+ 0x2555, 0x2563, 0x2551, 0x2557, 0x255D, 0x255C, 0x255B, 0x2510,
+ 0x2514, 0x2534, 0x252C, 0x251C, 0x2500, 0x253C, 0x255E, 0x255F,
+ 0x255A, 0x2554, 0x2569, 0x2566, 0x2560, 0x2550, 0x256C, 0x2567,
+ 0x2568, 0x2564, 0x2565, 0x2559, 0x2558, 0x2552, 0x2553, 0x256B,
+ 0x256A, 0x2518, 0x250C, 0x2588, 0x2584, 0x258C, 0x2590, 0x2580,
+ 0x03B1, 0x00DF, 0x0393, 0x03C0, 0x03A3, 0x03C3, 0x00B5, 0x03C4,
+ 0x03A6, 0x0398, 0x03A9, 0x03B4, 0x221E, 0x03C6, 0x03B5, 0x2229,
+ 0x2261, 0x00B1, 0x2265, 0x2264, 0x2320, 0x2321, 0x00F7, 0x2248,
+ 0x00B0, 0x2219, 0x00B7, 0x221A, 0x207F, 0x00B2, 0x25A0, 0x00A0
+ };
+
+ public Cp861()
+ {
+ super("Cp861", new String[] {
+ "cp-861"
+ });
+ lookupTable = lookup;
+ }
+
+} // class Cp861
Added: llvm-gcc-4.2/trunk/libjava/classpath/gnu/java/nio/charset/Cp862.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/gnu/java/nio/charset/Cp862.java?rev=43913&view=auto
==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/gnu/java/nio/charset/Cp862.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/gnu/java/nio/charset/Cp862.java Thu Nov 8 16:56:19 2007
@@ -0,0 +1,91 @@
+/* Cp862.java -- Charset implementation for the Cp862 character set.
+ Copyright (C) 2005 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 gnu.java.nio.charset;
+
+public class Cp862 extends ByteCharset
+{
+
+ /**
+ * This is the lookup table for this encoding
+ */
+ private static final char[] lookup =
+ {
+ 0x0000, 0x0001, 0x0002, 0x0003, 0x0004, 0x0005, 0x0006, 0x0007,
+ 0x0008, 0x0009, 0x000A, 0x000B, 0x000C, 0x000D, 0x000E, 0x000F,
+ 0x0010, 0x0011, 0x0012, 0x0013, 0x0014, 0x0015, 0x0016, 0x0017,
+ 0x0018, 0x0019, 0x001A, 0x001B, 0x001C, 0x001D, 0x001E, 0x001F,
+ 0x0020, 0x0021, 0x0022, 0x0023, 0x0024, 0x0025, 0x0026, 0x0027,
+ 0x0028, 0x0029, 0x002A, 0x002B, 0x002C, 0x002D, 0x002E, 0x002F,
+ 0x0030, 0x0031, 0x0032, 0x0033, 0x0034, 0x0035, 0x0036, 0x0037,
+ 0x0038, 0x0039, 0x003A, 0x003B, 0x003C, 0x003D, 0x003E, 0x003F,
+ 0x0040, 0x0041, 0x0042, 0x0043, 0x0044, 0x0045, 0x0046, 0x0047,
+ 0x0048, 0x0049, 0x004A, 0x004B, 0x004C, 0x004D, 0x004E, 0x004F,
+ 0x0050, 0x0051, 0x0052, 0x0053, 0x0054, 0x0055, 0x0056, 0x0057,
+ 0x0058, 0x0059, 0x005A, 0x005B, 0x005C, 0x005D, 0x005E, 0x005F,
+ 0x0060, 0x0061, 0x0062, 0x0063, 0x0064, 0x0065, 0x0066, 0x0067,
+ 0x0068, 0x0069, 0x006A, 0x006B, 0x006C, 0x006D, 0x006E, 0x006F,
+ 0x0070, 0x0071, 0x0072, 0x0073, 0x0074, 0x0075, 0x0076, 0x0077,
+ 0x0078, 0x0079, 0x007A, 0x007B, 0x007C, 0x007D, 0x007E, 0x007F,
+ 0x05D0, 0x05D1, 0x05D2, 0x05D3, 0x05D4, 0x05D5, 0x05D6, 0x05D7,
+ 0x05D8, 0x05D9, 0x05DA, 0x05DB, 0x05DC, 0x05DD, 0x05DE, 0x05DF,
+ 0x05E0, 0x05E1, 0x05E2, 0x05E3, 0x05E4, 0x05E5, 0x05E6, 0x05E7,
+ 0x05E8, 0x05E9, 0x05EA, 0x00A2, 0x00A3, 0x00A5, 0x20A7, 0x0192,
+ 0x00E1, 0x00ED, 0x00F3, 0x00FA, 0x00F1, 0x00D1, 0x00AA, 0x00BA,
+ 0x00BF, 0x2310, 0x00AC, 0x00BD, 0x00BC, 0x00A1, 0x00AB, 0x00BB,
+ 0x2591, 0x2592, 0x2593, 0x2502, 0x2524, 0x2561, 0x2562, 0x2556,
+ 0x2555, 0x2563, 0x2551, 0x2557, 0x255D, 0x255C, 0x255B, 0x2510,
+ 0x2514, 0x2534, 0x252C, 0x251C, 0x2500, 0x253C, 0x255E, 0x255F,
+ 0x255A, 0x2554, 0x2569, 0x2566, 0x2560, 0x2550, 0x256C, 0x2567,
+ 0x2568, 0x2564, 0x2565, 0x2559, 0x2558, 0x2552, 0x2553, 0x256B,
+ 0x256A, 0x2518, 0x250C, 0x2588, 0x2584, 0x258C, 0x2590, 0x2580,
+ 0x03B1, 0x00DF, 0x0393, 0x03C0, 0x03A3, 0x03C3, 0x00B5, 0x03C4,
+ 0x03A6, 0x0398, 0x03A9, 0x03B4, 0x221E, 0x03C6, 0x03B5, 0x2229,
+ 0x2261, 0x00B1, 0x2265, 0x2264, 0x2320, 0x2321, 0x00F7, 0x2248,
+ 0x00B0, 0x2219, 0x00B7, 0x221A, 0x207F, 0x00B2, 0x25A0, 0x00A0
+ };
+
+ public Cp862()
+ {
+ super("Cp862", new String[] {
+ "Cp-862"
+ });
+ lookupTable = lookup;
+ }
+
+} // class Cp862
Added: llvm-gcc-4.2/trunk/libjava/classpath/gnu/java/nio/charset/Cp863.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/gnu/java/nio/charset/Cp863.java?rev=43913&view=auto
==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/gnu/java/nio/charset/Cp863.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/gnu/java/nio/charset/Cp863.java Thu Nov 8 16:56:19 2007
@@ -0,0 +1,91 @@
+/* Cp863.java -- Charset implementation for the Cp863 character set.
+ Copyright (C) 2005 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 gnu.java.nio.charset;
+
+public class Cp863 extends ByteCharset
+{
+
+ /**
+ * This is the lookup table for this encoding
+ */
+ private static final char[] lookup =
+ {
+ 0x0000, 0x0001, 0x0002, 0x0003, 0x0004, 0x0005, 0x0006, 0x0007,
+ 0x0008, 0x0009, 0x000A, 0x000B, 0x000C, 0x000D, 0x000E, 0x000F,
+ 0x0010, 0x0011, 0x0012, 0x0013, 0x0014, 0x0015, 0x0016, 0x0017,
+ 0x0018, 0x0019, 0x001A, 0x001B, 0x001C, 0x001D, 0x001E, 0x001F,
+ 0x0020, 0x0021, 0x0022, 0x0023, 0x0024, 0x0025, 0x0026, 0x0027,
+ 0x0028, 0x0029, 0x002A, 0x002B, 0x002C, 0x002D, 0x002E, 0x002F,
+ 0x0030, 0x0031, 0x0032, 0x0033, 0x0034, 0x0035, 0x0036, 0x0037,
+ 0x0038, 0x0039, 0x003A, 0x003B, 0x003C, 0x003D, 0x003E, 0x003F,
+ 0x0040, 0x0041, 0x0042, 0x0043, 0x0044, 0x0045, 0x0046, 0x0047,
+ 0x0048, 0x0049, 0x004A, 0x004B, 0x004C, 0x004D, 0x004E, 0x004F,
+ 0x0050, 0x0051, 0x0052, 0x0053, 0x0054, 0x0055, 0x0056, 0x0057,
+ 0x0058, 0x0059, 0x005A, 0x005B, 0x005C, 0x005D, 0x005E, 0x005F,
+ 0x0060, 0x0061, 0x0062, 0x0063, 0x0064, 0x0065, 0x0066, 0x0067,
+ 0x0068, 0x0069, 0x006A, 0x006B, 0x006C, 0x006D, 0x006E, 0x006F,
+ 0x0070, 0x0071, 0x0072, 0x0073, 0x0074, 0x0075, 0x0076, 0x0077,
+ 0x0078, 0x0079, 0x007A, 0x007B, 0x007C, 0x007D, 0x007E, 0x007F,
+ 0x00C7, 0x00FC, 0x00E9, 0x00E2, 0x00C2, 0x00E0, 0x00B6, 0x00E7,
+ 0x00EA, 0x00EB, 0x00E8, 0x00EF, 0x00EE, 0x2017, 0x00C0, 0x00A7,
+ 0x00C9, 0x00C8, 0x00CA, 0x00F4, 0x00CB, 0x00CF, 0x00FB, 0x00F9,
+ 0x00A4, 0x00D4, 0x00DC, 0x00A2, 0x00A3, 0x00D9, 0x00DB, 0x0192,
+ 0x00A6, 0x00B4, 0x00F3, 0x00FA, 0x00A8, 0x00B8, 0x00B3, 0x00AF,
+ 0x00CE, 0x2310, 0x00AC, 0x00BD, 0x00BC, 0x00BE, 0x00AB, 0x00BB,
+ 0x2591, 0x2592, 0x2593, 0x2502, 0x2524, 0x2561, 0x2562, 0x2556,
+ 0x2555, 0x2563, 0x2551, 0x2557, 0x255D, 0x255C, 0x255B, 0x2510,
+ 0x2514, 0x2534, 0x252C, 0x251C, 0x2500, 0x253C, 0x255E, 0x255F,
+ 0x255A, 0x2554, 0x2569, 0x2566, 0x2560, 0x2550, 0x256C, 0x2567,
+ 0x2568, 0x2564, 0x2565, 0x2559, 0x2558, 0x2552, 0x2553, 0x256B,
+ 0x256A, 0x2518, 0x250C, 0x2588, 0x2584, 0x258C, 0x2590, 0x2580,
+ 0x03B1, 0x00DF, 0x0393, 0x03C0, 0x03A3, 0x03C3, 0x00B5, 0x03C4,
+ 0x03A6, 0x0398, 0x03A9, 0x03B4, 0x221E, 0x03C6, 0x03B5, 0x2229,
+ 0x2261, 0x00B1, 0x2265, 0x2264, 0x2320, 0x2321, 0x00F7, 0x2248,
+ 0x00B0, 0x2219, 0x00B7, 0x221A, 0x207F, 0x00B2, 0x25A0, 0x00A0
+ };
+
+ public Cp863()
+ {
+ super("Cp863", new String[] {
+ "Cp-863"
+ });
+ lookupTable = lookup;
+ }
+
+} // class Cp863
Added: llvm-gcc-4.2/trunk/libjava/classpath/gnu/java/nio/charset/Cp864.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/gnu/java/nio/charset/Cp864.java?rev=43913&view=auto
==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/gnu/java/nio/charset/Cp864.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/gnu/java/nio/charset/Cp864.java Thu Nov 8 16:56:19 2007
@@ -0,0 +1,91 @@
+/* Cp864.java -- Charset implementation for the Cp864 character set.
+ Copyright (C) 2005 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 gnu.java.nio.charset;
+
+public class Cp864 extends ByteCharset
+{
+
+ /**
+ * This is the lookup table for this encoding
+ */
+ private static final char[] lookup =
+ {
+ 0x0000, 0x0001, 0x0002, 0x0003, 0x0004, 0x0005, 0x0006, 0x0007,
+ 0x0008, 0x0009, 0x000A, 0x000B, 0x000C, 0x000D, 0x000E, 0x000F,
+ 0x0010, 0x0011, 0x0012, 0x0013, 0x0014, 0x0015, 0x0016, 0x0017,
+ 0x0018, 0x0019, 0x001A, 0x001B, 0x001C, 0x001D, 0x001E, 0x001F,
+ 0x0020, 0x0021, 0x0022, 0x0023, 0x0024, 0x066A, 0x0026, 0x0027,
+ 0x0028, 0x0029, 0x002A, 0x002B, 0x002C, 0x002D, 0x002E, 0x002F,
+ 0x0030, 0x0031, 0x0032, 0x0033, 0x0034, 0x0035, 0x0036, 0x0037,
+ 0x0038, 0x0039, 0x003A, 0x003B, 0x003C, 0x003D, 0x003E, 0x003F,
+ 0x0040, 0x0041, 0x0042, 0x0043, 0x0044, 0x0045, 0x0046, 0x0047,
+ 0x0048, 0x0049, 0x004A, 0x004B, 0x004C, 0x004D, 0x004E, 0x004F,
+ 0x0050, 0x0051, 0x0052, 0x0053, 0x0054, 0x0055, 0x0056, 0x0057,
+ 0x0058, 0x0059, 0x005A, 0x005B, 0x005C, 0x005D, 0x005E, 0x005F,
+ 0x0060, 0x0061, 0x0062, 0x0063, 0x0064, 0x0065, 0x0066, 0x0067,
+ 0x0068, 0x0069, 0x006A, 0x006B, 0x006C, 0x006D, 0x006E, 0x006F,
+ 0x0070, 0x0071, 0x0072, 0x0073, 0x0074, 0x0075, 0x0076, 0x0077,
+ 0x0078, 0x0079, 0x007A, 0x007B, 0x007C, 0x007D, 0x007E, 0x007F,
+ 0x00B0, 0x00B7, 0x2219, 0x221A, 0x2592, 0x2500, 0x2502, 0x253C,
+ 0x2524, 0x252C, 0x251C, 0x2534, 0x2510, 0x250C, 0x2514, 0x2518,
+ 0x03B2, 0x221E, 0x03C6, 0x00B1, 0x00BD, 0x00BC, 0x2248, 0x00AB,
+ 0x00BB, 0xFEF7, 0xFEF8, NONE, NONE, 0xFEFB, 0xFEFC, NONE,
+ 0x00A0, 0x00AD, 0xFE82, 0x00A3, 0x00A4, 0xFE84, NONE, NONE,
+ 0xFE8E, 0xFE8F, 0xFE95, 0xFE99, 0x060C, 0xFE9D, 0xFEA1, 0xFEA5,
+ 0x0660, 0x0661, 0x0662, 0x0663, 0x0664, 0x0665, 0x0666, 0x0667,
+ 0x0668, 0x0669, 0xFED1, 0x061B, 0xFEB1, 0xFEB5, 0xFEB9, 0x061F,
+ 0x00A2, 0xFE80, 0xFE81, 0xFE83, 0xFE85, 0xFECA, 0xFE8B, 0xFE8D,
+ 0xFE91, 0xFE93, 0xFE97, 0xFE9B, 0xFE9F, 0xFEA3, 0xFEA7, 0xFEA9,
+ 0xFEAB, 0xFEAD, 0xFEAF, 0xFEB3, 0xFEB7, 0xFEBB, 0xFEBF, 0xFEC1,
+ 0xFEC5, 0xFECB, 0xFECF, 0x00A6, 0x00AC, 0x00F7, 0x00D7, 0xFEC9,
+ 0x0640, 0xFED3, 0xFED7, 0xFEDB, 0xFEDF, 0xFEE3, 0xFEE7, 0xFEEB,
+ 0xFEED, 0xFEEF, 0xFEF3, 0xFEBD, 0xFECC, 0xFECE, 0xFECD, 0xFEE1,
+ 0xFE7D, 0x0651, 0xFEE5, 0xFEE9, 0xFEEC, 0xFEF0, 0xFEF2, 0xFED0,
+ 0xFED5, 0xFEF5, 0xFEF6, 0xFEDD, 0xFED9, 0xFEF1, 0x25A0, NONE
+ };
+
+ public Cp864()
+ {
+ super("Cp864", new String[] {
+ "Cp-864"
+ });
+ lookupTable = lookup;
+ }
+
+} // class Cp864
Added: llvm-gcc-4.2/trunk/libjava/classpath/gnu/java/nio/charset/Cp865.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/gnu/java/nio/charset/Cp865.java?rev=43913&view=auto
==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/gnu/java/nio/charset/Cp865.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/gnu/java/nio/charset/Cp865.java Thu Nov 8 16:56:19 2007
@@ -0,0 +1,91 @@
+/* Cp865.java -- Charset implementation for the Cp865 character set.
+ Copyright (C) 2005 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 gnu.java.nio.charset;
+
+public class Cp865 extends ByteCharset
+{
+
+ /**
+ * This is the lookup table for this encoding
+ */
+ private static final char[] lookup =
+ {
+ 0x0000, 0x0001, 0x0002, 0x0003, 0x0004, 0x0005, 0x0006, 0x0007,
+ 0x0008, 0x0009, 0x000A, 0x000B, 0x000C, 0x000D, 0x000E, 0x000F,
+ 0x0010, 0x0011, 0x0012, 0x0013, 0x0014, 0x0015, 0x0016, 0x0017,
+ 0x0018, 0x0019, 0x001A, 0x001B, 0x001C, 0x001D, 0x001E, 0x001F,
+ 0x0020, 0x0021, 0x0022, 0x0023, 0x0024, 0x0025, 0x0026, 0x0027,
+ 0x0028, 0x0029, 0x002A, 0x002B, 0x002C, 0x002D, 0x002E, 0x002F,
+ 0x0030, 0x0031, 0x0032, 0x0033, 0x0034, 0x0035, 0x0036, 0x0037,
+ 0x0038, 0x0039, 0x003A, 0x003B, 0x003C, 0x003D, 0x003E, 0x003F,
+ 0x0040, 0x0041, 0x0042, 0x0043, 0x0044, 0x0045, 0x0046, 0x0047,
+ 0x0048, 0x0049, 0x004A, 0x004B, 0x004C, 0x004D, 0x004E, 0x004F,
+ 0x0050, 0x0051, 0x0052, 0x0053, 0x0054, 0x0055, 0x0056, 0x0057,
+ 0x0058, 0x0059, 0x005A, 0x005B, 0x005C, 0x005D, 0x005E, 0x005F,
+ 0x0060, 0x0061, 0x0062, 0x0063, 0x0064, 0x0065, 0x0066, 0x0067,
+ 0x0068, 0x0069, 0x006A, 0x006B, 0x006C, 0x006D, 0x006E, 0x006F,
+ 0x0070, 0x0071, 0x0072, 0x0073, 0x0074, 0x0075, 0x0076, 0x0077,
+ 0x0078, 0x0079, 0x007A, 0x007B, 0x007C, 0x007D, 0x007E, 0x007F,
+ 0x00C7, 0x00FC, 0x00E9, 0x00E2, 0x00E4, 0x00E0, 0x00E5, 0x00E7,
+ 0x00EA, 0x00EB, 0x00E8, 0x00EF, 0x00EE, 0x00EC, 0x00C4, 0x00C5,
+ 0x00C9, 0x00E6, 0x00C6, 0x00F4, 0x00F6, 0x00F2, 0x00FB, 0x00F9,
+ 0x00FF, 0x00D6, 0x00DC, 0x00F8, 0x00A3, 0x00D8, 0x20A7, 0x0192,
+ 0x00E1, 0x00ED, 0x00F3, 0x00FA, 0x00F1, 0x00D1, 0x00AA, 0x00BA,
+ 0x00BF, 0x2310, 0x00AC, 0x00BD, 0x00BC, 0x00A1, 0x00AB, 0x00A4,
+ 0x2591, 0x2592, 0x2593, 0x2502, 0x2524, 0x2561, 0x2562, 0x2556,
+ 0x2555, 0x2563, 0x2551, 0x2557, 0x255D, 0x255C, 0x255B, 0x2510,
+ 0x2514, 0x2534, 0x252C, 0x251C, 0x2500, 0x253C, 0x255E, 0x255F,
+ 0x255A, 0x2554, 0x2569, 0x2566, 0x2560, 0x2550, 0x256C, 0x2567,
+ 0x2568, 0x2564, 0x2565, 0x2559, 0x2558, 0x2552, 0x2553, 0x256B,
+ 0x256A, 0x2518, 0x250C, 0x2588, 0x2584, 0x258C, 0x2590, 0x2580,
+ 0x03B1, 0x00DF, 0x0393, 0x03C0, 0x03A3, 0x03C3, 0x00B5, 0x03C4,
+ 0x03A6, 0x0398, 0x03A9, 0x03B4, 0x221E, 0x03C6, 0x03B5, 0x2229,
+ 0x2261, 0x00B1, 0x2265, 0x2264, 0x2320, 0x2321, 0x00F7, 0x2248,
+ 0x00B0, 0x2219, 0x00B7, 0x221A, 0x207F, 0x00B2, 0x25A0, 0x00A0
+ };
+
+ public Cp865()
+ {
+ super("Cp865", new String[] {
+ "Cp-865"
+ });
+ lookupTable = lookup;
+ }
+
+} // class Cp865
Added: llvm-gcc-4.2/trunk/libjava/classpath/gnu/java/nio/charset/Cp866.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/gnu/java/nio/charset/Cp866.java?rev=43913&view=auto
==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/gnu/java/nio/charset/Cp866.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/gnu/java/nio/charset/Cp866.java Thu Nov 8 16:56:19 2007
@@ -0,0 +1,91 @@
+/* Cp866.java -- Charset implementation for the Cp866 character set.
+ Copyright (C) 2005 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 gnu.java.nio.charset;
+
+public class Cp866 extends ByteCharset
+{
+
+ /**
+ * This is the lookup table for this encoding
+ */
+ private static final char[] lookup =
+ {
+ 0x0000, 0x0001, 0x0002, 0x0003, 0x0004, 0x0005, 0x0006, 0x0007,
+ 0x0008, 0x0009, 0x000A, 0x000B, 0x000C, 0x000D, 0x000E, 0x000F,
+ 0x0010, 0x0011, 0x0012, 0x0013, 0x0014, 0x0015, 0x0016, 0x0017,
+ 0x0018, 0x0019, 0x001A, 0x001B, 0x001C, 0x001D, 0x001E, 0x001F,
+ 0x0020, 0x0021, 0x0022, 0x0023, 0x0024, 0x0025, 0x0026, 0x0027,
+ 0x0028, 0x0029, 0x002A, 0x002B, 0x002C, 0x002D, 0x002E, 0x002F,
+ 0x0030, 0x0031, 0x0032, 0x0033, 0x0034, 0x0035, 0x0036, 0x0037,
+ 0x0038, 0x0039, 0x003A, 0x003B, 0x003C, 0x003D, 0x003E, 0x003F,
+ 0x0040, 0x0041, 0x0042, 0x0043, 0x0044, 0x0045, 0x0046, 0x0047,
+ 0x0048, 0x0049, 0x004A, 0x004B, 0x004C, 0x004D, 0x004E, 0x004F,
+ 0x0050, 0x0051, 0x0052, 0x0053, 0x0054, 0x0055, 0x0056, 0x0057,
+ 0x0058, 0x0059, 0x005A, 0x005B, 0x005C, 0x005D, 0x005E, 0x005F,
+ 0x0060, 0x0061, 0x0062, 0x0063, 0x0064, 0x0065, 0x0066, 0x0067,
+ 0x0068, 0x0069, 0x006A, 0x006B, 0x006C, 0x006D, 0x006E, 0x006F,
+ 0x0070, 0x0071, 0x0072, 0x0073, 0x0074, 0x0075, 0x0076, 0x0077,
+ 0x0078, 0x0079, 0x007A, 0x007B, 0x007C, 0x007D, 0x007E, 0x007F,
+ 0x0410, 0x0411, 0x0412, 0x0413, 0x0414, 0x0415, 0x0416, 0x0417,
+ 0x0418, 0x0419, 0x041A, 0x041B, 0x041C, 0x041D, 0x041E, 0x041F,
+ 0x0420, 0x0421, 0x0422, 0x0423, 0x0424, 0x0425, 0x0426, 0x0427,
+ 0x0428, 0x0429, 0x042A, 0x042B, 0x042C, 0x042D, 0x042E, 0x042F,
+ 0x0430, 0x0431, 0x0432, 0x0433, 0x0434, 0x0435, 0x0436, 0x0437,
+ 0x0438, 0x0439, 0x043A, 0x043B, 0x043C, 0x043D, 0x043E, 0x043F,
+ 0x2591, 0x2592, 0x2593, 0x2502, 0x2524, 0x2561, 0x2562, 0x2556,
+ 0x2555, 0x2563, 0x2551, 0x2557, 0x255D, 0x255C, 0x255B, 0x2510,
+ 0x2514, 0x2534, 0x252C, 0x251C, 0x2500, 0x253C, 0x255E, 0x255F,
+ 0x255A, 0x2554, 0x2569, 0x2566, 0x2560, 0x2550, 0x256C, 0x2567,
+ 0x2568, 0x2564, 0x2565, 0x2559, 0x2558, 0x2552, 0x2553, 0x256B,
+ 0x256A, 0x2518, 0x250C, 0x2588, 0x2584, 0x258C, 0x2590, 0x2580,
+ 0x0440, 0x0441, 0x0442, 0x0443, 0x0444, 0x0445, 0x0446, 0x0447,
+ 0x0448, 0x0449, 0x044A, 0x044B, 0x044C, 0x044D, 0x044E, 0x044F,
+ 0x0401, 0x0451, 0x0404, 0x0454, 0x0407, 0x0457, 0x040E, 0x045E,
+ 0x00B0, 0x2219, 0x00B7, 0x221A, 0x2116, 0x00A4, 0x25A0, 0x00A0
+ };
+
+ public Cp866()
+ {
+ super("Cp866", new String[] {
+ "cp-866"
+ });
+ lookupTable = lookup;
+ }
+
+} // class Cp866
Added: llvm-gcc-4.2/trunk/libjava/classpath/gnu/java/nio/charset/Cp869.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/gnu/java/nio/charset/Cp869.java?rev=43913&view=auto
==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/gnu/java/nio/charset/Cp869.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/gnu/java/nio/charset/Cp869.java Thu Nov 8 16:56:19 2007
@@ -0,0 +1,91 @@
+/* Cp869.java -- Charset implementation for the Cp869 character set.
+ Copyright (C) 2005 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 gnu.java.nio.charset;
+
+public class Cp869 extends ByteCharset
+{
+
+ /**
+ * This is the lookup table for this encoding
+ */
+ private static final char[] lookup =
+ {
+ 0x0000, 0x0001, 0x0002, 0x0003, 0x0004, 0x0005, 0x0006, 0x0007,
+ 0x0008, 0x0009, 0x000A, 0x000B, 0x000C, 0x000D, 0x000E, 0x000F,
+ 0x0010, 0x0011, 0x0012, 0x0013, 0x0014, 0x0015, 0x0016, 0x0017,
+ 0x0018, 0x0019, 0x001A, 0x001B, 0x001C, 0x001D, 0x001E, 0x001F,
+ 0x0020, 0x0021, 0x0022, 0x0023, 0x0024, 0x0025, 0x0026, 0x0027,
+ 0x0028, 0x0029, 0x002A, 0x002B, 0x002C, 0x002D, 0x002E, 0x002F,
+ 0x0030, 0x0031, 0x0032, 0x0033, 0x0034, 0x0035, 0x0036, 0x0037,
+ 0x0038, 0x0039, 0x003A, 0x003B, 0x003C, 0x003D, 0x003E, 0x003F,
+ 0x0040, 0x0041, 0x0042, 0x0043, 0x0044, 0x0045, 0x0046, 0x0047,
+ 0x0048, 0x0049, 0x004A, 0x004B, 0x004C, 0x004D, 0x004E, 0x004F,
+ 0x0050, 0x0051, 0x0052, 0x0053, 0x0054, 0x0055, 0x0056, 0x0057,
+ 0x0058, 0x0059, 0x005A, 0x005B, 0x005C, 0x005D, 0x005E, 0x005F,
+ 0x0060, 0x0061, 0x0062, 0x0063, 0x0064, 0x0065, 0x0066, 0x0067,
+ 0x0068, 0x0069, 0x006A, 0x006B, 0x006C, 0x006D, 0x006E, 0x006F,
+ 0x0070, 0x0071, 0x0072, 0x0073, 0x0074, 0x0075, 0x0076, 0x0077,
+ 0x0078, 0x0079, 0x007A, 0x007B, 0x007C, 0x007D, 0x007E, 0x007F,
+ NONE, NONE, NONE, NONE, NONE, NONE, 0x0386, NONE,
+ 0x00B7, 0x00AC, 0x00A6, 0x2018, 0x2019, 0x0388, 0x2015, 0x0389,
+ 0x038A, 0x03AA, 0x038C, NONE, NONE, 0x038E, 0x03AB, 0x00A9,
+ 0x038F, 0x00B2, 0x00B3, 0x03AC, 0x00A3, 0x03AD, 0x03AE, 0x03AF,
+ 0x03CA, 0x0390, 0x03CC, 0x03CD, 0x0391, 0x0392, 0x0393, 0x0394,
+ 0x0395, 0x0396, 0x0397, 0x00BD, 0x0398, 0x0399, 0x00AB, 0x00BB,
+ 0x2591, 0x2592, 0x2593, 0x2502, 0x2524, 0x039A, 0x039B, 0x039C,
+ 0x039D, 0x2563, 0x2551, 0x2557, 0x255D, 0x039E, 0x039F, 0x2510,
+ 0x2514, 0x2534, 0x252C, 0x251C, 0x2500, 0x253C, 0x03A0, 0x03A1,
+ 0x255A, 0x2554, 0x2569, 0x2566, 0x2560, 0x2550, 0x256C, 0x03A3,
+ 0x03A4, 0x03A5, 0x03A6, 0x03A7, 0x03A8, 0x03A9, 0x03B1, 0x03B2,
+ 0x03B3, 0x2518, 0x250C, 0x2588, 0x2584, 0x03B4, 0x03B5, 0x2580,
+ 0x03B6, 0x03B7, 0x03B8, 0x03B9, 0x03BA, 0x03BB, 0x03BC, 0x03BD,
+ 0x03BE, 0x03BF, 0x03C0, 0x03C1, 0x03C3, 0x03C2, 0x03C4, 0x0384,
+ 0x00AD, 0x00B1, 0x03C5, 0x03C6, 0x03C7, 0x00A7, 0x03C8, 0x0385,
+ 0x00B0, 0x00A8, 0x03C9, 0x03CB, 0x03B0, 0x03CE, 0x25A0, 0x00A0
+ };
+
+ public Cp869()
+ {
+ super("Cp869", new String[] {
+ "Cp-869"
+ });
+ lookupTable = lookup;
+ }
+
+} // class Cp869
Added: llvm-gcc-4.2/trunk/libjava/classpath/gnu/java/nio/charset/Cp874.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/gnu/java/nio/charset/Cp874.java?rev=43913&view=auto
==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/gnu/java/nio/charset/Cp874.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/gnu/java/nio/charset/Cp874.java Thu Nov 8 16:56:19 2007
@@ -0,0 +1,89 @@
+/* Cp874.java -- Charset implementation for the Cp874 character set.
+ Copyright (C) 2005 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 gnu.java.nio.charset;
+
+public class Cp874 extends ByteCharset
+{
+
+ /**
+ * This is the lookup table for this encoding
+ */
+ private static final char[] lookup =
+ {
+ 0x0000, 0x0001, 0x0002, 0x0003, 0x0004, 0x0005, 0x0006, 0x0007,
+ 0x0008, 0x0009, 0x000A, 0x000B, 0x000C, 0x000D, 0x000E, 0x000F,
+ 0x0010, 0x0011, 0x0012, 0x0013, 0x0014, 0x0015, 0x0016, 0x0017,
+ 0x0018, 0x0019, 0x001A, 0x001B, 0x001C, 0x001D, 0x001E, 0x001F,
+ 0x0020, 0x0021, 0x0022, 0x0023, 0x0024, 0x0025, 0x0026, 0x0027,
+ 0x0028, 0x0029, 0x002A, 0x002B, 0x002C, 0x002D, 0x002E, 0x002F,
+ 0x0030, 0x0031, 0x0032, 0x0033, 0x0034, 0x0035, 0x0036, 0x0037,
+ 0x0038, 0x0039, 0x003A, 0x003B, 0x003C, 0x003D, 0x003E, 0x003F,
+ 0x0040, 0x0041, 0x0042, 0x0043, 0x0044, 0x0045, 0x0046, 0x0047,
+ 0x0048, 0x0049, 0x004A, 0x004B, 0x004C, 0x004D, 0x004E, 0x004F,
+ 0x0050, 0x0051, 0x0052, 0x0053, 0x0054, 0x0055, 0x0056, 0x0057,
+ 0x0058, 0x0059, 0x005A, 0x005B, 0x005C, 0x005D, 0x005E, 0x005F,
+ 0x0060, 0x0061, 0x0062, 0x0063, 0x0064, 0x0065, 0x0066, 0x0067,
+ 0x0068, 0x0069, 0x006A, 0x006B, 0x006C, 0x006D, 0x006E, 0x006F,
+ 0x0070, 0x0071, 0x0072, 0x0073, 0x0074, 0x0075, 0x0076, 0x0077,
+ 0x0078, 0x0079, 0x007A, 0x007B, 0x007C, 0x007D, 0x007E, 0x007F,
+ 0x20AC, NONE, NONE, NONE, NONE, 0x2026, NONE, NONE,
+ NONE, NONE, NONE, NONE, NONE, NONE, NONE, NONE,
+ NONE, 0x2018, 0x2019, 0x201C, 0x201D, 0x2022, 0x2013, 0x2014,
+ NONE, NONE, NONE, NONE, NONE, NONE, NONE, NONE,
+ 0x00A0, 0x0E01, 0x0E02, 0x0E03, 0x0E04, 0x0E05, 0x0E06, 0x0E07,
+ 0x0E08, 0x0E09, 0x0E0A, 0x0E0B, 0x0E0C, 0x0E0D, 0x0E0E, 0x0E0F,
+ 0x0E10, 0x0E11, 0x0E12, 0x0E13, 0x0E14, 0x0E15, 0x0E16, 0x0E17,
+ 0x0E18, 0x0E19, 0x0E1A, 0x0E1B, 0x0E1C, 0x0E1D, 0x0E1E, 0x0E1F,
+ 0x0E20, 0x0E21, 0x0E22, 0x0E23, 0x0E24, 0x0E25, 0x0E26, 0x0E27,
+ 0x0E28, 0x0E29, 0x0E2A, 0x0E2B, 0x0E2C, 0x0E2D, 0x0E2E, 0x0E2F,
+ 0x0E30, 0x0E31, 0x0E32, 0x0E33, 0x0E34, 0x0E35, 0x0E36, 0x0E37,
+ 0x0E38, 0x0E39, 0x0E3A, NONE, NONE, NONE, NONE, 0x0E3F,
+ 0x0E40, 0x0E41, 0x0E42, 0x0E43, 0x0E44, 0x0E45, 0x0E46, 0x0E47,
+ 0x0E48, 0x0E49, 0x0E4A, 0x0E4B, 0x0E4C, 0x0E4D, 0x0E4E, 0x0E4F,
+ 0x0E50, 0x0E51, 0x0E52, 0x0E53, 0x0E54, 0x0E55, 0x0E56, 0x0E57,
+ 0x0E58, 0x0E59, 0x0E5A, 0x0E5B, NONE, NONE, NONE, NONE
+ };
+
+ public Cp874()
+ {
+ super("Cp874", new String[] {
+ });
+ lookupTable = lookup;
+ }
+
+} // class Cp874
Added: llvm-gcc-4.2/trunk/libjava/classpath/gnu/java/nio/charset/EncodingHelper.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/gnu/java/nio/charset/EncodingHelper.java?rev=43913&view=auto
==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/gnu/java/nio/charset/EncodingHelper.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/gnu/java/nio/charset/EncodingHelper.java Thu Nov 8 16:56:19 2007
@@ -0,0 +1,154 @@
+/* EncodingHelper.java -- Useful character encoding methods.
+ Copyright (C) 2005 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 gnu.java.nio.charset;
+
+import java.util.HashMap;
+import java.nio.charset.IllegalCharsetNameException;
+import java.nio.charset.UnsupportedCharsetException;
+import java.nio.charset.Charset;
+import java.io.UnsupportedEncodingException;
+
+/**
+ * This class provides some useful utility methods
+ * for charset encoding for the java.lang and java.io methods.
+ *
+ * @author Sven de Marothy
+ */
+public class EncodingHelper
+{
+
+ /**
+ * Contains the mapping from java.io canonical names
+ * to java.nio canonical names.
+ */
+ private static HashMap canonicalNames;
+
+ static {
+ canonicalNames = new HashMap();
+ canonicalNames.put("US-ASCII", "ASCII");
+ canonicalNames.put("windows-1250", "Cp1250");
+ canonicalNames.put("windows-1251", "Cp1251");
+ canonicalNames.put("windows-1252", "Cp1252");
+ canonicalNames.put("windows-1253", "Cp1253");
+ canonicalNames.put("windows-1254", "Cp1254");
+ canonicalNames.put("windows-1257", "Cp1257");
+ canonicalNames.put("ISO-8859-1", "ISO8859_1");
+ canonicalNames.put("ISO-8859-2", "ISO8859_2");
+ canonicalNames.put("ISO-8859-4", "ISO8859_4");
+ canonicalNames.put("ISO-8859-5", "ISO8859_5");
+ canonicalNames.put("ISO-8859-7", "ISO8859_7");
+ canonicalNames.put("ISO-8859-9", "ISO8859_9");
+ canonicalNames.put("ISO-8859-13", "ISO8859_13");
+ canonicalNames.put("ISO-8859-15", "ISO8859_15");
+ canonicalNames.put("KOI8-R", "KOI8_R");
+ canonicalNames.put("UTF-8", "UTF8");
+ canonicalNames.put("UTF-16BE", "UnicodeBigUnmarked");
+ canonicalNames.put("UTF-16LE", "UnicodeLittleUnmarked");
+ canonicalNames.put("windows-1255", "Cp1255");
+ canonicalNames.put("windows-1256", "Cp1256");
+ canonicalNames.put("windows-1258", "Cp1258");
+ canonicalNames.put("ISO-8859-3", "ISO8859_3");
+ canonicalNames.put("ISO-8859-6", "ISO8859_6");
+ canonicalNames.put("ISO-8859-8", "ISO8859_8");
+ }
+
+ /**
+ * Returns the name of the default encoding,
+ * falls back on defaults to Latin-1 if there's a problem.
+ */
+ public static String getDefaultEncoding()
+ {
+ String encoding;
+ try
+ {
+ return System.getProperty("file.encoding");
+ } catch(SecurityException e) {
+ } catch(IllegalArgumentException e) {
+ }
+ // XXX - Throw an error here? For now, default to the 'safe' encoding.
+ return "8859_1";
+ }
+
+ /**
+ * Returns the java.io canonical name of a charset given with the
+ * java.nio canonical name. If the charset does not have a java.io
+ * canonical name, the input string is returned.
+ */
+ public static String getOldCanonical(String newCanonical)
+ {
+ String oldCanonical = (String) canonicalNames.get(newCanonical);
+ return (oldCanonical != null)?oldCanonical : newCanonical;
+ }
+
+ public static boolean isISOLatin1(String s)
+ {
+ if(s.equals("ISO-8859-1") ||
+ s.equals("8859_1") ||
+ s.equals("ISO_8859-1") ||
+ s.equals("latin1") ||
+ s.equals("ISO8859_1") ||
+ s.equals("ISO_8859_1"))
+ return true;
+ return false;
+ }
+
+ /**
+ * Gets a charset, throwing the java.io exception and not
+ * the java.nio exception if an error occurs.
+ */
+ public static Charset getCharset(String name)
+ throws UnsupportedEncodingException
+ {
+ try
+ {
+ return Charset.forName(name);
+ }
+ catch(IllegalCharsetNameException e)
+ {
+ throw new UnsupportedEncodingException("Charset "+name+" not found.");
+ }
+ catch(UnsupportedCharsetException e)
+ {
+ throw new UnsupportedEncodingException("Charset "+name+" not found.");
+ }
+ }
+}
+
+
+
Added: llvm-gcc-4.2/trunk/libjava/classpath/gnu/java/nio/charset/ISO_8859_1.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/gnu/java/nio/charset/ISO_8859_1.java?rev=43913&view=auto
==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/gnu/java/nio/charset/ISO_8859_1.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/gnu/java/nio/charset/ISO_8859_1.java Thu Nov 8 16:56:19 2007
@@ -0,0 +1,168 @@
+/* ISO_8859_1.java --
+ Copyright (C) 2002, 2004, 2005 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 gnu.java.nio.charset;
+
+import java.nio.ByteBuffer;
+import java.nio.CharBuffer;
+import java.nio.charset.Charset;
+import java.nio.charset.CharsetDecoder;
+import java.nio.charset.CharsetEncoder;
+import java.nio.charset.CoderResult;
+
+/**
+ * ISO-8859-1 charset.
+ *
+ * @author Jesse Rosenstock
+ */
+final class ISO_8859_1 extends Charset
+{
+ ISO_8859_1 ()
+ {
+ /* Canonical charset name chosen according to:
+ * http://java.sun.com/j2se/1.5.0/docs/guide/intl/encoding.doc.html
+ */
+ super ("ISO-8859-1", new String[] {
+ /* These names are provided by
+ * http://www.iana.org/assignments/character-sets
+ */
+ "iso-ir-100",
+ "ISO_8859-1",
+ "latin1",
+ "l1",
+ "IBM819",
+ "CP819",
+ "csISOLatin1",
+ "8859_1",
+ /* These names are provided by
+ * http://oss.software.ibm.com/cgi-bin/icu/convexp?s=ALL
+ */
+ "ISO8859_1", "ISO_8859_1", "ibm-819", "ISO_8859-1:1987",
+ "819"
+ });
+
+ }
+
+ public boolean contains (Charset cs)
+ {
+ return cs instanceof US_ASCII || cs instanceof ISO_8859_1;
+ }
+
+ public CharsetDecoder newDecoder ()
+ {
+ return new Decoder (this);
+ }
+
+ public CharsetEncoder newEncoder ()
+ {
+ return new Encoder (this);
+ }
+
+ private static final class Decoder extends CharsetDecoder
+ {
+ // Package-private to avoid a trampoline constructor.
+ Decoder (Charset cs)
+ {
+ super (cs, 1.0f, 1.0f);
+ }
+
+ protected CoderResult decodeLoop (ByteBuffer in, CharBuffer out)
+ {
+ // TODO: Optimize this in the case in.hasArray() / out.hasArray()
+ while (in.hasRemaining ())
+ {
+ byte b = in.get ();
+
+ if (!out.hasRemaining ())
+ {
+ in.position (in.position () - 1);
+ return CoderResult.OVERFLOW;
+ }
+
+ out.put ((char) (b & 0xFF));
+ }
+
+ return CoderResult.UNDERFLOW;
+ }
+ }
+
+ private static final class Encoder extends CharsetEncoder
+ {
+ // Package-private to avoid a trampoline constructor.
+ Encoder (Charset cs)
+ {
+ super (cs, 1.0f, 1.0f);
+ }
+
+ public boolean canEncode(char c)
+ {
+ return c <= 0xff;
+ }
+
+ public boolean canEncode(CharSequence cs)
+ {
+ for (int i = 0; i < cs.length(); ++i)
+ if (! canEncode(cs.charAt(i)))
+ return false;
+ return true;
+ }
+
+ protected CoderResult encodeLoop (CharBuffer in, ByteBuffer out)
+ {
+ // TODO: Optimize this in the case in.hasArray() / out.hasArray()
+ while (in.hasRemaining ())
+ {
+ char c = in.get ();
+
+ if (c > 0xFF)
+ {
+ in.position (in.position () - 1);
+ return CoderResult.unmappableForLength (1);
+ }
+ if (!out.hasRemaining ())
+ {
+ in.position (in.position () - 1);
+ return CoderResult.OVERFLOW;
+ }
+
+ out.put ((byte) c);
+ }
+
+ return CoderResult.UNDERFLOW;
+ }
+ }
+}
Added: llvm-gcc-4.2/trunk/libjava/classpath/gnu/java/nio/charset/ISO_8859_13.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/gnu/java/nio/charset/ISO_8859_13.java?rev=43913&view=auto
==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/gnu/java/nio/charset/ISO_8859_13.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/gnu/java/nio/charset/ISO_8859_13.java Thu Nov 8 16:56:19 2007
@@ -0,0 +1,104 @@
+/* ISO_8859_13.java -- Charset for ISO-8859-13 iso latin character set.
+ Copyright (C) 2005 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 gnu.java.nio.charset;
+
+/**
+ * Encoding table for ISO-8859-13, ISO Latin-7 char set.
+ */
+public class ISO_8859_13 extends ByteCharset
+{
+
+ /**
+ * This is the lookup table for this encoding
+ */
+ private static final char[] lookup =
+ {
+ 0x0000, 0x0001, 0x0002, 0x0003, 0x0004, 0x0005, 0x0006, 0x0007,
+ 0x0008, 0x0009, 0x000A, 0x000B, 0x000C, 0x000D, 0x000E, 0x000F,
+ 0x0010, 0x0011, 0x0012, 0x0013, 0x0014, 0x0015, 0x0016, 0x0017,
+ 0x0018, 0x0019, 0x001A, 0x001B, 0x001C, 0x001D, 0x001E, 0x001F,
+ 0x0020, 0x0021, 0x0022, 0x0023, 0x0024, 0x0025, 0x0026, 0x0027,
+ 0x0028, 0x0029, 0x002A, 0x002B, 0x002C, 0x002D, 0x002E, 0x002F,
+ 0x0030, 0x0031, 0x0032, 0x0033, 0x0034, 0x0035, 0x0036, 0x0037,
+ 0x0038, 0x0039, 0x003A, 0x003B, 0x003C, 0x003D, 0x003E, 0x003F,
+ 0x0040, 0x0041, 0x0042, 0x0043, 0x0044, 0x0045, 0x0046, 0x0047,
+ 0x0048, 0x0049, 0x004A, 0x004B, 0x004C, 0x004D, 0x004E, 0x004F,
+ 0x0050, 0x0051, 0x0052, 0x0053, 0x0054, 0x0055, 0x0056, 0x0057,
+ 0x0058, 0x0059, 0x005A, 0x005B, 0x005C, 0x005D, 0x005E, 0x005F,
+ 0x0060, 0x0061, 0x0062, 0x0063, 0x0064, 0x0065, 0x0066, 0x0067,
+ 0x0068, 0x0069, 0x006A, 0x006B, 0x006C, 0x006D, 0x006E, 0x006F,
+ 0x0070, 0x0071, 0x0072, 0x0073, 0x0074, 0x0075, 0x0076, 0x0077,
+ 0x0078, 0x0079, 0x007A, 0x007B, 0x007C, 0x007D, 0x007E, 0x007F,
+ 0x0080, 0x0081, 0x0082, 0x0083, 0x0084, 0x0085, 0x0086, 0x0087,
+ 0x0088, 0x0089, 0x008A, 0x008B, 0x008C, 0x008D, 0x008E, 0x008F,
+ 0x0090, 0x0091, 0x0092, 0x0093, 0x0094, 0x0095, 0x0096, 0x0097,
+ 0x0098, 0x0099, 0x009A, 0x009B, 0x009C, 0x009D, 0x009E, 0x009F,
+ 0x00A0, 0x201D, 0x00A2, 0x00A3, 0x00A4, 0x201E, 0x00A6, 0x00A7,
+ 0x00D8, 0x00A9, 0x0156, 0x00AB, 0x00AC, 0x00AD, 0x00AE, 0x00C6,
+ 0x00B0, 0x00B1, 0x00B2, 0x00B3, 0x201C, 0x00B5, 0x00B6, 0x00B7,
+ 0x00F8, 0x00B9, 0x0157, 0x00BB, 0x00BC, 0x00BD, 0x00BE, 0x00E6,
+ 0x0104, 0x012E, 0x0100, 0x0106, 0x00C4, 0x00C5, 0x0118, 0x0112,
+ 0x010C, 0x00C9, 0x0179, 0x0116, 0x0122, 0x0136, 0x012A, 0x013B,
+ 0x0160, 0x0143, 0x0145, 0x00D3, 0x014C, 0x00D5, 0x00D6, 0x00D7,
+ 0x0172, 0x0141, 0x015A, 0x016A, 0x00DC, 0x017B, 0x017D, 0x00DF,
+ 0x0105, 0x012F, 0x0101, 0x0107, 0x00E4, 0x00E5, 0x0119, 0x0113,
+ 0x010D, 0x00E9, 0x017A, 0x0117, 0x0123, 0x0137, 0x012B, 0x013C,
+ 0x0161, 0x0144, 0x0146, 0x00F3, 0x014D, 0x00F5, 0x00F6, 0x00F7,
+ 0x0173, 0x0142, 0x015B, 0x016B, 0x00FC, 0x017C, 0x017E, 0x2019
+ };
+
+ public ISO_8859_13()
+ {
+ super("ISO-8859-13", new String[] {
+ "ISO8859_13",
+ "8859_13",
+ "ibm-921_P100-1995",
+ "ibm-921",
+ "iso_8859_13",
+ "iso8859_13",
+ "iso-8859-13",
+ "8859_13",
+ "cp921",
+ "921"
+ });
+ lookupTable = lookup;
+ }
+
+} // class ISO_8859_13
+
Added: llvm-gcc-4.2/trunk/libjava/classpath/gnu/java/nio/charset/ISO_8859_15.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/gnu/java/nio/charset/ISO_8859_15.java?rev=43913&view=auto
==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/gnu/java/nio/charset/ISO_8859_15.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/gnu/java/nio/charset/ISO_8859_15.java Thu Nov 8 16:56:19 2007
@@ -0,0 +1,111 @@
+/* ISO_8859_15.java -- Charset for ISO-8859-15 iso latin character set.
+ Copyright (C) 2005 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 gnu.java.nio.charset;
+
+/**
+ * Encoding table for ISO-8859-15, ISO Latin-9 char set.
+ */
+public class ISO_8859_15 extends ByteCharset
+{
+
+ /**
+ * This is the lookup table for this encoding
+ */
+ private static final char[] lookup =
+ {
+ 0x0000, 0x0001, 0x0002, 0x0003, 0x0004, 0x0005, 0x0006, 0x0007,
+ 0x0008, 0x0009, 0x000A, 0x000B, 0x000C, 0x000D, 0x000E, 0x000F,
+ 0x0010, 0x0011, 0x0012, 0x0013, 0x0014, 0x0015, 0x0016, 0x0017,
+ 0x0018, 0x0019, 0x001A, 0x001B, 0x001C, 0x001D, 0x001E, 0x001F,
+ 0x0020, 0x0021, 0x0022, 0x0023, 0x0024, 0x0025, 0x0026, 0x0027,
+ 0x0028, 0x0029, 0x002A, 0x002B, 0x002C, 0x002D, 0x002E, 0x002F,
+ 0x0030, 0x0031, 0x0032, 0x0033, 0x0034, 0x0035, 0x0036, 0x0037,
+ 0x0038, 0x0039, 0x003A, 0x003B, 0x003C, 0x003D, 0x003E, 0x003F,
+ 0x0040, 0x0041, 0x0042, 0x0043, 0x0044, 0x0045, 0x0046, 0x0047,
+ 0x0048, 0x0049, 0x004A, 0x004B, 0x004C, 0x004D, 0x004E, 0x004F,
+ 0x0050, 0x0051, 0x0052, 0x0053, 0x0054, 0x0055, 0x0056, 0x0057,
+ 0x0058, 0x0059, 0x005A, 0x005B, 0x005C, 0x005D, 0x005E, 0x005F,
+ 0x0060, 0x0061, 0x0062, 0x0063, 0x0064, 0x0065, 0x0066, 0x0067,
+ 0x0068, 0x0069, 0x006A, 0x006B, 0x006C, 0x006D, 0x006E, 0x006F,
+ 0x0070, 0x0071, 0x0072, 0x0073, 0x0074, 0x0075, 0x0076, 0x0077,
+ 0x0078, 0x0079, 0x007A, 0x007B, 0x007C, 0x007D, 0x007E, 0x007F,
+ 0x0080, 0x0081, 0x0082, 0x0083, 0x0084, 0x0085, 0x0086, 0x0087,
+ 0x0088, 0x0089, 0x008A, 0x008B, 0x008C, 0x008D, 0x008E, 0x008F,
+ 0x0090, 0x0091, 0x0092, 0x0093, 0x0094, 0x0095, 0x0096, 0x0097,
+ 0x0098, 0x0099, 0x009A, 0x009B, 0x009C, 0x009D, 0x009E, 0x009F,
+ 0x00A0, 0x00A1, 0x00A2, 0x00A3, 0x20AC, 0x00A5, 0x0160, 0x00A7,
+ 0x0161, 0x00A9, 0x00AA, 0x00AB, 0x00AC, 0x00AD, 0x00AE, 0x00AF,
+ 0x00B0, 0x00B1, 0x00B2, 0x00B3, 0x017D, 0x00B5, 0x00B6, 0x00B7,
+ 0x017E, 0x00B9, 0x00BA, 0x00BB, 0x0152, 0x0153, 0x0178, 0x00BF,
+ 0x00C0, 0x00C1, 0x00C2, 0x00C3, 0x00C4, 0x00C5, 0x00C6, 0x00C7,
+ 0x00C8, 0x00C9, 0x00CA, 0x00CB, 0x00CC, 0x00CD, 0x00CE, 0x00CF,
+ 0x00D0, 0x00D1, 0x00D2, 0x00D3, 0x00D4, 0x00D5, 0x00D6, 0x00D7,
+ 0x00D8, 0x00D9, 0x00DA, 0x00DB, 0x00DC, 0x00DD, 0x00DE, 0x00DF,
+ 0x00E0, 0x00E1, 0x00E2, 0x00E3, 0x00E4, 0x00E5, 0x00E6, 0x00E7,
+ 0x00E8, 0x00E9, 0x00EA, 0x00EB, 0x00EC, 0x00ED, 0x00EE, 0x00EF,
+ 0x00F0, 0x00F1, 0x00F2, 0x00F3, 0x00F4, 0x00F5, 0x00F6, 0x00F7,
+ 0x00F8, 0x00F9, 0x00FA, 0x00FB, 0x00FC, 0x00FD, 0x00FE, 0x00FF
+ };
+
+ public ISO_8859_15()
+ {
+ super("ISO-8859-15", new String[] {
+ "8859_15",
+ "iso8859_15",
+ "iso-8859-15",
+ "8859-15",
+ "latin9",
+ "iso_8859_15",
+ "ibm-923_P100-1998",
+ "ibm-923",
+ "Latin-9",
+ "l9",
+ "latin0",
+ "csisolatin0",
+ "csisolatin9",
+ "iso8859_15_fdis",
+ "cp923",
+ "923",
+ "windows-28605"
+ });
+ lookupTable = lookup;
+ }
+
+} // class ISO_8859_15
+
Added: llvm-gcc-4.2/trunk/libjava/classpath/gnu/java/nio/charset/ISO_8859_2.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/gnu/java/nio/charset/ISO_8859_2.java?rev=43913&view=auto
==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/gnu/java/nio/charset/ISO_8859_2.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/gnu/java/nio/charset/ISO_8859_2.java Thu Nov 8 16:56:19 2007
@@ -0,0 +1,110 @@
+/* ISO_8859_2.java -- Charset for ISO-8859-2 Character set.
+ Copyright (C) 2005 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 gnu.java.nio.charset;
+
+/**
+ * Encoding table for ISO-8859-2, ISO Latin-2 char set.
+ */
+public class ISO_8859_2 extends ByteCharset
+{
+
+ /**
+ * This is the lookup table for this encoding
+ * Note: ranges 0-1F and 7f-97 aren't defined in the spec file aron used.
+ */
+ private static final char[] lookup =
+ {
+ 0x0000, 0x0001, 0x0002, 0x0003, 0x0004, 0x0005, 0x0006, 0x0007,
+ 0x0008, 0x0009, 0x000A, 0x000B, 0x000C, 0x000D, 0x000E, 0x000F,
+ 0x0010, 0x0011, 0x0012, 0x0013, 0x0014, 0x0015, 0x0016, 0x0017,
+ 0x0018, 0x0019, 0x001A, 0x001B, 0x001C, 0x001D, 0x001E, 0x001F,
+ 0x0020, 0x0021, 0x0022, 0x0023, 0x0024, 0x0025, 0x0026, 0x0027,
+ 0x0028, 0x0029, 0x002A, 0x002B, 0x002C, 0x002D, 0x002E, 0x002F,
+ 0x0030, 0x0031, 0x0032, 0x0033, 0x0034, 0x0035, 0x0036, 0x0037,
+ 0x0038, 0x0039, 0x003A, 0x003B, 0x003C, 0x003D, 0x003E, 0x003F,
+ 0x0040, 0x0041, 0x0042, 0x0043, 0x0044, 0x0045, 0x0046, 0x0047,
+ 0x0048, 0x0049, 0x004A, 0x004B, 0x004C, 0x004D, 0x004E, 0x004F,
+ 0x0050, 0x0051, 0x0052, 0x0053, 0x0054, 0x0055, 0x0056, 0x0057,
+ 0x0058, 0x0059, 0x005A, 0x005B, 0x005C, 0x005D, 0x005E, 0x005F,
+ 0x0060, 0x0061, 0x0062, 0x0063, 0x0064, 0x0065, 0x0066, 0x0067,
+ 0x0068, 0x0069, 0x006A, 0x006B, 0x006C, 0x006D, 0x006E, 0x006F,
+ 0x0070, 0x0071, 0x0072, 0x0073, 0x0074, 0x0075, 0x0076, 0x0077,
+ 0x0078, 0x0079, 0x007A, 0x007B, 0x007C, 0x007D, 0x007E, 0x007F,
+ 0x0080, 0x0081, 0x0082, 0x0083, 0x0084, 0x0085, 0x0086, 0x0087,
+ 0x0088, 0x0089, 0x008A, 0x008B, 0x008C, 0x008D, 0x008E, 0x008F,
+ 0x0090, 0x0091, 0x0092, 0x0093, 0x0094, 0x0095, 0x0096, 0x0097,
+ 0x0098, 0x0099, 0x009A, 0x009B, 0x009C, 0x009D, 0x009E, 0x009F,
+ 0x00A0, 0x0104, 0x02D8, 0x0141, 0x00A4, 0x013D, 0x015A, 0x00A7,
+ 0x00A8, 0x0160, 0x015E, 0x0164, 0x0179, 0x00AD, 0x017D, 0x017B,
+ 0x00B0, 0x0105, 0x02DB, 0x0142, 0x00B4, 0x013E, 0x015B, 0x02C7,
+ 0x00B8, 0x0161, 0x015F, 0x0165, 0x017A, 0x02DD, 0x017E, 0x017C,
+ 0x0154, 0x00C1, 0x00C2, 0x0102, 0x00C4, 0x0139, 0x0106, 0x00C7,
+ 0x010C, 0x00C9, 0x0118, 0x00CB, 0x011A, 0x00CD, 0x00CE, 0x010E,
+ 0x0110, 0x0143, 0x0147, 0x00D3, 0x00D4, 0x0150, 0x00D6, 0x00D7,
+ 0x0158, 0x016E, 0x00DA, 0x0170, 0x00DC, 0x00DD, 0x0162, 0x00DF,
+ 0x0155, 0x00E1, 0x00E2, 0x0103, 0x00E4, 0x013A, 0x0107, 0x00E7,
+ 0x010D, 0x00E9, 0x0119, 0x00EB, 0x011B, 0x00ED, 0x00EE, 0x010F,
+ 0x0111, 0x0144, 0x0148, 0x00F3, 0x00F4, 0x0151, 0x00F6, 0x00F7,
+ 0x0159, 0x016F, 0x00FA, 0x0171, 0x00FC, 0x00FD, 0x0163, 0x02D9
+ };
+
+ public ISO_8859_2()
+ {
+ super("ISO-8859-2", new String[] {
+ "ISO8859_2",
+ "8859_2",
+ "ibm-912_P100-1995",
+ "ibm-912",
+ "iso_8859_2",
+ "iso8859_2",
+ "iso-8859-2",
+ "ISO_8859-2:1987",
+ "latin2",
+ "csISOLatin2",
+ "iso-ir-101",
+ "l2",
+ "cp912",
+ "912",
+ "windows-28592"
+ });
+ lookupTable = lookup;
+ }
+
+} // class ISO_8859_2
+
Added: llvm-gcc-4.2/trunk/libjava/classpath/gnu/java/nio/charset/ISO_8859_3.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/gnu/java/nio/charset/ISO_8859_3.java?rev=43913&view=auto
==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/gnu/java/nio/charset/ISO_8859_3.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/gnu/java/nio/charset/ISO_8859_3.java Thu Nov 8 16:56:19 2007
@@ -0,0 +1,109 @@
+/* ISO_8859_3.java -- Charset for ISO-8859-3 Character set.
+ Copyright (C) 2005 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 gnu.java.nio.charset;
+
+/**
+ * Encoding table for ISO-8859-3, ISO Latin-3 char set.
+ */
+public class ISO_8859_3 extends ByteCharset
+{
+
+ /**
+ * This is the lookup table for this encoding
+ */
+ private static final char[] lookup =
+ {
+ 0x0000, 0x0001, 0x0002, 0x0003, 0x0004, 0x0005, 0x0006, 0x0007,
+ 0x0008, 0x0009, 0x000A, 0x000B, 0x000C, 0x000D, 0x000E, 0x000F,
+ 0x0010, 0x0011, 0x0012, 0x0013, 0x0014, 0x0015, 0x0016, 0x0017,
+ 0x0018, 0x0019, 0x001A, 0x001B, 0x001C, 0x001D, 0x001E, 0x001F,
+ 0x0020, 0x0021, 0x0022, 0x0023, 0x0024, 0x0025, 0x0026, 0x0027,
+ 0x0028, 0x0029, 0x002A, 0x002B, 0x002C, 0x002D, 0x002E, 0x002F,
+ 0x0030, 0x0031, 0x0032, 0x0033, 0x0034, 0x0035, 0x0036, 0x0037,
+ 0x0038, 0x0039, 0x003A, 0x003B, 0x003C, 0x003D, 0x003E, 0x003F,
+ 0x0040, 0x0041, 0x0042, 0x0043, 0x0044, 0x0045, 0x0046, 0x0047,
+ 0x0048, 0x0049, 0x004A, 0x004B, 0x004C, 0x004D, 0x004E, 0x004F,
+ 0x0050, 0x0051, 0x0052, 0x0053, 0x0054, 0x0055, 0x0056, 0x0057,
+ 0x0058, 0x0059, 0x005A, 0x005B, 0x005C, 0x005D, 0x005E, 0x005F,
+ 0x0060, 0x0061, 0x0062, 0x0063, 0x0064, 0x0065, 0x0066, 0x0067,
+ 0x0068, 0x0069, 0x006A, 0x006B, 0x006C, 0x006D, 0x006E, 0x006F,
+ 0x0070, 0x0071, 0x0072, 0x0073, 0x0074, 0x0075, 0x0076, 0x0077,
+ 0x0078, 0x0079, 0x007A, 0x007B, 0x007C, 0x007D, 0x007E, 0x007F,
+ 0x0080, 0x0081, 0x0082, 0x0083, 0x0084, 0x0085, 0x0086, 0x0087,
+ 0x0088, 0x0089, 0x008A, 0x008B, 0x008C, 0x008D, 0x008E, 0x008F,
+ 0x0090, 0x0091, 0x0092, 0x0093, 0x0094, 0x0095, 0x0096, 0x0097,
+ 0x0098, 0x0099, 0x009A, 0x009B, 0x009C, 0x009D, 0x009E, 0x009F,
+ 0x00A0, 0x0126, 0x02D8, 0x00A3, 0x00A4, NONE, 0x0124, 0x00A7,
+ 0x00A8, 0x0130, 0x015E, 0x011E, 0x0134, 0x00AD, NONE, 0x017B,
+ 0x00B0, 0x0127, 0x00B2, 0x00B3, 0x00B4, 0x00B5, 0x0125, 0x00B7,
+ 0x00B8, 0x0131, 0x015F, 0x011F, 0x0135, 0x00BD, NONE, 0x017C,
+ 0x00C0, 0x00C1, 0x00C2, NONE, 0x00C4, 0x010A, 0x0108, 0x00C7,
+ 0x00C8, 0x00C9, 0x00CA, 0x00CB, 0x00CC, 0x00CD, 0x00CE, 0x00CF,
+ NONE, 0x00D1, 0x00D2, 0x00D3, 0x00D4, 0x0120, 0x00D6, 0x00D7,
+ 0x011C, 0x00D9, 0x00DA, 0x00DB, 0x00DC, 0x016C, 0x015C, 0x00DF,
+ 0x00E0, 0x00E1, 0x00E2, NONE, 0x00E4, 0x010B, 0x0109, 0x00E7,
+ 0x00E8, 0x00E9, 0x00EA, 0x00EB, 0x00EC, 0x00ED, 0x00EE, 0x00EF,
+ NONE, 0x00F1, 0x00F2, 0x00F3, 0x00F4, 0x0121, 0x00F6, 0x00F7,
+ 0x011D, 0x00F9, 0x00FA, 0x00FB, 0x00FC, 0x016D, 0x015D, 0x02D9
+ };
+
+ public ISO_8859_3()
+ {
+ super("ISO-8859-3", new String[] {
+ "ISO8859_3",
+ "8859_3",
+ "ibm-913_P100-2000",
+ "ibm-913",
+ "iso_8859_3",
+ "iso8859_3",
+ "iso-8859-3",
+ "ISO_8859-3:1988",
+ "latin3",
+ "csISOLatin3",
+ "iso-ir-109",
+ "l3",
+ "cp913",
+ "913",
+ "windows-28593"
+ });
+ lookupTable = lookup;
+ }
+
+} // class ISO_8859_3
+
Added: llvm-gcc-4.2/trunk/libjava/classpath/gnu/java/nio/charset/ISO_8859_4.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/gnu/java/nio/charset/ISO_8859_4.java?rev=43913&view=auto
==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/gnu/java/nio/charset/ISO_8859_4.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/gnu/java/nio/charset/ISO_8859_4.java Thu Nov 8 16:56:19 2007
@@ -0,0 +1,110 @@
+/* ISO_8859_4.java -- Charset for ISO-8859-4 Character set.
+ Copyright (C) 2005 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 gnu.java.nio.charset;
+
+/**
+ * Encoding table for ISO-8859-4, ISO Latin-4 char set.
+ */
+public class ISO_8859_4 extends ByteCharset
+{
+
+ /**
+ * This is the lookup table for this encoding
+ * Note: ranges 0-1F and 7f-9f aren't defined in the spec file aron used.
+ */
+ private static final char[] lookup =
+ {
+ 0x0000, 0x0001, 0x0002, 0x0003, 0x0004, 0x0005, 0x0006, 0x0007,
+ 0x0008, 0x0009, 0x000A, 0x000B, 0x000C, 0x000D, 0x000E, 0x000F,
+ 0x0010, 0x0011, 0x0012, 0x0013, 0x0014, 0x0015, 0x0016, 0x0017,
+ 0x0018, 0x0019, 0x001A, 0x001B, 0x001C, 0x001D, 0x001E, 0x001F,
+ 0x0020, 0x0021, 0x0022, 0x0023, 0x0024, 0x0025, 0x0026, 0x0027,
+ 0x0028, 0x0029, 0x002A, 0x002B, 0x002C, 0x002D, 0x002E, 0x002F,
+ 0x0030, 0x0031, 0x0032, 0x0033, 0x0034, 0x0035, 0x0036, 0x0037,
+ 0x0038, 0x0039, 0x003A, 0x003B, 0x003C, 0x003D, 0x003E, 0x003F,
+ 0x0040, 0x0041, 0x0042, 0x0043, 0x0044, 0x0045, 0x0046, 0x0047,
+ 0x0048, 0x0049, 0x004A, 0x004B, 0x004C, 0x004D, 0x004E, 0x004F,
+ 0x0050, 0x0051, 0x0052, 0x0053, 0x0054, 0x0055, 0x0056, 0x0057,
+ 0x0058, 0x0059, 0x005A, 0x005B, 0x005C, 0x005D, 0x005E, 0x005F,
+ 0x0060, 0x0061, 0x0062, 0x0063, 0x0064, 0x0065, 0x0066, 0x0067,
+ 0x0068, 0x0069, 0x006A, 0x006B, 0x006C, 0x006D, 0x006E, 0x006F,
+ 0x0070, 0x0071, 0x0072, 0x0073, 0x0074, 0x0075, 0x0076, 0x0077,
+ 0x0078, 0x0079, 0x007A, 0x007B, 0x007C, 0x007D, 0x007E, 0x007F,
+ 0x0080, 0x0081, 0x0082, 0x0083, 0x0084, 0x0085, 0x0086, 0x0087,
+ 0x0088, 0x0089, 0x008A, 0x008B, 0x008C, 0x008D, 0x008E, 0x008F,
+ 0x0090, 0x0091, 0x0092, 0x0093, 0x0094, 0x0095, 0x0096, 0x0097,
+ 0x0098, 0x0099, 0x009A, 0x009B, 0x009C, 0x009D, 0x009E, 0x009F,
+ 0x00A0, 0x0104, 0x0138, 0x0156, 0x00A4, 0x0128, 0x013B, 0x00A7,
+ 0x00A8, 0x0160, 0x0112, 0x0122, 0x0166, 0x00AD, 0x017D, 0x00AF,
+ 0x00B0, 0x0105, 0x02DB, 0x0157, 0x00B4, 0x0129, 0x013C, 0x02C7,
+ 0x00B8, 0x0161, 0x0113, 0x0123, 0x0167, 0x014A, 0x017E, 0x014B,
+ 0x0100, 0x00C1, 0x00C2, 0x00C3, 0x00C4, 0x00C5, 0x00C6, 0x012E,
+ 0x010C, 0x00C9, 0x0118, 0x00CB, 0x0116, 0x00CD, 0x00CE, 0x012A,
+ 0x0110, 0x0145, 0x014C, 0x0136, 0x00D4, 0x00D5, 0x00D6, 0x00D7,
+ 0x00D8, 0x0172, 0x00DA, 0x00DB, 0x00DC, 0x0168, 0x016A, 0x00DF,
+ 0x0101, 0x00E1, 0x00E2, 0x00E3, 0x00E4, 0x00E5, 0x00E6, 0x012F,
+ 0x010D, 0x00E9, 0x0119, 0x00EB, 0x0117, 0x00ED, 0x00EE, 0x012B,
+ 0x0111, 0x0146, 0x014D, 0x0137, 0x00F4, 0x00F5, 0x00F6, 0x00F7,
+ 0x00F8, 0x0173, 0x00FA, 0x00FB, 0x00FC, 0x0169, 0x016B, 0x02D9
+ };
+
+ public ISO_8859_4()
+ {
+ super("ISO-8859-4", new String[] {
+ "ISO8859_4",
+ "8859_4",
+ "ibm-914_P100-1995",
+ "ibm-914",
+ "iso_8859_4",
+ "iso8859_4",
+ "iso-8859-4",
+ "latin4",
+ "csISOLatin4",
+ "iso-ir-110",
+ "ISO_8859-4:1988",
+ "l4",
+ "cp914",
+ "914",
+ "windows-28594"
+ });
+ lookupTable = lookup;
+ }
+
+} // class ISO_8859_4
+
Added: llvm-gcc-4.2/trunk/libjava/classpath/gnu/java/nio/charset/ISO_8859_5.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/gnu/java/nio/charset/ISO_8859_5.java?rev=43913&view=auto
==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/gnu/java/nio/charset/ISO_8859_5.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/gnu/java/nio/charset/ISO_8859_5.java Thu Nov 8 16:56:19 2007
@@ -0,0 +1,108 @@
+/* ISO_8859_5.java -- Charset for ISO-8859-5 cyrillic character set.
+ Copyright (C) 2005 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 gnu.java.nio.charset;
+
+/**
+ * Encoding table for ISO-8859-5, ISO cyrillic char set.
+ */
+public class ISO_8859_5 extends ByteCharset
+{
+
+ /**
+ * This is the lookup table for this encoding
+ */
+ private static final char[] lookup =
+ {
+ 0x0000, 0x0001, 0x0002, 0x0003, 0x0004, 0x0005, 0x0006, 0x0007,
+ 0x0008, 0x0009, 0x000A, 0x000B, 0x000C, 0x000D, 0x000E, 0x000F,
+ 0x0010, 0x0011, 0x0012, 0x0013, 0x0014, 0x0015, 0x0016, 0x0017,
+ 0x0018, 0x0019, 0x001A, 0x001B, 0x001C, 0x001D, 0x001E, 0x001F,
+ 0x0020, 0x0021, 0x0022, 0x0023, 0x0024, 0x0025, 0x0026, 0x0027,
+ 0x0028, 0x0029, 0x002A, 0x002B, 0x002C, 0x002D, 0x002E, 0x002F,
+ 0x0030, 0x0031, 0x0032, 0x0033, 0x0034, 0x0035, 0x0036, 0x0037,
+ 0x0038, 0x0039, 0x003A, 0x003B, 0x003C, 0x003D, 0x003E, 0x003F,
+ 0x0040, 0x0041, 0x0042, 0x0043, 0x0044, 0x0045, 0x0046, 0x0047,
+ 0x0048, 0x0049, 0x004A, 0x004B, 0x004C, 0x004D, 0x004E, 0x004F,
+ 0x0050, 0x0051, 0x0052, 0x0053, 0x0054, 0x0055, 0x0056, 0x0057,
+ 0x0058, 0x0059, 0x005A, 0x005B, 0x005C, 0x005D, 0x005E, 0x005F,
+ 0x0060, 0x0061, 0x0062, 0x0063, 0x0064, 0x0065, 0x0066, 0x0067,
+ 0x0068, 0x0069, 0x006A, 0x006B, 0x006C, 0x006D, 0x006E, 0x006F,
+ 0x0070, 0x0071, 0x0072, 0x0073, 0x0074, 0x0075, 0x0076, 0x0077,
+ 0x0078, 0x0079, 0x007A, 0x007B, 0x007C, 0x007D, 0x007E, 0x007F,
+ 0x0080, 0x0081, 0x0082, 0x0083, 0x0084, 0x0085, 0x0086, 0x0087,
+ 0x0088, 0x0089, 0x008A, 0x008B, 0x008C, 0x008D, 0x008E, 0x008F,
+ 0x0090, 0x0091, 0x0092, 0x0093, 0x0094, 0x0095, 0x0096, 0x0097,
+ 0x0098, 0x0099, 0x009A, 0x009B, 0x009C, 0x009D, 0x009E, 0x009F,
+ 0x00A0, 0x0401, 0x0402, 0x0403, 0x0404, 0x0405, 0x0406, 0x0407,
+ 0x0408, 0x0409, 0x040A, 0x040B, 0x040C, 0x00AD, 0x040E, 0x040F,
+ 0x0410, 0x0411, 0x0412, 0x0413, 0x0414, 0x0415, 0x0416, 0x0417,
+ 0x0418, 0x0419, 0x041A, 0x041B, 0x041C, 0x041D, 0x041E, 0x041F,
+ 0x0420, 0x0421, 0x0422, 0x0423, 0x0424, 0x0425, 0x0426, 0x0427,
+ 0x0428, 0x0429, 0x042A, 0x042B, 0x042C, 0x042D, 0x042E, 0x042F,
+ 0x0430, 0x0431, 0x0432, 0x0433, 0x0434, 0x0435, 0x0436, 0x0437,
+ 0x0438, 0x0439, 0x043A, 0x043B, 0x043C, 0x043D, 0x043E, 0x043F,
+ 0x0440, 0x0441, 0x0442, 0x0443, 0x0444, 0x0445, 0x0446, 0x0447,
+ 0x0448, 0x0449, 0x044A, 0x044B, 0x044C, 0x044D, 0x044E, 0x044F,
+ 0x2116, 0x0451, 0x0452, 0x0453, 0x0454, 0x0455, 0x0456, 0x0457,
+ 0x0458, 0x0459, 0x045A, 0x045B, 0x045C, 0x00A7, 0x045E, 0x045F
+ };
+
+ public ISO_8859_5()
+ {
+ super("ISO-8859-5", new String[] {
+ "ISO8859_5",
+ "8859_5",
+ "ibm-915_P100-1995",
+ "ibm-915",
+ "iso_8859_5",
+ "iso8859_5",
+ "iso-8859-5",
+ "cyrillic",
+ "csISOLatinCyrillic",
+ "iso-ir-144",
+ "ISO_8859-5:1988",
+ "cp915",
+ "915",
+ "windows-28595"
+ });
+ lookupTable = lookup;
+ }
+
+} // class ISO_8859_5
+
Added: llvm-gcc-4.2/trunk/libjava/classpath/gnu/java/nio/charset/ISO_8859_6.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/gnu/java/nio/charset/ISO_8859_6.java?rev=43913&view=auto
==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/gnu/java/nio/charset/ISO_8859_6.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/gnu/java/nio/charset/ISO_8859_6.java Thu Nov 8 16:56:19 2007
@@ -0,0 +1,112 @@
+/* ISO_8859_6.java -- Charset for ISO-8859-6 iso Arabic character set.
+ Copyright (C) 2005 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 gnu.java.nio.charset;
+
+/**
+ * Encoding table for ISO-8859-6, ISO Arabic char set.
+ */
+public class ISO_8859_6 extends ByteCharset
+{
+
+ /**
+ * This is the lookup table for this encoding
+ */
+ private static final char[] lookup =
+ {
+ 0x0000, 0x0001, 0x0002, 0x0003, 0x0004, 0x0005, 0x0006, 0x0007,
+ 0x0008, 0x0009, 0x000A, 0x000B, 0x000C, 0x000D, 0x000E, 0x000F,
+ 0x0010, 0x0011, 0x0012, 0x0013, 0x0014, 0x0015, 0x0016, 0x0017,
+ 0x0018, 0x0019, 0x001A, 0x001B, 0x001C, 0x001D, 0x001E, 0x001F,
+ 0x0020, 0x0021, 0x0022, 0x0023, 0x0024, 0x0025, 0x0026, 0x0027,
+ 0x0028, 0x0029, 0x002A, 0x002B, 0x002C, 0x002D, 0x002E, 0x002F,
+ 0x0030, 0x0031, 0x0032, 0x0033, 0x0034, 0x0035, 0x0036, 0x0037,
+ 0x0038, 0x0039, 0x003A, 0x003B, 0x003C, 0x003D, 0x003E, 0x003F,
+ 0x0040, 0x0041, 0x0042, 0x0043, 0x0044, 0x0045, 0x0046, 0x0047,
+ 0x0048, 0x0049, 0x004A, 0x004B, 0x004C, 0x004D, 0x004E, 0x004F,
+ 0x0050, 0x0051, 0x0052, 0x0053, 0x0054, 0x0055, 0x0056, 0x0057,
+ 0x0058, 0x0059, 0x005A, 0x005B, 0x005C, 0x005D, 0x005E, 0x005F,
+ 0x0060, 0x0061, 0x0062, 0x0063, 0x0064, 0x0065, 0x0066, 0x0067,
+ 0x0068, 0x0069, 0x006A, 0x006B, 0x006C, 0x006D, 0x006E, 0x006F,
+ 0x0070, 0x0071, 0x0072, 0x0073, 0x0074, 0x0075, 0x0076, 0x0077,
+ 0x0078, 0x0079, 0x007A, 0x007B, 0x007C, 0x007D, 0x007E, 0x007F,
+ 0x0080, 0x0081, 0x0082, 0x0083, 0x0084, 0x0085, 0x0086, 0x0087,
+ 0x0088, 0x0089, 0x008A, 0x008B, 0x008C, 0x008D, 0x008E, 0x008F,
+ 0x0090, 0x0091, 0x0092, 0x0093, 0x0094, 0x0095, 0x0096, 0x0097,
+ 0x0098, 0x0099, 0x009A, 0x009B, 0x009C, 0x009D, 0x009E, 0x009F,
+ 0x00A0, NONE, NONE, NONE, 0x00A4, NONE, NONE, NONE,
+ NONE, NONE, NONE, NONE, 0x060C, 0x00AD, NONE, NONE,
+ NONE, NONE, NONE, NONE, NONE, NONE, NONE, NONE,
+ NONE, NONE, NONE, 0x061B, NONE, NONE, NONE, 0x061F,
+ NONE, 0x0621, 0x0622, 0x0623, 0x0624, 0x0625, 0x0626, 0x0627,
+ 0x0628, 0x0629, 0x062A, 0x062B, 0x062C, 0x062D, 0x062E, 0x062F,
+ 0x0630, 0x0631, 0x0632, 0x0633, 0x0634, 0x0635, 0x0636, 0x0637,
+ 0x0638, 0x0639, 0x063A, NONE, NONE, NONE, NONE, NONE,
+ 0x0640, 0x0641, 0x0642, 0x0643, 0x0644, 0x0645, 0x0646, 0x0647,
+ 0x0648, 0x0649, 0x064A, 0x064B, 0x064C, 0x064D, 0x064E, 0x064F,
+ 0x0650, 0x0651, 0x0652, NONE, NONE, NONE, NONE, NONE,
+ NONE, NONE, NONE, NONE, NONE, NONE, NONE, NONE
+ };
+
+ public ISO_8859_6()
+ {
+ super("ISO-8859-6", new String[] {
+ "8859_6",
+ "ibm-1089_P100-1995",
+ "ibm-1089",
+ "iso_8859_6",
+ "iso8859_6",
+ "iso-8859-6",
+ "arabic",
+ "csISOLatinArabic",
+ "iso-ir-127",
+ "ISO_8859-6:1987",
+ "ECMA-114",
+ "ASMO-708",
+ "8859_6",
+ "cp1089",
+ "1089",
+ "windows-28596",
+ "ISO-8859-6-I",
+ "ISO-8859-6-E"
+ });
+ lookupTable = lookup;
+ }
+
+} // class ISO_8859_6
+
Added: llvm-gcc-4.2/trunk/libjava/classpath/gnu/java/nio/charset/ISO_8859_7.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/gnu/java/nio/charset/ISO_8859_7.java?rev=43913&view=auto
==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/gnu/java/nio/charset/ISO_8859_7.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/gnu/java/nio/charset/ISO_8859_7.java Thu Nov 8 16:56:19 2007
@@ -0,0 +1,111 @@
+/* ISO_8859_7.java -- Charset for ISO-8859-7 Character set.
+ Copyright (C) 2005 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 gnu.java.nio.charset;
+
+/**
+ * Encoding table for ISO-8859-7, ISO Latin/Greek char set.
+ */
+public class ISO_8859_7 extends ByteCharset
+{
+
+ /**
+ * This is the lookup table for this encoding
+ */
+ private static final char[] lookup =
+ {
+ 0x0000, 0x0001, 0x0002, 0x0003, 0x0004, 0x0005, 0x0006, 0x0007,
+ 0x0008, 0x0009, 0x000A, 0x000B, 0x000C, 0x000D, 0x000E, 0x000F,
+ 0x0010, 0x0011, 0x0012, 0x0013, 0x0014, 0x0015, 0x0016, 0x0017,
+ 0x0018, 0x0019, 0x001A, 0x001B, 0x001C, 0x001D, 0x001E, 0x001F,
+ 0x0020, 0x0021, 0x0022, 0x0023, 0x0024, 0x0025, 0x0026, 0x0027,
+ 0x0028, 0x0029, 0x002A, 0x002B, 0x002C, 0x002D, 0x002E, 0x002F,
+ 0x0030, 0x0031, 0x0032, 0x0033, 0x0034, 0x0035, 0x0036, 0x0037,
+ 0x0038, 0x0039, 0x003A, 0x003B, 0x003C, 0x003D, 0x003E, 0x003F,
+ 0x0040, 0x0041, 0x0042, 0x0043, 0x0044, 0x0045, 0x0046, 0x0047,
+ 0x0048, 0x0049, 0x004A, 0x004B, 0x004C, 0x004D, 0x004E, 0x004F,
+ 0x0050, 0x0051, 0x0052, 0x0053, 0x0054, 0x0055, 0x0056, 0x0057,
+ 0x0058, 0x0059, 0x005A, 0x005B, 0x005C, 0x005D, 0x005E, 0x005F,
+ 0x0060, 0x0061, 0x0062, 0x0063, 0x0064, 0x0065, 0x0066, 0x0067,
+ 0x0068, 0x0069, 0x006A, 0x006B, 0x006C, 0x006D, 0x006E, 0x006F,
+ 0x0070, 0x0071, 0x0072, 0x0073, 0x0074, 0x0075, 0x0076, 0x0077,
+ 0x0078, 0x0079, 0x007A, 0x007B, 0x007C, 0x007D, 0x007E, 0x007F,
+ 0x0080, 0x0081, 0x0082, 0x0083, 0x0084, 0x0085, 0x0086, 0x0087,
+ 0x0088, 0x0089, 0x008A, 0x008B, 0x008C, 0x008D, 0x008E, 0x008F,
+ 0x0090, 0x0091, 0x0092, 0x0093, 0x0094, 0x0095, 0x0096, 0x0097,
+ 0x0098, 0x0099, 0x009A, 0x009B, 0x009C, 0x009D, 0x009E, 0x009F,
+ 0x00A0, 0x02BD, 0x02BC, 0x00A3, NONE, NONE, 0x00A6, 0x00A7,
+ 0x00A8, 0x00A9, NONE, 0x00AB, 0x00AC, 0x00AD, NONE, 0x2015,
+ 0x00B0, 0x00B1, 0x00B2, 0x00B3, 0x0384, 0x0385, 0x0386, 0x00B7,
+ 0x0388, 0x0389, 0x038A, 0x00BB, 0x038C, 0x00BD, 0x038E, 0x038F,
+ 0x0390, 0x0391, 0x0392, 0x0393, 0x0394, 0x0395, 0x0396, 0x0397,
+ 0x0398, 0x0399, 0x039A, 0x039B, 0x039C, 0x039D, 0x039E, 0x039F,
+ 0x03A0, 0x03A1, NONE, 0x03A3, 0x03A4, 0x03A5, 0x03A6, 0x03A7,
+ 0x03A8, 0x03A9, 0x03AA, 0x03AB, 0x03AC, 0x03AD, 0x03AE, 0x03AF,
+ 0x03B0, 0x03B1, 0x03B2, 0x03B3, 0x03B4, 0x03B5, 0x03B6, 0x03B7,
+ 0x03B8, 0x03B9, 0x03BA, 0x03BB, 0x03BC, 0x03BD, 0x03BE, 0x03BF,
+ 0x03C0, 0x03C1, 0x03C2, 0x03C3, 0x03C4, 0x03C5, 0x03C6, 0x03C7,
+ 0x03C8, 0x03C9, 0x03CA, 0x03CB, 0x03CC, 0x03CD, 0x03CE, NONE
+ };
+
+ public ISO_8859_7()
+ {
+ super("ISO-8859-7", new String[] {
+ "ISO8859_7",
+ "8859_7",
+ "ibm-813_P100-1995",
+ "ibm-813",
+ "iso_8859_7",
+ "iso8859_7",
+ "iso-8859-7",
+ "greek",
+ "greek8",
+ "ELOT_928",
+ "ECMA-118",
+ "csISOLatinGreek",
+ "iso-ir-126",
+ "ISO_8859-7:1987",
+ "cp813",
+ "813",
+ "windows-28597"
+ });
+ lookupTable = lookup;
+ }
+
+} // class ISO_8859_7
+
Added: llvm-gcc-4.2/trunk/libjava/classpath/gnu/java/nio/charset/ISO_8859_8.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/gnu/java/nio/charset/ISO_8859_8.java?rev=43913&view=auto
==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/gnu/java/nio/charset/ISO_8859_8.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/gnu/java/nio/charset/ISO_8859_8.java Thu Nov 8 16:56:19 2007
@@ -0,0 +1,110 @@
+/* ISO_8859_8.java -- Charset for ISO-8859-8 iso Hebrew character set.
+ Copyright (C) 2005 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 gnu.java.nio.charset;
+
+/**
+ * Encoding table for ISO-8859-8, ISO Latin/Hebrew char set.
+ */
+public class ISO_8859_8 extends ByteCharset
+{
+
+ /**
+ * This is the lookup table for this encoding
+ */
+ private static final char[] lookup =
+ {
+ 0x0000, 0x0001, 0x0002, 0x0003, 0x0004, 0x0005, 0x0006, 0x0007,
+ 0x0008, 0x0009, 0x000A, 0x000B, 0x000C, 0x000D, 0x000E, 0x000F,
+ 0x0010, 0x0011, 0x0012, 0x0013, 0x0014, 0x0015, 0x0016, 0x0017,
+ 0x0018, 0x0019, 0x001A, 0x001B, 0x001C, 0x001D, 0x001E, 0x001F,
+ 0x0020, 0x0021, 0x0022, 0x0023, 0x0024, 0x0025, 0x0026, 0x0027,
+ 0x0028, 0x0029, 0x002A, 0x002B, 0x002C, 0x002D, 0x002E, 0x002F,
+ 0x0030, 0x0031, 0x0032, 0x0033, 0x0034, 0x0035, 0x0036, 0x0037,
+ 0x0038, 0x0039, 0x003A, 0x003B, 0x003C, 0x003D, 0x003E, 0x003F,
+ 0x0040, 0x0041, 0x0042, 0x0043, 0x0044, 0x0045, 0x0046, 0x0047,
+ 0x0048, 0x0049, 0x004A, 0x004B, 0x004C, 0x004D, 0x004E, 0x004F,
+ 0x0050, 0x0051, 0x0052, 0x0053, 0x0054, 0x0055, 0x0056, 0x0057,
+ 0x0058, 0x0059, 0x005A, 0x005B, 0x005C, 0x005D, 0x005E, 0x005F,
+ 0x0060, 0x0061, 0x0062, 0x0063, 0x0064, 0x0065, 0x0066, 0x0067,
+ 0x0068, 0x0069, 0x006A, 0x006B, 0x006C, 0x006D, 0x006E, 0x006F,
+ 0x0070, 0x0071, 0x0072, 0x0073, 0x0074, 0x0075, 0x0076, 0x0077,
+ 0x0078, 0x0079, 0x007A, 0x007B, 0x007C, 0x007D, 0x007E, 0x007F,
+ 0x0080, 0x0081, 0x0082, 0x0083, 0x0084, 0x0085, 0x0086, 0x0087,
+ 0x0088, 0x0089, 0x008A, 0x008B, 0x008C, 0x008D, 0x008E, 0x008F,
+ 0x0090, 0x0091, 0x0092, 0x0093, 0x0094, 0x0095, 0x0096, 0x0097,
+ 0x0098, 0x0099, 0x009A, 0x009B, 0x009C, 0x009D, 0x009E, 0x009F,
+ 0x00A0, NONE, 0x00A2, 0x00A3, 0x00A4, 0x00A5, 0x00A6, 0x00A7,
+ 0x00A8, 0x00A9, 0x00D7, 0x00AB, 0x00AC, 0x00AD, 0x00AE, 0x203E,
+ 0x00B0, 0x00B1, 0x00B2, 0x00B3, 0x00B4, 0x00B5, 0x00B6, 0x00B7,
+ 0x00B8, 0x00B9, 0x00F7, 0x00BB, 0x00BC, 0x00BD, 0x00BE, NONE,
+ NONE, NONE, NONE, NONE, NONE, NONE, NONE, NONE,
+ NONE, NONE, NONE, NONE, NONE, NONE, NONE, NONE,
+ NONE, NONE, NONE, NONE, NONE, NONE, NONE, NONE,
+ NONE, NONE, NONE, NONE, NONE, NONE, NONE, 0x2017,
+ 0x05D0, 0x05D1, 0x05D2, 0x05D3, 0x05D4, 0x05D5, 0x05D6, 0x05D7,
+ 0x05D8, 0x05D9, 0x05DA, 0x05DB, 0x05DC, 0x05DD, 0x05DE, 0x05DF,
+ 0x05E0, 0x05E1, 0x05E2, 0x05E3, 0x05E4, 0x05E5, 0x05E6, 0x05E7,
+ 0x05E8, 0x05E9, 0x05EA, NONE, NONE, NONE, NONE, NONE
+ };
+
+ public ISO_8859_8()
+ {
+ super("ISO-8859-8", new String[] {
+ "ISO8859_8",
+ "8859_8",
+ "ibm-916_P100-1995",
+ "ibm-916",
+ "iso_8859_8",
+ "iso8859_8",
+ "iso-8859-8",
+ "hebrew",
+ "csISOLatinHebrew",
+ "iso-ir-138",
+ "ISO_8859-8:1988",
+ "ISO-8859-8-I",
+ "ISO-8859-8-E",
+ "cp916",
+ "916",
+ "windows-28598"
+ });
+ lookupTable = lookup;
+ }
+
+} // class ISO_8859_8
+
Added: llvm-gcc-4.2/trunk/libjava/classpath/gnu/java/nio/charset/ISO_8859_9.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/gnu/java/nio/charset/ISO_8859_9.java?rev=43913&view=auto
==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/gnu/java/nio/charset/ISO_8859_9.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/gnu/java/nio/charset/ISO_8859_9.java Thu Nov 8 16:56:19 2007
@@ -0,0 +1,110 @@
+/* ISO_8859_9.java -- Charset for ISO-8859-9 iso latin character set.
+ Copyright (C) 2005 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 gnu.java.nio.charset;
+
+/**
+ * Encoding table for ISO-8859-9, ISO Latin-5 char set.
+ */
+public class ISO_8859_9 extends ByteCharset
+{
+
+ /**
+ * This is the lookup table for this encoding
+ */
+ private static final char[] lookup =
+ {
+ 0x0000, 0x0001, 0x0002, 0x0003, 0x0004, 0x0005, 0x0006, 0x0007,
+ 0x0008, 0x0009, 0x000A, 0x000B, 0x000C, 0x000D, 0x000E, 0x000F,
+ 0x0010, 0x0011, 0x0012, 0x0013, 0x0014, 0x0015, 0x0016, 0x0017,
+ 0x0018, 0x0019, 0x001A, 0x001B, 0x001C, 0x001D, 0x001E, 0x001F,
+ 0x0020, 0x0021, 0x0022, 0x0023, 0x0024, 0x0025, 0x0026, 0x0027,
+ 0x0028, 0x0029, 0x002A, 0x002B, 0x002C, 0x002D, 0x002E, 0x002F,
+ 0x0030, 0x0031, 0x0032, 0x0033, 0x0034, 0x0035, 0x0036, 0x0037,
+ 0x0038, 0x0039, 0x003A, 0x003B, 0x003C, 0x003D, 0x003E, 0x003F,
+ 0x0040, 0x0041, 0x0042, 0x0043, 0x0044, 0x0045, 0x0046, 0x0047,
+ 0x0048, 0x0049, 0x004A, 0x004B, 0x004C, 0x004D, 0x004E, 0x004F,
+ 0x0050, 0x0051, 0x0052, 0x0053, 0x0054, 0x0055, 0x0056, 0x0057,
+ 0x0058, 0x0059, 0x005A, 0x005B, 0x005C, 0x005D, 0x005E, 0x005F,
+ 0x0060, 0x0061, 0x0062, 0x0063, 0x0064, 0x0065, 0x0066, 0x0067,
+ 0x0068, 0x0069, 0x006A, 0x006B, 0x006C, 0x006D, 0x006E, 0x006F,
+ 0x0070, 0x0071, 0x0072, 0x0073, 0x0074, 0x0075, 0x0076, 0x0077,
+ 0x0078, 0x0079, 0x007A, 0x007B, 0x007C, 0x007D, 0x007E, 0x007F,
+ 0x0080, 0x0081, 0x0082, 0x0083, 0x0084, 0x0085, 0x0086, 0x0087,
+ 0x0088, 0x0089, 0x008A, 0x008B, 0x008C, 0x008D, 0x008E, 0x008F,
+ 0x0090, 0x0091, 0x0092, 0x0093, 0x0094, 0x0095, 0x0096, 0x0097,
+ 0x0098, 0x0099, 0x009A, 0x009B, 0x009C, 0x009D, 0x009E, 0x009F,
+ 0x00A0, 0x00A1, 0x00A2, 0x00A3, 0x00A4, 0x00A5, 0x00A6, 0x00A7,
+ 0x00A8, 0x00A9, 0x00AA, 0x00AB, 0x00AC, 0x00AD, 0x00AE, 0x00AF,
+ 0x00B0, 0x00B1, 0x00B2, 0x00B3, 0x00B4, 0x00B5, 0x00B6, 0x00B7,
+ 0x00B8, 0x00B9, 0x00BA, 0x00BB, 0x00BC, 0x00BD, 0x00BE, 0x00BF,
+ 0x00C0, 0x00C1, 0x00C2, 0x00C3, 0x00C4, 0x00C5, 0x00C6, 0x00C7,
+ 0x00C8, 0x00C9, 0x00CA, 0x00CB, 0x00CC, 0x00CD, 0x00CE, 0x00CF,
+ 0x011E, 0x00D1, 0x00D2, 0x00D3, 0x00D4, 0x00D5, 0x00D6, 0x00D7,
+ 0x00D8, 0x00D9, 0x00DA, 0x00DB, 0x00DC, 0x0130, 0x015E, 0x00DF,
+ 0x00E0, 0x00E1, 0x00E2, 0x00E3, 0x00E4, 0x00E5, 0x00E6, 0x00E7,
+ 0x00E8, 0x00E9, 0x00EA, 0x00EB, 0x00EC, 0x00ED, 0x00EE, 0x00EF,
+ 0x011F, 0x00F1, 0x00F2, 0x00F3, 0x00F4, 0x00F5, 0x00F6, 0x00F7,
+ 0x00F8, 0x00F9, 0x00FA, 0x00FB, 0x00FC, 0x0131, 0x015F, 0x00FF
+ };
+
+ public ISO_8859_9()
+ {
+ super("ISO-8859-9", new String[] {
+ "ISO8859_9",
+ "8859_9",
+ "ibm-920_P100-1995",
+ "ibm-920",
+ "iso8859_9",
+ "iso-8859-9",
+ "iso_8859_9",
+ "latin5",
+ "csISOLatin5",
+ "iso-ir-148",
+ "ISO_8859-9:1989",
+ "l5",
+ "cp920",
+ "920",
+ "windows-28599",
+ "ECMA-128"
+ });
+ lookupTable = lookup;
+ }
+
+} // class ISO_8859_9
+
Added: llvm-gcc-4.2/trunk/libjava/classpath/gnu/java/nio/charset/KOI_8.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/gnu/java/nio/charset/KOI_8.java?rev=43913&view=auto
==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/gnu/java/nio/charset/KOI_8.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/gnu/java/nio/charset/KOI_8.java Thu Nov 8 16:56:19 2007
@@ -0,0 +1,102 @@
+/* KOI_8.java -- Charset for KOI-8 cyrillic character set.
+ Copyright (C) 2005 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 gnu.java.nio.charset;
+
+/**
+ * Encoding table for the KOI8 cyrillic char set.
+ */
+public class KOI_8 extends ByteCharset
+{
+
+ /**
+ * This is the lookup table for this encoding
+ */
+ private static final char[] lookup =
+ {
+ 0x0000, 0x0001, 0x0002, 0x0003, 0x0004, 0x0005, 0x0006, 0x0007,
+ 0x0008, 0x0009, 0x000A, 0x000B, 0x000C, 0x000D, 0x000E, 0x000F,
+ 0x0010, 0x0011, 0x0012, 0x0013, 0x0014, 0x0015, 0x0016, 0x0017,
+ 0x0018, 0x0019, 0x001A, 0x001B, 0x001C, 0x001D, 0x001E, 0x001F,
+ 0x0020, 0x0021, 0x0022, 0x0023, 0x0024, 0x0025, 0x0026, 0x0027,
+ 0x0028, 0x0029, 0x002A, 0x002B, 0x002C, 0x002D, 0x002E, 0x002F,
+ 0x0030, 0x0031, 0x0032, 0x0033, 0x0034, 0x0035, 0x0036, 0x0037,
+ 0x0038, 0x0039, 0x003A, 0x003B, 0x003C, 0x003D, 0x003E, 0x003F,
+ 0x0040, 0x0041, 0x0042, 0x0043, 0x0044, 0x0045, 0x0046, 0x0047,
+ 0x0048, 0x0049, 0x004A, 0x004B, 0x004C, 0x004D, 0x004E, 0x004F,
+ 0x0050, 0x0051, 0x0052, 0x0053, 0x0054, 0x0055, 0x0056, 0x0057,
+ 0x0058, 0x0059, 0x005A, 0x005B, 0x005C, 0x005D, 0x005E, 0x005F,
+ 0x0060, 0x0061, 0x0062, 0x0063, 0x0064, 0x0065, 0x0066, 0x0067,
+ 0x0068, 0x0069, 0x006A, 0x006B, 0x006C, 0x006D, 0x006E, 0x006F,
+ 0x0070, 0x0071, 0x0072, 0x0073, 0x0074, 0x0075, 0x0076, 0x0077,
+ 0x0078, 0x0079, 0x007A, 0x007B, 0x007C, 0x007D, 0x007E, 0x007F,
+ 0x2500, 0x2502, 0x250C, 0x2510, 0x2514, 0x2518, 0x251C, 0x2524,
+ 0x252C, 0x2534, 0x253C, 0x2580, 0x2584, 0x2588, 0x258C, 0x2590,
+ 0x2591, 0x2592, 0x2593, 0x2320, 0x25A0, 0x2219, 0x221A, 0x2248,
+ 0x2264, 0x2265, 0x00A0, 0x2321, 0x00B0, 0x00B2, 0x00B7, 0x00F7,
+ 0x2550, 0x2551, 0x2552, 0x0451, 0x2553, 0x2554, 0x2555, 0x2556,
+ 0x2557, 0x2558, 0x2559, 0x255A, 0x255B, 0x255C, 0x255D, 0x255E,
+ 0x255F, 0x2560, 0x2561, 0x0401, 0x2562, 0x2563, 0x2564, 0x2565,
+ 0x2566, 0x2567, 0x2568, 0x2569, 0x256A, 0x256B, 0x256C, 0x00A9,
+ 0x044E, 0x0430, 0x0431, 0x0446, 0x0434, 0x0435, 0x0444, 0x0433,
+ 0x0445, 0x0438, 0x0439, 0x043A, 0x043B, 0x043C, 0x043D, 0x043E,
+ 0x043F, 0x044F, 0x0440, 0x0441, 0x0442, 0x0443, 0x0436, 0x0432,
+ 0x044C, 0x044B, 0x0437, 0x0448, 0x044D, 0x0449, 0x0447, 0x044A,
+ 0x042E, 0x0410, 0x0411, 0x0426, 0x0414, 0x0415, 0x0424, 0x0413,
+ 0x0425, 0x0418, 0x0419, 0x041A, 0x041B, 0x041C, 0x041D, 0x041E,
+ 0x041F, 0x042F, 0x0420, 0x0421, 0x0422, 0x0423, 0x0416, 0x0412,
+ 0x042C, 0x042B, 0x0417, 0x0428, 0x042D, 0x0429, 0x0427, 0x042A
+ };
+
+ public KOI_8()
+ {
+ super("KOI8-R", new String[] {
+ "KOI8_R",
+ "KOI8",
+ "KOI-8",
+ "KOI_8",
+ "koi8-r",
+ "koi8r",
+ "koi-8-r",
+ "koi"
+ });
+ lookupTable = lookup;
+ }
+
+} // class KOI_8
+
Added: llvm-gcc-4.2/trunk/libjava/classpath/gnu/java/nio/charset/MS874.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/gnu/java/nio/charset/MS874.java?rev=43913&view=auto
==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/gnu/java/nio/charset/MS874.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/gnu/java/nio/charset/MS874.java Thu Nov 8 16:56:19 2007
@@ -0,0 +1,89 @@
+/* MS874.java -- Charset implementation for the MS874 Thai character set.
+ Copyright (C) 2005 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 gnu.java.nio.charset;
+
+public class MS874 extends ByteCharset
+{
+
+ /**
+ * This is the lookup table for this encoding
+ */
+ private static final char[] lookup =
+ {
+ 0x0000, 0x0001, 0x0002, 0x0003, 0x0004, 0x0005, 0x0006, 0x0007,
+ 0x0008, 0x0009, 0x000A, 0x000B, 0x000C, 0x000D, 0x000E, 0x000F,
+ 0x0010, 0x0011, 0x0012, 0x0013, 0x0014, 0x0015, 0x0016, 0x0017,
+ 0x0018, 0x0019, 0x001A, 0x001B, 0x001C, 0x001D, 0x001E, 0x001F,
+ 0x0020, 0x0021, 0x0022, 0x0023, 0x0024, 0x0025, 0x0026, 0x0027,
+ 0x0028, 0x0029, 0x002A, 0x002B, 0x002C, 0x002D, 0x002E, 0x002F,
+ 0x0030, 0x0031, 0x0032, 0x0033, 0x0034, 0x0035, 0x0036, 0x0037,
+ 0x0038, 0x0039, 0x003A, 0x003B, 0x003C, 0x003D, 0x003E, 0x003F,
+ 0x0040, 0x0041, 0x0042, 0x0043, 0x0044, 0x0045, 0x0046, 0x0047,
+ 0x0048, 0x0049, 0x004A, 0x004B, 0x004C, 0x004D, 0x004E, 0x004F,
+ 0x0050, 0x0051, 0x0052, 0x0053, 0x0054, 0x0055, 0x0056, 0x0057,
+ 0x0058, 0x0059, 0x005A, 0x005B, 0x005C, 0x005D, 0x005E, 0x005F,
+ 0x0060, 0x0061, 0x0062, 0x0063, 0x0064, 0x0065, 0x0066, 0x0067,
+ 0x0068, 0x0069, 0x006A, 0x006B, 0x006C, 0x006D, 0x006E, 0x006F,
+ 0x0070, 0x0071, 0x0072, 0x0073, 0x0074, 0x0075, 0x0076, 0x0077,
+ 0x0078, 0x0079, 0x007A, 0x007B, 0x007C, 0x007D, 0x007E, 0x007F,
+ 0x20AC, NONE, NONE, NONE, NONE, 0x2026, NONE, NONE,
+ NONE, NONE, NONE, NONE, NONE, NONE, NONE, NONE,
+ NONE, 0x2018, 0x2019, 0x201C, 0x201D, 0x2022, 0x2013, 0x2014,
+ NONE, NONE, NONE, NONE, NONE, NONE, NONE, NONE,
+ 0x00A0, 0x0E01, 0x0E02, 0x0E03, 0x0E04, 0x0E05, 0x0E06, 0x0E07,
+ 0x0E08, 0x0E09, 0x0E0A, 0x0E0B, 0x0E0C, 0x0E0D, 0x0E0E, 0x0E0F,
+ 0x0E10, 0x0E11, 0x0E12, 0x0E13, 0x0E14, 0x0E15, 0x0E16, 0x0E17,
+ 0x0E18, 0x0E19, 0x0E1A, 0x0E1B, 0x0E1C, 0x0E1D, 0x0E1E, 0x0E1F,
+ 0x0E20, 0x0E21, 0x0E22, 0x0E23, 0x0E24, 0x0E25, 0x0E26, 0x0E27,
+ 0x0E28, 0x0E29, 0x0E2A, 0x0E2B, 0x0E2C, 0x0E2D, 0x0E2E, 0x0E2F,
+ 0x0E30, 0x0E31, 0x0E32, 0x0E33, 0x0E34, 0x0E35, 0x0E36, 0x0E37,
+ 0x0E38, 0x0E39, 0x0E3A, NONE, NONE, NONE, NONE, 0x0E3F,
+ 0x0E40, 0x0E41, 0x0E42, 0x0E43, 0x0E44, 0x0E45, 0x0E46, 0x0E47,
+ 0x0E48, 0x0E49, 0x0E4A, 0x0E4B, 0x0E4C, 0x0E4D, 0x0E4E, 0x0E4F,
+ 0x0E50, 0x0E51, 0x0E52, 0x0E53, 0x0E54, 0x0E55, 0x0E56, 0x0E57,
+ 0x0E58, 0x0E59, 0x0E5A, 0x0E5B, NONE, NONE, NONE, NONE
+ };
+
+ public MS874()
+ {
+ super("MS874", new String[] {
+ });
+ lookupTable = lookup;
+ }
+
+} // class MS874
Added: llvm-gcc-4.2/trunk/libjava/classpath/gnu/java/nio/charset/MacCentralEurope.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/gnu/java/nio/charset/MacCentralEurope.java?rev=43913&view=auto
==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/gnu/java/nio/charset/MacCentralEurope.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/gnu/java/nio/charset/MacCentralEurope.java Thu Nov 8 16:56:19 2007
@@ -0,0 +1,89 @@
+/* MacCentralEurope.java -- Charset implementation for the MacCentralEurope character set.
+ Copyright (C) 2005 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 gnu.java.nio.charset;
+
+public class MacCentralEurope extends ByteCharset
+{
+
+ /**
+ * This is the lookup table for this encoding
+ */
+ private static final char[] lookup =
+ {
+ 0x0000, 0x0001, 0x0002, 0x0003, 0x0004, 0x0005, 0x0006, 0x0007,
+ 0x0008, 0x0009, 0x000A, 0x000B, 0x000C, 0x000D, 0x000E, 0x000F,
+ 0x0010, 0x0011, 0x0012, 0x0013, 0x0014, 0x0015, 0x0016, 0x0017,
+ 0x0018, 0x0019, 0x001A, 0x001B, 0x001C, 0x001D, 0x001E, 0x001F,
+ 0x0020, 0x0021, 0x0022, 0x0023, 0x0024, 0x0025, 0x0026, 0x0027,
+ 0x0028, 0x0029, 0x002A, 0x002B, 0x002C, 0x002D, 0x002E, 0x002F,
+ 0x0030, 0x0031, 0x0032, 0x0033, 0x0034, 0x0035, 0x0036, 0x0037,
+ 0x0038, 0x0039, 0x003A, 0x003B, 0x003C, 0x003D, 0x003E, 0x003F,
+ 0x0040, 0x0041, 0x0042, 0x0043, 0x0044, 0x0045, 0x0046, 0x0047,
+ 0x0048, 0x0049, 0x004A, 0x004B, 0x004C, 0x004D, 0x004E, 0x004F,
+ 0x0050, 0x0051, 0x0052, 0x0053, 0x0054, 0x0055, 0x0056, 0x0057,
+ 0x0058, 0x0059, 0x005A, 0x005B, 0x005C, 0x005D, 0x005E, 0x005F,
+ 0x0060, 0x0061, 0x0062, 0x0063, 0x0064, 0x0065, 0x0066, 0x0067,
+ 0x0068, 0x0069, 0x006A, 0x006B, 0x006C, 0x006D, 0x006E, 0x006F,
+ 0x0070, 0x0071, 0x0072, 0x0073, 0x0074, 0x0075, 0x0076, 0x0077,
+ 0x0078, 0x0079, 0x007A, 0x007B, 0x007C, 0x007D, 0x007E, NONE,
+ 0x00C4, 0x0100, 0x0101, 0x00C9, 0x0104, 0x00D6, 0x00DC, 0x00E1,
+ 0x0105, 0x010C, 0x00E4, 0x010D, 0x0106, 0x0107, 0x00E9, 0x0179,
+ 0x017A, 0x010E, 0x00ED, 0x010F, 0x0112, 0x0113, 0x0116, 0x00F3,
+ 0x0117, 0x00F4, 0x00F6, 0x00F5, 0x00FA, 0x011A, 0x011B, 0x00FC,
+ 0x2020, 0x00B0, 0x0118, 0x00A3, 0x00A7, 0x2022, 0x00B6, 0x00DF,
+ 0x00AE, 0x00A9, 0x2122, 0x0119, 0x00A8, 0x2260, 0x0123, 0x012E,
+ 0x012F, 0x012A, 0x2264, 0x2265, 0x012B, 0x0136, 0x2202, 0x2211,
+ 0x0142, 0x013B, 0x013C, 0x013D, 0x013E, 0x0139, 0x013A, 0x0145,
+ 0x0146, 0x0143, 0x00AC, 0x221A, 0x0144, 0x0147, 0x2206, 0x00AB,
+ 0x00BB, 0x2026, 0x00A0, 0x0148, 0x0150, 0x00D5, 0x0151, 0x014C,
+ 0x2013, 0x2014, 0x201C, 0x201D, 0x2018, 0x2019, 0x00F7, 0x25CA,
+ 0x014D, 0x0154, 0x0155, 0x0158, 0x2039, 0x203A, 0x0159, 0x0156,
+ 0x0157, 0x0160, 0x201A, 0x201E, 0x0161, 0x015A, 0x015B, 0x00C1,
+ 0x0164, 0x0165, 0x00CD, 0x017D, 0x017E, 0x016A, 0x00D3, 0x00D4,
+ 0x016B, 0x016E, 0x00DA, 0x016F, 0x0170, 0x0171, 0x0172, 0x0173,
+ 0x00DD, 0x00FD, 0x0137, 0x017B, 0x0141, 0x017C, 0x0122, 0x02C7
+ };
+
+ public MacCentralEurope()
+ {
+ super("MacCentralEurope", new String[] {
+ });
+ lookupTable = lookup;
+ }
+
+} // class MacCentralEurope
Added: llvm-gcc-4.2/trunk/libjava/classpath/gnu/java/nio/charset/MacCroatian.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/gnu/java/nio/charset/MacCroatian.java?rev=43913&view=auto
==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/gnu/java/nio/charset/MacCroatian.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/gnu/java/nio/charset/MacCroatian.java Thu Nov 8 16:56:19 2007
@@ -0,0 +1,89 @@
+/* MacCroatian.java -- Charset implementation for the MacCroatian character set.
+ Copyright (C) 2005 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 gnu.java.nio.charset;
+
+public class MacCroatian extends ByteCharset
+{
+
+ /**
+ * This is the lookup table for this encoding
+ */
+ private static final char[] lookup =
+ {
+ 0x0000, 0x0001, 0x0002, 0x0003, 0x0004, 0x0005, 0x0006, 0x0007,
+ 0x0008, 0x0009, 0x000A, 0x000B, 0x000C, 0x000D, 0x000E, 0x000F,
+ 0x0010, 0x0011, 0x0012, 0x0013, 0x0014, 0x0015, 0x0016, 0x0017,
+ 0x0018, 0x0019, 0x001A, 0x001B, 0x001C, 0x001D, 0x001E, 0x001F,
+ 0x0020, 0x0021, 0x0022, 0x0023, 0x0024, 0x0025, 0x0026, 0x0027,
+ 0x0028, 0x0029, 0x002A, 0x002B, 0x002C, 0x002D, 0x002E, 0x002F,
+ 0x0030, 0x0031, 0x0032, 0x0033, 0x0034, 0x0035, 0x0036, 0x0037,
+ 0x0038, 0x0039, 0x003A, 0x003B, 0x003C, 0x003D, 0x003E, 0x003F,
+ 0x0040, 0x0041, 0x0042, 0x0043, 0x0044, 0x0045, 0x0046, 0x0047,
+ 0x0048, 0x0049, 0x004A, 0x004B, 0x004C, 0x004D, 0x004E, 0x004F,
+ 0x0050, 0x0051, 0x0052, 0x0053, 0x0054, 0x0055, 0x0056, 0x0057,
+ 0x0058, 0x0059, 0x005A, 0x005B, 0x005C, 0x005D, 0x005E, 0x005F,
+ 0x0060, 0x0061, 0x0062, 0x0063, 0x0064, 0x0065, 0x0066, 0x0067,
+ 0x0068, 0x0069, 0x006A, 0x006B, 0x006C, 0x006D, 0x006E, 0x006F,
+ 0x0070, 0x0071, 0x0072, 0x0073, 0x0074, 0x0075, 0x0076, 0x0077,
+ 0x0078, 0x0079, 0x007A, 0x007B, 0x007C, 0x007D, 0x007E, NONE,
+ 0x00C4, 0x00C5, 0x00C7, 0x00C9, 0x00D1, 0x00D6, 0x00DC, 0x00E1,
+ 0x00E0, 0x00E2, 0x00E4, 0x00E3, 0x00E5, 0x00E7, 0x00E9, 0x00E8,
+ 0x00EA, 0x00EB, 0x00ED, 0x00EC, 0x00EE, 0x00EF, 0x00F1, 0x00F3,
+ 0x00F2, 0x00F4, 0x00F6, 0x00F5, 0x00FA, 0x00F9, 0x00FB, 0x00FC,
+ 0x2020, 0x00B0, 0x00A2, 0x00A3, 0x00A7, 0x2022, 0x00B6, 0x00DF,
+ 0x00AE, 0x0160, 0x2122, 0x00B4, 0x00A8, 0x2260, 0x017D, 0x00D8,
+ 0x221E, 0x00B1, 0x2264, 0x2265, 0x2206, 0x00B5, 0x2202, 0x2211,
+ 0x220F, 0x0161, 0x222B, 0x00AA, 0x00BA, 0x03A9, 0x017E, 0x00F8,
+ 0x00BF, 0x00A1, 0x00AC, 0x221A, 0x0192, 0x2248, 0x0106, 0x00AB,
+ 0x010C, 0x2026, 0x00A0, 0x00C0, 0x00C3, 0x00D5, 0x0152, 0x0153,
+ 0x0110, 0x2014, 0x201C, 0x201D, 0x2018, 0x2019, 0x00F7, 0x25CA,
+ 0xF8FF, 0x00A9, 0x2044, 0x20AC, 0x2039, 0x203A, 0x00C6, 0x00BB,
+ 0x2013, 0x00B7, 0x201A, 0x201E, 0x2030, 0x00C2, 0x0107, 0x00C1,
+ 0x010D, 0x00C8, 0x00CD, 0x00CE, 0x00CF, 0x00CC, 0x00D3, 0x00D4,
+ 0x0111, 0x00D2, 0x00DA, 0x00DB, 0x00D9, 0x0131, 0x02C6, 0x02DC,
+ 0x00AF, 0x03C0, 0x00CB, 0x02DA, 0x00B8, 0x00CA, 0x00E6, 0x02C7
+ };
+
+ public MacCroatian()
+ {
+ super("MacCroatian", new String[] {
+ });
+ lookupTable = lookup;
+ }
+
+} // class MacCroatian
Added: llvm-gcc-4.2/trunk/libjava/classpath/gnu/java/nio/charset/MacCyrillic.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/gnu/java/nio/charset/MacCyrillic.java?rev=43913&view=auto
==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/gnu/java/nio/charset/MacCyrillic.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/gnu/java/nio/charset/MacCyrillic.java Thu Nov 8 16:56:19 2007
@@ -0,0 +1,89 @@
+/* MacCyrillic.java -- Charset implementation for the MacCyrillic character set.
+ Copyright (C) 2005 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 gnu.java.nio.charset;
+
+public class MacCyrillic extends ByteCharset
+{
+
+ /**
+ * This is the lookup table for this encoding
+ */
+ private static final char[] lookup =
+ {
+ 0x0000, 0x0001, 0x0002, 0x0003, 0x0004, 0x0005, 0x0006, 0x0007,
+ 0x0008, 0x0009, 0x000A, 0x000B, 0x000C, 0x000D, 0x000E, 0x000F,
+ 0x0010, 0x0011, 0x0012, 0x0013, 0x0014, 0x0015, 0x0016, 0x0017,
+ 0x0018, 0x0019, 0x001A, 0x001B, 0x001C, 0x001D, 0x001E, 0x001F,
+ 0x0020, 0x0021, 0x0022, 0x0023, 0x0024, 0x0025, 0x0026, 0x0027,
+ 0x0028, 0x0029, 0x002A, 0x002B, 0x002C, 0x002D, 0x002E, 0x002F,
+ 0x0030, 0x0031, 0x0032, 0x0033, 0x0034, 0x0035, 0x0036, 0x0037,
+ 0x0038, 0x0039, 0x003A, 0x003B, 0x003C, 0x003D, 0x003E, 0x003F,
+ 0x0040, 0x0041, 0x0042, 0x0043, 0x0044, 0x0045, 0x0046, 0x0047,
+ 0x0048, 0x0049, 0x004A, 0x004B, 0x004C, 0x004D, 0x004E, 0x004F,
+ 0x0050, 0x0051, 0x0052, 0x0053, 0x0054, 0x0055, 0x0056, 0x0057,
+ 0x0058, 0x0059, 0x005A, 0x005B, 0x005C, 0x005D, 0x005E, 0x005F,
+ 0x0060, 0x0061, 0x0062, 0x0063, 0x0064, 0x0065, 0x0066, 0x0067,
+ 0x0068, 0x0069, 0x006A, 0x006B, 0x006C, 0x006D, 0x006E, 0x006F,
+ 0x0070, 0x0071, 0x0072, 0x0073, 0x0074, 0x0075, 0x0076, 0x0077,
+ 0x0078, 0x0079, 0x007A, 0x007B, 0x007C, 0x007D, 0x007E, NONE,
+ 0x0410, 0x0411, 0x0412, 0x0413, 0x0414, 0x0415, 0x0416, 0x0417,
+ 0x0418, 0x0419, 0x041A, 0x041B, 0x041C, 0x041D, 0x041E, 0x041F,
+ 0x0420, 0x0421, 0x0422, 0x0423, 0x0424, 0x0425, 0x0426, 0x0427,
+ 0x0428, 0x0429, 0x042A, 0x042B, 0x042C, 0x042D, 0x042E, 0x042F,
+ 0x2020, 0x00B0, 0x0490, 0x00A3, 0x00A7, 0x2022, 0x00B6, 0x0406,
+ 0x00AE, 0x00A9, 0x2122, 0x0402, 0x0452, 0x2260, 0x0403, 0x0453,
+ 0x221E, 0x00B1, 0x2264, 0x2265, 0x0456, 0x00B5, 0x0491, 0x0408,
+ 0x0404, 0x0454, 0x0407, 0x0457, 0x0409, 0x0459, 0x040A, 0x045A,
+ 0x0458, 0x0405, 0x00AC, 0x221A, 0x0192, 0x2248, 0x2206, 0x00AB,
+ 0x00BB, 0x2026, 0x00A0, 0x040B, 0x045B, 0x040C, 0x045C, 0x0455,
+ 0x2013, 0x2014, 0x201C, 0x201D, 0x2018, 0x2019, 0x00F7, 0x201E,
+ 0x040E, 0x045E, 0x040F, 0x045F, 0x2116, 0x0401, 0x0451, 0x044F,
+ 0x0430, 0x0431, 0x0432, 0x0433, 0x0434, 0x0435, 0x0436, 0x0437,
+ 0x0438, 0x0439, 0x043A, 0x043B, 0x043C, 0x043D, 0x043E, 0x043F,
+ 0x0440, 0x0441, 0x0442, 0x0443, 0x0444, 0x0445, 0x0446, 0x0447,
+ 0x0448, 0x0449, 0x044A, 0x044B, 0x044C, 0x044D, 0x044E, 0x20AC
+ };
+
+ public MacCyrillic()
+ {
+ super("MacCyrillic", new String[] {
+ });
+ lookupTable = lookup;
+ }
+
+} // class MacCyrillic
Added: llvm-gcc-4.2/trunk/libjava/classpath/gnu/java/nio/charset/MacDingbat.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/gnu/java/nio/charset/MacDingbat.java?rev=43913&view=auto
==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/gnu/java/nio/charset/MacDingbat.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/gnu/java/nio/charset/MacDingbat.java Thu Nov 8 16:56:19 2007
@@ -0,0 +1,89 @@
+/* MacDingbat.java -- Charset implementation for the MacDingbat character set.
+ Copyright (C) 2005 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 gnu.java.nio.charset;
+
+public class MacDingbat extends ByteCharset
+{
+
+ /**
+ * This is the lookup table for this encoding
+ */
+ private static final char[] lookup =
+ {
+ 0x0000, 0x0001, 0x0002, 0x0003, 0x0004, 0x0005, 0x0006, 0x0007,
+ 0x0008, 0x0009, 0x000A, 0x000B, 0x000C, 0x000D, 0x000E, 0x000F,
+ 0x0010, 0x0011, 0x0012, 0x0013, 0x0014, 0x0015, 0x0016, 0x0017,
+ 0x0018, 0x0019, 0x001A, 0x001B, 0x001C, 0x001D, 0x001E, 0x001F,
+ 0x0020, 0x2701, 0x2702, 0x2703, 0x2704, 0x260E, 0x2706, 0x2707,
+ 0x2708, 0x2709, 0x261B, 0x261E, 0x270C, 0x270D, 0x270E, 0x270F,
+ 0x2710, 0x2711, 0x2712, 0x2713, 0x2714, 0x2715, 0x2716, 0x2717,
+ 0x2718, 0x2719, 0x271A, 0x271B, 0x271C, 0x271D, 0x271E, 0x271F,
+ 0x2720, 0x2721, 0x2722, 0x2723, 0x2724, 0x2725, 0x2726, 0x2727,
+ 0x2605, 0x2729, 0x272A, 0x272B, 0x272C, 0x272D, 0x272E, 0x272F,
+ 0x2730, 0x2731, 0x2732, 0x2733, 0x2734, 0x2735, 0x2736, 0x2737,
+ 0x2738, 0x2739, 0x273A, 0x273B, 0x273C, 0x273D, 0x273E, 0x273F,
+ 0x2740, 0x2741, 0x2742, 0x2743, 0x2744, 0x2745, 0x2746, 0x2747,
+ 0x2748, 0x2749, 0x274A, 0x274B, 0x25CF, 0x274D, 0x25A0, 0x274F,
+ 0x2750, 0x2751, 0x2752, 0x25B2, 0x25BC, 0x25C6, 0x2756, 0x25D7,
+ 0x2758, 0x2759, 0x275A, 0x275B, 0x275C, 0x275D, 0x275E, NONE,
+ 0x2768, 0x2769, 0x276A, 0x276B, 0x276C, 0x276D, 0x276E, 0x276F,
+ 0x2770, 0x2771, 0x2772, 0x2773, 0x2774, 0x2775, NONE, NONE,
+ NONE, NONE, NONE, NONE, NONE, NONE, NONE, NONE,
+ NONE, NONE, NONE, NONE, NONE, NONE, NONE, NONE,
+ NONE, 0x2761, 0x2762, 0x2763, 0x2764, 0x2765, 0x2766, 0x2767,
+ 0x2663, 0x2666, 0x2665, 0x2660, 0x2460, 0x2461, 0x2462, 0x2463,
+ 0x2464, 0x2465, 0x2466, 0x2467, 0x2468, 0x2469, 0x2776, 0x2777,
+ 0x2778, 0x2779, 0x277A, 0x277B, 0x277C, 0x277D, 0x277E, 0x277F,
+ 0x2780, 0x2781, 0x2782, 0x2783, 0x2784, 0x2785, 0x2786, 0x2787,
+ 0x2788, 0x2789, 0x278A, 0x278B, 0x278C, 0x278D, 0x278E, 0x278F,
+ 0x2790, 0x2791, 0x2792, 0x2793, 0x2794, 0x2192, 0x2194, 0x2195,
+ 0x2798, 0x2799, 0x279A, 0x279B, 0x279C, 0x279D, 0x279E, 0x279F,
+ 0x27A0, 0x27A1, 0x27A2, 0x27A3, 0x27A4, 0x27A5, 0x27A6, 0x27A7,
+ 0x27A8, 0x27A9, 0x27AA, 0x27AB, 0x27AC, 0x27AD, 0x27AE, 0x27AF,
+ NONE, 0x27B1, 0x27B2, 0x27B3, 0x27B4, 0x27B5, 0x27B6, 0x27B7,
+ 0x27B8, 0x27B9, 0x27BA, 0x27BB, 0x27BC, 0x27BD, 0x27BE, NONE
+ };
+
+ public MacDingbat()
+ {
+ super("MacDingbat", new String[] {
+ });
+ lookupTable = lookup;
+ }
+
+} // class MacDingbat
Added: llvm-gcc-4.2/trunk/libjava/classpath/gnu/java/nio/charset/MacGreek.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/gnu/java/nio/charset/MacGreek.java?rev=43913&view=auto
==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/gnu/java/nio/charset/MacGreek.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/gnu/java/nio/charset/MacGreek.java Thu Nov 8 16:56:19 2007
@@ -0,0 +1,89 @@
+/* MacGreek.java -- Charset implementation for the MacGreek character set.
+ Copyright (C) 2005 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 gnu.java.nio.charset;
+
+public class MacGreek extends ByteCharset
+{
+
+ /**
+ * This is the lookup table for this encoding
+ */
+ private static final char[] lookup =
+ {
+ 0x0000, 0x0001, 0x0002, 0x0003, 0x0004, 0x0005, 0x0006, 0x0007,
+ 0x0008, 0x0009, 0x000A, 0x000B, 0x000C, 0x000D, 0x000E, 0x000F,
+ 0x0010, 0x0011, 0x0012, 0x0013, 0x0014, 0x0015, 0x0016, 0x0017,
+ 0x0018, 0x0019, 0x001A, 0x001B, 0x001C, 0x001D, 0x001E, 0x001F,
+ 0x0020, 0x0021, 0x0022, 0x0023, 0x0024, 0x0025, 0x0026, 0x0027,
+ 0x0028, 0x0029, 0x002A, 0x002B, 0x002C, 0x002D, 0x002E, 0x002F,
+ 0x0030, 0x0031, 0x0032, 0x0033, 0x0034, 0x0035, 0x0036, 0x0037,
+ 0x0038, 0x0039, 0x003A, 0x003B, 0x003C, 0x003D, 0x003E, 0x003F,
+ 0x0040, 0x0041, 0x0042, 0x0043, 0x0044, 0x0045, 0x0046, 0x0047,
+ 0x0048, 0x0049, 0x004A, 0x004B, 0x004C, 0x004D, 0x004E, 0x004F,
+ 0x0050, 0x0051, 0x0052, 0x0053, 0x0054, 0x0055, 0x0056, 0x0057,
+ 0x0058, 0x0059, 0x005A, 0x005B, 0x005C, 0x005D, 0x005E, 0x005F,
+ 0x0060, 0x0061, 0x0062, 0x0063, 0x0064, 0x0065, 0x0066, 0x0067,
+ 0x0068, 0x0069, 0x006A, 0x006B, 0x006C, 0x006D, 0x006E, 0x006F,
+ 0x0070, 0x0071, 0x0072, 0x0073, 0x0074, 0x0075, 0x0076, 0x0077,
+ 0x0078, 0x0079, 0x007A, 0x007B, 0x007C, 0x007D, 0x007E, NONE,
+ 0x00C4, 0x00B9, 0x00B2, 0x00C9, 0x00B3, 0x00D6, 0x00DC, 0x0385,
+ 0x00E0, 0x00E2, 0x00E4, 0x0384, 0x00A8, 0x00E7, 0x00E9, 0x00E8,
+ 0x00EA, 0x00EB, 0x00A3, 0x2122, 0x00EE, 0x00EF, 0x2022, 0x00BD,
+ 0x2030, 0x00F4, 0x00F6, 0x00A6, 0x20AC, 0x00F9, 0x00FB, 0x00FC,
+ 0x2020, 0x0393, 0x0394, 0x0398, 0x039B, 0x039E, 0x03A0, 0x00DF,
+ 0x00AE, 0x00A9, 0x03A3, 0x03AA, 0x00A7, 0x2260, 0x00B0, 0x00B7,
+ 0x0391, 0x00B1, 0x2264, 0x2265, 0x00A5, 0x0392, 0x0395, 0x0396,
+ 0x0397, 0x0399, 0x039A, 0x039C, 0x03A6, 0x03AB, 0x03A8, 0x03A9,
+ 0x03AC, 0x039D, 0x00AC, 0x039F, 0x03A1, 0x2248, 0x03A4, 0x00AB,
+ 0x00BB, 0x2026, 0x00A0, 0x03A5, 0x03A7, 0x0386, 0x0388, 0x0153,
+ 0x2013, 0x2015, 0x201C, 0x201D, 0x2018, 0x2019, 0x00F7, 0x0389,
+ 0x038A, 0x038C, 0x038E, 0x03AD, 0x03AE, 0x03AF, 0x03CC, 0x038F,
+ 0x03CD, 0x03B1, 0x03B2, 0x03C8, 0x03B4, 0x03B5, 0x03C6, 0x03B3,
+ 0x03B7, 0x03B9, 0x03BE, 0x03BA, 0x03BB, 0x03BC, 0x03BD, 0x03BF,
+ 0x03C0, 0x03CE, 0x03C1, 0x03C3, 0x03C4, 0x03B8, 0x03C9, 0x03C2,
+ 0x03C7, 0x03C5, 0x03B6, 0x03CA, 0x03CB, 0x0390, 0x03B0, 0x00AD
+ };
+
+ public MacGreek()
+ {
+ super("MacGreek", new String[] {
+ });
+ lookupTable = lookup;
+ }
+
+} // class MacGreek
Added: llvm-gcc-4.2/trunk/libjava/classpath/gnu/java/nio/charset/MacIceland.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/gnu/java/nio/charset/MacIceland.java?rev=43913&view=auto
==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/gnu/java/nio/charset/MacIceland.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/gnu/java/nio/charset/MacIceland.java Thu Nov 8 16:56:19 2007
@@ -0,0 +1,89 @@
+/* MacIceland.java -- Charset implementation for the MacIceland character set.
+ Copyright (C) 2005 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 gnu.java.nio.charset;
+
+public class MacIceland extends ByteCharset
+{
+
+ /**
+ * This is the lookup table for this encoding
+ */
+ private static final char[] lookup =
+ {
+ 0x0000, 0x0001, 0x0002, 0x0003, 0x0004, 0x0005, 0x0006, 0x0007,
+ 0x0008, 0x0009, 0x000A, 0x000B, 0x000C, 0x000D, 0x000E, 0x000F,
+ 0x0010, 0x0011, 0x0012, 0x0013, 0x0014, 0x0015, 0x0016, 0x0017,
+ 0x0018, 0x0019, 0x001A, 0x001B, 0x001C, 0x001D, 0x001E, 0x001F,
+ 0x0020, 0x0021, 0x0022, 0x0023, 0x0024, 0x0025, 0x0026, 0x0027,
+ 0x0028, 0x0029, 0x002A, 0x002B, 0x002C, 0x002D, 0x002E, 0x002F,
+ 0x0030, 0x0031, 0x0032, 0x0033, 0x0034, 0x0035, 0x0036, 0x0037,
+ 0x0038, 0x0039, 0x003A, 0x003B, 0x003C, 0x003D, 0x003E, 0x003F,
+ 0x0040, 0x0041, 0x0042, 0x0043, 0x0044, 0x0045, 0x0046, 0x0047,
+ 0x0048, 0x0049, 0x004A, 0x004B, 0x004C, 0x004D, 0x004E, 0x004F,
+ 0x0050, 0x0051, 0x0052, 0x0053, 0x0054, 0x0055, 0x0056, 0x0057,
+ 0x0058, 0x0059, 0x005A, 0x005B, 0x005C, 0x005D, 0x005E, 0x005F,
+ 0x0060, 0x0061, 0x0062, 0x0063, 0x0064, 0x0065, 0x0066, 0x0067,
+ 0x0068, 0x0069, 0x006A, 0x006B, 0x006C, 0x006D, 0x006E, 0x006F,
+ 0x0070, 0x0071, 0x0072, 0x0073, 0x0074, 0x0075, 0x0076, 0x0077,
+ 0x0078, 0x0079, 0x007A, 0x007B, 0x007C, 0x007D, 0x007E, NONE,
+ 0x00C4, 0x00C5, 0x00C7, 0x00C9, 0x00D1, 0x00D6, 0x00DC, 0x00E1,
+ 0x00E0, 0x00E2, 0x00E4, 0x00E3, 0x00E5, 0x00E7, 0x00E9, 0x00E8,
+ 0x00EA, 0x00EB, 0x00ED, 0x00EC, 0x00EE, 0x00EF, 0x00F1, 0x00F3,
+ 0x00F2, 0x00F4, 0x00F6, 0x00F5, 0x00FA, 0x00F9, 0x00FB, 0x00FC,
+ 0x00DD, 0x00B0, 0x00A2, 0x00A3, 0x00A7, 0x2022, 0x00B6, 0x00DF,
+ 0x00AE, 0x00A9, 0x2122, 0x00B4, 0x00A8, 0x2260, 0x00C6, 0x00D8,
+ 0x221E, 0x00B1, 0x2264, 0x2265, 0x00A5, 0x00B5, 0x2202, 0x2211,
+ 0x220F, 0x03C0, 0x222B, 0x00AA, 0x00BA, 0x03A9, 0x00E6, 0x00F8,
+ 0x00BF, 0x00A1, 0x00AC, 0x221A, 0x0192, 0x2248, 0x2206, 0x00AB,
+ 0x00BB, 0x2026, 0x00A0, 0x00C0, 0x00C3, 0x00D5, 0x0152, 0x0153,
+ 0x2013, 0x2014, 0x201C, 0x201D, 0x2018, 0x2019, 0x00F7, 0x25CA,
+ 0x00FF, 0x0178, 0x2044, 0x20AC, 0x00D0, 0x00F0, 0x00DE, 0x00FE,
+ 0x00FD, 0x00B7, 0x201A, 0x201E, 0x2030, 0x00C2, 0x00CA, 0x00C1,
+ 0x00CB, 0x00C8, 0x00CD, 0x00CE, 0x00CF, 0x00CC, 0x00D3, 0x00D4,
+ 0xF8FF, 0x00D2, 0x00DA, 0x00DB, 0x00D9, 0x0131, 0x02C6, 0x02DC,
+ 0x00AF, 0x02D8, 0x02D9, 0x02DA, 0x00B8, 0x02DD, 0x02DB, 0x02C7
+ };
+
+ public MacIceland()
+ {
+ super("MacIceland", new String[] {
+ });
+ lookupTable = lookup;
+ }
+
+} // class MacIceland
Added: llvm-gcc-4.2/trunk/libjava/classpath/gnu/java/nio/charset/MacRoman.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/gnu/java/nio/charset/MacRoman.java?rev=43913&view=auto
==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/gnu/java/nio/charset/MacRoman.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/gnu/java/nio/charset/MacRoman.java Thu Nov 8 16:56:19 2007
@@ -0,0 +1,89 @@
+/* MacRoman.java -- Charset implementation for the MacRoman character set.
+ Copyright (C) 2005 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 gnu.java.nio.charset;
+
+public class MacRoman extends ByteCharset
+{
+
+ /**
+ * This is the lookup table for this encoding
+ */
+ private static final char[] lookup =
+ {
+ 0x0000, 0x0001, 0x0002, 0x0003, 0x0004, 0x0005, 0x0006, 0x0007,
+ 0x0008, 0x0009, 0x000A, 0x000B, 0x000C, 0x000D, 0x000E, 0x000F,
+ 0x0010, 0x0011, 0x0012, 0x0013, 0x0014, 0x0015, 0x0016, 0x0017,
+ 0x0018, 0x0019, 0x001A, 0x001B, 0x001C, 0x001D, 0x001E, 0x001F,
+ 0x0020, 0x0021, 0x0022, 0x0023, 0x0024, 0x0025, 0x0026, 0x0027,
+ 0x0028, 0x0029, 0x002A, 0x002B, 0x002C, 0x002D, 0x002E, 0x002F,
+ 0x0030, 0x0031, 0x0032, 0x0033, 0x0034, 0x0035, 0x0036, 0x0037,
+ 0x0038, 0x0039, 0x003A, 0x003B, 0x003C, 0x003D, 0x003E, 0x003F,
+ 0x0040, 0x0041, 0x0042, 0x0043, 0x0044, 0x0045, 0x0046, 0x0047,
+ 0x0048, 0x0049, 0x004A, 0x004B, 0x004C, 0x004D, 0x004E, 0x004F,
+ 0x0050, 0x0051, 0x0052, 0x0053, 0x0054, 0x0055, 0x0056, 0x0057,
+ 0x0058, 0x0059, 0x005A, 0x005B, 0x005C, 0x005D, 0x005E, 0x005F,
+ 0x0060, 0x0061, 0x0062, 0x0063, 0x0064, 0x0065, 0x0066, 0x0067,
+ 0x0068, 0x0069, 0x006A, 0x006B, 0x006C, 0x006D, 0x006E, 0x006F,
+ 0x0070, 0x0071, 0x0072, 0x0073, 0x0074, 0x0075, 0x0076, 0x0077,
+ 0x0078, 0x0079, 0x007A, 0x007B, 0x007C, 0x007D, 0x007E, NONE,
+ 0x00C4, 0x00C5, 0x00C7, 0x00C9, 0x00D1, 0x00D6, 0x00DC, 0x00E1,
+ 0x00E0, 0x00E2, 0x00E4, 0x00E3, 0x00E5, 0x00E7, 0x00E9, 0x00E8,
+ 0x00EA, 0x00EB, 0x00ED, 0x00EC, 0x00EE, 0x00EF, 0x00F1, 0x00F3,
+ 0x00F2, 0x00F4, 0x00F6, 0x00F5, 0x00FA, 0x00F9, 0x00FB, 0x00FC,
+ 0x2020, 0x00B0, 0x00A2, 0x00A3, 0x00A7, 0x2022, 0x00B6, 0x00DF,
+ 0x00AE, 0x00A9, 0x2122, 0x00B4, 0x00A8, 0x2260, 0x00C6, 0x00D8,
+ 0x221E, 0x00B1, 0x2264, 0x2265, 0x00A5, 0x00B5, 0x2202, 0x2211,
+ 0x220F, 0x03C0, 0x222B, 0x00AA, 0x00BA, 0x03A9, 0x00E6, 0x00F8,
+ 0x00BF, 0x00A1, 0x00AC, 0x221A, 0x0192, 0x2248, 0x2206, 0x00AB,
+ 0x00BB, 0x2026, 0x00A0, 0x00C0, 0x00C3, 0x00D5, 0x0152, 0x0153,
+ 0x2013, 0x2014, 0x201C, 0x201D, 0x2018, 0x2019, 0x00F7, 0x25CA,
+ 0x00FF, 0x0178, 0x2044, 0x20AC, 0x2039, 0x203A, 0xFB01, 0xFB02,
+ 0x2021, 0x00B7, 0x201A, 0x201E, 0x2030, 0x00C2, 0x00CA, 0x00C1,
+ 0x00CB, 0x00C8, 0x00CD, 0x00CE, 0x00CF, 0x00CC, 0x00D3, 0x00D4,
+ 0xF8FF, 0x00D2, 0x00DA, 0x00DB, 0x00D9, 0x0131, 0x02C6, 0x02DC,
+ 0x00AF, 0x02D8, 0x02D9, 0x02DA, 0x00B8, 0x02DD, 0x02DB, 0x02C7
+ };
+
+ public MacRoman()
+ {
+ super("MacRoman", new String[] {
+ });
+ lookupTable = lookup;
+ }
+
+} // class MacRoman
Added: llvm-gcc-4.2/trunk/libjava/classpath/gnu/java/nio/charset/MacRomania.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/gnu/java/nio/charset/MacRomania.java?rev=43913&view=auto
==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/gnu/java/nio/charset/MacRomania.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/gnu/java/nio/charset/MacRomania.java Thu Nov 8 16:56:19 2007
@@ -0,0 +1,89 @@
+/* MacRomania.java -- Charset implementation for the MacRomania character set.
+ Copyright (C) 2005 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 gnu.java.nio.charset;
+
+public class MacRomania extends ByteCharset
+{
+
+ /**
+ * This is the lookup table for this encoding
+ */
+ private static final char[] lookup =
+ {
+ 0x0000, 0x0001, 0x0002, 0x0003, 0x0004, 0x0005, 0x0006, 0x0007,
+ 0x0008, 0x0009, 0x000A, 0x000B, 0x000C, 0x000D, 0x000E, 0x000F,
+ 0x0010, 0x0011, 0x0012, 0x0013, 0x0014, 0x0015, 0x0016, 0x0017,
+ 0x0018, 0x0019, 0x001A, 0x001B, 0x001C, 0x001D, 0x001E, 0x001F,
+ 0x0020, 0x0021, 0x0022, 0x0023, 0x0024, 0x0025, 0x0026, 0x0027,
+ 0x0028, 0x0029, 0x002A, 0x002B, 0x002C, 0x002D, 0x002E, 0x002F,
+ 0x0030, 0x0031, 0x0032, 0x0033, 0x0034, 0x0035, 0x0036, 0x0037,
+ 0x0038, 0x0039, 0x003A, 0x003B, 0x003C, 0x003D, 0x003E, 0x003F,
+ 0x0040, 0x0041, 0x0042, 0x0043, 0x0044, 0x0045, 0x0046, 0x0047,
+ 0x0048, 0x0049, 0x004A, 0x004B, 0x004C, 0x004D, 0x004E, 0x004F,
+ 0x0050, 0x0051, 0x0052, 0x0053, 0x0054, 0x0055, 0x0056, 0x0057,
+ 0x0058, 0x0059, 0x005A, 0x005B, 0x005C, 0x005D, 0x005E, 0x005F,
+ 0x0060, 0x0061, 0x0062, 0x0063, 0x0064, 0x0065, 0x0066, 0x0067,
+ 0x0068, 0x0069, 0x006A, 0x006B, 0x006C, 0x006D, 0x006E, 0x006F,
+ 0x0070, 0x0071, 0x0072, 0x0073, 0x0074, 0x0075, 0x0076, 0x0077,
+ 0x0078, 0x0079, 0x007A, 0x007B, 0x007C, 0x007D, 0x007E, NONE,
+ 0x00C4, 0x00C5, 0x00C7, 0x00C9, 0x00D1, 0x00D6, 0x00DC, 0x00E1,
+ 0x00E0, 0x00E2, 0x00E4, 0x00E3, 0x00E5, 0x00E7, 0x00E9, 0x00E8,
+ 0x00EA, 0x00EB, 0x00ED, 0x00EC, 0x00EE, 0x00EF, 0x00F1, 0x00F3,
+ 0x00F2, 0x00F4, 0x00F6, 0x00F5, 0x00FA, 0x00F9, 0x00FB, 0x00FC,
+ 0x2020, 0x00B0, 0x00A2, 0x00A3, 0x00A7, 0x2022, 0x00B6, 0x00DF,
+ 0x00AE, 0x00A9, 0x2122, 0x00B4, 0x00A8, 0x2260, 0x0102, 0x0218,
+ 0x221E, 0x00B1, 0x2264, 0x2265, 0x00A5, 0x00B5, 0x2202, 0x2211,
+ 0x220F, 0x03C0, 0x222B, 0x00AA, 0x00BA, 0x03A9, 0x0103, 0x0219,
+ 0x00BF, 0x00A1, 0x00AC, 0x221A, 0x0192, 0x2248, 0x2206, 0x00AB,
+ 0x00BB, 0x2026, 0x00A0, 0x00C0, 0x00C3, 0x00D5, 0x0152, 0x0153,
+ 0x2013, 0x2014, 0x201C, 0x201D, 0x2018, 0x2019, 0x00F7, 0x25CA,
+ 0x00FF, 0x0178, 0x2044, 0x20AC, 0x2039, 0x203A, 0x021A, 0x021B,
+ 0x2021, 0x00B7, 0x201A, 0x201E, 0x2030, 0x00C2, 0x00CA, 0x00C1,
+ 0x00CB, 0x00C8, 0x00CD, 0x00CE, 0x00CF, 0x00CC, 0x00D3, 0x00D4,
+ 0xF8FF, 0x00D2, 0x00DA, 0x00DB, 0x00D9, 0x0131, 0x02C6, 0x02DC,
+ 0x00AF, 0x02D8, 0x02D9, 0x02DA, 0x00B8, 0x02DD, 0x02DB, 0x02C7
+ };
+
+ public MacRomania()
+ {
+ super("MacRomania", new String[] {
+ });
+ lookupTable = lookup;
+ }
+
+} // class MacRomania
Added: llvm-gcc-4.2/trunk/libjava/classpath/gnu/java/nio/charset/MacSymbol.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/gnu/java/nio/charset/MacSymbol.java?rev=43913&view=auto
==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/gnu/java/nio/charset/MacSymbol.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/gnu/java/nio/charset/MacSymbol.java Thu Nov 8 16:56:19 2007
@@ -0,0 +1,89 @@
+/* MacSymbol.java -- Charset implementation for the MacSymbol character set.
+ Copyright (C) 2005 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 gnu.java.nio.charset;
+
+public class MacSymbol extends ByteCharset
+{
+
+ /**
+ * This is the lookup table for this encoding
+ */
+ private static final char[] lookup =
+ {
+ 0x0000, 0x0001, 0x0002, 0x0003, 0x0004, 0x0005, 0x0006, 0x0007,
+ 0x0008, 0x0009, 0x000A, 0x000B, 0x000C, 0x000D, 0x000E, 0x000F,
+ 0x0010, 0x0011, 0x0012, 0x0013, 0x0014, 0x0015, 0x0016, 0x0017,
+ 0x0018, 0x0019, 0x001A, 0x001B, 0x001C, 0x001D, 0x001E, 0x001F,
+ 0x0020, 0x0021, 0x2200, 0x0023, 0x2203, 0x0025, 0x0026, 0x220D,
+ 0x0028, 0x0029, 0x2217, 0x002B, 0x002C, 0x2212, 0x002E, 0x002F,
+ 0x0030, 0x0031, 0x0032, 0x0033, 0x0034, 0x0035, 0x0036, 0x0037,
+ 0x0038, 0x0039, 0x003A, 0x003B, 0x003C, 0x003D, 0x003E, 0x003F,
+ 0x2245, 0x0391, 0x0392, 0x03A7, 0x0394, 0x0395, 0x03A6, 0x0393,
+ 0x0397, 0x0399, 0x03D1, 0x039A, 0x039B, 0x039C, 0x039D, 0x039F,
+ 0x03A0, 0x0398, 0x03A1, 0x03A3, 0x03A4, 0x03A5, 0x03C2, 0x03A9,
+ 0x039E, 0x03A8, 0x0396, 0x005B, 0x2234, 0x005D, 0x22A5, 0x005F,
+ 0xF8E5, 0x03B1, 0x03B2, 0x03C7, 0x03B4, 0x03B5, 0x03C6, 0x03B3,
+ 0x03B7, 0x03B9, 0x03D5, 0x03BA, 0x03BB, 0x03BC, 0x03BD, 0x03BF,
+ 0x03C0, 0x03B8, 0x03C1, 0x03C3, 0x03C4, 0x03C5, 0x03D6, 0x03C9,
+ 0x03BE, 0x03C8, 0x03B6, 0x007B, 0x007C, 0x007D, 0x223C, NONE,
+ NONE, NONE, NONE, NONE, NONE, NONE, NONE, NONE,
+ NONE, NONE, NONE, NONE, NONE, NONE, NONE, NONE,
+ NONE, NONE, NONE, NONE, NONE, NONE, NONE, NONE,
+ NONE, NONE, NONE, NONE, NONE, NONE, NONE, NONE,
+ 0x20AC, 0x03D2, 0x2032, 0x2264, 0x2044, 0x221E, 0x0192, 0x2663,
+ 0x2666, 0x2665, 0x2660, 0x2194, 0x2190, 0x2191, 0x2192, 0x2193,
+ 0x00B0, 0x00B1, 0x2033, 0x2265, 0x00D7, 0x221D, 0x2202, 0x2022,
+ 0x00F7, 0x2260, 0x2261, 0x2248, 0x2026, 0xF8E6, 0x23AF, 0x21B5,
+ 0x2135, 0x2111, 0x211C, 0x2118, 0x2297, 0x2295, 0x2205, 0x2229,
+ 0x222A, 0x2283, 0x2287, 0x2284, 0x2282, 0x2286, 0x2208, 0x2209,
+ 0x2220, 0x2207, 0x00AE, 0x00A9, 0x2122, 0x220F, 0x221A, 0x22C5,
+ 0x00AC, 0x2227, 0x2228, 0x21D4, 0x21D0, 0x21D1, 0x21D2, 0x21D3,
+ 0x22C4, 0x3008, NONE, NONE, NONE, 0x2211, 0x239B, 0x239C,
+ 0x239D, 0x23A1, 0x23A2, 0x23A3, 0x23A7, 0x23A8, 0x23A9, 0x23AA,
+ 0xF8FF, 0x3009, 0x222B, 0x2320, 0x23AE, 0x2321, 0x239E, 0x239F,
+ 0x23A0, 0x23A4, 0x23A5, 0x23A6, 0x23AB, 0x23AC, 0x23AD, NONE
+ };
+
+ public MacSymbol()
+ {
+ super("MacSymbol", new String[] {
+ });
+ lookupTable = lookup;
+ }
+
+} // class MacSymbol
Added: llvm-gcc-4.2/trunk/libjava/classpath/gnu/java/nio/charset/MacThai.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/gnu/java/nio/charset/MacThai.java?rev=43913&view=auto
==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/gnu/java/nio/charset/MacThai.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/gnu/java/nio/charset/MacThai.java Thu Nov 8 16:56:19 2007
@@ -0,0 +1,89 @@
+/* MacThai.java -- Charset implementation for the MacThai character set.
+ Copyright (C) 2005 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 gnu.java.nio.charset;
+
+public class MacThai extends ByteCharset
+{
+
+ /**
+ * This is the lookup table for this encoding
+ */
+ private static final char[] lookup =
+ {
+ 0x0000, 0x0001, 0x0002, 0x0003, 0x0004, 0x0005, 0x0006, 0x0007,
+ 0x0008, 0x0009, 0x000A, 0x000B, 0x000C, 0x000D, 0x000E, 0x000F,
+ 0x0010, 0x0011, 0x0012, 0x0013, 0x0014, 0x0015, 0x0016, 0x0017,
+ 0x0018, 0x0019, 0x001A, 0x001B, 0x001C, 0x001D, 0x001E, 0x001F,
+ 0x0020, 0x0021, 0x0022, 0x0023, 0x0024, 0x0025, 0x0026, 0x0027,
+ 0x0028, 0x0029, 0x002A, 0x002B, 0x002C, 0x002D, 0x002E, 0x002F,
+ 0x0030, 0x0031, 0x0032, 0x0033, 0x0034, 0x0035, 0x0036, 0x0037,
+ 0x0038, 0x0039, 0x003A, 0x003B, 0x003C, 0x003D, 0x003E, 0x003F,
+ 0x0040, 0x0041, 0x0042, 0x0043, 0x0044, 0x0045, 0x0046, 0x0047,
+ 0x0048, 0x0049, 0x004A, 0x004B, 0x004C, 0x004D, 0x004E, 0x004F,
+ 0x0050, 0x0051, 0x0052, 0x0053, 0x0054, 0x0055, 0x0056, 0x0057,
+ 0x0058, 0x0059, 0x005A, 0x005B, 0x005C, 0x005D, 0x005E, 0x005F,
+ 0x0060, 0x0061, 0x0062, 0x0063, 0x0064, 0x0065, 0x0066, 0x0067,
+ 0x0068, 0x0069, 0x006A, 0x006B, 0x006C, 0x006D, 0x006E, 0x006F,
+ 0x0070, 0x0071, 0x0072, 0x0073, 0x0074, 0x0075, 0x0076, 0x0077,
+ 0x0078, 0x0079, 0x007A, 0x007B, 0x007C, 0x007D, 0x007E, NONE,
+ 0x00AB, 0x00BB, 0x2026, NONE, NONE, NONE, NONE, NONE,
+ NONE, NONE, NONE, NONE, NONE, 0x201C, 0x201D, NONE,
+ NONE, 0x2022, NONE, NONE, NONE, NONE, NONE, NONE,
+ NONE, NONE, NONE, NONE, NONE, 0x2018, 0x2019, NONE,
+ 0x00A0, 0x0E01, 0x0E02, 0x0E03, 0x0E04, 0x0E05, 0x0E06, 0x0E07,
+ 0x0E08, 0x0E09, 0x0E0A, 0x0E0B, 0x0E0C, 0x0E0D, 0x0E0E, 0x0E0F,
+ 0x0E10, 0x0E11, 0x0E12, 0x0E13, 0x0E14, 0x0E15, 0x0E16, 0x0E17,
+ 0x0E18, 0x0E19, 0x0E1A, 0x0E1B, 0x0E1C, 0x0E1D, 0x0E1E, 0x0E1F,
+ 0x0E20, 0x0E21, 0x0E22, 0x0E23, 0x0E24, 0x0E25, 0x0E26, 0x0E27,
+ 0x0E28, 0x0E29, 0x0E2A, 0x0E2B, 0x0E2C, 0x0E2D, 0x0E2E, 0x0E2F,
+ 0x0E30, 0x0E31, 0x0E32, 0x0E33, 0x0E34, 0x0E35, 0x0E36, 0x0E37,
+ 0x0E38, 0x0E39, 0x0E3A, 0x2060, 0x200B, 0x2013, 0x2014, 0x0E3F,
+ 0x0E40, 0x0E41, 0x0E42, 0x0E43, 0x0E44, 0x0E45, 0x0E46, 0x0E47,
+ 0x0E48, 0x0E49, 0x0E4A, 0x0E4B, 0x0E4C, 0x0E4D, 0x2122, 0x0E4F,
+ 0x0E50, 0x0E51, 0x0E52, 0x0E53, 0x0E54, 0x0E55, 0x0E56, 0x0E57,
+ 0x0E58, 0x0E59, 0x00AE, 0x00A9, NONE, NONE, NONE, NONE
+ };
+
+ public MacThai()
+ {
+ super("MacThai", new String[] {
+ });
+ lookupTable = lookup;
+ }
+
+} // class MacThai
Added: llvm-gcc-4.2/trunk/libjava/classpath/gnu/java/nio/charset/MacTurkish.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/gnu/java/nio/charset/MacTurkish.java?rev=43913&view=auto
==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/gnu/java/nio/charset/MacTurkish.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/gnu/java/nio/charset/MacTurkish.java Thu Nov 8 16:56:19 2007
@@ -0,0 +1,89 @@
+/* MacTurkish.java -- Charset implementation for the MacTurkish character set.
+ Copyright (C) 2005 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 gnu.java.nio.charset;
+
+public class MacTurkish extends ByteCharset
+{
+
+ /**
+ * This is the lookup table for this encoding
+ */
+ private static final char[] lookup =
+ {
+ 0x0000, 0x0001, 0x0002, 0x0003, 0x0004, 0x0005, 0x0006, 0x0007,
+ 0x0008, 0x0009, 0x000A, 0x000B, 0x000C, 0x000D, 0x000E, 0x000F,
+ 0x0010, 0x0011, 0x0012, 0x0013, 0x0014, 0x0015, 0x0016, 0x0017,
+ 0x0018, 0x0019, 0x001A, 0x001B, 0x001C, 0x001D, 0x001E, 0x001F,
+ 0x0020, 0x0021, 0x0022, 0x0023, 0x0024, 0x0025, 0x0026, 0x0027,
+ 0x0028, 0x0029, 0x002A, 0x002B, 0x002C, 0x002D, 0x002E, 0x002F,
+ 0x0030, 0x0031, 0x0032, 0x0033, 0x0034, 0x0035, 0x0036, 0x0037,
+ 0x0038, 0x0039, 0x003A, 0x003B, 0x003C, 0x003D, 0x003E, 0x003F,
+ 0x0040, 0x0041, 0x0042, 0x0043, 0x0044, 0x0045, 0x0046, 0x0047,
+ 0x0048, 0x0049, 0x004A, 0x004B, 0x004C, 0x004D, 0x004E, 0x004F,
+ 0x0050, 0x0051, 0x0052, 0x0053, 0x0054, 0x0055, 0x0056, 0x0057,
+ 0x0058, 0x0059, 0x005A, 0x005B, 0x005C, 0x005D, 0x005E, 0x005F,
+ 0x0060, 0x0061, 0x0062, 0x0063, 0x0064, 0x0065, 0x0066, 0x0067,
+ 0x0068, 0x0069, 0x006A, 0x006B, 0x006C, 0x006D, 0x006E, 0x006F,
+ 0x0070, 0x0071, 0x0072, 0x0073, 0x0074, 0x0075, 0x0076, 0x0077,
+ 0x0078, 0x0079, 0x007A, 0x007B, 0x007C, 0x007D, 0x007E, NONE,
+ 0x00C4, 0x00C5, 0x00C7, 0x00C9, 0x00D1, 0x00D6, 0x00DC, 0x00E1,
+ 0x00E0, 0x00E2, 0x00E4, 0x00E3, 0x00E5, 0x00E7, 0x00E9, 0x00E8,
+ 0x00EA, 0x00EB, 0x00ED, 0x00EC, 0x00EE, 0x00EF, 0x00F1, 0x00F3,
+ 0x00F2, 0x00F4, 0x00F6, 0x00F5, 0x00FA, 0x00F9, 0x00FB, 0x00FC,
+ 0x2020, 0x00B0, 0x00A2, 0x00A3, 0x00A7, 0x2022, 0x00B6, 0x00DF,
+ 0x00AE, 0x00A9, 0x2122, 0x00B4, 0x00A8, 0x2260, 0x00C6, 0x00D8,
+ 0x221E, 0x00B1, 0x2264, 0x2265, 0x00A5, 0x00B5, 0x2202, 0x2211,
+ 0x220F, 0x03C0, 0x222B, 0x00AA, 0x00BA, 0x03A9, 0x00E6, 0x00F8,
+ 0x00BF, 0x00A1, 0x00AC, 0x221A, 0x0192, 0x2248, 0x2206, 0x00AB,
+ 0x00BB, 0x2026, 0x00A0, 0x00C0, 0x00C3, 0x00D5, 0x0152, 0x0153,
+ 0x2013, 0x2014, 0x201C, 0x201D, 0x2018, 0x2019, 0x00F7, 0x25CA,
+ 0x00FF, 0x0178, 0x011E, 0x011F, 0x0130, 0x0131, 0x015E, 0x015F,
+ 0x2021, 0x00B7, 0x201A, 0x201E, 0x2030, 0x00C2, 0x00CA, 0x00C1,
+ 0x00CB, 0x00C8, 0x00CD, 0x00CE, 0x00CF, 0x00CC, 0x00D3, 0x00D4,
+ 0xF8FF, 0x00D2, 0x00DA, 0x00DB, 0x00D9, 0xF8A0, 0x02C6, 0x02DC,
+ 0x00AF, 0x02D8, 0x02D9, 0x02DA, 0x00B8, 0x02DD, 0x02DB, 0x02C7
+ };
+
+ public MacTurkish()
+ {
+ super("MacTurkish", new String[] {
+ });
+ lookupTable = lookup;
+ }
+
+} // class MacTurkish
Added: llvm-gcc-4.2/trunk/libjava/classpath/gnu/java/nio/charset/Provider.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/gnu/java/nio/charset/Provider.java?rev=43913&view=auto
==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/gnu/java/nio/charset/Provider.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/gnu/java/nio/charset/Provider.java Thu Nov 8 16:56:19 2007
@@ -0,0 +1,271 @@
+/* Provider.java --
+ Copyright (C) 2002, 2005, 2006 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 gnu.java.nio.charset;
+
+import java.nio.charset.Charset;
+import java.nio.charset.spi.CharsetProvider;
+import java.security.AccessController;
+import java.security.PrivilegedAction;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.Iterator;
+
+/**
+ * Charset provider for the required charsets. Used by
+ * {@link Charset#charsetForName} and * {@link Charset#availableCharsets}.
+ *
+ * Note: This class is a privileged class, because it can be instantiated without
+ * requiring the RuntimePermission("charsetProvider"). There is a check in
+ * java.nio.charset.spi.CharsetProvider to skip the security check if the provider
+ * is an instance of this class.
+ *
+ * @author Jesse Rosenstock
+ * @author Robert Schuster (thebohemian at gmx.net)
+ * @see Charset
+ */
+public final class Provider extends CharsetProvider
+{
+ private static Provider singleton;
+
+ /**
+ * Map from charset name to charset canonical name. The strings
+ * are all lower-case to allow case-insensitive retrieval of
+ * Charset instances.
+ */
+ private final HashMap canonicalNames;
+
+ /**
+ * Map from lower-case canonical name to Charset.
+ * TODO: We may want to use soft references. We would then need to keep
+ * track of the class name to regenerate the object.
+ */
+ private final HashMap charsets;
+
+ /**
+ * We don't load all available charsets at the start
+ */
+ private boolean extendedLoaded;
+
+ // Package private to avoid an accessor method in PrivilegedAction below.
+ Provider ()
+ {
+ extendedLoaded = false;
+ canonicalNames = new HashMap ();
+ charsets = new HashMap ();
+
+ // US-ASCII aka ISO646-US
+ addCharset (new US_ASCII ());
+
+ // ISO-8859-1 aka ISO-LATIN-1
+ addCharset (new ISO_8859_1 ());
+
+ // UTF-8
+ addCharset (new UTF_8 ());
+
+ // UTF-16BE
+ addCharset (new UTF_16BE ());
+
+ // UTF-16LE
+ addCharset (new UTF_16LE ());
+
+ // UTF-16
+ addCharset (new UTF_16 ());
+
+ // UTF-16LE (marked)
+ addCharset (new UnicodeLittle ());
+
+ // Windows-1250 aka cp-1250 (East European)
+ addCharset (new Windows1250 ());
+
+ // Windows-1251 (Cyrillic)
+ addCharset (new Windows1251 ());
+
+ // Windows-1252 aka cp-1252 (Latin-1)
+ addCharset (new Windows1252 ());
+
+ // Windows-1253 (Greek)
+ addCharset (new Windows1253 ());
+
+ // Windows-1254 (Turkish)
+ addCharset (new Windows1254 ());
+
+ // Windows-1257 (Baltic)
+ addCharset (new Windows1257 ());
+
+ // ISO-8859-2 aka ISO-LATIN-2
+ addCharset (new ISO_8859_2 ());
+
+ // ISO-8859-4 aka ISO-LATIN-4
+ addCharset (new ISO_8859_4 ());
+
+ // ISO-8859-5 (Cyrillic)
+ addCharset (new ISO_8859_5 ());
+
+ // ISO-8859-7 (Greek)
+ addCharset (new ISO_8859_7 ());
+
+ // ISO-8859-9 aka ISO-LATIN-5
+ addCharset (new ISO_8859_9 ());
+
+ // ISO-8859-13 aka ISO-LATIN-7
+ addCharset (new ISO_8859_13 ());
+
+ // ISO-8859-15 aka ISO-LATIN-9
+ addCharset (new ISO_8859_15 ());
+
+ // KOI8 (Cyrillic)
+ addCharset (new KOI_8 ());
+ }
+
+ /**
+ * Load non-mandatory charsets.
+ */
+ private synchronized void loadExtended ()
+ {
+ if (extendedLoaded)
+ return;
+
+ addCharset (new ISO_8859_3 ()); // ISO-8859-3 aka ISO-LATIN-3
+ addCharset (new ISO_8859_6 ()); // ISO-8859-6 (Arabic)
+ addCharset (new ISO_8859_8 ()); // ISO-8859-8 (Hebrew)
+
+ // Some more codepages
+ addCharset (new Cp424());
+ addCharset (new Cp437());
+ addCharset (new Cp737());
+ addCharset (new Cp775());
+ addCharset (new Cp850());
+ addCharset (new Cp852());
+ addCharset (new Cp855()); // IBM Cyrillic
+ addCharset (new Cp857()); // IBM Turkish
+ addCharset (new Cp860()); // MSDOS Portugese
+ addCharset (new Cp861()); // MSDOS Icelandic
+ addCharset (new Cp862()); // PC Hebrew
+ addCharset (new Cp863()); // MSDOS Can. French
+ addCharset (new Cp864()); // PC Arabic
+ addCharset (new Cp865()); // MSDOS Nordic
+ addCharset (new Cp866()); // MSDOS Russian
+ addCharset (new Cp869()); // IBM modern Greek
+ addCharset (new Cp874()); // IBM Thai
+
+ addCharset (new MacCentralEurope());
+ addCharset (new MacCroatian());
+ addCharset (new MacCyrillic());
+ addCharset (new MacDingbat());
+ addCharset (new MacGreek());
+ addCharset (new MacIceland());
+ addCharset (new MacRoman());
+ addCharset (new MacRomania());
+ addCharset (new MacSymbol());
+ addCharset (new MacThai());
+ addCharset (new MacTurkish());
+ addCharset (new MS874());
+
+ addCharset (new Windows1255());
+ addCharset (new Windows1256());
+ addCharset (new Windows1258());
+
+ extendedLoaded = true;
+ }
+
+ public Iterator charsets ()
+ {
+ loadExtended();
+ return Collections.unmodifiableCollection (charsets.values ())
+ .iterator ();
+ }
+
+ /**
+ * Returns a Charset instance by converting the given
+ * name to lower-case, looking up the canonical charset
+ * name and finally looking up the Charset with that name.
+ *
+ * <p>The lookup is therefore case-insensitive.</p>
+ *
+ * @returns The Charset having <code>charsetName</code>
+ * as its alias or null if no such Charset exist.
+ */
+ public Charset charsetForName (String charsetName)
+ {
+ Charset cs = (Charset) charsets.get(canonicalNames.get(charsetName.toLowerCase()));
+ if (cs == null)
+ {
+ loadExtended();
+ cs = (Charset) charsets.get(canonicalNames.get(charsetName.toLowerCase()));
+ }
+ return cs;
+ }
+
+ /**
+ * Puts a Charset under its canonical name into the 'charsets' map.
+ * Then puts a mapping from all its alias names to the canonical name.
+ *
+ * <p>All names are converted to lower-case</p>.
+ *
+ * @param cs
+ */
+ private void addCharset (Charset cs)
+ {
+ String canonicalName = cs.name().toLowerCase();
+ charsets.put (canonicalName, cs);
+
+ /* Adds a mapping between the canonical name
+ * itself making a lookup using that name
+ * no special case.
+ */
+ canonicalNames.put(canonicalName, canonicalName);
+
+ for (Iterator i = cs.aliases ().iterator (); i.hasNext (); )
+ canonicalNames.put (((String) i.next()).toLowerCase(), canonicalName);
+ }
+
+ public static synchronized Provider provider ()
+ {
+ // The default provider is safe to instantiate.
+ if (singleton == null)
+ singleton = (Provider) AccessController.doPrivileged
+ (new PrivilegedAction()
+ {
+ public Object run()
+ {
+ return new Provider();
+ }
+ });
+ return singleton;
+ }
+}
Added: llvm-gcc-4.2/trunk/libjava/classpath/gnu/java/nio/charset/US_ASCII.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/gnu/java/nio/charset/US_ASCII.java?rev=43913&view=auto
==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/gnu/java/nio/charset/US_ASCII.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/gnu/java/nio/charset/US_ASCII.java Thu Nov 8 16:56:19 2007
@@ -0,0 +1,174 @@
+/* US_ASCII.java --
+ Copyright (C) 2002, 2004, 2005 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 gnu.java.nio.charset;
+
+import java.nio.ByteBuffer;
+import java.nio.CharBuffer;
+import java.nio.charset.Charset;
+import java.nio.charset.CharsetDecoder;
+import java.nio.charset.CharsetEncoder;
+import java.nio.charset.CoderResult;
+
+/**
+ * US-ASCII charset.
+ *
+ * @author Jesse Rosenstock
+ */
+final class US_ASCII extends Charset
+{
+ US_ASCII ()
+ {
+ /* Canonical charset name chosen according to:
+ * http://java.sun.com/j2se/1.5.0/docs/guide/intl/encoding.doc.html
+ */
+ super ("US-ASCII", new String[] {
+ /* These names are provided by
+ * http://www.iana.org/assignments/character-sets
+ */
+ "iso-ir-6",
+ "ANSI_X3.4-1986",
+ "ISO_646.irv:1991",
+ "ASCII",
+ "ISO646-US",
+ "ASCII",
+ "us",
+ "IBM367",
+ "cp367",
+ "csASCII",
+ /* These names are provided by
+ * http://oss.software.ibm.com/cgi-bin/icu/convexp?s=ALL
+ */
+ "ANSI_X3.4-1968", "iso_646.irv:1983", "ascii7", "646",
+ "windows-20127"
+ });
+ }
+
+ public boolean contains (Charset cs)
+ {
+ return cs instanceof US_ASCII;
+ }
+
+ public CharsetDecoder newDecoder ()
+ {
+ return new Decoder (this);
+ }
+
+ public CharsetEncoder newEncoder ()
+ {
+ return new Encoder (this);
+ }
+
+ private static final class Decoder extends CharsetDecoder
+ {
+ // Package-private to avoid a trampoline constructor.
+ Decoder (Charset cs)
+ {
+ super (cs, 1.0f, 1.0f);
+ }
+
+ protected CoderResult decodeLoop (ByteBuffer in, CharBuffer out)
+ {
+ // TODO: Optimize this in the case in.hasArray() / out.hasArray()
+ while (in.hasRemaining ())
+ {
+ byte b = in.get ();
+
+ if (b < 0)
+ {
+ in.position (in.position () - 1);
+ return CoderResult.malformedForLength (1);
+ }
+ if (!out.hasRemaining ())
+ {
+ in.position (in.position () - 1);
+ return CoderResult.OVERFLOW;
+ }
+
+ out.put ((char) b);
+ }
+
+ return CoderResult.UNDERFLOW;
+ }
+ }
+
+ private static final class Encoder extends CharsetEncoder
+ {
+ // Package-private to avoid a trampoline constructor.
+ Encoder (Charset cs)
+ {
+ super (cs, 1.0f, 1.0f);
+ }
+
+ public boolean canEncode(char c)
+ {
+ return c <= 0x7f;
+ }
+
+ public boolean canEncode(CharSequence cs)
+ {
+ for (int i = 0; i < cs.length(); ++i)
+ if (! canEncode(cs.charAt(i)))
+ return false;
+ return true;
+ }
+
+ protected CoderResult encodeLoop (CharBuffer in, ByteBuffer out)
+ {
+ // TODO: Optimize this in the case in.hasArray() / out.hasArray()
+ while (in.hasRemaining ())
+ {
+ char c = in.get ();
+
+ if (c > 0x7f)
+ {
+ in.position (in.position () - 1);
+ return CoderResult.unmappableForLength (1);
+ }
+ if (!out.hasRemaining ())
+ {
+ in.position (in.position () - 1);
+ return CoderResult.OVERFLOW;
+ }
+
+ out.put ((byte) c);
+ }
+
+ return CoderResult.UNDERFLOW;
+ }
+ }
+}
Added: llvm-gcc-4.2/trunk/libjava/classpath/gnu/java/nio/charset/UTF_16.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/gnu/java/nio/charset/UTF_16.java?rev=43913&view=auto
==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/gnu/java/nio/charset/UTF_16.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/gnu/java/nio/charset/UTF_16.java Thu Nov 8 16:56:19 2007
@@ -0,0 +1,80 @@
+/* UTF_16.java --
+ Copyright (C) 2002, 2004, 2005 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 gnu.java.nio.charset;
+
+import java.nio.charset.Charset;
+import java.nio.charset.CharsetDecoder;
+import java.nio.charset.CharsetEncoder;
+
+/**
+ * UTF-16 charset.
+ *
+ * @author Jesse Rosenstock
+ */
+final class UTF_16 extends Charset
+{
+ UTF_16 ()
+ {
+ super ("UTF-16", new String[] {
+ // witnessed by the internet
+ "UTF16",
+ /* These names are provided by
+ * http://oss.software.ibm.com/cgi-bin/icu/convexp?s=ALL
+ */
+ "ISO-10646-UCS-2", "unicode", "csUnicode", "ucs-2", "UnicodeBig"
+ });
+ }
+
+ public boolean contains (Charset cs)
+ {
+ return cs instanceof US_ASCII || cs instanceof ISO_8859_1
+ || cs instanceof UTF_8 || cs instanceof UTF_16BE
+ || cs instanceof UTF_16LE || cs instanceof UTF_16;
+ }
+
+ public CharsetDecoder newDecoder ()
+ {
+ return new UTF_16Decoder (this, UTF_16Decoder.UNKNOWN_ENDIAN);
+ }
+
+ public CharsetEncoder newEncoder ()
+ {
+ return new UTF_16Encoder (this, UTF_16Encoder.BIG_ENDIAN, true);
+ }
+}
Added: llvm-gcc-4.2/trunk/libjava/classpath/gnu/java/nio/charset/UTF_16BE.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/gnu/java/nio/charset/UTF_16BE.java?rev=43913&view=auto
==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/gnu/java/nio/charset/UTF_16BE.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/gnu/java/nio/charset/UTF_16BE.java Thu Nov 8 16:56:19 2007
@@ -0,0 +1,84 @@
+/* UTF_16BE.java --
+ Copyright (C) 2002, 2004, 2005 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 gnu.java.nio.charset;
+
+import java.nio.charset.Charset;
+import java.nio.charset.CharsetDecoder;
+import java.nio.charset.CharsetEncoder;
+
+/**
+ * UTF-16BE charset.
+ *
+ * @author Jesse Rosenstock
+ */
+final class UTF_16BE extends Charset
+{
+ UTF_16BE ()
+ {
+ super ("UTF-16BE", new String[] {
+ // witnessed by the internet
+ "UTF16BE",
+ /* These names are provided by
+ * http://oss.software.ibm.com/cgi-bin/icu/convexp?s=ALL
+ */
+ "x-utf-16be", "ibm-1200", "ibm-1201", "ibm-5297",
+ "ibm-13488", "ibm-17584", "windows-1201", "cp1200", "cp1201",
+ "UTF16_BigEndian",
+ // see http://java.sun.com/j2se/1.5.0/docs/guide/intl/encoding.doc.html
+ "UnicodeBigUnmarked"
+ });
+ }
+
+ public boolean contains (Charset cs)
+ {
+ return cs instanceof US_ASCII || cs instanceof ISO_8859_1
+ || cs instanceof UTF_8 || cs instanceof UTF_16BE
+ || cs instanceof UTF_16LE || cs instanceof UTF_16;
+ }
+
+ public CharsetDecoder newDecoder ()
+ {
+ return new UTF_16Decoder (this, UTF_16Decoder.BIG_ENDIAN);
+ }
+
+ public CharsetEncoder newEncoder ()
+ {
+ return new UTF_16Encoder (this, UTF_16Encoder.BIG_ENDIAN, false);
+ }
+}
Added: llvm-gcc-4.2/trunk/libjava/classpath/gnu/java/nio/charset/UTF_16Decoder.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/gnu/java/nio/charset/UTF_16Decoder.java?rev=43913&view=auto
==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/gnu/java/nio/charset/UTF_16Decoder.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/gnu/java/nio/charset/UTF_16Decoder.java Thu Nov 8 16:56:19 2007
@@ -0,0 +1,167 @@
+/* UTF_16Decoder.java --
+ Copyright (C) 2002, 2005 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 gnu.java.nio.charset;
+
+import java.nio.ByteBuffer;
+import java.nio.CharBuffer;
+import java.nio.charset.Charset;
+import java.nio.charset.CharsetDecoder;
+import java.nio.charset.CoderResult;
+
+/**
+ * Decoder for UTF-16, UTF-15LE, and UTF-16BE.
+ *
+ * @author Jesse Rosenstock
+ */
+final class UTF_16Decoder extends CharsetDecoder
+{
+ // byte orders
+ static final int BIG_ENDIAN = 0;
+ static final int LITTLE_ENDIAN = 1;
+ static final int UNKNOWN_ENDIAN = 2;
+ static final int MAYBE_BIG_ENDIAN = 3;
+ static final int MAYBE_LITTLE_ENDIAN = 4;
+
+ private static final char BYTE_ORDER_MARK = 0xFEFF;
+ private static final char REVERSED_BYTE_ORDER_MARK = 0xFFFE;
+
+ private final int originalByteOrder;
+ private int byteOrder;
+
+ UTF_16Decoder (Charset cs, int byteOrder)
+ {
+ super (cs, 0.5f, 1.0f);
+ this.originalByteOrder = byteOrder;
+ this.byteOrder = byteOrder;
+ }
+
+ protected CoderResult decodeLoop (ByteBuffer in, CharBuffer out)
+ {
+ // TODO: Optimize this in the case in.hasArray() / out.hasArray()
+
+ int inPos = in.position ();
+ try
+ {
+ while (in.remaining () >= 2)
+ {
+ byte b1 = in.get ();
+ byte b2 = in.get ();
+
+ // handle byte order mark
+ if (byteOrder == UNKNOWN_ENDIAN ||
+ byteOrder == MAYBE_BIG_ENDIAN ||
+ byteOrder == MAYBE_LITTLE_ENDIAN)
+ {
+ char c = (char) (((b1 & 0xFF) << 8) | (b2 & 0xFF));
+ if (c == BYTE_ORDER_MARK)
+ {
+ if (byteOrder == MAYBE_LITTLE_ENDIAN)
+ {
+ return CoderResult.malformedForLength (2);
+ }
+ byteOrder = BIG_ENDIAN;
+ inPos += 2;
+ continue;
+ }
+ else if (c == REVERSED_BYTE_ORDER_MARK)
+ {
+ if (byteOrder == MAYBE_BIG_ENDIAN)
+ {
+ return CoderResult.malformedForLength (2);
+ }
+ byteOrder = LITTLE_ENDIAN;
+ inPos += 2;
+ continue;
+ }
+ else
+ {
+ // assume big or little endian, do not consume bytes,
+ // continue with normal processing
+ byteOrder = (byteOrder == MAYBE_LITTLE_ENDIAN ?
+ LITTLE_ENDIAN : BIG_ENDIAN);
+ }
+ }
+
+ // FIXME: Change so you only do a single comparison here.
+ char c = (byteOrder == BIG_ENDIAN
+ ? (char) (((b1 & 0xFF) << 8) | (b2 & 0xFF))
+ : (char) (((b2 & 0xFF) << 8) | (b1 & 0xFF)));
+
+ if (0xD800 <= c && c <= 0xDFFF)
+ {
+ // c is a surrogate
+
+ // make sure c is a high surrogate
+ if (c > 0xDBFF)
+ return CoderResult.malformedForLength (2);
+ if (in.remaining () < 2)
+ return CoderResult.UNDERFLOW;
+ byte b3 = in.get ();
+ byte b4 = in.get ();
+ char d = (byteOrder == BIG_ENDIAN
+ ? (char) (((b3 & 0xFF) << 8) | (b4 & 0xFF))
+ : (char) (((b4 & 0xFF) << 8) | (b3 & 0xFF)));
+ // make sure d is a low surrogate
+ if (d < 0xDC00 || d > 0xDFFF)
+ return CoderResult.malformedForLength (2);
+ out.put (c);
+ out.put (d);
+ inPos += 4;
+ }
+ else
+ {
+ if (!out.hasRemaining ())
+ return CoderResult.UNDERFLOW;
+ out.put (c);
+ inPos += 2;
+ }
+ }
+
+ return CoderResult.UNDERFLOW;
+ }
+ finally
+ {
+ in.position (inPos);
+ }
+ }
+
+ protected void implReset ()
+ {
+ byteOrder = originalByteOrder;
+ }
+}
Added: llvm-gcc-4.2/trunk/libjava/classpath/gnu/java/nio/charset/UTF_16Encoder.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/gnu/java/nio/charset/UTF_16Encoder.java?rev=43913&view=auto
==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/gnu/java/nio/charset/UTF_16Encoder.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/gnu/java/nio/charset/UTF_16Encoder.java Thu Nov 8 16:56:19 2007
@@ -0,0 +1,145 @@
+/* UTF_16Encoder.java --
+ Copyright (C) 2002 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 gnu.java.nio.charset;
+
+import java.nio.ByteBuffer;
+import java.nio.ByteOrder;
+import java.nio.CharBuffer;
+import java.nio.charset.Charset;
+import java.nio.charset.CharsetEncoder;
+import java.nio.charset.CoderResult;
+
+/**
+ * Encoder for UTF-16, UTF-15LE, and UTF-16BE.
+ *
+ * @author Jesse Rosenstock
+ */
+final class UTF_16Encoder extends CharsetEncoder
+{
+ // byte orders
+ static final int BIG_ENDIAN = 0;
+ static final int LITTLE_ENDIAN = 1;
+
+ private static final char BYTE_ORDER_MARK = 0xFEFF;
+
+ private final ByteOrder byteOrder;
+ private final boolean useByteOrderMark;
+ private boolean needsByteOrderMark;
+
+ UTF_16Encoder (Charset cs, int byteOrder, boolean useByteOrderMark)
+ {
+ super (cs, 2.0f,
+ useByteOrderMark ? 4.0f : 2.0f,
+ byteOrder == BIG_ENDIAN
+ ? new byte[] { (byte) 0xFF, (byte) 0xFD }
+ : new byte[] { (byte) 0xFD, (byte) 0xFF });
+ this.byteOrder = (byteOrder == BIG_ENDIAN) ?
+ ByteOrder.BIG_ENDIAN : ByteOrder.LITTLE_ENDIAN;
+ this.useByteOrderMark = useByteOrderMark;
+ this.needsByteOrderMark = useByteOrderMark;
+ }
+
+ protected CoderResult encodeLoop (CharBuffer in, ByteBuffer out)
+ {
+ // TODO: Optimize this in the case in.hasArray() / out.hasArray()
+
+ ByteOrder originalBO = out.order();
+ out.order(byteOrder);
+
+ if (needsByteOrderMark)
+ {
+ if (out.remaining () < 2)
+ {
+ out.order(originalBO);
+ return CoderResult.OVERFLOW;
+ }
+ out.putChar (BYTE_ORDER_MARK);
+ needsByteOrderMark = false;
+ }
+
+ int inPos = in.position ();
+ try
+ {
+ while (in.hasRemaining ())
+ {
+ char c = in.get ();
+ if (0xD800 <= c && c <= 0xDFFF)
+ {
+ // c is a surrogate
+
+ // make sure c is a high surrogate
+ if (c > 0xDBFF)
+ return CoderResult.malformedForLength (1);
+ if (in.remaining () < 1)
+ return CoderResult.UNDERFLOW;
+ char d = in.get ();
+ // make sure d is a low surrogate
+ if (d < 0xDC00 || d > 0xDFFF)
+ return CoderResult.malformedForLength (1);
+ out.putChar (c);
+ out.putChar (d);
+ inPos += 2;
+ }
+ else
+ {
+ if (out.remaining () < 2)
+ {
+ out.order(originalBO);
+ return CoderResult.OVERFLOW;
+ }
+ out.putChar (c);
+ inPos++;
+ }
+ }
+ out.order(originalBO);
+ return CoderResult.UNDERFLOW;
+ }
+ finally
+ {
+ in.position (inPos);
+ }
+ }
+
+ protected void implReset ()
+ {
+ needsByteOrderMark = useByteOrderMark;
+ }
+
+ // TODO: override canEncode(char) and canEncode(CharSequence)
+ // for performance
+}
Added: llvm-gcc-4.2/trunk/libjava/classpath/gnu/java/nio/charset/UTF_16LE.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/gnu/java/nio/charset/UTF_16LE.java?rev=43913&view=auto
==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/gnu/java/nio/charset/UTF_16LE.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/gnu/java/nio/charset/UTF_16LE.java Thu Nov 8 16:56:19 2007
@@ -0,0 +1,83 @@
+/* UTF_16LE.java --
+ Copyright (C) 2002, 2004, 2005 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 gnu.java.nio.charset;
+
+import java.nio.charset.Charset;
+import java.nio.charset.CharsetDecoder;
+import java.nio.charset.CharsetEncoder;
+
+/**
+ * UTF-16LE charset.
+ *
+ * @author Jesse Rosenstock
+ */
+final class UTF_16LE extends Charset
+{
+ UTF_16LE ()
+ {
+ super ("UTF-16LE", new String[] {
+ // witnessed by the internet
+ "UTF16LE",
+ /* These names are provided by
+ * http://oss.software.ibm.com/cgi-bin/icu/convexp?s=ALL
+ */
+ "x-utf-16le", "ibm-1202", "ibm-13490", "ibm-17586",
+ "UTF16_LittleEndian",
+ // see http://java.sun.com/j2se/1.5.0/docs/guide/intl/encoding.doc.html
+ "UnicodeLittleUnmarked"
+ });
+ }
+
+ public boolean contains (Charset cs)
+ {
+ return cs instanceof US_ASCII || cs instanceof ISO_8859_1
+ || cs instanceof UTF_8 || cs instanceof UTF_16BE
+ || cs instanceof UTF_16LE || cs instanceof UTF_16;
+ }
+
+ public CharsetDecoder newDecoder ()
+ {
+ return new UTF_16Decoder (this, UTF_16Decoder.LITTLE_ENDIAN);
+ }
+
+ public CharsetEncoder newEncoder ()
+ {
+ return new UTF_16Encoder (this, UTF_16Encoder.LITTLE_ENDIAN, false);
+ }
+}
Added: llvm-gcc-4.2/trunk/libjava/classpath/gnu/java/nio/charset/UTF_8.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/gnu/java/nio/charset/UTF_8.java?rev=43913&view=auto
==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/gnu/java/nio/charset/UTF_8.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/gnu/java/nio/charset/UTF_8.java Thu Nov 8 16:56:19 2007
@@ -0,0 +1,311 @@
+/* UTF_8.java --
+ Copyright (C) 2002, 2004, 2005 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 gnu.java.nio.charset;
+
+import java.nio.ByteBuffer;
+import java.nio.CharBuffer;
+import java.nio.charset.Charset;
+import java.nio.charset.CharsetDecoder;
+import java.nio.charset.CharsetEncoder;
+import java.nio.charset.CoderResult;
+
+/**
+ * UTF-8 charset.
+ *
+ * <p> UTF-8 references:
+ * <ul>
+ * <li> <a href="http://ietf.org/rfc/rfc2279.txt">RFC 2279</a>
+ * <li> The <a href="http://www.unicode.org/unicode/standard/standard.html">
+ * Unicode standard</a> and
+ * <a href="http://www.unicode.org/versions/corrigendum1.html">
+ * Corrigendum</a>
+ * </ul>
+ *
+ * @author Jesse Rosenstock
+ */
+final class UTF_8 extends Charset
+{
+ UTF_8 ()
+ {
+ super ("UTF-8", new String[] {
+ /* These names are provided by
+ * http://oss.software.ibm.com/cgi-bin/icu/convexp?s=ALL
+ */
+ "ibm-1208", "ibm-1209", "ibm-5304", "ibm-5305",
+ "windows-65001", "cp1208",
+ // see http://java.sun.com/j2se/1.5.0/docs/guide/intl/encoding.doc.html
+ "UTF8"
+ });
+ }
+
+ public boolean contains (Charset cs)
+ {
+ return cs instanceof US_ASCII || cs instanceof ISO_8859_1
+ || cs instanceof UTF_8 || cs instanceof UTF_16BE
+ || cs instanceof UTF_16LE || cs instanceof UTF_16;
+ }
+
+ public CharsetDecoder newDecoder ()
+ {
+ return new Decoder (this);
+ }
+
+ public CharsetEncoder newEncoder ()
+ {
+ return new Encoder (this);
+ }
+
+ private static final class Decoder extends CharsetDecoder
+ {
+ // Package-private to avoid a trampoline constructor.
+ Decoder (Charset cs)
+ {
+ super (cs, 1f, 1f);
+ }
+
+ protected CoderResult decodeLoop (ByteBuffer in, CharBuffer out)
+ {
+ // TODO: Optimize this in the case in.hasArray() / out.hasArray()
+ int inPos = in.position();
+ try
+ {
+ while (in.hasRemaining ())
+ {
+ char c;
+ byte b1 = in.get ();
+ int highNibble = ((b1 & 0xFF) >> 4) & 0xF;
+ switch (highNibble)
+ {
+ case 0: case 1: case 2: case 3:
+ case 4: case 5: case 6: case 7:
+ if (out.remaining () < 1)
+ return CoderResult.OVERFLOW;
+ out.put ((char) b1);
+ inPos++;
+ break;
+
+ case 0xC: case 0xD:
+ byte b2;
+ if (in.remaining () < 1)
+ return CoderResult.UNDERFLOW;
+ if (out.remaining () < 1)
+ return CoderResult.OVERFLOW;
+ if (!isContinuation (b2 = in.get ()))
+ return CoderResult.malformedForLength (1);
+ c = (char) (((b1 & 0x1F) << 6) | (b2 & 0x3F));
+ // check that we had the shortest encoding
+ if (c <= 0x7F)
+ return CoderResult.malformedForLength (2);
+ out.put (c);
+ inPos += 2;
+ break;
+
+ case 0xE:
+ byte b3;
+ if (in.remaining () < 2)
+ return CoderResult.UNDERFLOW;
+ if (out.remaining () < 1)
+ return CoderResult.OVERFLOW;
+ if (!isContinuation (b2 = in.get ()))
+ return CoderResult.malformedForLength (1);
+ if (!isContinuation (b3 = in.get ()))
+ return CoderResult.malformedForLength (1);
+ c = (char) (((b1 & 0x0F) << 12)
+ | ((b2 & 0x3F) << 6)
+ | (b3 & 0x3F));
+ // check that we had the shortest encoding
+ if (c <= 0x7FF)
+ return CoderResult.malformedForLength (3);
+ out.put (c);
+ inPos += 3;
+ break;
+
+ case 0xF:
+ byte b4;
+ if (in.remaining () < 3)
+ return CoderResult.UNDERFLOW;
+ if((b1&0x0F) > 4)
+ return CoderResult.malformedForLength (4);
+ if (out.remaining () < 2)
+ return CoderResult.OVERFLOW;
+ if (!isContinuation (b2 = in.get ()))
+ return CoderResult.malformedForLength (3);
+ if (!isContinuation (b3 = in.get ()))
+ return CoderResult.malformedForLength (2);
+ if (!isContinuation (b4 = in.get ()))
+ return CoderResult.malformedForLength (1);
+ int n = (((b1 & 0x3) << 18)
+ | ((b2 & 0x3F) << 12)
+ | ((b3 & 0x3F) << 6)
+ | (b4 & 0x3F)) - 0x10000;
+ char c1 = (char)(0xD800 | (n & 0xFFC00)>>10);
+ char c2 = (char)(0xDC00 | (n & 0x003FF));
+ out.put (c1);
+ out.put (c2);
+ inPos += 4;
+ break;
+
+ default:
+ return CoderResult.malformedForLength (1);
+ }
+ }
+
+ return CoderResult.UNDERFLOW;
+ }
+ finally
+ {
+ // In case we did a get(), then encountered an error, reset the
+ // position to before the error. If there was no error, this
+ // will benignly reset the position to the value it already has.
+ in.position (inPos);
+ }
+ }
+
+ private static boolean isContinuation (byte b)
+ {
+ return (b & 0xC0) == 0x80;
+ }
+ }
+
+ private static final class Encoder extends CharsetEncoder
+ {
+ // Package-private to avoid a trampoline constructor.
+ Encoder (Charset cs)
+ {
+ // According to
+ // http://www-106.ibm.com/developerworks/unicode/library/utfencodingforms/index.html
+ // On average, English takes slightly over one unit per code point.
+ // Most Latin-script languages take about 1.1 bytes. Greek, Russian,
+ // Arabic and Hebrew take about 1.7 bytes, and most others (including
+ // Japanese, Chinese, Korean and Hindi) take about 3 bytes.
+ // We assume we will be dealing with latin scripts, and use 1.1
+ // for averageBytesPerChar.
+ super (cs, 1.1f, 4.0f);
+ }
+
+ protected CoderResult encodeLoop (CharBuffer in, ByteBuffer out)
+ {
+ int inPos = in.position();
+ try
+ {
+ // TODO: Optimize this in the case in.hasArray() / out.hasArray()
+ while (in.hasRemaining ())
+ {
+ int remaining = out.remaining ();
+ char c = in.get ();
+
+ // UCS-4 range (hex.) UTF-8 octet sequence (binary)
+ // 0000 0000-0000 007F 0xxxxxxx
+ // 0000 0080-0000 07FF 110xxxxx 10xxxxxx
+ // 0000 0800-0000 FFFF 1110xxxx 10xxxxxx 10xxxxxx
+
+ // Scalar Value UTF-16 byte 1 byte 2 byte 3 byte 4
+ // 0000 0000 0xxx xxxx 0000 0000 0xxx xxxx 0xxx xxxx
+ // 0000 0yyy yyxx xxxx 0000 0yyy yyxx xxxx 110y yyyy 10xx xxxx
+ // zzzz yyyy yyxx xxxx zzzz yyyy yyxx xxxx 1110 zzzz 10yy yyyy 10xx xxxx
+ // u uuuu zzzz yyyy yyxx xxxx 1101 10ww wwzz zzyy 1111 0uuu 10uu zzzz 10yy yyyy 10xx xxxx
+ // + 1101 11yy yyxx xxxx
+ // Note: uuuuu = wwww + 1
+ if (c <= 0x7F)
+ {
+ if (remaining < 1)
+ return CoderResult.OVERFLOW;
+ out.put ((byte) c);
+ inPos++;
+ }
+ else if (c <= 0x7FF)
+ {
+ if (remaining < 2)
+ return CoderResult.OVERFLOW;
+ out.put ((byte) (0xC0 | (c >> 6)));
+ out.put ((byte) (0x80 | (c & 0x3F)));
+ inPos++;
+ }
+ else if (0xD800 <= c && c <= 0xDFFF)
+ {
+ if (remaining < 4)
+ return CoderResult.OVERFLOW;
+
+ // we got a low surrogate without a preciding high one
+ if (c > 0xDBFF)
+ return CoderResult.malformedForLength (1);
+
+ // high surrogates
+ if (!in.hasRemaining ())
+ return CoderResult.UNDERFLOW;
+
+ char d = in.get ();
+
+ // make sure d is a low surrogate
+ if (d < 0xDC00 || d > 0xDFFF)
+ return CoderResult.malformedForLength (1);
+
+ // make the 32 bit value
+ // int value2 = (c - 0xD800) * 0x400 + (d - 0xDC00) + 0x10000;
+ int value = (((c & 0x3FF) << 10) | (d & 0x3FF)) + 0x10000;
+ // assert value == value2;
+ out.put ((byte) (0xF0 | ((value >> 18) & 0x07)));
+ out.put ((byte) (0x80 | ((value >> 12) & 0x3F)));
+ out.put ((byte) (0x80 | ((value >> 6) & 0x3F)));
+ out.put ((byte) (0x80 | ((value ) & 0x3F)));
+ inPos += 2;
+ }
+ else
+ {
+ if (remaining < 3)
+ return CoderResult.OVERFLOW;
+
+ out.put ((byte) (0xE0 | (c >> 12)));
+ out.put ((byte) (0x80 | ((c >> 6) & 0x3F)));
+ out.put ((byte) (0x80 | (c & 0x3F)));
+ inPos++;
+ }
+ }
+
+ return CoderResult.UNDERFLOW;
+ }
+ finally
+ {
+ // In case we did a get(), then encountered an error, reset the
+ // position to before the error. If there was no error, this
+ // will benignly reset the position to the value it already has.
+ in.position (inPos);
+ }
+ }
+ }
+}
Added: llvm-gcc-4.2/trunk/libjava/classpath/gnu/java/nio/charset/UnicodeLittle.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/gnu/java/nio/charset/UnicodeLittle.java?rev=43913&view=auto
==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/gnu/java/nio/charset/UnicodeLittle.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/gnu/java/nio/charset/UnicodeLittle.java Thu Nov 8 16:56:19 2007
@@ -0,0 +1,74 @@
+/* UnicodeLittle.java --
+ Copyright (C) 2005 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 gnu.java.nio.charset;
+
+import java.nio.charset.Charset;
+import java.nio.charset.CharsetDecoder;
+import java.nio.charset.CharsetEncoder;
+
+/**
+ * UTF-16 little endian with a byte-order mark
+ * Included for java.io completeness.
+ * ("UTF-16" is equal to UnicodeBig, and
+ * UTF-16BE/LE do not have a BOM
+ */
+final class UnicodeLittle extends Charset
+{
+ UnicodeLittle ()
+ {
+ super ("UnicodeLittle", new String[] {});
+ }
+
+ public boolean contains (Charset cs)
+ {
+ return cs instanceof US_ASCII || cs instanceof ISO_8859_1
+ || cs instanceof UTF_8 || cs instanceof UTF_16BE
+ || cs instanceof UTF_16LE || cs instanceof UTF_16;
+ }
+
+ public CharsetDecoder newDecoder ()
+ {
+ return new UTF_16Decoder (this, UTF_16Decoder.MAYBE_LITTLE_ENDIAN);
+ }
+
+ public CharsetEncoder newEncoder ()
+ {
+ return new UTF_16Encoder (this, UTF_16Encoder.LITTLE_ENDIAN, true);
+ }
+}
Added: llvm-gcc-4.2/trunk/libjava/classpath/gnu/java/nio/charset/Windows1250.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/gnu/java/nio/charset/Windows1250.java?rev=43913&view=auto
==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/gnu/java/nio/charset/Windows1250.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/gnu/java/nio/charset/Windows1250.java Thu Nov 8 16:56:19 2007
@@ -0,0 +1,103 @@
+/* Windows1250.java -- Charset for Windows-1250 Character set.
+ Copyright (C) 2005 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 gnu.java.nio.charset;
+
+/**
+ * Encoding table for Windows-1250-Latin-1,
+ * aka cp1250 or Windows-1250 or whatever.
+ */
+public class Windows1250 extends ByteCharset
+{
+
+ /**
+ * This is the lookup table for this encoding
+ */
+ private static final char[] lookup =
+ {
+ 0x0000, 0x0001, 0x0002, 0x0003, 0x0004, 0x0005, 0x0006, 0x0007,
+ 0x0008, 0x0009, 0x000A, 0x000B, 0x000C, 0x000D, 0x000E, 0x000F,
+ 0x0010, 0x0011, 0x0012, 0x0013, 0x0014, 0x0015, 0x0016, 0x0017,
+ 0x0018, 0x0019, 0x001A, 0x001B, 0x001C, 0x001D, 0x001E, 0x001F,
+ 0x0020, 0x0021, 0x0022, 0x0023, 0x0024, 0x0025, 0x0026, 0x0027,
+ 0x0028, 0x0029, 0x002A, 0x002B, 0x002C, 0x002D, 0x002E, 0x002F,
+ 0x0030, 0x0031, 0x0032, 0x0033, 0x0034, 0x0035, 0x0036, 0x0037,
+ 0x0038, 0x0039, 0x003A, 0x003B, 0x003C, 0x003D, 0x003E, 0x003F,
+ 0x0040, 0x0041, 0x0042, 0x0043, 0x0044, 0x0045, 0x0046, 0x0047,
+ 0x0048, 0x0049, 0x004A, 0x004B, 0x004C, 0x004D, 0x004E, 0x004F,
+ 0x0050, 0x0051, 0x0052, 0x0053, 0x0054, 0x0055, 0x0056, 0x0057,
+ 0x0058, 0x0059, 0x005A, 0x005B, 0x005C, 0x005D, 0x005E, 0x005F,
+ 0x0060, 0x0061, 0x0062, 0x0063, 0x0064, 0x0065, 0x0066, 0x0067,
+ 0x0068, 0x0069, 0x006A, 0x006B, 0x006C, 0x006D, 0x006E, 0x006F,
+ 0x0070, 0x0071, 0x0072, 0x0073, 0x0074, 0x0075, 0x0076, 0x0077,
+ 0x0078, 0x0079, 0x007A, 0x007B, 0x007C, 0x007D, 0x007E, 0x007F,
+ 0x20AC, 0xFFFD, 0x201A, 0xFFFD, 0x201E, 0x2026, 0x2020, 0x2021,
+ 0xFFFD, 0x2030, 0x0160, 0x2039, 0x015A, 0x0164, 0x017D, 0x0179,
+ 0xFFFD, 0x2018, 0x2019, 0x201C, 0x201D, 0x2022, 0x2013, 0x2014,
+ 0xFFFD, 0x2122, 0x0161, 0x203A, 0x015B, 0x0165, 0x017E, 0x017A,
+ 0x00A0, 0x02C7, 0x02D8, 0x0141, 0x00A4, 0x0104, 0x00A6, 0x00A7,
+ 0x00A8, 0x00A9, 0x015E, 0x00AB, 0x00AC, 0x00AD, 0x00AE, 0x017B,
+ 0x00B0, 0x00B1, 0x02DB, 0x0142, 0x00B4, 0x00B5, 0x00B6, 0x00B7,
+ 0x00B8, 0x0105, 0x015F, 0x00BB, 0x013D, 0x02DD, 0x013E, 0x017C,
+ 0x0154, 0x00C1, 0x00C2, 0x0102, 0x00C4, 0x0139, 0x0106, 0x00C7,
+ 0x010C, 0x00C9, 0x0118, 0x00CB, 0x011A, 0x00CD, 0x00CE, 0x010E,
+ 0x0110, 0x0143, 0x0147, 0x00D3, 0x00D4, 0x0150, 0x00D6, 0x00D7,
+ 0x0158, 0x016E, 0x00DA, 0x0170, 0x00DC, 0x00DD, 0x0162, 0x00DF,
+ 0x0155, 0x00E1, 0x00E2, 0x0103, 0x00E4, 0x013A, 0x0107, 0x00E7,
+ 0x010D, 0x00E9, 0x0119, 0x00EB, 0x011B, 0x00ED, 0x00EE, 0x010F,
+ 0x0111, 0x0144, 0x0148, 0x00F3, 0x00F4, 0x0151, 0x00F6, 0x00F7,
+ 0x0159, 0x016F, 0x00FA, 0x0171, 0x00FC, 0x00FD, 0x0163, 0x02D9
+ };
+
+ public Windows1250()
+ {
+ super("windows-1250", new String[] {
+ "Windows1250",
+ "ibm-5346_P100-1998",
+ "ibm-5346",
+ "cp1250",
+ "cp-1250",
+ "cp_1250",
+ "windows1250",
+ "windows_1250"
+ });
+ lookupTable = lookup;
+ }
+
+} // class Windows1250
+
Added: llvm-gcc-4.2/trunk/libjava/classpath/gnu/java/nio/charset/Windows1251.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/gnu/java/nio/charset/Windows1251.java?rev=43913&view=auto
==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/gnu/java/nio/charset/Windows1251.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/gnu/java/nio/charset/Windows1251.java Thu Nov 8 16:56:19 2007
@@ -0,0 +1,101 @@
+/* Windows1251.java -- Charset for Windows-1251 Cyrillic character set.
+ Copyright (C) 2005 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 gnu.java.nio.charset;
+
+/**
+ * Encoding table for Windows-1251 Cyrillic char set.
+ * aka cp1251 or Windows-1251 or whatever.
+ */
+public class Windows1251 extends ByteCharset
+{
+
+ /**
+ * This is the lookup table for this encoding
+ */
+ private static final char[] lookup =
+ {
+ 0x0000, 0x0001, 0x0002, 0x0003, 0x0004, 0x0005, 0x0006, 0x0007,
+ 0x0008, 0x0009, 0x000A, 0x000B, 0x000C, 0x000D, 0x000E, 0x000F,
+ 0x0010, 0x0011, 0x0012, 0x0013, 0x0014, 0x0015, 0x0016, 0x0017,
+ 0x0018, 0x0019, 0x001A, 0x001B, 0x001C, 0x001D, 0x001E, 0x001F,
+ 0x0020, 0x0021, 0x0022, 0x0023, 0x0024, 0x0025, 0x0026, 0x0027,
+ 0x0028, 0x0029, 0x002A, 0x002B, 0x002C, 0x002D, 0x002E, 0x002F,
+ 0x0030, 0x0031, 0x0032, 0x0033, 0x0034, 0x0035, 0x0036, 0x0037,
+ 0x0038, 0x0039, 0x003A, 0x003B, 0x003C, 0x003D, 0x003E, 0x003F,
+ 0x0040, 0x0041, 0x0042, 0x0043, 0x0044, 0x0045, 0x0046, 0x0047,
+ 0x0048, 0x0049, 0x004A, 0x004B, 0x004C, 0x004D, 0x004E, 0x004F,
+ 0x0050, 0x0051, 0x0052, 0x0053, 0x0054, 0x0055, 0x0056, 0x0057,
+ 0x0058, 0x0059, 0x005A, 0x005B, 0x005C, 0x005D, 0x005E, 0x005F,
+ 0x0060, 0x0061, 0x0062, 0x0063, 0x0064, 0x0065, 0x0066, 0x0067,
+ 0x0068, 0x0069, 0x006A, 0x006B, 0x006C, 0x006D, 0x006E, 0x006F,
+ 0x0070, 0x0071, 0x0072, 0x0073, 0x0074, 0x0075, 0x0076, 0x0077,
+ 0x0078, 0x0079, 0x007A, 0x007B, 0x007C, 0x007D, 0x007E, 0x007F,
+ 0x0402, 0x0403, 0x201A, 0x0453, 0x201E, 0x2026, 0x2020, 0x2021,
+ 0x20AC, 0x2030, 0x0409, 0x2039, 0x040A, 0x040C, 0x040B, 0x040F,
+ 0x0452, 0x2018, 0x2019, 0x201C, 0x201D, 0x2022, 0x2013, 0x2014,
+ NONE, 0x2122, 0x0459, 0x203A, 0x045A, 0x045C, 0x045B, 0x045F,
+ 0x00A0, 0x040E, 0x045E, 0x0408, 0x00A4, 0x0490, 0x00A6, 0x00A7,
+ 0x0401, 0x00A9, 0x0404, 0x00AB, 0x00AC, 0x00AD, 0x00AE, 0x0407,
+ 0x00B0, 0x00B1, 0x0406, 0x0456, 0x0491, 0x00B5, 0x00B6, 0x00B7,
+ 0x0451, 0x2116, 0x0454, 0x00BB, 0x0458, 0x0405, 0x0455, 0x0457,
+ 0x0410, 0x0411, 0x0412, 0x0413, 0x0414, 0x0415, 0x0416, 0x0417,
+ 0x0418, 0x0419, 0x041A, 0x041B, 0x041C, 0x041D, 0x041E, 0x041F,
+ 0x0420, 0x0421, 0x0422, 0x0423, 0x0424, 0x0425, 0x0426, 0x0427,
+ 0x0428, 0x0429, 0x042A, 0x042B, 0x042C, 0x042D, 0x042E, 0x042F,
+ 0x0430, 0x0431, 0x0432, 0x0433, 0x0434, 0x0435, 0x0436, 0x0437,
+ 0x0438, 0x0439, 0x043A, 0x043B, 0x043C, 0x043D, 0x043E, 0x043F,
+ 0x0440, 0x0441, 0x0442, 0x0443, 0x0444, 0x0445, 0x0446, 0x0447,
+ 0x0448, 0x0449, 0x044A, 0x044B, 0x044C, 0x044D, 0x044E, 0x044F
+ };
+
+ public Windows1251()
+ {
+ super("windows-1251", new String[] {
+ "Windows1251",
+ "cp1251",
+ "cp-1251",
+ "cp_1251",
+ "windows1251",
+ "windows_1251"
+ });
+ lookupTable = lookup;
+ }
+
+} // class Windows1251
+
Added: llvm-gcc-4.2/trunk/libjava/classpath/gnu/java/nio/charset/Windows1252.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/gnu/java/nio/charset/Windows1252.java?rev=43913&view=auto
==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/gnu/java/nio/charset/Windows1252.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/gnu/java/nio/charset/Windows1252.java Thu Nov 8 16:56:19 2007
@@ -0,0 +1,100 @@
+/* Windows1252.java -- Charset for Windows-1252 Character set.
+ Copyright (C) 2005 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 gnu.java.nio.charset;
+
+/**
+ * Encoding table for Windows-1252-Latin-1,
+ * aka cp1252 or Windows-1252 or whatever.
+ */
+public class Windows1252 extends ByteCharset
+{
+
+ /**
+ * This is the lookup table for this encoding
+ */
+ private static final char[] lookup =
+ { 0x0000, 0x0001, 0x0002, 0x0003, 0x0004, 0x0005, 0x0006, 0x0007,
+ 0x0008, 0x0009, 0x000A, 0x000B, 0x000C, 0x000D, 0x000E, 0x000F,
+ 0x0010, 0x0011, 0x0012, 0x0013, 0x0014, 0x0015, 0x0016, 0x0017,
+ 0x0018, 0x0019, 0x001A, 0x001B, 0x001C, 0x001D, 0x001E, 0x001F,
+ 0x0020, 0x0021, 0x0022, 0x0023, 0x0024, 0x0025, 0x0026, 0x0027,
+ 0x0028, 0x0029, 0x002A, 0x002B, 0x002C, 0x002D, 0x002E, 0x002F,
+ 0x0030, 0x0031, 0x0032, 0x0033, 0x0034, 0x0035, 0x0036, 0x0037,
+ 0x0038, 0x0039, 0x003A, 0x003B, 0x003C, 0x003D, 0x003E, 0x003F,
+ 0x0040, 0x0041, 0x0042, 0x0043, 0x0044, 0x0045, 0x0046, 0x0047,
+ 0x0048, 0x0049, 0x004A, 0x004B, 0x004C, 0x004D, 0x004E, 0x004F,
+ 0x0050, 0x0051, 0x0052, 0x0053, 0x0054, 0x0055, 0x0056, 0x0057,
+ 0x0058, 0x0059, 0x005A, 0x005B, 0x005C, 0x005D, 0x005E, 0x005F,
+ 0x0060, 0x0061, 0x0062, 0x0063, 0x0064, 0x0065, 0x0066, 0x0067,
+ 0x0068, 0x0069, 0x006A, 0x006B, 0x006C, 0x006D, 0x006E, 0x006F,
+ 0x0070, 0x0071, 0x0072, 0x0073, 0x0074, 0x0075, 0x0076, 0x0077,
+ 0x0078, 0x0079, 0x007A, 0x007B, 0x007C, 0x007D, 0x007E, 0x007F,
+ 0x20AC, NONE, 0x201A, 0x0192, 0x201E, 0x2026, 0x2020, 0x2021,
+ 0x02C6, 0x2030, 0x0160, 0x2039, 0x0152, NONE, 0x017D, NONE,
+ NONE, 0x2018, 0x2019, 0x201C, 0x201D, 0x2022, 0x2013, 0x2014,
+ 0x02DC, 0x2122, 0x0161, 0x203A, 0x0153, NONE, 0x017E, 0x0178,
+ 0x00A0, 0x00A1, 0x00A2, 0x00A3, 0x00A4, 0x00A5, 0x00A6, 0x00A7,
+ 0x00A8, 0x00A9, 0x00AA, 0x00AB, 0x00AC, 0x00AD, 0x00AE, 0x00AF,
+ 0x00B0, 0x00B1, 0x00B2, 0x00B3, 0x00B4, 0x00B5, 0x00B6, 0x00B7,
+ 0x00B8, 0x00B9, 0x00BA, 0x00BB, 0x00BC, 0x00BD, 0x00BE, 0x00BF,
+ 0x00C0, 0x00C1, 0x00C2, 0x00C3, 0x00C4, 0x00C5, 0x00C6, 0x00C7,
+ 0x00C8, 0x00C9, 0x00CA, 0x00CB, 0x00CC, 0x00CD, 0x00CE, 0x00CF,
+ 0x00D0, 0x00D1, 0x00D2, 0x00D3, 0x00D4, 0x00D5, 0x00D6, 0x00D7,
+ 0x00D8, 0x00D9, 0x00DA, 0x00DB, 0x00DC, 0x00DD, 0x00DE, 0x00DF,
+ 0x00E0, 0x00E1, 0x00E2, 0x00E3, 0x00E4, 0x00E5, 0x00E6, 0x00E7,
+ 0x00E8, 0x00E9, 0x00EA, 0x00EB, 0x00EC, 0x00ED, 0x00EE, 0x00EF,
+ 0x00F0, 0x00F1, 0x00F2, 0x00F3, 0x00F4, 0x00F5, 0x00F6, 0x00F7,
+ 0x00F8, 0x00F9, 0x00FA, 0x00FB, 0x00FC, 0x00FD, 0x00FE, 0x00FF
+ };
+
+ public Windows1252()
+ {
+ super("windows-1252", new String[] {
+ "Windows1252",
+ "ibm-5348_P100-1997",
+ "ibm-5348",
+ "windows-1252",
+ "cp1252",
+ "cp-1252"
+ });
+ lookupTable = lookup;
+ }
+
+} // class Windows1252
+
Added: llvm-gcc-4.2/trunk/libjava/classpath/gnu/java/nio/charset/Windows1253.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/gnu/java/nio/charset/Windows1253.java?rev=43913&view=auto
==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/gnu/java/nio/charset/Windows1253.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/gnu/java/nio/charset/Windows1253.java Thu Nov 8 16:56:19 2007
@@ -0,0 +1,101 @@
+/* Windows1253.java -- Charset for Windows-1253 Greek character set.
+ Copyright (C) 2005 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 gnu.java.nio.charset;
+
+/**
+ * Encoding table for Windows-1253 Greek char set.
+ * aka cp1253 or Windows-1253 or whatever.
+ */
+public class Windows1253 extends ByteCharset
+{
+
+ /**
+ * This is the lookup table for this encoding
+ */
+ private static final char[] lookup =
+ {
+ 0x0000, 0x0001, 0x0002, 0x0003, 0x0004, 0x0005, 0x0006, 0x0007,
+ 0x0008, 0x0009, 0x000A, 0x000B, 0x000C, 0x000D, 0x000E, 0x000F,
+ 0x0010, 0x0011, 0x0012, 0x0013, 0x0014, 0x0015, 0x0016, 0x0017,
+ 0x0018, 0x0019, 0x001A, 0x001B, 0x001C, 0x001D, 0x001E, 0x001F,
+ 0x0020, 0x0021, 0x0022, 0x0023, 0x0024, 0x0025, 0x0026, 0x0027,
+ 0x0028, 0x0029, 0x002A, 0x002B, 0x002C, 0x002D, 0x002E, 0x002F,
+ 0x0030, 0x0031, 0x0032, 0x0033, 0x0034, 0x0035, 0x0036, 0x0037,
+ 0x0038, 0x0039, 0x003A, 0x003B, 0x003C, 0x003D, 0x003E, 0x003F,
+ 0x0040, 0x0041, 0x0042, 0x0043, 0x0044, 0x0045, 0x0046, 0x0047,
+ 0x0048, 0x0049, 0x004A, 0x004B, 0x004C, 0x004D, 0x004E, 0x004F,
+ 0x0050, 0x0051, 0x0052, 0x0053, 0x0054, 0x0055, 0x0056, 0x0057,
+ 0x0058, 0x0059, 0x005A, 0x005B, 0x005C, 0x005D, 0x005E, 0x005F,
+ 0x0060, 0x0061, 0x0062, 0x0063, 0x0064, 0x0065, 0x0066, 0x0067,
+ 0x0068, 0x0069, 0x006A, 0x006B, 0x006C, 0x006D, 0x006E, 0x006F,
+ 0x0070, 0x0071, 0x0072, 0x0073, 0x0074, 0x0075, 0x0076, 0x0077,
+ 0x0078, 0x0079, 0x007A, 0x007B, 0x007C, 0x007D, 0x007E, 0x007F,
+ 0x20AC, NONE, 0x201A, 0x0192, 0x201E, 0x2026, 0x2020, 0x2021,
+ NONE, 0x2030, NONE, 0x2039, NONE, NONE, NONE, NONE,
+ NONE, 0x2018, 0x2019, 0x201C, 0x201D, 0x2022, 0x2013, 0x2014,
+ NONE, 0x2122, NONE, 0x203A, NONE, NONE, NONE, NONE,
+ 0x00A0, 0x0385, 0x0386, 0x00A3, 0x00A4, 0x00A5, 0x00A6, 0x00A7,
+ 0x00A8, 0x00A9, NONE, 0x00AB, 0x00AC, 0x00AD, 0x00AE, 0x2015,
+ 0x00B0, 0x00B1, 0x00B2, 0x00B3, 0x0384, 0x00B5, 0x00B6, 0x00B7,
+ 0x0388, 0x0389, 0x038A, 0x00BB, 0x038C, 0x00BD, 0x038E, 0x038F,
+ 0x0390, 0x0391, 0x0392, 0x0393, 0x0394, 0x0395, 0x0396, 0x0397,
+ 0x0398, 0x0399, 0x039A, 0x039B, 0x039C, 0x039D, 0x039E, 0x039F,
+ 0x03A0, 0x03A1, NONE, 0x03A3, 0x03A4, 0x03A5, 0x03A6, 0x03A7,
+ 0x03A8, 0x03A9, 0x03AA, 0x03AB, 0x03AC, 0x03AD, 0x03AE, 0x03AF,
+ 0x03B0, 0x03B1, 0x03B2, 0x03B3, 0x03B4, 0x03B5, 0x03B6, 0x03B7,
+ 0x03B8, 0x03B9, 0x03BA, 0x03BB, 0x03BC, 0x03BD, 0x03BE, 0x03BF,
+ 0x03C0, 0x03C1, 0x03C2, 0x03C3, 0x03C4, 0x03C5, 0x03C6, 0x03C7,
+ 0x03C8, 0x03C9, 0x03CA, 0x03CB, 0x03CC, 0x03CD, 0x03CE, NONE
+ };
+
+ public Windows1253()
+ {
+ super("windows-1253", new String[] {
+ "Windows1253",
+ "cp1253",
+ "cp-1253",
+ "cp_1253",
+ "windows1253",
+ "windows_1253"
+ });
+ lookupTable = lookup;
+ }
+
+} // class Windows1253
+
Added: llvm-gcc-4.2/trunk/libjava/classpath/gnu/java/nio/charset/Windows1254.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/gnu/java/nio/charset/Windows1254.java?rev=43913&view=auto
==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/gnu/java/nio/charset/Windows1254.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/gnu/java/nio/charset/Windows1254.java Thu Nov 8 16:56:19 2007
@@ -0,0 +1,101 @@
+/* Windows1254.java -- Charset for Windows-1254 Turkish character set.
+ Copyright (C) 2005 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 gnu.java.nio.charset;
+
+/**
+ * Encoding table for Windows-1254 Turkish char set.
+ * aka cp1254 or Windows-1254 or whatever.
+ */
+public class Windows1254 extends ByteCharset
+{
+
+ /**
+ * This is the lookup table for this encoding
+ */
+ private static final char[] lookup =
+ {
+ 0x0000, 0x0001, 0x0002, 0x0003, 0x0004, 0x0005, 0x0006, 0x0007,
+ 0x0008, 0x0009, 0x000A, 0x000B, 0x000C, 0x000D, 0x000E, 0x000F,
+ 0x0010, 0x0011, 0x0012, 0x0013, 0x0014, 0x0015, 0x0016, 0x0017,
+ 0x0018, 0x0019, 0x001A, 0x001B, 0x001C, 0x001D, 0x001E, 0x001F,
+ 0x0020, 0x0021, 0x0022, 0x0023, 0x0024, 0x0025, 0x0026, 0x0027,
+ 0x0028, 0x0029, 0x002A, 0x002B, 0x002C, 0x002D, 0x002E, 0x002F,
+ 0x0030, 0x0031, 0x0032, 0x0033, 0x0034, 0x0035, 0x0036, 0x0037,
+ 0x0038, 0x0039, 0x003A, 0x003B, 0x003C, 0x003D, 0x003E, 0x003F,
+ 0x0040, 0x0041, 0x0042, 0x0043, 0x0044, 0x0045, 0x0046, 0x0047,
+ 0x0048, 0x0049, 0x004A, 0x004B, 0x004C, 0x004D, 0x004E, 0x004F,
+ 0x0050, 0x0051, 0x0052, 0x0053, 0x0054, 0x0055, 0x0056, 0x0057,
+ 0x0058, 0x0059, 0x005A, 0x005B, 0x005C, 0x005D, 0x005E, 0x005F,
+ 0x0060, 0x0061, 0x0062, 0x0063, 0x0064, 0x0065, 0x0066, 0x0067,
+ 0x0068, 0x0069, 0x006A, 0x006B, 0x006C, 0x006D, 0x006E, 0x006F,
+ 0x0070, 0x0071, 0x0072, 0x0073, 0x0074, 0x0075, 0x0076, 0x0077,
+ 0x0078, 0x0079, 0x007A, 0x007B, 0x007C, 0x007D, 0x007E, 0x007F,
+ 0x20AC, NONE, 0x201A, 0x0192, 0x201E, 0x2026, 0x2020, 0x2021,
+ 0x02C6, 0x2030, 0x0160, 0x2039, 0x0152, NONE, NONE, NONE,
+ NONE, 0x2018, 0x2019, 0x201C, 0x201D, 0x2022, 0x2013, 0x2014,
+ 0x02DC, 0x2122, 0x0161, 0x203A, 0x0153, NONE, NONE, 0x0178,
+ 0x00A0, 0x00A1, 0x00A2, 0x00A3, 0x00A4, 0x00A5, 0x00A6, 0x00A7,
+ 0x00A8, 0x00A9, 0x00AA, 0x00AB, 0x00AC, 0x00AD, 0x00AE, 0x00AF,
+ 0x00B0, 0x00B1, 0x00B2, 0x00B3, 0x00B4, 0x00B5, 0x00B6, 0x00B7,
+ 0x00B8, 0x00B9, 0x00BA, 0x00BB, 0x00BC, 0x00BD, 0x00BE, 0x00BF,
+ 0x00C0, 0x00C1, 0x00C2, 0x00C3, 0x00C4, 0x00C5, 0x00C6, 0x00C7,
+ 0x00C8, 0x00C9, 0x00CA, 0x00CB, 0x00CC, 0x00CD, 0x00CE, 0x00CF,
+ 0x011E, 0x00D1, 0x00D2, 0x00D3, 0x00D4, 0x00D5, 0x00D6, 0x00D7,
+ 0x00D8, 0x00D9, 0x00DA, 0x00DB, 0x00DC, 0x0130, 0x015E, 0x00DF,
+ 0x00E0, 0x00E1, 0x00E2, 0x00E3, 0x00E4, 0x00E5, 0x00E6, 0x00E7,
+ 0x00E8, 0x00E9, 0x00EA, 0x00EB, 0x00EC, 0x00ED, 0x00EE, 0x00EF,
+ 0x011F, 0x00F1, 0x00F2, 0x00F3, 0x00F4, 0x00F5, 0x00F6, 0x00F7,
+ 0x00F8, 0x00F9, 0x00FA, 0x00FB, 0x00FC, 0x0131, 0x015F, 0x00FF
+ };
+
+ public Windows1254()
+ {
+ super("windows-1254", new String[] {
+ "Windows1254",
+ "cp1254",
+ "cp-1254",
+ "cp_1254",
+ "windows1254",
+ "windows_1254"
+ });
+ lookupTable = lookup;
+ }
+
+} // class Windows1254
+
Added: llvm-gcc-4.2/trunk/libjava/classpath/gnu/java/nio/charset/Windows1255.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/gnu/java/nio/charset/Windows1255.java?rev=43913&view=auto
==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/gnu/java/nio/charset/Windows1255.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/gnu/java/nio/charset/Windows1255.java Thu Nov 8 16:56:19 2007
@@ -0,0 +1,101 @@
+/* Windows1255.java -- Charset for Windows-1255 Character set.
+ Copyright (C) 2005 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 gnu.java.nio.charset;
+
+/**
+ * Encoding table for Windows-1255 Hebrew char set.
+ * aka cp1255 or Windows-1255 or whatever.
+ */
+public class Windows1255 extends ByteCharset
+{
+
+ /**
+ * This is the lookup table for this encoding
+ */
+ private static final char[] lookup =
+ {
+ 0x0000, 0x0001, 0x0002, 0x0003, 0x0004, 0x0005, 0x0006, 0x0007,
+ 0x0008, 0x0009, 0x000A, 0x000B, 0x000C, 0x000D, 0x000E, 0x000F,
+ 0x0010, 0x0011, 0x0012, 0x0013, 0x0014, 0x0015, 0x0016, 0x0017,
+ 0x0018, 0x0019, 0x001A, 0x001B, 0x001C, 0x001D, 0x001E, 0x001F,
+ 0x0020, 0x0021, 0x0022, 0x0023, 0x0024, 0x0025, 0x0026, 0x0027,
+ 0x0028, 0x0029, 0x002A, 0x002B, 0x002C, 0x002D, 0x002E, 0x002F,
+ 0x0030, 0x0031, 0x0032, 0x0033, 0x0034, 0x0035, 0x0036, 0x0037,
+ 0x0038, 0x0039, 0x003A, 0x003B, 0x003C, 0x003D, 0x003E, 0x003F,
+ 0x0040, 0x0041, 0x0042, 0x0043, 0x0044, 0x0045, 0x0046, 0x0047,
+ 0x0048, 0x0049, 0x004A, 0x004B, 0x004C, 0x004D, 0x004E, 0x004F,
+ 0x0050, 0x0051, 0x0052, 0x0053, 0x0054, 0x0055, 0x0056, 0x0057,
+ 0x0058, 0x0059, 0x005A, 0x005B, 0x005C, 0x005D, 0x005E, 0x005F,
+ 0x0060, 0x0061, 0x0062, 0x0063, 0x0064, 0x0065, 0x0066, 0x0067,
+ 0x0068, 0x0069, 0x006A, 0x006B, 0x006C, 0x006D, 0x006E, 0x006F,
+ 0x0070, 0x0071, 0x0072, 0x0073, 0x0074, 0x0075, 0x0076, 0x0077,
+ 0x0078, 0x0079, 0x007A, 0x007B, 0x007C, 0x007D, 0x007E, 0x007F,
+ 0x20AC, 0xFFFD, 0x201A, 0x0192, 0x201E, 0x2026, 0x2020, 0x2021,
+ 0x02C6, 0x2030, 0xFFFD, 0x2039, 0xFFFD, 0xFFFD, 0xFFFD, 0xFFFD,
+ 0xFFFD, 0x2018, 0x2019, 0x201C, 0x201D, 0x2022, 0x2013, 0x2014,
+ 0x02DC, 0x2122, 0xFFFD, 0x203A, 0xFFFD, 0xFFFD, 0xFFFD, 0xFFFD,
+ 0x00A0, 0x00A1, 0x00A2, 0x00A3, 0x20AA, 0x00A5, 0x00A6, 0x00A7,
+ 0x00A8, 0x00A9, 0x00D7, 0x00AB, 0x00AC, 0x00AD, 0x00AE, 0x00AF,
+ 0x00B0, 0x00B1, 0x00B2, 0x00B3, 0x00B4, 0x00B5, 0x00B6, 0x00B7,
+ 0x00B8, 0x00B9, 0x00F7, 0x00BB, 0x00BC, 0x00BD, 0x00BE, 0x00BF,
+ 0x05B0, 0x05B1, 0x05B2, 0x05B3, 0x05B4, 0x05B5, 0x05B6, 0x05B7,
+ 0x05B8, 0x05B9, 0xFFFD, 0x05BB, 0x05BC, 0x05BD, 0x05BE, 0x05BF,
+ 0x05C0, 0x05C1, 0x05C2, 0x05C3, 0x05F0, 0x05F1, 0x05F2, 0x05F3,
+ 0x05F4, 0xFFFD, 0xFFFD, 0xFFFD, 0xFFFD, 0xFFFD, 0xFFFD, 0xFFFD,
+ 0x05D0, 0x05D1, 0x05D2, 0x05D3, 0x05D4, 0x05D5, 0x05D6, 0x05D7,
+ 0x05D8, 0x05D9, 0x05DA, 0x05DB, 0x05DC, 0x05DD, 0x05DE, 0x05DF,
+ 0x05E0, 0x05E1, 0x05E2, 0x05E3, 0x05E4, 0x05E5, 0x05E6, 0x05E7,
+ 0x05E8, 0x05E9, 0x05EA, 0xFFFD, 0xFFFD, 0x200E, 0x200F, 0xFFFD
+ };
+
+ public Windows1255()
+ {
+ super("windows-1255", new String[] {
+ "Windows1255",
+ "cp1255",
+ "cp-1255",
+ "cp_1255",
+ "windows1255",
+ "windows_1255"
+ });
+ lookupTable = lookup;
+ }
+
+} // class Windows1255
+
Added: llvm-gcc-4.2/trunk/libjava/classpath/gnu/java/nio/charset/Windows1256.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/gnu/java/nio/charset/Windows1256.java?rev=43913&view=auto
==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/gnu/java/nio/charset/Windows1256.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/gnu/java/nio/charset/Windows1256.java Thu Nov 8 16:56:19 2007
@@ -0,0 +1,101 @@
+/* Windows1256.java -- Charset for Windows-1256 Arabic character set.
+ Copyright (C) 2005 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 gnu.java.nio.charset;
+
+/**
+ * Encoding table for Windows-1256 Arabic char set.
+ * aka cp1256 or Windows-1256 or whatever.
+ */
+public class Windows1256 extends ByteCharset
+{
+
+ /**
+ * This is the lookup table for this encoding
+ */
+ private static final char[] lookup =
+ {
+ 0x0000, 0x0001, 0x0002, 0x0003, 0x0004, 0x0005, 0x0006, 0x0007,
+ 0x0008, 0x0009, 0x000A, 0x000B, 0x000C, 0x000D, 0x000E, 0x000F,
+ 0x0010, 0x0011, 0x0012, 0x0013, 0x0014, 0x0015, 0x0016, 0x0017,
+ 0x0018, 0x0019, 0x001A, 0x001B, 0x001C, 0x001D, 0x001E, 0x001F,
+ 0x0020, 0x0021, 0x0022, 0x0023, 0x0024, 0x0025, 0x0026, 0x0027,
+ 0x0028, 0x0029, 0x002A, 0x002B, 0x002C, 0x002D, 0x002E, 0x002F,
+ 0x0030, 0x0031, 0x0032, 0x0033, 0x0034, 0x0035, 0x0036, 0x0037,
+ 0x0038, 0x0039, 0x003A, 0x003B, 0x003C, 0x003D, 0x003E, 0x003F,
+ 0x0040, 0x0041, 0x0042, 0x0043, 0x0044, 0x0045, 0x0046, 0x0047,
+ 0x0048, 0x0049, 0x004A, 0x004B, 0x004C, 0x004D, 0x004E, 0x004F,
+ 0x0050, 0x0051, 0x0052, 0x0053, 0x0054, 0x0055, 0x0056, 0x0057,
+ 0x0058, 0x0059, 0x005A, 0x005B, 0x005C, 0x005D, 0x005E, 0x005F,
+ 0x0060, 0x0061, 0x0062, 0x0063, 0x0064, 0x0065, 0x0066, 0x0067,
+ 0x0068, 0x0069, 0x006A, 0x006B, 0x006C, 0x006D, 0x006E, 0x006F,
+ 0x0070, 0x0071, 0x0072, 0x0073, 0x0074, 0x0075, 0x0076, 0x0077,
+ 0x0078, 0x0079, 0x007A, 0x007B, 0x007C, 0x007D, 0x007E, 0x007F,
+ 0x20AC, 0x067E, 0x201A, 0x0192, 0x201E, 0x2026, 0x2020, 0x2021,
+ 0x02C6, 0x2030, 0x0679, 0x2039, 0x0152, 0x0686, 0x0698, 0x0688,
+ 0x06AF, 0x2018, 0x2019, 0x201C, 0x201D, 0x2022, 0x2013, 0x2014,
+ 0x06A9, 0x2122, 0x0691, 0x203A, 0x0153, 0x200C, 0x200D, 0x06BA,
+ 0x00A0, 0x060C, 0x00A2, 0x00A3, 0x00A4, 0x00A5, 0x00A6, 0x00A7,
+ 0x00A8, 0x00A9, 0x06BE, 0x00AB, 0x00AC, 0x00AD, 0x00AE, 0x00AF,
+ 0x00B0, 0x00B1, 0x00B2, 0x00B3, 0x00B4, 0x00B5, 0x00B6, 0x00B7,
+ 0x00B8, 0x00B9, 0x061B, 0x00BB, 0x00BC, 0x00BD, 0x00BE, 0x061F,
+ 0x06C1, 0x0621, 0x0622, 0x0623, 0x0624, 0x0625, 0x0626, 0x0627,
+ 0x0628, 0x0629, 0x062A, 0x062B, 0x062C, 0x062D, 0x062E, 0x062F,
+ 0x0630, 0x0631, 0x0632, 0x0633, 0x0634, 0x0635, 0x0636, 0x00D7,
+ 0x0637, 0x0638, 0x0639, 0x063A, 0x0640, 0x0641, 0x0642, 0x0643,
+ 0x00E0, 0x0644, 0x00E2, 0x0645, 0x0646, 0x0647, 0x0648, 0x00E7,
+ 0x00E8, 0x00E9, 0x00EA, 0x00EB, 0x0649, 0x064A, 0x00EE, 0x00EF,
+ 0x064B, 0x064C, 0x064D, 0x064E, 0x00F4, 0x064F, 0x0650, 0x00F7,
+ 0x0651, 0x00F9, 0x0652, 0x00FB, 0x00FC, 0x200E, 0x200F, 0x06D2
+ };
+
+ public Windows1256()
+ {
+ super("windows-1256", new String[] {
+ "Windows1256",
+ "cp1256",
+ "cp-1256",
+ "cp_1256",
+ "windows1256",
+ "windows_1256"
+ });
+ lookupTable = lookup;
+ }
+
+} // class Windows1256
+
Added: llvm-gcc-4.2/trunk/libjava/classpath/gnu/java/nio/charset/Windows1257.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/gnu/java/nio/charset/Windows1257.java?rev=43913&view=auto
==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/gnu/java/nio/charset/Windows1257.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/gnu/java/nio/charset/Windows1257.java Thu Nov 8 16:56:19 2007
@@ -0,0 +1,101 @@
+/* Windows1257.java -- Charset for Windows-1257 Baltic character set.
+ Copyright (C) 2005 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 gnu.java.nio.charset;
+
+/**
+ * Encoding table for Windows-1257 Baltic char set.
+ * aka cp1257 or Windows-1257 or whatever.
+ */
+public class Windows1257 extends ByteCharset
+{
+
+ /**
+ * This is the lookup table for this encoding
+ */
+ private static final char[] lookup =
+ {
+ 0x0000, 0x0001, 0x0002, 0x0003, 0x0004, 0x0005, 0x0006, 0x0007,
+ 0x0008, 0x0009, 0x000A, 0x000B, 0x000C, 0x000D, 0x000E, 0x000F,
+ 0x0010, 0x0011, 0x0012, 0x0013, 0x0014, 0x0015, 0x0016, 0x0017,
+ 0x0018, 0x0019, 0x001A, 0x001B, 0x001C, 0x001D, 0x001E, 0x001F,
+ 0x0020, 0x0021, 0x0022, 0x0023, 0x0024, 0x0025, 0x0026, 0x0027,
+ 0x0028, 0x0029, 0x002A, 0x002B, 0x002C, 0x002D, 0x002E, 0x002F,
+ 0x0030, 0x0031, 0x0032, 0x0033, 0x0034, 0x0035, 0x0036, 0x0037,
+ 0x0038, 0x0039, 0x003A, 0x003B, 0x003C, 0x003D, 0x003E, 0x003F,
+ 0x0040, 0x0041, 0x0042, 0x0043, 0x0044, 0x0045, 0x0046, 0x0047,
+ 0x0048, 0x0049, 0x004A, 0x004B, 0x004C, 0x004D, 0x004E, 0x004F,
+ 0x0050, 0x0051, 0x0052, 0x0053, 0x0054, 0x0055, 0x0056, 0x0057,
+ 0x0058, 0x0059, 0x005A, 0x005B, 0x005C, 0x005D, 0x005E, 0x005F,
+ 0x0060, 0x0061, 0x0062, 0x0063, 0x0064, 0x0065, 0x0066, 0x0067,
+ 0x0068, 0x0069, 0x006A, 0x006B, 0x006C, 0x006D, 0x006E, 0x006F,
+ 0x0070, 0x0071, 0x0072, 0x0073, 0x0074, 0x0075, 0x0076, 0x0077,
+ 0x0078, 0x0079, 0x007A, 0x007B, 0x007C, 0x007D, 0x007E, 0x007F,
+ 0x20AC, NONE, 0x201A, NONE, 0x201E, 0x2026, 0x2020, 0x2021,
+ NONE, 0x2030, NONE, 0x2039, NONE, 0x00A8, 0x02C7, 0x00B8,
+ NONE, 0x2018, 0x2019, 0x201C, 0x201D, 0x2022, 0x2013, 0x2014,
+ NONE, 0x2122, NONE, 0x203A, NONE, 0x00AF, 0x02DB, NONE,
+ 0x00A0, NONE, 0x00A2, 0x00A3, 0x00A4, NONE, 0x00A6, 0x00A7,
+ 0x00D8, 0x00A9, 0x0156, 0x00AB, 0x00AC, 0x00AD, 0x00AE, 0x00C6,
+ 0x00B0, 0x00B1, 0x00B2, 0x00B3, 0x00B4, 0x00B5, 0x00B6, 0x00B7,
+ 0x00F8, 0x00B9, 0x0157, 0x00BB, 0x00BC, 0x00BD, 0x00BE, 0x00E6,
+ 0x0104, 0x012E, 0x0100, 0x0106, 0x00C4, 0x00C5, 0x0118, 0x0112,
+ 0x010C, 0x00C9, 0x0179, 0x0116, 0x0122, 0x0136, 0x012A, 0x013B,
+ 0x0160, 0x0143, 0x0145, 0x00D3, 0x014C, 0x00D5, 0x00D6, 0x00D7,
+ 0x0172, 0x0141, 0x015A, 0x016A, 0x00DC, 0x017B, 0x017D, 0x00DF,
+ 0x0105, 0x012F, 0x0101, 0x0107, 0x00E4, 0x00E5, 0x0119, 0x0113,
+ 0x010D, 0x00E9, 0x017A, 0x0117, 0x0123, 0x0137, 0x012B, 0x013C,
+ 0x0161, 0x0144, 0x0146, 0x00F3, 0x014D, 0x00F5, 0x00F6, 0x00F7,
+ 0x0173, 0x0142, 0x015B, 0x016B, 0x00FC, 0x017C, 0x017E, 0x02D9
+ };
+
+ public Windows1257()
+ {
+ super("windows-1257", new String[] {
+ "Windows1257",
+ "cp1257",
+ "cp-1257",
+ "cp_1257",
+ "windows1257",
+ "windows_1257"
+ });
+ lookupTable = lookup;
+ }
+
+} // class Windows1257
+
Added: llvm-gcc-4.2/trunk/libjava/classpath/gnu/java/nio/charset/Windows1258.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/gnu/java/nio/charset/Windows1258.java?rev=43913&view=auto
==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/gnu/java/nio/charset/Windows1258.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/gnu/java/nio/charset/Windows1258.java Thu Nov 8 16:56:19 2007
@@ -0,0 +1,101 @@
+/* Windows1258.java -- Charset for Windows-1258 Vietnamese character set.
+ Copyright (C) 2005 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 gnu.java.nio.charset;
+
+/**
+ * Encoding table for Windows-1258 Arabic char set.
+ * aka cp1258 or Windows-1258 or whatever.
+ */
+public class Windows1258 extends ByteCharset
+{
+
+ /**
+ * This is the lookup table for this encoding
+ */
+ private static final char[] lookup =
+ {
+ 0x0000, 0x0001, 0x0002, 0x0003, 0x0004, 0x0005, 0x0006, 0x0007,
+ 0x0008, 0x0009, 0x000A, 0x000B, 0x000C, 0x000D, 0x000E, 0x000F,
+ 0x0010, 0x0011, 0x0012, 0x0013, 0x0014, 0x0015, 0x0016, 0x0017,
+ 0x0018, 0x0019, 0x001A, 0x001B, 0x001C, 0x001D, 0x001E, 0x001F,
+ 0x0020, 0x0021, 0x0022, 0x0023, 0x0024, 0x0025, 0x0026, 0x0027,
+ 0x0028, 0x0029, 0x002A, 0x002B, 0x002C, 0x002D, 0x002E, 0x002F,
+ 0x0030, 0x0031, 0x0032, 0x0033, 0x0034, 0x0035, 0x0036, 0x0037,
+ 0x0038, 0x0039, 0x003A, 0x003B, 0x003C, 0x003D, 0x003E, 0x003F,
+ 0x0040, 0x0041, 0x0042, 0x0043, 0x0044, 0x0045, 0x0046, 0x0047,
+ 0x0048, 0x0049, 0x004A, 0x004B, 0x004C, 0x004D, 0x004E, 0x004F,
+ 0x0050, 0x0051, 0x0052, 0x0053, 0x0054, 0x0055, 0x0056, 0x0057,
+ 0x0058, 0x0059, 0x005A, 0x005B, 0x005C, 0x005D, 0x005E, 0x005F,
+ 0x0060, 0x0061, 0x0062, 0x0063, 0x0064, 0x0065, 0x0066, 0x0067,
+ 0x0068, 0x0069, 0x006A, 0x006B, 0x006C, 0x006D, 0x006E, 0x006F,
+ 0x0070, 0x0071, 0x0072, 0x0073, 0x0074, 0x0075, 0x0076, 0x0077,
+ 0x0078, 0x0079, 0x007A, 0x007B, 0x007C, 0x007D, 0x007E, 0x007F,
+ 0x20AC, NONE, 0x201A, 0x0192, 0x201E, 0x2026, 0x2020, 0x2021,
+ 0x02C6, 0x2030, NONE, 0x2039, 0x0152, NONE, NONE, NONE,
+ NONE, 0x2018, 0x2019, 0x201C, 0x201D, 0x2022, 0x2013, 0x2014,
+ 0x02DC, 0x2122, NONE, 0x203A, 0x0153, NONE, NONE, 0x0178,
+ 0x00A0, 0x00A1, 0x00A2, 0x00A3, 0x00A4, 0x00A5, 0x00A6, 0x00A7,
+ 0x00A8, 0x00A9, 0x00AA, 0x00AB, 0x00AC, 0x00AD, 0x00AE, 0x00AF,
+ 0x00B0, 0x00B1, 0x00B2, 0x00B3, 0x00B4, 0x00B5, 0x00B6, 0x00B7,
+ 0x00B8, 0x00B9, 0x00BA, 0x00BB, 0x00BC, 0x00BD, 0x00BE, 0x00BF,
+ 0x00C0, 0x00C1, 0x00C2, 0x0102, 0x00C4, 0x00C5, 0x00C6, 0x00C7,
+ 0x00C8, 0x00C9, 0x00CA, 0x00CB, 0x0300, 0x00CD, 0x00CE, 0x00CF,
+ 0x0110, 0x00D1, 0x0309, 0x00D3, 0x00D4, 0x01A0, 0x00D6, 0x00D7,
+ 0x00D8, 0x00D9, 0x00DA, 0x00DB, 0x00DC, 0x01AF, 0x0303, 0x00DF,
+ 0x00E0, 0x00E1, 0x00E2, 0x0103, 0x00E4, 0x00E5, 0x00E6, 0x00E7,
+ 0x00E8, 0x00E9, 0x00EA, 0x00EB, 0x0301, 0x00ED, 0x00EE, 0x00EF,
+ 0x0111, 0x00F1, 0x0323, 0x00F3, 0x00F4, 0x01A1, 0x00F6, 0x00F7,
+ 0x00F8, 0x00F9, 0x00FA, 0x00FB, 0x00FC, 0x01B0, 0x20AB, 0x00FF
+ };
+
+ public Windows1258()
+ {
+ super("windows-1258", new String[] {
+ "Windows1258",
+ "cp1258",
+ "cp-1258",
+ "cp_1258",
+ "windows1258",
+ "windows_1258"
+ });
+ lookupTable = lookup;
+ }
+
+} // class Windows1258
+
Added: llvm-gcc-4.2/trunk/libjava/classpath/gnu/java/nio/charset/iconv/IconvCharset.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/gnu/java/nio/charset/iconv/IconvCharset.java?rev=43913&view=auto
==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/gnu/java/nio/charset/iconv/IconvCharset.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/gnu/java/nio/charset/iconv/IconvCharset.java Thu Nov 8 16:56:19 2007
@@ -0,0 +1,85 @@
+/* IconvCharset.java -- Wrapper for iconv charsets.
+ Copyright (C) 2005 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 gnu.java.nio.charset.iconv;
+
+import java.nio.charset.Charset;
+import java.nio.charset.CharsetDecoder;
+import java.nio.charset.CharsetEncoder;
+
+public final class IconvCharset extends Charset
+{
+ private IconvMetaData info;
+
+ public IconvCharset(IconvMetaData info)
+ {
+ super(info.nioCanonical(), info.aliases());
+ this.info = info;
+ if (newEncoder() == null || newDecoder() == null)
+ throw new IllegalArgumentException();
+ }
+
+ public boolean contains(Charset cs)
+ {
+ return false;
+ }
+
+ public CharsetDecoder newDecoder()
+ {
+ try
+ {
+ return new IconvDecoder(this, info);
+ }
+ catch (IllegalArgumentException e)
+ {
+ return null;
+ }
+ }
+
+ public CharsetEncoder newEncoder()
+ {
+ try
+ {
+ return new IconvEncoder(this, info);
+ }
+ catch (IllegalArgumentException e)
+ {
+ return null;
+ }
+ }
+}
Added: llvm-gcc-4.2/trunk/libjava/classpath/gnu/java/nio/charset/iconv/IconvDecoder.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/gnu/java/nio/charset/iconv/IconvDecoder.java?rev=43913&view=auto
==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/gnu/java/nio/charset/iconv/IconvDecoder.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/gnu/java/nio/charset/iconv/IconvDecoder.java Thu Nov 8 16:56:19 2007
@@ -0,0 +1,112 @@
+/* IconvDecoder.java --
+ Copyright (C) 2005 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 gnu.java.nio.charset.iconv;
+
+import gnu.classpath.Pointer;
+
+import java.nio.ByteBuffer;
+import java.nio.CharBuffer;
+import java.nio.charset.Charset;
+import java.nio.charset.CharsetDecoder;
+import java.nio.charset.CoderResult;
+
+final class IconvDecoder extends CharsetDecoder
+{
+ IconvDecoder(Charset cs, IconvMetaData info)
+ {
+ super(cs, info.averageCharsPerByte(), info.maxCharsPerByte());
+ openIconv(info.iconvName());
+ }
+
+ private Pointer data;
+ private int inremaining;
+ private int outremaining;
+
+ private native void openIconv(String name);
+
+ private native int decode(byte[] in, char[] out, int posIn, int remIn,
+ int posOut, int remOut);
+
+ private native void closeIconv();
+
+ protected CoderResult decodeLoop(ByteBuffer in, CharBuffer out)
+ {
+ int remIn = in.remaining();
+ int inPos = in.position();
+ int outPos = out.position();
+ int remOut = out.remaining();
+ byte[] inArr;
+ int ret;
+
+ if (in.hasArray())
+ inArr = in.array();
+ else
+ {
+ inArr = new byte[remIn];
+ in.get(inArr);
+ }
+
+ if (out.hasArray())
+ {
+ ret = decode(inArr, out.array(), inPos, remIn, outPos, remOut);
+ out.position(outPos + (remOut - outremaining));
+ }
+ else
+ {
+ char[] outArr = new char[remOut];
+ ret = decode(inArr, outArr, inPos, remIn, outPos, remOut);
+ out.put(outArr, 0, (remOut - outremaining));
+ }
+ in.position(inPos + (remIn - inremaining));
+
+ if (ret == 1)
+ return CoderResult.malformedForLength(1);
+
+ if (in.remaining() == 0)
+ return CoderResult.UNDERFLOW;
+ return CoderResult.OVERFLOW;
+ }
+
+ protected void finalize()
+ {
+ closeIconv();
+ }
+}
+
+
Added: llvm-gcc-4.2/trunk/libjava/classpath/gnu/java/nio/charset/iconv/IconvEncoder.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/gnu/java/nio/charset/iconv/IconvEncoder.java?rev=43913&view=auto
==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/gnu/java/nio/charset/iconv/IconvEncoder.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/gnu/java/nio/charset/iconv/IconvEncoder.java Thu Nov 8 16:56:19 2007
@@ -0,0 +1,110 @@
+/* IconvEncoder.java --
+ Copyright (C) 2005 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 gnu.java.nio.charset.iconv;
+
+import gnu.classpath.Pointer;
+
+import java.nio.ByteBuffer;
+import java.nio.CharBuffer;
+import java.nio.charset.Charset;
+import java.nio.charset.CharsetEncoder;
+import java.nio.charset.CoderResult;
+
+final class IconvEncoder extends CharsetEncoder
+{
+ private Pointer data;
+ private int inremaining;
+ private int outremaining;
+
+ private native void openIconv(String name);
+
+ private native int encode(char[] in, byte[] out, int posIn, int remIn,
+ int posOut, int remOut);
+
+ private native void closeIconv();
+
+ IconvEncoder(Charset cs, IconvMetaData info)
+ {
+ super(cs, info.averageBytesPerChar(), info.maxBytesPerChar());
+ openIconv(info.iconvName());
+ }
+
+ protected CoderResult encodeLoop(CharBuffer in, ByteBuffer out)
+ {
+ int inPos = in.position();
+ int outPos = out.position();
+ int remIn = in.remaining();
+ int remOut = out.remaining();
+ char[] inArr;
+ int ret;
+
+ if (in.hasArray())
+ inArr = in.array();
+ else
+ {
+ inArr = new char[remIn];
+ in.get(inArr);
+ }
+
+ if (out.hasArray())
+ {
+ ret = encode(inArr, out.array(), inPos, remIn, outPos, remOut);
+ out.position(outPos + (remOut - outremaining));
+ }
+ else
+ {
+ byte[] outArr = new byte[remOut];
+ ret = encode(inArr, outArr, inPos, remIn, outPos, remOut);
+ out.put(outArr, 0, (remOut - outremaining));
+ }
+ in.position(inPos + (remIn - inremaining));
+
+ if (ret == 1)
+ return CoderResult.malformedForLength(1);
+
+ if (in.remaining() == 0)
+ return CoderResult.UNDERFLOW;
+ return CoderResult.OVERFLOW;
+ }
+
+ protected void finalize()
+ {
+ closeIconv();
+ }
+}
Added: llvm-gcc-4.2/trunk/libjava/classpath/gnu/java/nio/charset/iconv/IconvMetaData.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/gnu/java/nio/charset/iconv/IconvMetaData.java?rev=43913&view=auto
==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/gnu/java/nio/charset/iconv/IconvMetaData.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/gnu/java/nio/charset/iconv/IconvMetaData.java Thu Nov 8 16:56:19 2007
@@ -0,0 +1,450 @@
+/* IconvMetaData.java --
+ Copyright (C) 2005 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 gnu.java.nio.charset.iconv;
+
+import java.util.HashMap;
+import java.util.Vector;
+
+/**
+ * This is ugly glue. iconv doesn't have character metadata,
+ * so we include it here.
+ *
+ * TODO: Add more charsets which GNU iconv and the JDK support which aren't
+ * included here.
+ *
+ * @author Sven de Marothy
+ */
+final class IconvMetaData
+{
+ /**
+ * Map of names (and aliases) to metadata instances
+ */
+ private static HashMap names;
+
+ /**
+ * Vector of MetaData instances
+ */
+ private static Vector charsets;
+
+ /**
+ * Name to use with iconv (may differ from the nio canonical.
+ */
+ private String iconvName;
+
+ /**
+ * Average number of bytes per char.
+ */
+ private float averageBperC;
+
+ /**
+ * Maximum number of bytes per char.
+ */
+ private float maxBperC;
+
+ /**
+ * Average number of chars per byte.
+ */
+ private float averageCperB;
+
+ /**
+ * Maximum number of chars per byte.
+ */
+ private float maxCperB;
+
+ /**
+ * NIO canonical name.
+ */
+ private String nioCanonical;
+
+ /**
+ * Charset aliases.
+ */
+ private String[] aliases;
+
+ IconvMetaData(String nioCanonical, float averageBperC, float maxBperC,
+ float averageCperB, float maxCperB, String[] aliases,
+ String iconvName)
+ {
+ this.nioCanonical = nioCanonical;
+ this.iconvName = iconvName;
+
+ this.averageBperC = averageBperC;
+ this.maxBperC = maxBperC;
+ this.averageCperB = averageCperB;
+ this.maxCperB = maxCperB;
+ this.aliases = aliases;
+
+ names.put(nioCanonical, this);
+ names.put(iconvName, this);
+ for (int i = 0; i < aliases.length; i++)
+ names.put(aliases[i], this);
+ charsets.add(this);
+ }
+
+ static Vector charsets()
+ {
+ return charsets;
+ }
+
+ String[] aliases()
+ {
+ return aliases;
+ }
+
+ String nioCanonical()
+ {
+ return nioCanonical;
+ }
+
+ String iconvName()
+ {
+ return iconvName;
+ }
+
+ float maxBytesPerChar()
+ {
+ return maxBperC;
+ }
+
+ float maxCharsPerByte()
+ {
+ return maxCperB;
+ }
+
+ float averageBytesPerChar()
+ {
+ return averageBperC;
+ }
+
+ float averageCharsPerByte()
+ {
+ return averageCperB;
+ }
+
+ static IconvMetaData get(String s)
+ {
+ return (IconvMetaData) names.get(s);
+ }
+
+ static void setup()
+ {
+ names = new HashMap();
+ charsets = new Vector();
+ new IconvMetaData("Big5", 2.0f, 2.0f, 0.5f, 1.0f,
+ new String[] { "big-5", "csBig5" }, "Big5");
+
+ new IconvMetaData("Big5-HKSCS", 2.0f, 2.0f, 0.5f, 1.0f,
+ new String[] { "big5-hkscs", "Big5_HKSCS", "big5hkscs" },
+ "Big5-HKSCS");
+
+ new IconvMetaData("EUC-CN", 2.0f, 2.0f, 0.5f, 1.0f, new String[] { },
+ "EUC-CN");
+
+ new IconvMetaData("EUC-JP", 3.0f, 3.0f, 0.5f, 1.0f,
+ new String[]
+ {
+ "eucjis", "x-eucjp", "csEUCPkdFmtjapanese", "eucjp",
+ "Extended_UNIX_Code_Packed_Format_for_Japanese",
+ "x-euc-jp", "euc_jp"
+ }, "EUC-JP");
+
+ new IconvMetaData("EUC-KR", 2.0f, 2.0f, 0.5f, 1.0f,
+ new String[]
+ {
+ "ksc5601", "5601", "ksc5601_1987", "ksc_5601",
+ "ksc5601-1987", "euc_kr", "ks_c_5601-1987", "euckr",
+ "csEUCKR"
+ }, "EUC-KR");
+
+ new IconvMetaData("EUC-TW", 4.0f, 4.0f, 2.0f, 2.0f,
+ new String[] { "cns11643", "euc_tw", "euctw", }, "EUC-TW");
+
+ new IconvMetaData("GB18030", 4.0f, 4.0f, 1.0f, 2.0f,
+ new String[] { "gb18030-2000", }, "GB18030");
+
+ new IconvMetaData("GBK", 2.0f, 2.0f, 0.5f, 1.0f, new String[] { "GBK" },
+ "GBK");
+
+ new IconvMetaData("ISO-2022-CN-CNS", 4.0f, 4.0f, 2.0f, 2.0f,
+ new String[] { "ISO2022CN_CNS" }, "ISO-2022-CN"); // will this work?
+
+ new IconvMetaData("ISO-2022-CN-GB", 4.0f, 4.0f, 2.0f, 2.0f,
+ new String[] { "ISO2022CN_GB" }, "ISO-2022-CN"); // same here?
+
+ new IconvMetaData("ISO-2022-KR", 4.0f, 4.0f, 1.0f, 1.0f,
+ new String[] { "ISO2022KR", "csISO2022KR" },
+ "ISO-2022-KR");
+
+ new IconvMetaData("ISO-8859-1", 1.0f, 1.0f, 1.0f, 1.0f,
+ new String[]
+ {
+ "iso-ir-100", "ISO_8859-1", "latin1", "l1", "IBM819",
+ "CP819", "csISOLatin1", "8859_1", "ISO8859_1",
+ "ISO_8859_1", "ibm-819", "ISO_8859-1:1987", "819"
+ }, "ISO-8859-1");
+
+ new IconvMetaData("ISO-8859-13", 1.0f, 1.0f, 1.0f, 1.0f,
+ new String[]
+ {
+ "ISO8859_13", "8859_13", "ibm-921_P100-1995", "ibm-921",
+ "iso_8859_13", "iso8859_13", "iso-8859-13", "8859_13",
+ "cp921", "921"
+ }, "ISO-8859-13");
+
+ new IconvMetaData("ISO-8859-15", 1.0f, 1.0f, 1.0f, 1.0f,
+ new String[]
+ {
+ "8859_15", "csISOlatin9", "IBM923", "cp923", "923",
+ "LATIN0", "csISOlatin0", "ISO8859_15_FDIS", "L9",
+ "IBM-923", "ISO8859-15", "LATIN9", "ISO_8859-15",
+ "ISO-8859-15",
+ }, "ISO-8859-15");
+
+ new IconvMetaData("ISO-8859-2", 1.0f, 1.0f, 1.0f, 1.0f,
+ new String[]
+ {
+ "ISO8859_2", "8859_2", "ibm-912_P100-1995", "ibm-912",
+ "iso_8859_2", "iso8859_2", "iso-8859-2",
+ "ISO_8859-2:1987", "latin2", "csISOLatin2",
+ "iso-ir-101", "l2", "cp912", "912", "windows-28592"
+ }, "ISO-8859-2");
+
+ new IconvMetaData("ISO-8859-3", 1.0f, 1.0f, 1.0f, 1.0f,
+ new String[]
+ {
+ "ISO8859_3", "8859_3", "ibm-913_P100-2000", "ibm-913",
+ "iso_8859_3", "iso8859_3", "iso-8859-3",
+ "ISO_8859-3:1988", "latin3", "csISOLatin3",
+ "iso-ir-109", "l3", "cp913", "913", "windows-28593"
+ }, "ISO-8859-3");
+
+ new IconvMetaData("ISO-8859-4", 1.0f, 1.0f, 1.0f, 1.0f,
+ new String[]
+ {
+ "ISO8859_4", "8859_4", "ibm-914_P100-1995", "ibm-914",
+ "iso_8859_4", "iso8859_4", "iso-8859-4", "latin4",
+ "csISOLatin4", "iso-ir-110", "ISO_8859-4:1988", "l4",
+ "cp914", "914", "windows-28594"
+ }, "ISO-8859-4");
+
+ new IconvMetaData("ISO-8859-5", 1.0f, 1.0f, 1.0f, 1.0f,
+ new String[]
+ {
+ "ISO8859_5", "8859_5", "ibm-915_P100-1995", "ibm-915",
+ "iso_8859_5", "iso8859_5", "iso-8859-5", "cyrillic",
+ "csISOLatinCyrillic", "iso-ir-144", "ISO_8859-5:1988",
+ "cp915", "915", "windows-28595"
+ }, "ISO-8859-5");
+
+ new IconvMetaData("ISO-8859-6", 1.0f, 1.0f, 1.0f, 1.0f,
+ new String[]
+ {
+ "8859_6", "ibm-1089_P100-1995", "ibm-1089",
+ "iso_8859_6", "iso8859_6", "iso-8859-6", "arabic",
+ "csISOLatinArabic", "iso-ir-127", "ISO_8859-6:1987",
+ "ECMA-114", "ASMO-708", "8859_6", "cp1089", "1089",
+ "windows-28596", "ISO-8859-6-I", "ISO-8859-6-E"
+ }, "ISO-8859-6");
+
+ new IconvMetaData("ISO-8859-7", 1.0f, 1.0f, 1.0f, 1.0f,
+ new String[]
+ {
+ "ISO8859_7", "8859_7", "ibm-813_P100-1995", "ibm-813",
+ "iso_8859_7", "iso8859_7", "iso-8859-7", "greek",
+ "greek8", "ELOT_928", "ECMA-118", "csISOLatinGreek",
+ "iso-ir-126", "ISO_8859-7:1987", "cp813", "813",
+ "windows-28597"
+ }, "ISO-8859-7");
+
+ new IconvMetaData("ISO-8859-8", 1.0f, 1.0f, 1.0f, 1.0f,
+ new String[]
+ {
+ "ISO8859_8", "8859_8", "ibm-916_P100-1995", "ibm-916",
+ "iso_8859_8", "iso8859_8", "iso-8859-8", "hebrew",
+ "csISOLatinHebrew", "iso-ir-138", "ISO_8859-8:1988",
+ "ISO-8859-8-I", "ISO-8859-8-E", "cp916", "916",
+ "windows-28598"
+ }, "ISO-8859-8");
+
+ new IconvMetaData("ISO-8859-9", 1.0f, 1.0f, 1.0f, 1.0f,
+ new String[]
+ {
+ "ISO8859_9", "8859_9", "ibm-920_P100-1995", "ibm-920",
+ "iso8859_9", "iso-8859-9", "iso_8859_9", "latin5",
+ "csISOLatin5", "iso-ir-148", "ISO_8859-9:1989", "l5",
+ "cp920", "920", "windows-28599", "ECMA-128"
+ }, "ISO-8859-9");
+
+ new IconvMetaData("Johab", 2.0f, 2.0f, 0.5f, 1.0f,
+ new String[] { "ms1361", "ksc5601_1992", "ksc5601-1992", },
+ "Johab");
+
+ new IconvMetaData("KOI8-R", 1.0f, 1.0f, 1.0f, 1.0f,
+ new String[]
+ {
+ "KOI8_R", "KOI8", "KOI-8", "KOI_8", "koi8-r", "koi8r",
+ "koi-8-r", "koi"
+ }, "KOI8-R");
+
+ new IconvMetaData("Shift_JIS", 2.0f, 2.0f, 0.5f, 1.0f,
+ new String[]
+ {
+ "shift-jis", "x-sjis", "ms_kanji", "shift_jis",
+ "csShiftJIS", "sjis", "pck",
+ }, "Shift_JIS");
+
+ new IconvMetaData("TIS-620", 1.0f, 1.0f, 1.0f, 1.0f, new String[] { },
+ "TIS-620");
+
+ new IconvMetaData("US-ASCII", 1.0f, 1.0f, 1.0f, 1.0f,
+ new String[]
+ {
+ "IBM367", "ISO646-US", "ANSI_X3.4-1986", "cp367",
+ "ASCII", "iso_646.irv:1983", "646", "us", "iso-ir-6",
+ "csASCII", "ANSI_X3.4-1968", "ISO_646.irv:1991",
+ }, "US-ASCII");
+
+ new IconvMetaData("UTF-16", 2.0f, 4.0f, 0.5f, 1.0f,
+ new String[]
+ {
+ "UTF_16", "UTF16", "ISO-10646-UCS-2", "unicode",
+ "csUnicode", "ucs-2", "UnicodeBig"
+ }, "UTF-16");
+
+ new IconvMetaData("UTF-16BE", 2.0f, 2.0f, 0.5f, 1.0f,
+ new String[]
+ {
+ "X-UTF-16BE", "UTF_16BE", "UTF16BE", "ISO-10646-UCS-2",
+ "x-utf-16be", "ibm-1200", "ibm-1201", "ibm-5297",
+ "ibm-13488", "ibm-17584", "windows-1201", "cp1200",
+ "cp1201", "UnicodeBigUnmarked"
+ }, "UTF-16BE");
+
+ new IconvMetaData("UTF-16LE", 2.0f, 2.0f, 0.5f, 1.0f,
+ new String[]
+ {
+ "UTF_16LE", "UTF16LE", "X-UTF-16LE", "ibm-1202",
+ "ibm-13490", "ibm-17586", "UTF16_LittleEndian",
+ "UnicodeLittleUnmarked"
+ }, "UTF-16LE");
+
+ new IconvMetaData("UTF-8", 1.1f, 4.0f, 1.0f, 2.0f,
+ new String[]
+ {
+ "UTF8", "ibm-1208", "ibm-1209", "ibm-5304", "ibm-5305",
+ "windows-65001", "cp1208"
+ }, "UTF-8");
+
+ new IconvMetaData("windows-1250", 1.0f, 1.0f, 1.0f, 1.0f,
+ new String[]
+ {
+ "Windows1250", "ibm-5346_P100-1998", "ibm-5346",
+ "cp1250", "cp-1250", "cp_1250", "windows1250",
+ "windows_1250"
+ }, "windows-1250");
+
+ new IconvMetaData("windows-1251", 1.0f, 1.0f, 1.0f, 1.0f,
+ new String[]
+ {
+ "Windows1251", "cp1251", "cp-1251", "cp_1251",
+ "windows1251", "windows_1251"
+ }, "windows-1251");
+
+ new IconvMetaData("windows-1252", 1.0f, 1.0f, 1.0f, 1.0f,
+ new String[]
+ {
+ "Windows1252", "ibm-5348_P100-1997", "ibm-5348",
+ "windows-1252", "cp1252", "cp-1252"
+ }, "windows-1252");
+
+ new IconvMetaData("windows-1253", 1.0f, 1.0f, 1.0f, 1.0f,
+ new String[]
+ {
+ "Windows1253", "cp1253", "cp-1253", "cp_1253",
+ "windows1253", "windows_1253"
+ }, "windows-1253");
+
+ new IconvMetaData("windows-1254", 1.0f, 1.0f, 1.0f, 1.0f,
+ new String[]
+ {
+ "Windows1254", "cp1254", "cp-1254", "cp_1254",
+ "windows1254", "windows_1254"
+ }, "windows-1254");
+
+ new IconvMetaData("windows-1255", 1.0f, 1.0f, 1.0f, 1.0f,
+ new String[]
+ {
+ "Windows1255", "cp1255", "cp-1255", "cp_1255",
+ "windows1255", "windows_1255"
+ }, "windows-1255");
+
+ new IconvMetaData("windows-1256", 1.0f, 1.0f, 1.0f, 1.0f,
+ new String[]
+ {
+ "Windows1255", "cp1256", "cp-1256", "cp_1256",
+ "windows1256", "windows_1256"
+ }, "windows-1256");
+
+ new IconvMetaData("windows-1257", 1.0f, 1.0f, 1.0f, 1.0f,
+ new String[]
+ {
+ "Windows1255", "cp1257", "cp-1257", "cp_1257",
+ "windows1257", "windows_1257"
+ }, "windows-1257");
+
+ new IconvMetaData("windows-1258", 1.0f, 1.0f, 1.0f, 1.0f,
+ new String[]
+ {
+ "Windows1255", "cp1258", "cp-1258", "cp_1258",
+ "windows1258", "windows_1258"
+ }, "windows-1258");
+
+ new IconvMetaData("windows-936", 2.0f, 2.0f, 0.5f, 1.0f,
+ new String[] { "cp936", "ms-936", "ms936", "ms_936" },
+ "windows-936");
+
+ new IconvMetaData("windows-949", 2.0f, 2.0f, 0.5f, 1.0f,
+ new String[] { "cp949", "ms-949", "ms_949", "ms949" },
+ "cp949");
+
+ new IconvMetaData("windows-950", 2.0f, 2.0f, 0.5f, 1.0f,
+ new String[] { "cp950", "ms_950", "ms-950", "ms950", },
+ "cp950");
+ }
+}
Added: llvm-gcc-4.2/trunk/libjava/classpath/gnu/java/nio/charset/iconv/IconvProvider.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/gnu/java/nio/charset/iconv/IconvProvider.java?rev=43913&view=auto
==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/gnu/java/nio/charset/iconv/IconvProvider.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/gnu/java/nio/charset/iconv/IconvProvider.java Thu Nov 8 16:56:19 2007
@@ -0,0 +1,110 @@
+/* IconvProvider.java --
+ Copyright (C) 2005, 2006 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 gnu.java.nio.charset.iconv;
+
+import java.nio.charset.Charset;
+import java.nio.charset.spi.CharsetProvider;
+import java.util.Iterator;
+import java.util.Vector;
+
+/**
+ * Charset provider wrapping iconv.
+ *
+ * Note: This class is a privileged class, because it can be instantiated without
+ * requiring the RuntimePermission("charsetProvider"). There is a check in
+ * java.nio.charset.spi.CharsetProvider to skip the security check if the provider
+ * is an instance of this class.
+ *
+ * @author Sven de Marothy
+ */
+public final class IconvProvider extends CharsetProvider
+{
+ private static IconvProvider singleton;
+
+ // Declaring the construtor public may violate the use of singleton.
+ // But it must be public so that an instance of this class can be
+ // created by Class.newInstance(), which is the case when this provider is
+ // defined in META-INF/services/java.nio.charset.spi.CharsetProvider.
+ public IconvProvider()
+ {
+ IconvMetaData.setup();
+ }
+
+ public Iterator charsets()
+ {
+ Vector names = IconvMetaData.charsets();
+ Vector charsets = new Vector();
+ for (int i = 0; i < names.size(); i++)
+ {
+ try
+ {
+ charsets.add(new IconvCharset((IconvMetaData) names.elementAt(i)));
+ }
+ catch (IllegalArgumentException e)
+ {
+ }
+ }
+ return charsets.iterator();
+ }
+
+ public Charset charsetForName(String charsetName)
+ {
+ try
+ {
+ IconvMetaData info = IconvMetaData.get(charsetName);
+
+ // Try anyway if the set isn't found.
+ if (info == null)
+ info = new IconvMetaData(charsetName, 2.0f, 2.0f, 2.0f, 2.0f,
+ new String[] { }, charsetName);
+ return new IconvCharset(info);
+ }
+ catch (IllegalArgumentException e)
+ {
+ return null;
+ }
+ }
+
+ public static synchronized IconvProvider provider()
+ {
+ if (singleton == null)
+ singleton = new IconvProvider();
+ return singleton;
+ }
+}
Added: llvm-gcc-4.2/trunk/libjava/classpath/gnu/java/nio/charset/package.html
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/gnu/java/nio/charset/package.html?rev=43913&view=auto
==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/gnu/java/nio/charset/package.html (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/gnu/java/nio/charset/package.html Thu Nov 8 16:56:19 2007
@@ -0,0 +1,46 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
+<!-- package.html - describes classes in gnu.java.nio.charset package.
+ Copyright (C) 2005 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. -->
+
+<html>
+<head><title>GNU Classpath - gnu.java.nio.charset</title></head>
+
+<body>
+<p></p>
+
+</body>
+</html>
Added: llvm-gcc-4.2/trunk/libjava/classpath/gnu/java/nio/package.html
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/gnu/java/nio/package.html?rev=43913&view=auto
==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/gnu/java/nio/package.html (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/gnu/java/nio/package.html Thu Nov 8 16:56:19 2007
@@ -0,0 +1,46 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
+<!-- package.html - describes classes in gnu.java.nio package.
+ Copyright (C) 2005 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. -->
+
+<html>
+<head><title>GNU Classpath - gnu.java.nio</title></head>
+
+<body>
+<p></p>
+
+</body>
+</html>
Added: llvm-gcc-4.2/trunk/libjava/classpath/gnu/java/rmi/RMIMarshalledObjectInputStream.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/gnu/java/rmi/RMIMarshalledObjectInputStream.java?rev=43913&view=auto
==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/gnu/java/rmi/RMIMarshalledObjectInputStream.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/gnu/java/rmi/RMIMarshalledObjectInputStream.java Thu Nov 8 16:56:19 2007
@@ -0,0 +1,71 @@
+/* gnu.java.rmi.RMIMarshalledObjectInputStream
+ Copyright (C) 2002 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 gnu.java.rmi;
+
+import gnu.java.rmi.server.RMIObjectInputStream;
+
+import java.io.ByteArrayInputStream;
+import java.io.IOException;
+import java.io.ObjectInputStream;
+
+/**
+ * This class is only for java.rmi.MarshalledObject to deserialize object from
+ * objBytes and locBytes
+ */
+
+public class RMIMarshalledObjectInputStream extends RMIObjectInputStream
+{
+ private ObjectInputStream locStream;
+
+ public RMIMarshalledObjectInputStream(byte[] objBytes, byte[] locBytes) throws IOException
+ {
+ super(new ByteArrayInputStream(objBytes));
+ if(locBytes != null)
+ locStream = new ObjectInputStream(new ByteArrayInputStream(locBytes));
+ }
+
+ //This method overrides RMIObjectInputStream's
+ protected Object getAnnotation() throws IOException, ClassNotFoundException
+ {
+ if(locStream == null)
+ return null;
+ return locStream.readObject();
+ }
+
+} // End of RMIMarshalledObjectInputStream
Added: llvm-gcc-4.2/trunk/libjava/classpath/gnu/java/rmi/RMIMarshalledObjectOutputStream.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/gnu/java/rmi/RMIMarshalledObjectOutputStream.java?rev=43913&view=auto
==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/gnu/java/rmi/RMIMarshalledObjectOutputStream.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/gnu/java/rmi/RMIMarshalledObjectOutputStream.java Thu Nov 8 16:56:19 2007
@@ -0,0 +1,79 @@
+/* gnu.java.rmi.RMIMarshalledObjectOutputStream
+ Copyright (C) 2002, 2004 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 gnu.java.rmi;
+
+import gnu.java.rmi.server.RMIObjectOutputStream;
+
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.io.ObjectOutputStream;
+import java.io.OutputStream;
+
+/**
+ * This class is only for java.rmi.MarshalledObject to serialize object and
+ * got objBytes and locBytes
+ */
+public class RMIMarshalledObjectOutputStream extends RMIObjectOutputStream
+{
+ private ObjectOutputStream locStream;
+ private ByteArrayOutputStream locBytesStream;
+
+ public RMIMarshalledObjectOutputStream(OutputStream objStream) throws IOException
+ {
+ super(objStream);
+ locBytesStream = new ByteArrayOutputStream(256);
+ locStream = new ObjectOutputStream(locBytesStream);
+ }
+
+ //This method overrides RMIObjectOutputStream's.
+ protected void setAnnotation(String annotation) throws IOException{
+ locStream.writeObject(annotation);
+ }
+
+ public void flush() throws IOException {
+ super.flush();
+ locStream.flush();
+ }
+
+ public byte[] getLocBytes(){
+ return locBytesStream.toByteArray();
+ }
+
+} // End of RMIMarshalledObjectOutputStream
+
More information about the llvm-commits
mailing list