|
From: <ls...@us...> - 2006-12-12 21:13:11
|
Revision: 2898
http://jnode.svn.sourceforge.net/jnode/?rev=2898&view=rev
Author: lsantha
Date: 2006-12-12 13:13:08 -0800 (Tue, 12 Dec 2006)
Log Message:
-----------
Migrating to Java 5 level classpath.
Added Paths:
-----------
trunk/core/src/classpath/java/java/lang/annotation/
trunk/core/src/classpath/java/java/lang/annotation/Annotation.java
trunk/core/src/classpath/java/java/lang/annotation/AnnotationFormatError.java
trunk/core/src/classpath/java/java/lang/annotation/AnnotationTypeMismatchException.java
trunk/core/src/classpath/java/java/lang/annotation/Documented.java
trunk/core/src/classpath/java/java/lang/annotation/ElementType.java
trunk/core/src/classpath/java/java/lang/annotation/IncompleteAnnotationException.java
trunk/core/src/classpath/java/java/lang/annotation/Inherited.java
trunk/core/src/classpath/java/java/lang/annotation/Retention.java
trunk/core/src/classpath/java/java/lang/annotation/RetentionPolicy.java
trunk/core/src/classpath/java/java/lang/annotation/Target.java
trunk/core/src/classpath/java/java/lang/annotation/package.html
Added: trunk/core/src/classpath/java/java/lang/annotation/Annotation.java
===================================================================
--- trunk/core/src/classpath/java/java/lang/annotation/Annotation.java (rev 0)
+++ trunk/core/src/classpath/java/java/lang/annotation/Annotation.java 2006-12-12 21:13:08 UTC (rev 2898)
@@ -0,0 +1,135 @@
+/* Annotation.java - Base interface for all annotations
+ Copyright (C) 2004 Free Software Foundation
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+package java.lang.annotation;
+
+/**
+ * This is the common interface for all annotations. Note that classes
+ * that implement this class manually are not classed as annotations, and
+ * that this interface does not define an annotation type in itself.
+ *
+ * @author Tom Tromey (tr...@re...)
+ * @author Andrew John Hughes (gnu...@me...)
+ * @since 1.5
+ */
+public interface Annotation
+{
+
+ /**
+ * Returns the type of this annotation.
+ *
+ * @return the class of which this annotation is an instance.
+ */
+ Class<? extends Annotation> annotationType();
+
+ /**
+ * <p>
+ * Returns true if the supplied object is equivalent to this annotation.
+ * For this property to hold, the following must be true of <code>o</code>:
+ * </p>
+ * <ul>
+ * <li>The object is also an instance of the same annotation type.</li>
+ * <li>The members of the supplied annotation are equal to those of this
+ * annotation, according to the following:
+ * <ul>
+ * <li>If the members are <code>float</code>s, then, for floats
+ * <code>x</code> and <code>y</code>,
+ * <code>Float.valueOf(x).equals(Float.valueOf(y)</code> must return
+ * true. This differs from the usual (<code>==</code>) comparison
+ * in that <code>NaN</code> is considered equal to itself and positive
+ * and negative zero are seen as different.</li>
+ * <li>Likewise, if the members are <code>double</code>s, then, for doubles
+ * <code>x</code> and <code>y</code>,
+ * <code>Double.valueOf(x).equals(Double.valueOf(y)</code> must return
+ * true. This differs from the usual (<code>==</code>) comparison
+ * in that <code>NaN</code> is considered equal to itself and positive
+ * and negative zero are seen as different.</li>
+ * <li>Strings, classes, enumerations and annotations are considered
+ * equal according to the <code>equals()</code> implementation for these
+ * types.</li>
+ * <li>Arrays are considered equal according to <code>Arrays.equals()</code>
+ * </li>
+ * <li>Any remaining types are considered equal using <code>==</code>.</li>
+ * </li>
+ * </ul>
+ *
+ * @param o the object to compare with this annotation.
+ * @return true if the supplied object is an annotation with equivalent
+ * members.
+ */
+ boolean equals(Object o);
+
+ /**
+ * <p>
+ * Returns the hash code of the annotation. This is computed as the
+ * sum of the hash codes of the annotation's members.
+ * </p>
+ * <p>
+ * The hash code of a member of the annotation is the result of XORing
+ * the hash code of its value with the result of multiplying the hash code
+ * of its name by 127. Formally, if the value is <code>v</code> and the
+ * name is <code>n</code>, the hash code of the member is
+ * v.hashCode() XOR (127 * String.hashCode(n)). <code>v.hashCode()</code>
+ * is defined as follows:
+ * </p>
+ * <ul>
+ * <li>The hash code of a primitive value (i.e. <code>byte</code>,
+ * <code>char</code>, <code>double</code>, <code>float</code>,
+ * <code>int</code>, <code>long</code>, <code>short</code> and
+ * <code>boolean</code>) is the hash code obtained from its corresponding
+ * wrapper class using <code>valueOf(v).hashCode()</code>, where
+ * <code>v</code> is the primitive value.</li>
+ * <li>The hash code of an enumeration, string, class or other annotation
+ * is obtained using <code>v.hashCode()</code>.</li>
+ * <li>The hash code of an array is computed using
+ * <code>Arrays.hashCode(v)</code>.</li>
+ * </ul>
+ *
+ * @return the hash code of the annotation, computed as the sum of its
+ * member hashcodes.
+ */
+ int hashCode();
+
+ /**
+ * Returns a textual representation of the annotation. This is
+ * implementation-dependent, but is expected to include the classname
+ * and the names and values of each member.
+ *
+ * @return a textual representation of the annotation.
+ */
+ String toString();
+}
Added: trunk/core/src/classpath/java/java/lang/annotation/AnnotationFormatError.java
===================================================================
--- trunk/core/src/classpath/java/java/lang/annotation/AnnotationFormatError.java (rev 0)
+++ trunk/core/src/classpath/java/java/lang/annotation/AnnotationFormatError.java 2006-12-12 21:13:08 UTC (rev 2898)
@@ -0,0 +1,105 @@
+/* AnnotationFormatError.java - Thrown when an binary annotation is malformed
+ Copyright (C) 2004, 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 java.lang.annotation;
+
+/**
+ * Thrown when an annotation found in a class file is
+ * malformed. When the virtual machine finds a class file
+ * containing annotations, it attempts to parse them.
+ * This error is thrown if this operation fails.
+ *
+ * @author Tom Tromey (tr...@re...)
+ * @author Andrew John Hughes (gnu...@me...)
+ * @since 1.5
+ */
+public class AnnotationFormatError extends Error
+{
+ private static final long serialVersionUID = -4256701562333669892L;
+
+ /**
+ * Constructs a new <code>AnnotationFormatError</code>
+ * using the specified message to give details of the error.
+ *
+ * @param message the message to use in the error output.
+ */
+ public AnnotationFormatError(String message)
+ {
+ super(message);
+ }
+
+ /**
+ * <p>
+ * Constructs a new <code>AnnotationFormatError</code>
+ * using the specified message to give details of the error.
+ * The supplied cause <code>Throwable</code> is used to
+ * provide additional history, with regards to the root
+ * of the problem. It is perfectly valid for this to be null, if
+ * the cause is unknown.
+ * </p>
+ * <p>
+ * <strong>Note</strong>: if a cause is supplied, the error
+ * message from this cause is not automatically included in the
+ * error message given by this error.
+ * </p>
+ *
+ * @param message the message to use in the error output
+ * @param cause the cause of this error, or null if the cause
+ * is unknown.
+ */
+ public AnnotationFormatError(String message, Throwable cause)
+ {
+ super(message, cause);
+ }
+
+ /**
+ * Constructs a new <code>AnnotationFormatError</code> using
+ * the supplied cause <code>Throwable</code> to
+ * provide additional history, with regards to the root
+ * of the problem. It is perfectly valid for this to be null, if
+ * the cause is unknown. If the cause is not null, the error
+ * message from this cause will also be used as the message
+ * for this error.
+ *
+ * @param cause the cause of the error.
+ */
+ public AnnotationFormatError(Throwable cause)
+ {
+ super(cause);
+ }
+
+}
Added: trunk/core/src/classpath/java/java/lang/annotation/AnnotationTypeMismatchException.java
===================================================================
--- trunk/core/src/classpath/java/java/lang/annotation/AnnotationTypeMismatchException.java (rev 0)
+++ trunk/core/src/classpath/java/java/lang/annotation/AnnotationTypeMismatchException.java 2006-12-12 21:13:08 UTC (rev 2898)
@@ -0,0 +1,116 @@
+/* AnnotationTypeMismatchException.java - Thrown when annotation has changed
+ Copyright (C) 2004, 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 java.lang.annotation;
+
+import java.lang.reflect.Method;
+
+/**
+ * Thrown when accessing an element within an annotation for
+ * which the type has changed, since compilation or serialization
+ * took place. The mismatch between the compiled or serialized
+ * type and the current type causes this exception to be thrown.
+ *
+ * @author Tom Tromey (tr...@re...)
+ * @author Andrew John Hughes (gnu...@me...)
+ * @since 1.5
+ */
+public class AnnotationTypeMismatchException extends RuntimeException
+{
+
+ /**
+ * For compatability with Sun's JDK
+ */
+ private static final long serialVersionUID = 8125925355765570191L;
+
+ /**
+ * Constructs an <code>AnnotationTypeMismatchException</code>
+ * which is due to a mismatched type in the annotation
+ * element, <code>m</code>. The erroneous type used for the
+ * data in <code>m</code> is represented by the string,
+ * <code>type</code>. This string is of an undefined format,
+ * and may contain the value as well as the type.
+ *
+ * @param m the element from the annotation.
+ * @param type the name of the erroneous type found in <code>m</code>.
+ */
+ public AnnotationTypeMismatchException(Method m, String type)
+ {
+ this.element = m;
+ this.foundType = type;
+ }
+
+ /**
+ * Returns the element from the annotation, for which a
+ * mismatch occurred.
+ *
+ * @return the element with the mismatched type.
+ */
+ public Method element()
+ {
+ return element;
+ }
+
+ /**
+ * Returns the erroneous type used by the element,
+ * represented as a <code>String</code>. The format
+ * of this <code>String</code> is not explicitly specified,
+ * and may contain the value as well as the type.
+ *
+ * @return the type found in the element.
+ */
+ public String foundType()
+ {
+ return foundType;
+ }
+
+ // Names are chosen from serialization spec.
+ /**
+ * The element from the annotation.
+ *
+ * @serial the element with the mismatched type.
+ */
+ private Method element;
+
+ /**
+ * The erroneous type used by the element.
+ *
+ * @serial the type found in the element.
+ */
+ private String foundType;
+
+}
Added: trunk/core/src/classpath/java/java/lang/annotation/Documented.java
===================================================================
--- trunk/core/src/classpath/java/java/lang/annotation/Documented.java (rev 0)
+++ trunk/core/src/classpath/java/java/lang/annotation/Documented.java 2006-12-12 21:13:08 UTC (rev 2898)
@@ -0,0 +1,50 @@
+/* Documented.java - Indicates documented source element
+ Copyright (C) 2004, 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 java.lang.annotation;
+
+import static java.lang.annotation.RetentionPolicy.RUNTIME;
+
+/**
+ * @author Tom Tromey (tr...@re...)
+ * @author Andrew John Hughes (gnu...@me...)
+ * @since 1.5
+ */
+@Documented @Retention(RUNTIME)
+public @interface Documented
+{
+}
Added: trunk/core/src/classpath/java/java/lang/annotation/ElementType.java
===================================================================
--- trunk/core/src/classpath/java/java/lang/annotation/ElementType.java (rev 0)
+++ trunk/core/src/classpath/java/java/lang/annotation/ElementType.java 2006-12-12 21:13:08 UTC (rev 2898)
@@ -0,0 +1,59 @@
+/* ElementType.java - Enum listing Java source elements
+ Copyright (C) 2004 Free Software Foundation
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+package java.lang.annotation;
+
+/**
+ * @since 1.5
+ */
+public enum ElementType
+{
+ ANNOTATION_TYPE,
+ CONSTRUCTOR,
+ FIELD,
+ LOCAL_VARIABLE,
+ METHOD,
+ PACKAGE,
+ PARAMETER,
+ TYPE;
+
+ /**
+ * For compatability with Sun's JDK
+ */
+ private static final long serialVersionUID = 2798216111136361587L;
+
+}
Added: trunk/core/src/classpath/java/java/lang/annotation/IncompleteAnnotationException.java
===================================================================
--- trunk/core/src/classpath/java/java/lang/annotation/IncompleteAnnotationException.java (rev 0)
+++ trunk/core/src/classpath/java/java/lang/annotation/IncompleteAnnotationException.java 2006-12-12 21:13:08 UTC (rev 2898)
@@ -0,0 +1,107 @@
+/* IncompleteAnnotationException.java - Thrown when annotation has changed
+ Copyright (C) 2004 Free Software Foundation
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+package java.lang.annotation;
+
+/**
+ * Thrown when accessing an element within an annotation which
+ * was added since compilation or serialization took place, and
+ * does not have a default value.
+ *
+ * @author Tom Tromey (tr...@re...)
+ * @author Andrew John Hughes (gnu...@me...)
+ * @since 1.5
+ */
+public class IncompleteAnnotationException extends RuntimeException
+{
+
+ /**
+ * Constructs a new <code>IncompleteAnnotationException</code>
+ * which indicates that the element, <code>name</code>, was missing
+ * from the annotation, <code>type</code> at compile time and does
+ * not have a default value.
+ *
+ * @param type the type of annotation from which an element is missing.
+ * @param name the name of the missing element.
+ */
+ public IncompleteAnnotationException(Class<? extends Annotation> type,
+ String name)
+ {
+ this.annotationType = type;
+ this.elementName = name;
+ }
+
+ /**
+ * Returns the class representing the type of annotation
+ * from which an element was missing.
+ *
+ * @return the type of annotation.
+ */
+ public Class<? extends Annotation> annotationType()
+ {
+ return annotationType;
+ }
+
+ /**
+ * Returns the name of the missing annotation element.
+ *
+ * @return the element name.
+ */
+ public String elementName()
+ {
+ return elementName;
+ }
+
+ // Names are chosen from serialization spec.
+
+ /**
+ * The class representing the type of annotation from
+ * which an element was found to be missing.
+ *
+ * @serial the type of the annotation from which an
+ * element was missing.
+ */
+ private Class<? extends Annotation> annotationType;
+
+ /**
+ * The name of the missing element.
+ *
+ * @serial the name of the missing element.
+ */
+ private String elementName;
+
+}
Added: trunk/core/src/classpath/java/java/lang/annotation/Inherited.java
===================================================================
--- trunk/core/src/classpath/java/java/lang/annotation/Inherited.java (rev 0)
+++ trunk/core/src/classpath/java/java/lang/annotation/Inherited.java 2006-12-12 21:13:08 UTC (rev 2898)
@@ -0,0 +1,51 @@
+/* Inherited.java - Indicates inherited annotation
+ Copyright (C) 2004, 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 java.lang.annotation;
+
+import static java.lang.annotation.RetentionPolicy.RUNTIME;
+import static java.lang.annotation.ElementType.ANNOTATION_TYPE;
+
+/**
+ * @author Tom Tromey (tr...@re...)
+ * @author Andrew John Hughes (gnu...@me...)
+ * @since 1.5
+ */
+@Documented @Retention(RUNTIME) @Target(ANNOTATION_TYPE)
+public @interface Inherited
+{
+}
Added: trunk/core/src/classpath/java/java/lang/annotation/Retention.java
===================================================================
--- trunk/core/src/classpath/java/java/lang/annotation/Retention.java (rev 0)
+++ trunk/core/src/classpath/java/java/lang/annotation/Retention.java 2006-12-12 21:13:08 UTC (rev 2898)
@@ -0,0 +1,59 @@
+/* Retention.java - Retention policy for an annotation
+ Copyright (C) 2004, 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 java.lang.annotation;
+
+import static java.lang.annotation.RetentionPolicy.RUNTIME;
+import static java.lang.annotation.ElementType.ANNOTATION_TYPE;
+
+/**
+ * This annotation is used to specify the desired lifetime of another
+ * annotation.
+ *
+ * @author Tom Tromey (tr...@re...)
+ * @author Andrew John Hughes (gnu...@me...)
+ * @see RetentionPolicy
+ * @since 1.5
+ */
+@Documented @Retention(RUNTIME) @Target(ANNOTATION...
[truncated message content] |
|
From: <ls...@us...> - 2006-12-12 21:13:42
|
Revision: 2899
http://jnode.svn.sourceforge.net/jnode/?rev=2899&view=rev
Author: lsantha
Date: 2006-12-12 13:13:38 -0800 (Tue, 12 Dec 2006)
Log Message:
-----------
Migrating to Java 5 level classpath.
Added Paths:
-----------
trunk/core/src/classpath/java/java/lang/ref/
trunk/core/src/classpath/java/java/lang/ref/PhantomReference.java
trunk/core/src/classpath/java/java/lang/ref/Reference.java
trunk/core/src/classpath/java/java/lang/ref/ReferenceQueue.java
trunk/core/src/classpath/java/java/lang/ref/SoftReference.java
trunk/core/src/classpath/java/java/lang/ref/WeakReference.java
trunk/core/src/classpath/java/java/lang/ref/package.html
Added: trunk/core/src/classpath/java/java/lang/ref/PhantomReference.java
===================================================================
--- trunk/core/src/classpath/java/java/lang/ref/PhantomReference.java (rev 0)
+++ trunk/core/src/classpath/java/java/lang/ref/PhantomReference.java 2006-12-12 21:13:38 UTC (rev 2899)
@@ -0,0 +1,73 @@
+/* java.lang.ref.PhantomReference
+ Copyright (C) 1999, 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 java.lang.ref;
+
+/**
+ * A phantom reference is useful, to get notified, when an object got
+ * finalized. You can't access that object though, since it is
+ * finalized. This is the reason, why <code>get()</code> always
+ * returns null.
+ *
+ * @author Jochen Hoenicke
+ */
+public class PhantomReference<T>
+ extends Reference<T>
+{
+ /**
+ * Creates a new phantom reference.
+ * @param referent the object that should be watched.
+ * @param q the queue that should be notified, if the referent was
+ * finalized. This mustn't be <code>null</code>.
+ * @exception NullPointerException if q is null.
+ */
+ public PhantomReference(T referent, ReferenceQueue<? super T> q)
+ {
+ super(referent, q);
+ }
+
+ /**
+ * Returns the object, this reference refers to.
+ * @return <code>null</code>, since the refered object may be
+ * finalized and thus not accessible.
+ */
+ public T get()
+ {
+ return null;
+ }
+}
Added: trunk/core/src/classpath/java/java/lang/ref/Reference.java
===================================================================
--- trunk/core/src/classpath/java/java/lang/ref/Reference.java (rev 0)
+++ trunk/core/src/classpath/java/java/lang/ref/Reference.java 2006-12-12 21:13:38 UTC (rev 2899)
@@ -0,0 +1,177 @@
+/* java.lang.ref.Reference
+ Copyright (C) 1999, 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 java.lang.ref;
+
+/**
+ * This is the base class of all references. A reference allows
+ * refering to an object without preventing the garbage collector to
+ * collect it. The only way to get the referred object is via the
+ * <code>get()</code>-method. This method will return
+ * <code>null</code> if the object was collected. <br>
+ *
+ * A reference may be registered with a queue. When a referred
+ * element gets collected the reference will be put on the queue, so
+ * that you will be notified. <br>
+ *
+ * There are currently three types of references: soft reference,
+ * weak reference and phantom reference. <br>
+ *
+ * Soft references will be cleared if the garbage collector is told
+ * to free some memory and there are no unreferenced or weakly referenced
+ * objects. It is useful for caches. <br>
+ *
+ * Weak references will be cleared as soon as the garbage collector
+ * determines that the refered object is only weakly reachable. They
+ * are useful as keys in hashtables (see <code>WeakHashtable</code>) as
+ * you get notified when nobody has the key anymore.
+ *
+ * Phantom references don't prevent finalization. If an object is only
+ * phantom reachable, it will be finalized, and the reference will be
+ * enqueued, but not cleared. Since you mustn't access an finalized
+ * object, the <code>get</code> method of a phantom reference will never
+ * work. It is useful to keep track, when an object is finalized.
+ *
+ * @author Jochen Hoenicke
+ * @see java.util.WeakHashMap
+ */
+public abstract class Reference<T>
+{
+ /**
+ * The underlying object. This field is handled in a special way by
+ * the garbage collector.
+ */
+ T referent;
+
+ /**
+ * The queue this reference is registered on. This is null, if this
+ * wasn't registered to any queue or reference was already enqueued.
+ */
+ ReferenceQueue<? super T> queue;
+
+ /**
+ * Link to the next entry on the queue. If this is null, this
+ * reference is not enqueued. Otherwise it points to the next
+ * reference. The last reference on a queue will point to itself
+ * (not to null, that value is used to mark a not enqueued
+ * reference).
+ */
+ Reference nextOnQueue;
+
+ /**
+ * This lock should be taken by the garbage collector, before
+ * determining reachability. It will prevent the get()-method to
+ * return the reference so that reachability doesn't change.
+ */
+ static Object lock = new Object();
+
+ /**
+ * Creates a new reference that is not registered to any queue.
+ * Since it is package private, it is not possible to overload this
+ * class in a different package.
+ * @param ref the object we refer to.
+ */
+ Reference(T ref)
+ {
+ referent = ref;
+ }
+
+ /**
+ * Creates a reference that is registered to a queue. Since this is
+ * package private, it is not possible to overload this class in a
+ * different package.
+ * @param ref the object we refer to.
+ * @param q the reference queue to register on.
+ * @exception NullPointerException if q is null.
+ */
+ Reference(T ref, ReferenceQueue<? super T> q)
+ {
+ if (q == null)
+ throw new NullPointerException();
+ referent = ref;
+ queue = q;
+ }
+
+ /**
+ * Returns the object, this reference refers to.
+ * @return the object, this reference refers to, or null if the
+ * reference was cleared.
+ */
+ public T get()
+ {
+ synchronized (lock)
+ {
+ return referent;
+ }
+ }
+
+ /**
+ * Clears the reference, so that it doesn't refer to its object
+ * anymore. For soft and weak references this is called by the
+ * garbage collector. For phantom references you should call
+ * this when enqueuing the reference.
+ */
+ public void clear()
+ {
+ referent = null;
+ }
+
+ /**
+ * Tells if the object is enqueued on a reference queue.
+ * @return true if it is enqueued, false otherwise.
+ */
+ public boolean isEnqueued()
+ {
+ return nextOnQueue != null;
+ }
+
+ /**
+ * Enqueue an object on a reference queue. This is normally executed
+ * by the garbage collector.
+ */
+ public boolean enqueue()
+ {
+ if (queue != null && nextOnQueue == null)
+ {
+ queue.enqueue(this);
+ queue = null;
+ return true;
+ }
+ return false;
+ }
+}
Added: trunk/core/src/classpath/java/java/lang/ref/ReferenceQueue.java
===================================================================
--- trunk/core/src/classpath/java/java/lang/ref/ReferenceQueue.java (rev 0)
+++ trunk/core/src/classpath/java/java/lang/ref/ReferenceQueue.java 2006-12-12 21:13:38 UTC (rev 2899)
@@ -0,0 +1,145 @@
+/* java.lang.ref.ReferenceQueue
+ Copyright (C) 1999, 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 java.lang.ref;
+
+/**
+ * This is the queue, where references can enqueue themselve on. Each
+ * reference may be registered to a queue at initialization time and
+ * will be appended to the queue, when the enqueue method is called.
+ *
+ * The enqueue method may be automatically called by the garbage
+ * collector if it detects, that the object is only reachable through
+ * the Reference objects.
+ *
+ * @author Jochen Hoenicke
+ * @see Reference#enqueue()
+ */
+public class ReferenceQueue<T>
+{
+ /**
+ * This is a linked list of references. If this is null, the list is
+ * empty. Otherwise this points to the first reference on the queue.
+ * The first reference will point to the next reference via the
+ * <code>nextOnQueue</code> field. The last reference will point to
+ * itself (not to null, since <code>nextOnQueue</code> is used to
+ * determine if a reference is enqueued).
+ */
+ private Reference<? extends T> first;
+
+ /**
+ * Creates a new empty reference queue.
+ */
+ public ReferenceQueue()
+ {
+ }
+
+ /**
+ * Checks if there is a reference on the queue, returning it
+ * immediately. The reference will be dequeued.
+ *
+ * @return a reference on the queue, if there is one,
+ * <code>null</code> otherwise.
+ */
+ public synchronized Reference<? extends T> poll()
+ {
+ return dequeue();
+ }
+
+ /**
+ * This is called by reference to enqueue itself on this queue.
+ * @param ref the reference that should be enqueued.
+ */
+ synchronized void enqueue(Reference<? extends T> ref)
+ {
+ /* last reference will point to itself */
+ ref.nextOnQueue = first == null ? ref : first;
+ first = ref;
+ /* this wakes only one remove thread. */
+ notify();
+ }
+
+ /**
+ * Remove a reference from the queue, if there is one.
+ * @return the first element of the queue, or null if there isn't any.
+ */
+ private Reference<? extends T> dequeue()
+ {
+ if (first == null)
+ return null;
+
+ Reference<? extends T> result = first;
+ first = (first == first.nextOnQueue) ? null : first.nextOnQueue;
+ result.nextOnQueue = null;
+ return result;
+ }
+
+ /**
+ * Removes a reference from the queue, blocking for <code>timeout</code>
+ * until a reference is enqueued.
+ * @param timeout the timeout period in milliseconds, <code>0</code> means
+ * wait forever.
+ * @return the reference removed from the queue, or
+ * <code>null</code> if timeout period expired.
+ * @exception InterruptedException if the wait was interrupted.
+ */
+ public synchronized Reference<? extends T> remove(long timeout)
+ throws InterruptedException
+ {
+ if (first == null)
+ {
+ wait(timeout);
+ }
+
+ return dequeue();
+ }
+
+
+ /**
+ * Removes a reference from the queue, blocking until a reference is
+ * enqueued.
+ *
+ * @return the reference removed from the queue.
+ * @exception InterruptedException if the wait was interrupted.
+ */
+ public Reference<? extends T> remove()
+ throws InterruptedException
+ {
+ return remove(0L);
+ }
+}
Added: trunk/core/src/classpath/java/java/lang/ref/SoftReference.java
===================================================================
--- trunk/core/src/classpath/java/java/lang/ref/SoftReference.java (rev 0)
+++ trunk/core/src/classpath/java/java/lang/ref/SoftReference.java 2006-12-12 21:13:38 UTC (rev 2899)
@@ -0,0 +1,84 @@
+/* java.lang.ref.SoftReference
+ Copyright (C) 1999, 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 java.lang.ref;
+
+/**
+ * A soft reference will be cleared, if the object is only softly
+ * reachable and the garbage collection needs more memory. The garbage
+ * collection will use an intelligent strategy to determine which soft
+ * references it should clear. This makes a soft reference ideal for
+ * caches.<br>
+ *
+ * @author Jochen Hoenicke
+ */
+public class SoftReference<T>
+ extends Reference<T>
+{
+ /**
+ * Create a new soft reference, that is not registered to any queue.
+ * @param referent the object we refer to.
+ */
+ public SoftReference(T referent)
+ {
+ super(referent);
+ }
+
+ /**
+ * Create a new soft reference.
+ * @param referent the object we refer to.
+ * @param q the reference queue to register on.
+ * @exception NullPointerException if q is null.
+ */
+ public SoftReference(T referent, ReferenceQueue<? super T> q)
+ {
+ super(referent, q);
+ }
+
+ /**
+ * Returns the object, this reference refers to.
+ * @return the object, this reference refers to, or null if the
+ * reference was cleared.
+ */
+ public T get()
+ {
+ /* Why is this overloaded???
+ * Maybe for a kind of LRU strategy. */
+ return super.get();
+ }
+}
Added: trunk/core/src/classpath/java/java/lang/ref/WeakReference.java
===================================================================
--- trunk/core/src/classpath/java/java/lang/ref/WeakReference.java (rev 0)
+++ trunk/core/src/classpath/java/java/lang/ref/WeakReference.java 2006-12-12 21:13:38 UTC (rev 2899)
@@ -0,0 +1,79 @@
+/* java.lang.ref.WeakReference
+ Copyright (C) 1999, 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 java.lang.ref;
+
+/**
+ * A weak reference will be cleared, if the object is only weakly
+ * reachable. It is useful for lookup tables, where you aren't
+ * interested in an entry, if the key isn't reachable anymore.
+ * <code>WeakHashtable</code> is a complete implementation of such a
+ * table. <br>
+ *
+ * It is also useful to make objects unique: You create a set of weak
+ * references to those objects, and when you create a new object you
+ * look in this set, if the object already exists and return it. If
+ * an object is not referenced anymore, the reference will
+ * automatically cleared, and you may remove it from the set. <br>
+ *
+ * @author Jochen Hoenicke
+ * @see java.util.WeakHashMap
+ */
+public class WeakReference<T>
+ extends Reference<T>
+{
+ /**
+ * Create a new weak reference, that is not registered to any queue.
+ * @param referent the object we refer to.
+ */
+ public WeakReference(T referent)
+ {
+ super(referent);
+ }
+
+ /**
+ * Create a new weak reference.
+ * @param referent the object we refer to.
+ * @param q the reference queue to register on.
+ * @exception NullPointerException if q is null.
+ */
+ public WeakReference(T referent, ReferenceQueue<? super T> q)
+ {
+ super(referent, q);
+ }
+}
Added: trunk/core/src/classpath/java/java/lang/ref/package.html
===================================================================
--- trunk/core/src/classpath/java/java/lang/ref/package.html (rev 0)
+++ trunk/core/src/classpath/java/java/lang/ref/package.html 2006-12-12 21:13:38 UTC (rev 2899)
@@ -0,0 +1,46 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
+<!-- package.html - describes classes in java.lang.ref package.
+ 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. -->
+
+<html>
+<head><title>GNU Classpath - java.lang.ref</title></head>
+
+<body>
+<p>Low level manipulation and monitoring of object references.</p>
+
+</body>
+</html>
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ls...@us...> - 2006-12-12 21:14:53
|
Revision: 2900
http://jnode.svn.sourceforge.net/jnode/?rev=2900&view=rev
Author: lsantha
Date: 2006-12-12 13:14:46 -0800 (Tue, 12 Dec 2006)
Log Message:
-----------
Migrating to Java 5 level classpath.
Added Paths:
-----------
trunk/core/src/classpath/java/java/lang/Boolean.java
trunk/core/src/classpath/java/java/lang/Byte.java
trunk/core/src/classpath/java/java/lang/Character.java
trunk/core/src/classpath/java/java/lang/Comparable.java
trunk/core/src/classpath/java/java/lang/Deprecated.java
trunk/core/src/classpath/java/java/lang/Double.java
trunk/core/src/classpath/java/java/lang/Enum.java
trunk/core/src/classpath/java/java/lang/EnumConstantNotPresentException.java
trunk/core/src/classpath/java/java/lang/Float.java
trunk/core/src/classpath/java/java/lang/Integer.java
trunk/core/src/classpath/java/java/lang/Iterable.java
trunk/core/src/classpath/java/java/lang/Long.java
trunk/core/src/classpath/java/java/lang/Object.java
trunk/core/src/classpath/java/java/lang/Override.java
trunk/core/src/classpath/java/java/lang/Short.java
trunk/core/src/classpath/java/java/lang/String.java
trunk/core/src/classpath/java/java/lang/StringBuilder.java
trunk/core/src/classpath/java/java/lang/SuppressWarnings.java
Added: trunk/core/src/classpath/java/java/lang/Boolean.java
===================================================================
--- trunk/core/src/classpath/java/java/lang/Boolean.java (rev 0)
+++ trunk/core/src/classpath/java/java/lang/Boolean.java 2006-12-12 21:14:46 UTC (rev 2900)
@@ -0,0 +1,251 @@
+/* Boolean.java -- object wrapper for boolean
+ Copyright (C) 1998, 2001, 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 java.lang;
+
+import java.io.Serializable;
+
+/**
+ * Instances of class <code>Boolean</code> represent primitive
+ * <code>boolean</code> values.
+ *
+ * @author Paul Fisher
+ * @author Eric Blake (eb...@em...)
+ * @since 1.0
+ * @status updated to 1.5
+ */
+public final class Boolean implements Serializable, Comparable<Boolean>
+{
+ /**
+ * Compatible with JDK 1.0.2+.
+ */
+ private static final long serialVersionUID = -3665804199014368530L;
+
+ /**
+ * This field is a <code>Boolean</code> object representing the
+ * primitive value <code>true</code>. This instance is returned
+ * by the static <code>valueOf()</code> methods if they return
+ * a <code>Boolean</code> representing <code>true</code>.
+ */
+ public static final Boolean TRUE = new Boolean(true);
+
+ /**
+ * This field is a <code>Boolean</code> object representing the
+ * primitive value <code>false</code>. This instance is returned
+ * by the static <code>valueOf()</code> methods if they return
+ * a <code>Boolean</code> representing <code>false</code>.
+ */
+ public static final Boolean FALSE = new Boolean(false);
+
+ /**
+ * The primitive type <code>boolean</code> is represented by this
+ * <code>Class</code> object.
+ *
+ * @since 1.1
+ */
+ public static final Class<Boolean> TYPE = (Class<Boolean>) VMClassLoader.getPrimitiveClass('Z');
+
+ /**
+ * The immutable value of this Boolean.
+ * @serial the wrapped value
+ */
+ private final boolean value;
+
+ /**
+ * Create a <code>Boolean</code> object representing the value of the
+ * argument <code>value</code>. In general the use of the static
+ * method <code>valueof(boolean)</code> is more efficient since it will
+ * not create a new object.
+ *
+ * @param value the primitive value of this <code>Boolean</code>
+ * @see #valueOf(boolean)
+ */
+ public Boolean(boolean value)
+ {
+ this.value = value;
+ }
+
+ /**
+ * Creates a <code>Boolean</code> object representing the primitive
+ * <code>true</code> if and only if <code>s</code> matches
+ * the string "true" ignoring case, otherwise the object will represent
+ * the primitive <code>false</code>. In general the use of the static
+ * method <code>valueof(String)</code> is more efficient since it will
+ * not create a new object.
+ *
+ * @param s the <code>String</code> representation of <code>true</code>
+ * or false
+ */
+ public Boolean(String s)
+ {
+ value = "true".equalsIgnoreCase(s);
+ }
+
+ /**
+ * Return the primitive <code>boolean</code> value of this
+ * <code>Boolean</code> object.
+ *
+ * @return true or false, depending on the value of this Boolean
+ */
+ public boolean booleanValue()
+ {
+ return value;
+ }
+
+ /**
+ * Returns the Boolean <code>TRUE</code> if the given boolean is
+ * <code>true</code>, otherwise it will return the Boolean
+ * <code>FALSE</code>.
+ *
+ * @param b the boolean to wrap
+ * @return the wrapper object
+ * @see #TRUE
+ * @see #FALSE
+ * @since 1.4
+ */
+ public static Boolean valueOf(boolean b)
+ {
+ return b ? TRUE : FALSE;
+ }
+
+ /**
+ * Returns the Boolean <code>TRUE</code> if and only if the given
+ * String is equal, ignoring case, to the the String "true", otherwise
+ * it will return the Boolean <code>FALSE</code>.
+ *
+ * @param s the string to convert
+ * @return a wrapped boolean from the string
+ */
+ public static Boolean valueOf(String s)
+ {
+ return "true".equalsIgnoreCase(s) ? TRUE : FALSE;
+ }
+
+ /**
+ * Returns "true" if the value of the give boolean is <code>true</code> and
+ * returns "false" if the value of the given boolean is <code>false</code>.
+ *
+ * @param b the boolean to convert
+ * @return the string representation of the boolean
+ * @since 1.4
+ */
+ public static String toString(boolean b)
+ {
+ return b ? "true" : "false";
+ }
+
+ /**
+ * Returns "true" if the value of this object is <code>true</code> and
+ * returns "false" if the value of this object is <code>false</code>.
+ *
+ * @return the string representation of this
+ */
+ public String toString()
+ {
+ return value ? "true" : "false";
+ }
+
+ /**
+ * Returns the integer <code>1231</code> if this object represents
+ * the primitive <code>true</code> and the integer <code>1237</code>
+ * otherwise.
+ *
+ * @return the hash code
+ */
+ public int hashCode()
+ {
+ return value ? 1231 : 1237;
+ }
+
+ /**
+ * If the <code>obj</code> is an instance of <code>Boolean</code> and
+ * has the same primitive value as this object then <code>true</code>
+ * is returned. In all other cases, including if the <code>obj</code>
+ * is <code>null</code>, <code>false</code> is returned.
+ *
+ * @param obj possibly an instance of any <code>Class</code>
+ * @return true if <code>obj</code> equals this
+ */
+ public boolean equals(Object obj)
+ {
+ return obj instanceof Boolean && value == ((Boolean) obj).value;
+ }
+
+ /**
+ * If the value of the system property <code>name</code> matches
+ * "true" ignoring case then the function returns <code>true</code>.
+ *
+ * @param name the property name to look up
+ * @return true if the property resulted in "true"
+ * @throws SecurityException if accessing the system property is forbidden
+ * @see System#getProperty(String)
+ */
+ public static boolean getBoolean(String name)
+ {
+ if (name == null || "".equals(name))
+ return false;
+ return "true".equalsIgnoreCase(System.getProperty(name));
+ }
+
+ /**
+ * Compares this Boolean to another.
+ *
+ * @param other the Boolean to compare this Boolean to
+ * @return 0 if both Booleans represent the same value, a positive number
+ * if this Boolean represents true and the other false, and a negative
+ * number otherwise.
+ * @since 1.5
+ */
+ public int compareTo(Boolean other)
+ {
+ return value == other.value ? 0 : (value ? 1 : -1);
+ }
+
+ /**
+ * If the String argument is "true", ignoring case, return true.
+ * Otherwise, return false.
+ *
+ * @param b String to parse
+ * @since 1.5
+ */
+ public static boolean parseBoolean(String b)
+ {
+ return "true".equalsIgnoreCase(b) ? true : false;
+ }
+
+}
Added: trunk/core/src/classpath/java/java/lang/Byte.java
===================================================================
--- trunk/core/src/classpath/java/java/lang/Byte.java (rev 0)
+++ trunk/core/src/classpath/java/java/lang/Byte.java 2006-12-12 21:14:46 UTC (rev 2900)
@@ -0,0 +1,373 @@
+/* Byte.java -- object wrapper for byte
+ Copyright (C) 1998, 2001, 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 java.lang;
+
+/**
+ * Instances of class <code>Byte</code> represent primitive <code>byte</code>
+ * values.
+ *
+ * Additionally, this class provides various helper functions and variables
+ * useful to bytes.
+ *
+ * @author Paul Fisher
+ * @author John Keiser
+ * @author Per Bothner
+ * @author Eric Blake (eb...@em...)
+ * @author Tom Tromey (tr...@re...)
+ * @author Andrew John Hughes (gnu...@me...)
+ * @since 1.1
+ * @status updated to 1.5
+ */
+public final class Byte extends Number implements Comparable<Byte>
+{
+ /**
+ * Compatible with JDK 1.1+.
+ */
+ private static final long serialVersionUID = -7183698231559129828L;
+
+ /**
+ * The minimum value a <code>byte</code> can represent is -128 (or
+ * -2<sup>7</sup>).
+ */
+ public static final byte MIN_VALUE = -128;
+
+ /**
+ * The maximum value a <code>byte</code> can represent is 127 (or
+ * 2<sup>7</sup> - 1).
+ */
+ public static final byte MAX_VALUE = 127;
+
+ /**
+ * The primitive type <code>byte</code> is represented by this
+ * <code>Class</code> object.
+ */
+ public static final Class<Byte> TYPE = (Class<Byte>) VMClassLoader.getPrimitiveClass('B');
+
+ /**
+ * The number of bits needed to represent a <code>byte</code>.
+ * @since 1.5
+ */
+ public static final int SIZE = 8;
+
+ // This caches Byte values, and is used by boxing conversions via
+ // valueOf(). We're required to cache all possible values here.
+ private static Byte[] byteCache = new Byte[MAX_VALUE - MIN_VALUE + 1];
+
+
+ /**
+ * The immutable value of this Byte.
+ *
+ * @serial the wrapped byte
+ */
+ private final byte value;
+
+ /**
+ * Create a <code>Byte</code> object representing the value of the
+ * <code>byte</code> argument.
+ *
+ * @param value the value to use
+ */
+ public Byte(byte value)
+ {
+ this.value = value;
+ }
+
+ /**
+ * Create a <code>Byte</code> object representing the value specified
+ * by the <code>String</code> argument
+ *
+ * @param s the string to convert
+ * @throws NumberFormatException if the String does not contain a byte
+ * @see #valueOf(String)
+ */
+ public Byte(String s)
+ {
+ value = parseByte(s, 10);
+ }
+
+ /**
+ * Converts the <code>byte</code> to a <code>String</code> and assumes
+ * a radix of 10.
+ *
+ * @param b the <code>byte</code> to convert to <code>String</code>
+ * @return the <code>String</code> representation of the argument
+ */
+ public static String toString(byte b)
+ {
+ return String.valueOf(b);
+ }
+
+ /**
+ * Converts the specified <code>String</code> into a <code>byte</code>.
+ * This function assumes a radix of 10.
+ *
+ * @param s the <code>String</code> to convert
+ * @return the <code>byte</code> value of <code>s</code>
+ * @throws NumberFormatException if <code>s</code> cannot be parsed as a
+ * <code>byte</code>
+ * @see #parseByte(String)
+ */
+ public static byte parseByte(String s)
+ {
+ return parseByte(s, 10);
+ }
+
+ /**
+ * Converts the specified <code>String</code> into an <code>int</code>
+ * using the specified radix (base). The string must not be <code>null</code>
+ * or empty. It may begin with an optional '-', which will negate the answer,
+ * provided that there are also valid digits. Each digit is parsed as if by
+ * <code>Character.digit(d, radix)</code>, and must be in the range
+ * <code>0</code> to <code>radix - 1</code>. Finally, the result must be
+ * within <code>MIN_VALUE</code> to <code>MAX_VALUE</code>, inclusive.
+ * Unlike Double.parseDouble, you may not have a leading '+'.
+ *
+ * @param s the <code>String</code> to convert
+ * @param radix the radix (base) to use in the conversion
+ * @return the <code>String</code> argument converted to <code>byte</code>
+ * @throws NumberFormatException if <code>s</code> cannot be parsed as a
+ * <code>byte</code>
+ */
+ public static byte parseByte(String s, int radix)
+ {
+ int i = Integer.parseInt(s, radix, false);
+ if ((byte) i != i)
+ throw new NumberFormatException();
+ return (byte) i;
+ }
+
+ /**
+ * Creates a new <code>Byte</code> object using the <code>String</code>
+ * and specified radix (base).
+ *
+ * @param s the <code>String</code> to convert
+ * @param radix the radix (base) to convert with
+ * @return the new <code>Byte</code>
+ * @throws NumberFormatException if <code>s</code> cannot be parsed as a
+ * <code>byte</code>
+ * @see #parseByte(String, int)
+ */
+ public static Byte valueOf(String s, int radix)
+ {
+ return new Byte(parseByte(s, radix));
+ }
+
+ /**
+ * Creates a new <code>Byte</code> object using the <code>String</code>,
+ * assuming a radix of 10.
+ *
+ * @param s the <code>String</code> to convert
+ * @return the new <code>Byte</code>
+ * @throws NumberFormatException if <code>s</code> cannot be parsed as a
+ * <code>byte</code>
+ * @see #Byte(String)
+ * @see #parseByte(String)
+ */
+ public static Byte valueOf(String s)
+ {
+ return new Byte(parseByte(s, 10));
+ }
+
+ /**
+ * Returns a <code>Byte</code> object wrapping the value.
+ * In contrast to the <code>Byte</code> constructor, this method
+ * will cache some values. It is used by boxing conversion.
+ *
+ * @param val the value to wrap
+ * @return the <code>Byte</code>
+ */
+ public static Byte valueOf(byte val)
+ {
+ synchronized (byteCache)
+ {
+ if (byteCache[val - MIN_VALUE] == null)
+ byteCache[val - MIN_VALUE] = new Byte(val);
+ return byteCache[val - MIN_VALUE];
+ }
+ }
+
+ /**
+ * Convert the specified <code>String</code> into a <code>Byte</code>.
+ * The <code>String</code> may represent decimal, hexadecimal, or
+ * octal numbers.
+ *
+ * <p>The extended BNF grammar is as follows:<br>
+ * <pre>
+ * <em>DecodableString</em>:
+ * ( [ <code>-</code> ] <em>DecimalNumber</em> )
+ * | ( [ <code>-</code> ] ( <code>0x</code> | <code>0X</code>
+ * | <code>#</code> ) { <em>HexDigit</em> }+ )
+ * | ( [ <code>-</code> ] <code>0</code> { <em>OctalDigit</em> } )
+ * <em>DecimalNumber</em>:
+ * <em>DecimalDigit except '0'</em> { <em>DecimalDigit</em> }
+ * <em>DecimalDigit</em>:
+ * <em>Character.digit(d, 10) has value 0 to 9</em>
+ * <em>OctalDigit</em>:
+ * <em>Character.digit(d, 8) has value 0 to 7</em>
+ * <em>DecimalDigit</em>:
+ * <em>Character.digit(d, 16) has value 0 to 15</em>
+ * </pre>
+ * Finally, the value must be in the range <code>MIN_VALUE</code> to
+ * <code>MAX_VALUE</code>, or an exception is thrown.
+ *
+ * @param s the <code>String</code> to interpret
+ * @return the value of the String as a <code>Byte</code>
+ * @throws NumberFormatException if <code>s</code> cannot be parsed as a
+ * <code>byte</code>
+ * @throws NullPointerException if <code>s</code> is null
+ * @see Integer#decode(String)
+ */
+ public static Byte decode(String s)
+ {
+ int i = Integer.parseInt(s, 10, true);
+ if ((byte) i != i)
+ throw new NumberFormatException();
+ return new Byte((byte) i);
+ }
+
+ /**
+ * Return the value of this <code>Byte</code>.
+ *
+ * @return the byte value
+ */
+ public byte byteValue()
+ {
+ return value;
+ }
+
+ /**
+ * Return the value of this <code>Byte</code> as a <code>short</code>.
+ *
+ * @return the short value
+ */
+ public short shortValue()
+ {
+ return value;
+ }
+
+ /**
+ * Return the value of this <code>Byte</code> as an <code>int</code>.
+ *
+ * @return the int value
+ */
+ public int intValue()
+ {
+ return value;
+ }
+
+ /**
+ * Return the value of this <code>Byte</code> as a <code>long</code>.
+ *
+ * @return the long value
+ */
+ public long longValue()
+ {
+ return value;
+ }
+
+ /**
+ * Return the value of this <code>Byte</code> as a <code>float</code>.
+ *
+ * @return the float value
+ */
+ public float floatValue()
+ {
+ return value;
+ }
+
+ /**
+ * Return the value of this <code>Byte</code> as a <code>double</code>.
+ *
+ * @return the double value
+ */
+ public double doubleValue()
+ {
+ return value;
+ }
+
+ /**
+ * Converts the <code>Byte</code> value to a <code>String</code> and
+ * assumes a radix of 10.
+ *
+ * @return the <code>String</code> representation of this <code>Byte</code>
+ * @see Integer#toString()
+ */
+ public String toString()
+ {
+ return String.valueOf(value);
+ }
+
+ /**
+ * Return a hashcode representing this Object. <code>Byte</code>'s hash
+ * code is simply its value.
+ *
+ * @return this Object's hash code
+ */
+ public int hashCode()
+ {
+ return value;
+ }
+
+ /**
+ * Returns <code>true</code> if <code>obj</code> is an instance of
+ * <code>Byte</code> and represents the same byte value.
+ *
+ * @param obj the object to compare
+ * @return whether these Objects are semantically equal
+ */
+ public boolean equals(Object obj)
+ {
+ return obj instanceof Byte && value == ((Byte) obj).value;
+ }
+
+ /**
+ * Compare two Bytes numerically by comparing their <code>byte</code> values.
+ * The result is positive if the first is greater, negative if the second
+ * is greater, and 0 if the two are equal.
+ *
+ * @param b the Byte to compare
+ * @return the comparison
+ * @since 1.2
+ */
+ public int compareTo(Byte b)
+ {
+ return value - b.value;
+ }
+
+}
Added: trunk/core/src/classpath/java/java/lang/Character.java
===================================================================
--- trunk/core/src/classpath/java/java/lang/Character.java (rev 0)
+++ trunk/core/src/classpath/java/java/lang/Character.java 2006-12-12 21:14:46 UTC (rev 2900)
@@ -0,0 +1,4551 @@
+/* java.lang.Character -- Wrapper class for char, and Unicode subsets
+ Copyright (C) 1998, 1999, 2001, 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 java.lang;
+
+import gnu.java.lang.CharData;
+
+import java.io.Serializable;
+import java.text.Collator;
+import java.util.Locale;
+
+/**
+ * Wrapper class for the primitive char data type. In addition, this class
+ * allows one to retrieve property information and perform transformations
+ * on the defined characters in the Unicode Standard, Version 4.0.0.
+ * java.lang.Character is designed to be very dynamic, and as such, it
+ * retrieves information on the Unicode character set from a separate
+ * database, gnu.java.lang.CharData, which can be easily upgraded.
+ *
+ * <p>For predicates, boundaries are used to describe
+ * the set of characters for which the method will return true.
+ * This syntax uses fairly normal regular expression notation.
+ * See 5.13 of the Unicode Standard, Version 4.0, for the
+ * boundary specification.
+ *
+ * <p>See <a href="http://www.unicode.org">http://www.unicode.org</a>
+ * for more information on the Unicode Standard.
+ *
+ * @author Tom Tromey (tr...@cy...)
+ * @author Paul N. Fisher
+ * @author Jochen Hoenicke
+ * @author Eric Blake (eb...@em...)
+ * @author Andrew John Hughes (gnu...@me...)
+ * @see CharData
+ * @since 1.0
+ * @status partly updated to 1.5; some things still missing
+ */
+public final class Character implements Serializable, Comparable<Character>
+{
+ /**
+ * A subset of Unicode blocks.
+ *
+ * @author Paul N. Fisher
+ * @author Eric Blake (eb...@em...)
+ * @since 1.2
+ */
+ public static class Subset
+ {
+ /** The name of the subset. */
+ private final String name;
+
+ /**
+ * Construct a new subset of characters.
+ *
+ * @param name the name of the subset
+ * @throws NullPointerException if name is null
+ */
+ protected Subset(String name)
+ {
+ // Note that name.toString() is name, unless name was null.
+ this.name = name.toString();
+ }
+
+ /**
+ * Compares two Subsets for equality. This is <code>final</code>, and
+ * restricts the comparison on the <code>==</code> operator, so it returns
+ * true only for the same object.
+ *
+ * @param o the object to compare
+ * @return true if o is this
+ */
+ public final boolean equals(Object o)
+ {
+ return o == this;
+ }
+
+ /**
+ * Makes the original hashCode of Object final, to be consistent with
+ * equals.
+ *
+ * @return the hash code for this object
+ */
+ public final int hashCode()
+ {
+ return super.hashCode();
+ }
+
+ /**
+ * Returns the name of the subset.
+ *
+ * @return the name
+ */
+ public final String toString()
+ {
+ return name;
+ }
+ } // class Subset
+
+ /**
+ * A family of character subsets in the Unicode specification. A character
+ * is in at most one of these blocks.
+ *
+ * This inner class was generated automatically from
+ * <code>doc/unicode/Blocks-4.0.0.txt</code>, by some perl scripts.
+ * This Unicode definition file can be found on the
+ * <a href="http://www.unicode.org">http://www.unicode.org</a> website.
+ * JDK 1.5 uses Unicode version 4.0.0.
+ *
+ * @author scripts/unicode-blocks.pl (written by Eric Blake)
+ * @since 1.2
+ */
+ public static final class UnicodeBlock extends Subset
+ {
+ /** The start of the subset. */
+ private final int start;
+
+ /** The end of the subset. */
+ private final int end;
+
+ /** The canonical name of the block according to the Unicode standard. */
+ private final String canonicalName;
+
+ /** Enumeration for the <code>forName()</code> method */
+ private enum NameType { CANONICAL, NO_SPACES, CONSTANT; };
+
+ /**
+ * Constructor for strictly defined blocks.
+ *
+ * @param start the start character of the range
+ * @param end the end character of the range
+ * @param name the block name
+ * @param canonicalName the name of the block as defined in the Unicode
+ * standard.
+ */
+ private UnicodeBlock(int start, int end, String name,
+ String canonicalName)
+ {
+ super(name);
+ this.start = start;
+ this.end = end;
+ this.canonicalName = canonicalName;
+ }
+
+ /**
+ * Returns the Unicode character block which a character belongs to.
+ * <strong>Note</strong>: This method does not support the use of
+ * supplementary characters. For such support, <code>of(int)</code>
+ * should be used instead.
+ *
+ * @param ch the character to look up
+ * @return the set it belongs to, or null if it is not in one
+ */
+ public static UnicodeBlock of(char ch)
+ {
+ return of((int) ch);
+ }
+
+ /**
+ * Returns the Unicode character block which a code point belongs to.
+ *
+ * @param codePoint the character to look up
+ * @return the set it belongs to, or null if it is not in one.
+ * @throws IllegalArgumentException if the specified code point is
+ * invalid.
+ * @since 1.5
+ */
+ public static UnicodeBlock of(int codePoint)
+ {
+ if (codePoint > MAX_CODE_POINT)
+ throw new IllegalArgumentException("The supplied integer value is " +
+ "too large to be a codepoint.");
+ // Simple binary search for the correct block.
+ int low = 0;
+ int hi = sets.length - 1;
+ while (low <= hi)
+ {
+ int mid = (low + hi) >> 1;
+ UnicodeBlock b = sets[mid];
+ if (codePoint < b.start)
+ hi = mid - 1;
+ else if (codePoint > b.end)
+ low = mid + 1;
+ else
+ return b;
+ }
+ return null;
+ }
+
+ /**
+ * <p>
+ * Returns the <code>UnicodeBlock</code> with the given name, as defined
+ * by the Unicode standard. The version of Unicode in use is defined by
+ * the <code>Character</code> class, and the names are given in the
+ * <code>Blocks-<version>.txt</code> file corresponding to that version.
+ * The name may be specified in one of three ways:
+ * </p>
+ * <ol>
+ * <li>The canonical, human-readable name used by the Unicode standard.
+ * This is the name with all spaces and hyphens retained. For example,
+ * `Basic Latin' retrieves the block, UnicodeBlock.BASIC_LATIN.</li>
+ * <li>The canonical name with all spaces removed e.g. `BasicLatin'.</li>
+ * <li>The name used for the constants specified by this class, which
+ * is the canonical name with all spaces and hyphens replaced with
+ * underscores e.g. `BASIC_LATIN'</li>
+ * </ol>
+ * <p>
+ * The names are compared case-insensitively using the case co...
[truncated message content] |
|
From: <ls...@us...> - 2007-01-07 12:53:05
|
Revision: 3022
http://jnode.svn.sourceforge.net/jnode/?rev=3022&view=rev
Author: lsantha
Date: 2007-01-07 04:53:02 -0800 (Sun, 07 Jan 2007)
Log Message:
-----------
Classpath patches.
Modified Paths:
--------------
trunk/core/src/classpath/java/java/lang/Character.java
trunk/core/src/classpath/java/java/lang/Enum.java
trunk/core/src/classpath/java/java/lang/System.java
trunk/core/src/classpath/java/java/lang/management/ManagementFactory.java
trunk/core/src/classpath/java/java/lang/management/MemoryPoolMXBean.java
trunk/core/src/classpath/java/java/lang/management/MemoryUsage.java
trunk/core/src/classpath/java/java/lang/management/OperatingSystemMXBean.java
trunk/core/src/classpath/java/java/lang/management/RuntimeMXBean.java
trunk/core/src/classpath/java/java/lang/management/ThreadInfo.java
trunk/core/src/classpath/java/java/lang/management/ThreadMXBean.java
Added Paths:
-----------
trunk/core/src/classpath/java/java/lang/ProcessBuilder.java
trunk/core/src/classpath/java/java/lang/management/LockInfo.java
trunk/core/src/classpath/java/java/lang/management/MemoryType.java
trunk/core/src/classpath/java/java/lang/management/MonitorInfo.java
Modified: trunk/core/src/classpath/java/java/lang/Character.java
===================================================================
--- trunk/core/src/classpath/java/java/lang/Character.java 2007-01-07 12:51:25 UTC (rev 3021)
+++ trunk/core/src/classpath/java/java/lang/Character.java 2007-01-07 12:53:02 UTC (rev 3022)
@@ -156,7 +156,7 @@
private final String canonicalName;
/** Enumeration for the <code>forName()</code> method */
- private enum NameType { CANONICAL, NO_SPACES, CONSTANT; };
+ private enum NameType { CANONICAL, NO_SPACES, CONSTANT; }
/**
* Constructor for strictly defined blocks.
Modified: trunk/core/src/classpath/java/java/lang/Enum.java
===================================================================
--- trunk/core/src/classpath/java/java/lang/Enum.java 2007-01-07 12:51:25 UTC (rev 3021)
+++ trunk/core/src/classpath/java/java/lang/Enum.java 2007-01-07 12:53:02 UTC (rev 3022)
@@ -60,13 +60,13 @@
/**
* The name of this enum constant.
*/
- String name;
+ final String name;
/**
* The number of this enum constant. Each constant is given a number
* which matches the order in which it was declared, starting with zero.
*/
- int ordinal;
+ final int ordinal;
/**
* This constructor is used by the compiler to create enumeration constants.
@@ -220,4 +220,14 @@
k = k.getSuperclass();
return k;
}
+
+ /**
+ * Enumerations can not have finalization methods.
+ *
+ * @since 1.6
+ */
+ protected final void finalize()
+ {
+ }
+
}
Added: trunk/core/src/classpath/java/java/lang/ProcessBuilder.java
===================================================================
--- trunk/core/src/classpath/java/java/lang/ProcessBuilder.java (rev 0)
+++ trunk/core/src/classpath/java/java/lang/ProcessBuilder.java 2007-01-07 12:53:02 UTC (rev 3022)
@@ -0,0 +1,337 @@
+/* ProcessBuilder.java - Represent spawned system process
+ 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 java.lang;
+
+import java.io.File;
+import java.io.IOException;
+
+import java.util.Arrays;
+import java.util.List;
+import java.util.Map;
+
+/**
+ * <p>
+ * This class is used to construct new operating system processes.
+ * A <code>ProcessBuilder</code> instance basically represent a
+ * template for a new process. Actual processes are generated from
+ * this template via use of the <code>start()</code> method, which
+ * may be invoked multiple times, with each invocation spawning a
+ * new process with the current attributes of the
+ * <code>ProcessBuilder</code> object. Each spawned process is
+ * independent of the <code>ProcessBuilder</code> object, and is
+ * unaffected by changes in its attributes.
+ * </p>
+ * <p>
+ * The following attributes define a process:
+ * </p>
+ * <ul>
+ * <li>The <emphasis>working directory</emphasis>; the activities of a
+ * process begin with the current directory set to this. By default,
+ * this is the working directory of the current process, as defined
+ * by the <code>user.dir</code> property.</li>
+ * <li>The <emphasis>command</emphasis> which invokes the process. This
+ * usually consists of the name of the program binary followed by an
+ * arbitrary number of arguments. For example, <code>find -type f</code>
+ * invokes the <code>find</code> binary with the arguments "-type" and "f".
+ * The command is provided a list, the elements of which are defined in a
+ * system dependent manner; the layout is affected by expected operating
+ * system conventions. A common method is to split the command on each
+ * space within the string. Thus, <code>find -type f</code> forms a
+ * three element list. However, in some cases, the expectation is that
+ * this split is performed by the program itself; thus, the list consists
+ * of only two elements (the program name and its arguments).</li>
+ * <li>The <emphasis>environment map</emphasis>, which links environment
+ * variables to their corresponding values. The initial contents of the map
+ * are the current environment values i.e. it contains the contents of the
+ * map returned by <code>System.getenv()</code>.</li>
+ * <li>The <emphasis>redirection flag</emphasis>, which specifies whether
+ * or not the contents of the error stream should be redirected to standard
+ * output. By default, this is false, and there are two output streams, one
+ * for normal data ({@link Process#getOutputStream()}) and one for error data
+ * ({@link Process#getErrorStream()}). When set to true, the two are merged,
+ * which simplifies the interleaving of the two streams. Data is read using
+ * the stream returned by {@link Process#getOutputStream()}, and the
+ * stream returned by {@link Process#getErrorStream()} throws an immediate
+ * end-of-file exception.</li>
+ * </ul>
+ * <p>
+ * All checks on attribute validity are delayed until <code>start()</code>
+ * is called. <code>ProcessBuilder</code> objects are <strong>not
+ * synchronized</strong>; the user must provide external synchronization
+ * where multiple threads may interact with the same
+ * <code>ProcessBuilder</code> object.
+ * </p>
+ *
+ * @author Tom Tromey (tr...@re...)
+ * @author Andrew John Hughes (gnu...@me...)
+ * @see Process
+ * @see System#getenv()
+ * @since 1.5
+ */
+public final class ProcessBuilder
+{
+
+ /**
+ * The working directory of the process.
+ */
+ private File directory = new File(System.getProperty("user.dir"));
+
+ /**
+ * The command line syntax for invoking the process.
+ */
+ private List<String> command;
+
+ /**
+ * The mapping of environment variables to values.
+ */
+ private Map<String, String> environment =
+ new System.EnvironmentMap(System.getenv());
+
+ /**
+ * A flag indicating whether to redirect the error stream to standard
+ * output.
+ */
+ private boolean redirect = false;
+
+ /**
+ * Constructs a new <code>ProcessBuilder</code> with the specified
+ * command being used to invoke the process. The list is used directly;
+ * external changes are reflected in the <code>ProcessBuilder</code>.
+ *
+ * @param command the name of the program followed by its arguments.
+ */
+ public ProcessBuilder(List<String> command)
+ {
+ this.command = command;
+ }
+
+ /**
+ * Constructs a new <code>ProcessBuilder</code> with the specified
+ * command being used to invoke the process. This constructor
+ * simplifies creating a new <code>ProcessBuilder</code> by
+ * converting the provided series of constructor arguments into a
+ * list of command-line arguments.
+ *
+ * @param command the name of the program followed by its arguments.
+ */
+ public ProcessBuilder(String... command)
+ {
+ this.command = Arrays.asList(command);
+ }
+
+ /**
+ * Returns the current command line, used to invoke the process.
+ * The return value is simply a reference to the list of command
+ * line arguments used by the <code>ProcessBuilder</code> object;
+ * any changes made to it will be reflected in the operation of
+ * the <code>ProcessBuilder</code>.
+ *
+ * @return the list of command-line arguments.
+ */
+ public List<String> command()
+ {
+ return command;
+ }
+
+ /**
+ * Sets the command-line arguments to those specified. The list is
+ * used directly; external changes are reflected in the
+ * <code>ProcessBuilder</code>.
+ *
+ * @param command the name of the program followed by its arguments.
+ * @return a reference to this process builder.
+ */
+ public ProcessBuilder command(List<String> command)
+ {
+ this.command = command;
+ return this;
+ }
+
+ /**
+ * Sets the command-line arguments to those specified.
+ * This simplifies modifying the arguments by converting
+ * the provided series of constructor arguments into a
+ * list of command-line arguments.
+ *
+ * @param command the name of the program followed by its arguments.
+ * @return a reference to this process builder.
+ */
+ public ProcessBuilder command(String... command)
+ {
+ this.command = Arrays.asList(command);
+ return this;
+ }
+
+ /**
+ * Returns the working directory of the process. The
+ * returned value may be <code>null</code>; this
+ * indicates that the default behaviour of using the
+ * working directory of the current process should
+ * be adopted.
+ *
+ * @return the working directory.
+ */
+ public File directory()
+ {
+ return directory;
+ }
+
+ /**
+ * Sets the working directory to that specified.
+ * The supplied argument may be <code>null</code>,
+ * which indicates the default value should be used.
+ * The default is the working directory of the current
+ * process.
+ *
+ * @param directory the new working directory.
+ * @return a reference to this process builder.
+ */
+ public ProcessBuilder directory(File directory)
+ {
+ this.directory = directory;
+ return this;
+ }
+
+ /**
+ * <p>
+ * Returns the system environment variables of the process.
+ * If the underlying system does not support environment variables,
+ * an empty map is returned.
+ * </p>
+ * <p>
+ * The returned map does not accept queries using
+ * null keys or values, or those of a type other than
+ * <code>String</code>. Attempts to pass in a null value will
+ * throw a <code>NullPointerException</code>. Types other than
+ * <code>String</code> throw a <code>ClassCastException</code>.
+ * </p>
+ * <p>
+ * As the returned map is generated using data from the underlying
+ * platform, it may not comply with the <code>equals()</code>
+ * and <code>hashCode()</code> contracts. It is also likely that
+ * the keys of this map will be case-sensitive.
+ * </p>
+ * <p>
+ * Modification of the map is reliant on the underlying platform;
+ * some may not allow any changes to the environment variables or
+ * may prevent certain values being used. Attempts to do so will
+ * throw an <code>UnsupportedOperationException</code> or
+ * <code>IllegalArgumentException</code>, respectively.
+ * </p>
+ * <p>
+ * Use of this method may require a security check for the
+ * RuntimePermission "getenv.*".
+ * </p>
+ *
+ * @return a map of the system environment variables for the process.
+ * @throws SecurityException if the checkPermission method of
+ * an installed security manager prevents access to
+ * the system environment variables.
+ * @since 1.5
+ */
+ public Map<String, String> environment()
+ {
+ return environment;
+ }
+
+ /**
+ * Returns true if the output stream and error stream of the
+ * process will be merged to form one composite stream. The
+ * default return value is <code>false</code>.
+ *
+ * @return true if the output stream and error stream are to
+ * be merged.
+ */
+ public boolean redirectErrorStream()
+ {
+ return redirect;
+ }
+
+ /**
+ * Sets the error stream redirection flag. If set, the output
+ * and error streams are merged to form one composite stream.
+ *
+ * @param redirect the new value of the redirection flag.
+ * @return a reference to this process builder.
+ */
+ public ProcessBuilder redirectErrorStream(boolean redirect)
+ {
+ this.redirect = redirect;
+ return this;
+ }
+
+ /**
+ * <p>
+ * Starts execution of a new process, based on the attributes of
+ * this <code>ProcessBuilder</code> object. This is the point
+ * at which the command-line arguments are checked. The list
+ * must be non-empty and contain only non-null string objects.
+ * The other attributes have default values which are used in
+ * cases where their values are not explicitly specified.
+ * </p>
+ * <p>
+ * If a security manager is in place, then the
+ * {@link SecurityManager#checkExec()} method is called to
+ * ensure that permission is given to execute the process.
+ * </p>
+ * <p>
+ * The execution of the process is system-dependent. Various
+ * exceptions may result, due to problems at the operating system
+ * level. These are all returned as a form of {@link IOException}.
+ * </p>
+ *
+ * @return a <code>Process</code> object, representing the spawned
+ * subprocess.
+ * @throws IOException if a problem occurs with executing the process
+ * at the operating system level.
+ * @throws IndexOutOfBoundsException if the command to execute is
+ * actually an empty list.
+ * @throws NullPointerException if the command to execute is null
+ * or the list contains null elements.
+ * @throws SecurityException if a security manager exists and prevents
+ * execution of the subprocess.
+ */
+ public Process start() throws IOException
+ {
+ SecurityManager sm = SecurityManager.current; // Be thread-safe!
+ if (sm != null)
+ sm.checkExec(command.get(0));
+ return VMProcess.exec(command, environment, directory, redirect);
+ }
+}
Modified: trunk/core/src/classpath/java/java/lang/System.java
===================================================================
--- trunk/core/src/classpath/java/java/lang/System.java 2007-01-07 12:51:25 UTC (rev 3021)
+++ trunk/core/src/classpath/java/java/lang/System.java 2007-01-07 12:53:02 UTC (rev 3022)
@@ -149,7 +149,6 @@
SecurityManager sm = SecurityManager.current; // Be thread-safe.
if (sm != null)
sm.checkPermission(new RuntimePermission("setIO"));
-
VMSystem.setOut(out);
}
@@ -263,9 +262,7 @@
*/
public static long nanoTime()
{
- //todo
- throw new RuntimeException("Implement it");
- //return VMSystem.nanoTime();
+ return VMSystem.nanoTime();
}
/**
@@ -464,6 +461,29 @@
}
/**
+ * Remove a single system property by name. A security check may be
+ * performed, <code>checkPropertyAccess(key, "write")</code>.
+ *
+ * @param key the name of the system property to remove
+ * @return the previous value, or null
+ * @throws SecurityException if permission is denied
+ * @throws NullPointerException if key is null
+ * @throws IllegalArgumentException if key is ""
+ * @since 1.5
+ */
+ public static String clearProperty(String key)
+ {
+ SecurityManager sm = SecurityManager.current; // Be thread-safe.
+ if (sm != null)
+ sm.checkPermission(new PropertyPermission(key, "write"));
+ // This handles both the null pointer exception and the illegal
+ // argument exception.
+ if (key.length() == 0)
+ throw new IllegalArgumentException("key can't be empty");
+ return SystemProperties.remove(key);
+ }
+
+ /**
* Gets the value of an environment variable.
*
* @param name the name of the environment variable
@@ -486,6 +506,60 @@
}
/**
+ * <p>
+ * Returns an unmodifiable view of the system environment variables.
+ * If the underlying system does not support environment variables,
+ * an empty map is returned.
+ * </p>
+ * <p>
+ * The returned map is read-only and does not accept queries using
+ * null keys or values, or those of a type other than <code>String</code>.
+ * Attempts to modify the map will throw an
+ * <code>UnsupportedOperationException</code>, while attempts
+ * to pass in a null value will throw a
+ * <code>NullPointerException</code>. Types other than <code>String</code>
+ * throw a <code>ClassCastException</code>.
+ * </p>
+ * <p>
+ * As the returned map is generated using data from the underlying
+ * platform, it may not comply with the <code>equals()</code>
+ * and <code>hashCode()</code> contracts. It is also likely that
+ * the keys of this map will be case-sensitive.
+ * </p>
+ * <p>
+ * Use of this method may require a security check for the
+ * RuntimePermission "getenv.*".
+ * </p>
+ *
+ * @return a map of the system environment variables.
+ * @throws SecurityException if the checkPermission method of
+ * an installed security manager prevents access to
+ * the system environment variables.
+ * @since 1.5
+ */
+ public static Map<String, String> getenv()
+ {
+ SecurityManager sm = SecurityManager.current; // Be thread-safe.
+ if (sm != null)
+ sm.checkPermission(new RuntimePermission("getenv.*"));
+ if (environmentMap == null)
+ {
+ List<String> environ = (List<String>)VMSystem.environ();
+ Map<String,String> variables = new EnvironmentMap();
+ for (String pair : environ)
+ {
+ String[] parts = pair.split("=");
+ if (parts.length == 2)
+ variables.put(parts[0], parts[1]);
+ else
+ variables.put(parts[0], "");
+ }
+ environmentMap = Collections.unmodifiableMap(variables);
+ }
+ return environmentMap;
+ }
+
+ /**
* Terminate the Virtual Machine. This just calls
* <code>Runtime.getRuntime().exit(status)</code>, and never returns.
* Obviously, a security check is in order, <code>checkExit</code>.
@@ -597,4 +671,419 @@
return VMRuntime.mapLibraryName(libname);
}
+
+ /**
+ * This is a specialised <code>Collection</code>, providing
+ * the necessary provisions for the collections used by the
+ * environment variable map. Namely, it prevents
+ * querying anything but <code>String</code>s.
+ *
+ * @author Andrew John Hughes (gnu...@me...)
+ */
+ private static class EnvironmentCollection
+ extends AbstractCollection<String>
+ {
+
+ /**
+ * The wrapped collection.
+ */
+ protected Collection<String> c;
+
+ /**
+ * Constructs a new environment collection, which
+ * wraps the elements of the supplied collection.
+ *
+ * @param coll the collection to use as a base for
+ * this collection.
+ */
+ public EnvironmentCollection(Collection<String> coll)
+ {
+ c = coll;
+ }
+
+ /**
+ * Blocks queries containing a null object or an object which
+ * isn't of type <code>String</code>. All other queries
+ * are forwarded to the underlying collection.
+ *
+ * @param obj the object to look for.
+ * @return true if the object exists in the collection.
+ * @throws NullPointerException if the specified object is null.
+ * @throws ClassCastException if the specified object is not a String.
+ */
+ public boolean contains(Object obj)
+ {
+ if (obj == null)
+ throw new
+ NullPointerException("This collection does not support " +
+ "null values.");
+ if (!(obj instanceof String))
+ throw new
+ ClassCastException("This collection only supports Strings.");
+ return c.contains(obj);
+ }
+
+ /**
+ * Blocks queries where the collection contains a null object or
+ * an object which isn't of type <code>String</code>. All other
+ * queries are forwarded to the underlying collection.
+ *
+ * @param coll the collection of objects to look for.
+ * @return true if the collection contains all elements in the collection.
+ * @throws NullPointerException if the collection is null.
+ * @throws NullPointerException if any collection entry is null.
+ * @throws ClassCastException if any collection entry is not a String.
+ */
+ public boolean containsAll(Collection<?> coll)
+ {
+ for (Object o: coll)
+ {
+ if (o == null)
+ throw new
+ NullPointerException("This collection does not support " +
+ "null values.");
+ if (!(o instanceof String))
+ throw new
+ ClassCastException("This collection only supports Strings.");
+ }
+ return c.containsAll(coll);
+ }
+
+ /**
+ * This returns an iterator over the map elements, with the
+ * same provisions as for the collection and underlying map.
+ *
+ * @return an iterator over the map elements.
+ */
+ public Iterator<String> iterator()
+ {
+ return c.iterator();
+ }
+
+ /**
+ * Blocks the removal of elements from the collection.
+ *
+ * @return true if the removal was sucessful.
+ * @throws NullPointerException if the collection is null.
+ * @throws NullPointerException if any collection entry is null.
+ * @throws ClassCastException if any collection entry is not a String.
+ */
+ public boolean remove(Object key)
+ {
+ if (key == null)
+ throw new
+ NullPointerException("This collection does not support " +
+ "null values.");
+ if (!(key instanceof String))
+ throw new
+ ClassCastException("This collection only supports Strings.");
+ return c.contains(key);
+ }
+
+ /**
+ * Blocks the removal of all elements in the specified
+ * collection from the collection.
+ *
+ * @param coll the collection of elements to remove.
+ * @return true if the elements were removed.
+ * @throws NullPointerException if the collection is null.
+ * @throws NullPointerException if any collection entry is null.
+ * @throws ClassCastException if any collection entry is not a String.
+ */
+ public boolean removeAll(Collection<?> coll)
+ {
+ for (Object o: coll)
+ {
+ if (o == null)
+ throw new
+ NullPointerException("This collection does not support " +
+ "null values.");
+ if (!(o instanceof String))
+ throw new
+ ClassCastException("This collection only supports Strings.");
+ }
+ return c.removeAll(coll);
+ }
+
+ /**
+ * Blocks the retention of all elements in the specified
+ * collection from the collection.
+ *
+ * @param c the collection of elements to retain.
+ * @return true if the other elements were removed.
+ * @throws NullPointerException if the collection is null.
+ * @throws NullPointerException if any collection entry is null.
+ * @throws ClassCastException if any collection entry is not a String.
+ */
+ public boolean retainAll(Collection<?> coll)
+ {
+ for (Object o: coll)
+ {
+ if (o == null)
+ throw new
+ NullPointerException("This collection does not support " +
+ "null values.");
+ if (!(o instanceof String))
+ throw new
+ ClassCastException("This collection only supports Strings.");
+ }
+ return c.containsAll(coll);
+ }
+
+ /**
+ * This simply calls the same method on the wrapped
+ * collection.
+ *
+ * @return the size of the underlying collection.
+ */
+ public int size()
+ {
+ return c.size();
+ }
+
+ } // class EnvironmentCollection<String>
+
+ /**
+ * This is a specialised <code>HashMap</code>, which
+ * prevents the addition or querying of anything other than
+ * <code>String</code> objects.
+ *
+ * @author Andrew John Hughes (gnu...@me...)
+ */
+ static class EnvironmentMap
+ extends HashMap<String,String>
+ {
+
+ /**
+ * Cache the entry set.
+ */
+ private transient Set<Map.Entry<String,String>> entries;
+
+ /**
+ * Cache the key set.
+ */
+ private transient Set<String> keys;
+
+ /**
+ * Cache the value collection.
+ */
+ private transient Collection<String> values;
+
+ /**
+ * Constructs a new empty <code>EnvironmentMap</code>.
+ */
+ EnvironmentMap()
+ {
+ super();
+ }
+
+ /**
+ * Constructs a new <code>EnvironmentMap</code> containing
+ * the contents of the specified map.
+ *
+ * @param m the map to be added to this.
+ * @throws NullPointerException if a key or value is null.
+ * @throws ClassCastException if a key or value is not a String.
+ */
+ EnvironmentMap(Map<String,String> m)
+ {
+ super(m);
+ }
+
+ /**
+ * Blocks queries containing a null key or one which is not
+ * of type <code>String</code>. All other queries
+ * are forwarded to the superclass.
+ *
+ * @param key the key to look for in the map.
+ * @return true if the key exists in the map.
+ * @throws NullPointerException if the specified key is null.
+ */
+ public boolean containsKey(Object key)
+ {
+ if (key == null)
+ throw new
+ NullPointerException("This map does not support null keys.");
+ if (!(key instanceof String))
+ throw new
+ ClassCastException("This map only allows queries using Strings.");
+ return super.containsKey(key);
+ }
+
+ /**
+ * Blocks queries using a null or non-<code>String</code> value.
+ * All other queries are forwarded to the superclass.
+ *
+ * @param value the value to look for in the map.
+ * @return true if the value exists in the map.
+ * @throws NullPointerException if the specified value is null.
+ */
+ public boolean containsValue(Object value)
+ {
+ if (value == null)
+ throw new
+ NullPointerException("This map does not support null values.");
+ if (!(value instanceof String))
+ throw new
+ ClassCastException("This map only allows queries using Strings.");
+ return super.containsValue(value);
+ }
+
+ /**
+ * Returns a set view of the map entries, with the same
+ * provisions as for the underlying map.
+ *
+ * @return a set containing the map entries.
+ */
+ public Set<Map.Entry<String,String>> entrySet()
+ {
+ if (entries == null)
+ entries = super.entrySet();
+ return entries;
+ }
+
+ /**
+ * Blocks queries containing a null or non-<code>String</code> key.
+ * All other queries are passed on to the superclass.
+ *
+ * @param key the key to retrieve the value for.
+ * @return the value associated with the given key.
+ * @throws NullPointerException if the specified key is null.
+ * @throws ClassCastException if the specified key is not a String.
+ */
+ public String get(Object key)
+ {
+ if (key == null)
+ throw new
+ NullPointerException("This map does not support null keys.");
+ if (!(key instanceof String))
+ throw new
+ ClassCastException("This map only allows queries using Strings.");
+ return super.get(key);
+ }
+
+ /**
+ * Returns a set view of the keys, with the same
+ * provisions as for the underlying map.
+ *
+ * @return a set containing the keys.
+ */
+ public Set<String> keySet()
+ {
+ if (keys == null)
+ keys = new EnvironmentSet(super.keySet());
+ return keys;
+ }
+
+ /**
+ * Associates the given key to the given value. If the
+ * map already contains the key, its value is replaced.
+ * The map does not accept null keys or values, or keys
+ * and values not of type {@link String}.
+ *
+ * @param key the key to map.
+ * @param value the value to be mapped.
+ * @return the previous value of the key, or null if there was no mapping
+ * @throws N...
[truncated message content] |
|
From: <ls...@us...> - 2007-06-17 07:14:13
|
Revision: 3266
http://jnode.svn.sourceforge.net/jnode/?rev=3266&view=rev
Author: lsantha
Date: 2007-06-17 00:14:11 -0700 (Sun, 17 Jun 2007)
Log Message:
-----------
Openjdk integration.
Modified Paths:
--------------
trunk/core/src/classpath/java/java/lang/String.java
Removed Paths:
-------------
trunk/core/src/classpath/java/java/lang/Byte.java
trunk/core/src/classpath/java/java/lang/Integer.java
trunk/core/src/classpath/java/java/lang/Long.java
trunk/core/src/classpath/java/java/lang/NumberFormatException.java
trunk/core/src/classpath/java/java/lang/Short.java
Deleted: trunk/core/src/classpath/java/java/lang/Byte.java
===================================================================
--- trunk/core/src/classpath/java/java/lang/Byte.java 2007-06-17 07:09:54 UTC (rev 3265)
+++ trunk/core/src/classpath/java/java/lang/Byte.java 2007-06-17 07:14:11 UTC (rev 3266)
@@ -1,373 +0,0 @@
-/* Byte.java -- object wrapper for byte
- Copyright (C) 1998, 2001, 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 java.lang;
-
-/**
- * Instances of class <code>Byte</code> represent primitive <code>byte</code>
- * values.
- *
- * Additionally, this class provides various helper functions and variables
- * useful to bytes.
- *
- * @author Paul Fisher
- * @author John Keiser
- * @author Per Bothner
- * @author Eric Blake (eb...@em...)
- * @author Tom Tromey (tr...@re...)
- * @author Andrew John Hughes (gnu...@me...)
- * @since 1.1
- * @status updated to 1.5
- */
-public final class Byte extends Number implements Comparable<Byte>
-{
- /**
- * Compatible with JDK 1.1+.
- */
- private static final long serialVersionUID = -7183698231559129828L;
-
- /**
- * The minimum value a <code>byte</code> can represent is -128 (or
- * -2<sup>7</sup>).
- */
- public static final byte MIN_VALUE = -128;
-
- /**
- * The maximum value a <code>byte</code> can represent is 127 (or
- * 2<sup>7</sup> - 1).
- */
- public static final byte MAX_VALUE = 127;
-
- /**
- * The primitive type <code>byte</code> is represented by this
- * <code>Class</code> object.
- */
- public static final Class<Byte> TYPE = (Class<Byte>) VMClassLoader.getPrimitiveClass('B');
-
- /**
- * The number of bits needed to represent a <code>byte</code>.
- * @since 1.5
- */
- public static final int SIZE = 8;
-
- // This caches Byte values, and is used by boxing conversions via
- // valueOf(). We're required to cache all possible values here.
- private static Byte[] byteCache = new Byte[MAX_VALUE - MIN_VALUE + 1];
-
-
- /**
- * The immutable value of this Byte.
- *
- * @serial the wrapped byte
- */
- private final byte value;
-
- /**
- * Create a <code>Byte</code> object representing the value of the
- * <code>byte</code> argument.
- *
- * @param value the value to use
- */
- public Byte(byte value)
- {
- this.value = value;
- }
-
- /**
- * Create a <code>Byte</code> object representing the value specified
- * by the <code>String</code> argument
- *
- * @param s the string to convert
- * @throws NumberFormatException if the String does not contain a byte
- * @see #valueOf(String)
- */
- public Byte(String s)
- {
- value = parseByte(s, 10);
- }
-
- /**
- * Converts the <code>byte</code> to a <code>String</code> and assumes
- * a radix of 10.
- *
- * @param b the <code>byte</code> to convert to <code>String</code>
- * @return the <code>String</code> representation of the argument
- */
- public static String toString(byte b)
- {
- return String.valueOf(b);
- }
-
- /**
- * Converts the specified <code>String</code> into a <code>byte</code>.
- * This function assumes a radix of 10.
- *
- * @param s the <code>String</code> to convert
- * @return the <code>byte</code> value of <code>s</code>
- * @throws NumberFormatException if <code>s</code> cannot be parsed as a
- * <code>byte</code>
- * @see #parseByte(String)
- */
- public static byte parseByte(String s)
- {
- return parseByte(s, 10);
- }
-
- /**
- * Converts the specified <code>String</code> into an <code>int</code>
- * using the specified radix (base). The string must not be <code>null</code>
- * or empty. It may begin with an optional '-', which will negate the answer,
- * provided that there are also valid digits. Each digit is parsed as if by
- * <code>Character.digit(d, radix)</code>, and must be in the range
- * <code>0</code> to <code>radix - 1</code>. Finally, the result must be
- * within <code>MIN_VALUE</code> to <code>MAX_VALUE</code>, inclusive.
- * Unlike Double.parseDouble, you may not have a leading '+'.
- *
- * @param s the <code>String</code> to convert
- * @param radix the radix (base) to use in the conversion
- * @return the <code>String</code> argument converted to <code>byte</code>
- * @throws NumberFormatException if <code>s</code> cannot be parsed as a
- * <code>byte</code>
- */
- public static byte parseByte(String s, int radix)
- {
- int i = Integer.parseInt(s, radix, false);
- if ((byte) i != i)
- throw new NumberFormatException();
- return (byte) i;
- }
-
- /**
- * Creates a new <code>Byte</code> object using the <code>String</code>
- * and specified radix (base).
- *
- * @param s the <code>String</code> to convert
- * @param radix the radix (base) to convert with
- * @return the new <code>Byte</code>
- * @throws NumberFormatException if <code>s</code> cannot be parsed as a
- * <code>byte</code>
- * @see #parseByte(String, int)
- */
- public static Byte valueOf(String s, int radix)
- {
- return new Byte(parseByte(s, radix));
- }
-
- /**
- * Creates a new <code>Byte</code> object using the <code>String</code>,
- * assuming a radix of 10.
- *
- * @param s the <code>String</code> to convert
- * @return the new <code>Byte</code>
- * @throws NumberFormatException if <code>s</code> cannot be parsed as a
- * <code>byte</code>
- * @see #Byte(String)
- * @see #parseByte(String)
- */
- public static Byte valueOf(String s)
- {
- return new Byte(parseByte(s, 10));
- }
-
- /**
- * Returns a <code>Byte</code> object wrapping the value.
- * In contrast to the <code>Byte</code> constructor, this method
- * will cache some values. It is used by boxing conversion.
- *
- * @param val the value to wrap
- * @return the <code>Byte</code>
- */
- public static Byte valueOf(byte val)
- {
- synchronized (byteCache)
- {
- if (byteCache[val - MIN_VALUE] == null)
- byteCache[val - MIN_VALUE] = new Byte(val);
- return byteCache[val - MIN_VALUE];
- }
- }
-
- /**
- * Convert the specified <code>String</code> into a <code>Byte</code>.
- * The <code>String</code> may represent decimal, hexadecimal, or
- * octal numbers.
- *
- * <p>The extended BNF grammar is as follows:<br>
- * <pre>
- * <em>DecodableString</em>:
- * ( [ <code>-</code> ] <em>DecimalNumber</em> )
- * | ( [ <code>-</code> ] ( <code>0x</code> | <code>0X</code>
- * | <code>#</code> ) { <em>HexDigit</em> }+ )
- * | ( [ <code>-</code> ] <code>0</code> { <em>OctalDigit</em> } )
- * <em>DecimalNumber</em>:
- * <em>DecimalDigit except '0'</em> { <em>DecimalDigit</em> }
- * <em>DecimalDigit</em>:
- * <em>Character.digit(d, 10) has value 0 to 9</em>
- * <em>OctalDigit</em>:
- * <em>Character.digit(d, 8) has value 0 to 7</em>
- * <em>DecimalDigit</em>:
- * <em>Character.digit(d, 16) has value 0 to 15</em>
- * </pre>
- * Finally, the value must be in the range <code>MIN_VALUE</code> to
- * <code>MAX_VALUE</code>, or an exception is thrown.
- *
- * @param s the <code>String</code> to interpret
- * @return the value of the String as a <code>Byte</code>
- * @throws NumberFormatException if <code>s</code> cannot be parsed as a
- * <code>byte</code>
- * @throws NullPointerException if <code>s</code> is null
- * @see Integer#decode(String)
- */
- public static Byte decode(String s)
- {
- int i = Integer.parseInt(s, 10, true);
- if ((byte) i != i)
- throw new NumberFormatException();
- return new Byte((byte) i);
- }
-
- /**
- * Return the value of this <code>Byte</code>.
- *
- * @return the byte value
- */
- public byte byteValue()
- {
- return value;
- }
-
- /**
- * Return the value of this <code>Byte</code> as a <code>short</code>.
- *
- * @return the short value
- */
- public short shortValue()
- {
- return value;
- }
-
- /**
- * Return the value of this <code>Byte</code> as an <code>int</code>.
- *
- * @return the int value
- */
- public int intValue()
- {
- return value;
- }
-
- /**
- * Return the value of this <code>Byte</code> as a <code>long</code>.
- *
- * @return the long value
- */
- public long longValue()
- {
- return value;
- }
-
- /**
- * Return the value of this <code>Byte</code> as a <code>float</code>.
- *
- * @return the float value
- */
- public float floatValue()
- {
- return value;
- }
-
- /**
- * Return the value of this <code>Byte</code> as a <code>double</code>.
- *
- * @return the double value
- */
- public double doubleValue()
- {
- return value;
- }
-
- /**
- * Converts the <code>Byte</code> value to a <code>String</code> and
- * assumes a radix of 10.
- *
- * @return the <code>String</code> representation of this <code>Byte</code>
- * @see Integer#toString()
- */
- public String toString()
- {
- return String.valueOf(value);
- }
-
- /**
- * Return a hashcode representing this Object. <code>Byte</code>'s hash
- * code is simply its value.
- *
- * @return this Object's hash code
- */
- public int hashCode()
- {
- return value;
- }
-
- /**
- * Returns <code>true</code> if <code>obj</code> is an instance of
- * <code>Byte</code> and represents the same byte value.
- *
- * @param obj the object to compare
- * @return whether these Objects are semantically equal
- */
- public boolean equals(Object obj)
- {
- return obj instanceof Byte && value == ((Byte) obj).value;
- }
-
- /**
- * Compare two Bytes numerically by comparing their <code>byte</code> values.
- * The result is positive if the first is greater, negative if the second
- * is greater, and 0 if the two are equal.
- *
- * @param b the Byte to compare
- * @return the comparison
- * @since 1.2
- */
- public int compareTo(Byte b)
- {
- return value - b.value;
- }
-
-}
Deleted: trunk/core/src/classpath/java/java/lang/Integer.java
===================================================================
--- trunk/core/src/classpath/java/java/lang/Integer.java 2007-06-17 07:09:54 UTC (rev 3265)
+++ trunk/core/src/classpath/java/java/lang/Integer.java 2007-06-17 07:14:11 UTC (rev 3266)
@@ -1,757 +0,0 @@
-/* Integer.java -- object wrapper for int
- Copyright (C) 1998, 1999, 2001, 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 java.lang;
-
-/**
- * Instances of class <code>Integer</code> represent primitive
- * <code>int</code> values.
- *
- * Additionally, this class provides various helper functions and variables
- * related to ints.
- *
- * @author Paul Fisher
- * @author John Keiser
- * @author Warren Levy
- * @author Eric Blake (eb...@em...)
- * @author Tom Tromey (tr...@re...)
- * @author Andrew John Hughes (gnu...@me...)
- * @since 1.0
- * @status updated to 1.5
- */
-public final class Integer extends Number implements Comparable<Integer>
-{
- /**
- * Compatible with JDK 1.0.2+.
- */
- private static final long serialVersionUID = 1360826667806852920L;
-
- /**
- * The minimum value an <code>int</code> can represent is -2147483648 (or
- * -2<sup>31</sup>).
- */
- public static final int MIN_VALUE = 0x80000000;
-
- /**
- * The maximum value an <code>int</code> can represent is 2147483647 (or
- * 2<sup>31</sup> - 1).
- */
- public static final int MAX_VALUE = 0x7fffffff;
-
- /**
- * The primitive type <code>int</code> is represented by this
- * <code>Class</code> object.
- * @since 1.1
- */
- public static final Class<Integer> TYPE = (Class<Integer>) VMClassLoader.getPrimitiveClass('I');
-
- /**
- * The number of bits needed to represent an <code>int</code>.
- * @since 1.5
- */
- public static final int SIZE = 32;
-
- // This caches some Integer values, and is used by boxing
- // conversions via valueOf(). We must cache at least -128..127;
- // these constants control how much we actually cache.
- private static final int MIN_CACHE = -128;
- private static final int MAX_CACHE = 127;
- private static Integer[] intCache = new Integer[MAX_CACHE - MIN_CACHE + 1];
-
- /**
- * The immutable value of this Integer.
- *
- * @serial the wrapped int
- */
- private final int value;
-
- /**
- * Create an <code>Integer</code> object representing the value of the
- * <code>int</code> argument.
- *
- * @param value the value to use
- */
- public Integer(int value)
- {
- this.value = value;
- }
-
- /**
- * Create an <code>Integer</code> object representing the value of the
- * argument after conversion to an <code>int</code>.
- *
- * @param s the string to convert
- * @throws NumberFormatException if the String does not contain an int
- * @see #valueOf(String)
- */
- public Integer(String s)
- {
- value = parseInt(s, 10, false);
- }
-
- /**
- * Converts the <code>int</code> to a <code>String</code> using
- * the specified radix (base). If the radix exceeds
- * <code>Character.MIN_RADIX</code> or <code>Character.MAX_RADIX</code>, 10
- * is used instead. If the result is negative, the leading character is
- * '-' ('\\u002D'). The remaining characters come from
- * <code>Character.forDigit(digit, radix)</code> ('0'-'9','a'-'z').
- *
- * @param num the <code>int</code> to convert to <code>String</code>
- * @param radix the radix (base) to use in the conversion
- * @return the <code>String</code> representation of the argument
- */
- public static String toString(int num, int radix)
- {
- if (radix < Character.MIN_RADIX || radix > Character.MAX_RADIX)
- radix = 10;
-
- // For negative numbers, print out the absolute value w/ a leading '-'.
- // Use an array large enough for a binary number.
- char[] buffer = new char[33];
- int i = 33;
- boolean isNeg = false;
- if (num < 0)
- {
- isNeg = true;
- num = -num;
-
- // When the value is MIN_VALUE, it overflows when made positive
- if (num < 0)
- {
- buffer[--i] = digits[(int) (-(num + radix) % radix)];
- num = -(num / radix);
- }
- }
-
- do
- {
- buffer[--i] = digits[num % radix];
- num /= radix;
- }
- while (num > 0);
-
- if (isNeg)
- buffer[--i] = '-';
-
- // Package constructor avoids an array copy.
- return new String(buffer, i, 33 - i, true);
- }
-
- /**
- * Converts the <code>int</code> to a <code>String</code> assuming it is
- * unsigned in base 16.
- *
- * @param i the <code>int</code> to convert to <code>String</code>
- * @return the <code>String</code> representation of the argument
- */
- public static String toHexString(int i)
- {
- return toUnsignedString(i, 4);
- }
-
- /**
- * Converts the <code>int</code> to a <code>String</code> assuming it is
- * unsigned in base 8.
- *
- * @param i the <code>int</code> to convert to <code>String</code>
- * @return the <code>String</code> representation of the argument
- */
- public static String toOctalString(int i)
- {
- return toUnsignedString(i, 3);
- }
-
- /**
- * Converts the <code>int</code> to a <code>String</code> assuming it is
- * unsigned in base 2.
- *
- * @param i the <code>int</code> to convert to <code>String</code>
- * @return the <code>String</code> representation of the argument
- */
- public static String toBinaryString(int i)
- {
- return toUnsignedString(i, 1);
- }
-
- /**
- * Converts the <code>int</code> to a <code>String</code> and assumes
- * a radix of 10.
- *
- * @param i the <code>int</code> to convert to <code>String</code>
- * @return the <code>String</code> representation of the argument
- * @see #toString(int, int)
- */
- public static String toString(int i)
- {
- // This is tricky: in libgcj, String.valueOf(int) is a fast native
- // implementation. In Classpath it just calls back to
- // Integer.toString(int, int).
- return String.valueOf(i);
- }
-
- /**
- * Converts the specified <code>String</code> into an <code>int</code>
- * using the specified radix (base). The string must not be <code>null</code>
- * or empty. It may begin with an optional '-', which will negate the answer,
- * provided that there are also valid digits. Each digit is parsed as if by
- * <code>Character.digit(d, radix)</code>, and must be in the range
- * <code>0</code> to <code>radix - 1</code>. Finally, the result must be
- * within <code>MIN_VALUE</code> to <code>MAX_VALUE</code>, inclusive.
- * Unlike Double.parseDouble, you may not have a leading '+'.
- *
- * @param str the <code>String</code> to convert
- * @param radix the radix (base) to use in the conversion
- * @return the <code>String</code> argument converted to <code>int</code>
- * @throws NumberFormatException if <code>s</code> cannot be parsed as an
- * <code>int</code>
- */
- public static int parseInt(String str, int radix)
- {
- return parseInt(str, radix, false);
- }
-
- /**
- * Converts the specified <code>String</code> into an <code>int</code>.
- * This function assumes a radix of 10.
- *
- * @param s the <code>String</code> to convert
- * @return the <code>int</code> value of <code>s</code>
- * @throws NumberFormatException if <code>s</code> cannot be parsed as an
- * <code>int</code>
- * @see #parseInt(String, int)
- */
- public static int parseInt(String s)
- {
- return parseInt(s, 10, false);
- }
-
- /**
- * Creates a new <code>Integer</code> object using the <code>String</code>
- * and specified radix (base).
- *
- * @param s the <code>String</code> to convert
- * @param radix the radix (base) to convert with
- * @return the new <code>Integer</code>
- * @throws NumberFormatException if <code>s</code> cannot be parsed as an
- * <code>int</code>
- * @see #parseInt(String, int)
- */
- public static Integer valueOf(String s, int radix)
- {
- return new Integer(parseInt(s, radix, false));
- }
-
- /**
- * Creates a new <code>Integer</code> object using the <code>String</code>,
- * assuming a radix of 10.
- *
- * @param s the <code>String</code> to convert
- * @return the new <code>Integer</code>
- * @throws NumberFormatException if <code>s</code> cannot be parsed as an
- * <code>int</code>
- * @see #Integer(String)
- * @see #parseInt(String)
- */
- public static Integer valueOf(String s)
- {
- return new Integer(parseInt(s, 10, false));
- }
-
- /**
- * Returns an <code>Integer</code> object wrapping the value.
- * In contrast to the <code>Integer</code> constructor, this method
- * will cache some values. It is used by boxing conversion.
- *
- * @param val the value to wrap
- * @return the <code>Integer</code>
- */
- public static Integer valueOf(int val)
- {
- if (val < MIN_CACHE || val > MAX_CACHE)
- return new Integer(val);
- synchronized (intCache)
- {
- if (intCache[val - MIN_CACHE] == null)
- intCache[val - MIN_CACHE] = new Integer(val);
- return intCache[val - MIN_CACHE];
- }
- }
-
- /**
- * Return the value of this <code>Integer</code> as a <code>byte</code>.
- *
- * @return the byte value
- */
- public byte byteValue()
- {
- return (byte) value;
- }
-
- /**
- * Return the value of this <code>Integer</code> as a <code>short</code>.
- *
- * @return the short value
- */
- public short shortValue()
- {
- return (short) value;
- }
-
- /**
- * Return the value of this <code>Integer</code>.
- * @return the int value
- */
- public int intValue()
- {
- return value;
- }
-
- /**
- * Return the value of this <code>Integer</code> as a <code>long</code>.
- *
- * @return the long value
- */
- public long longValue()
- {
- return value;
- }
-
- /**
- * Return the value of this <code>Integer</code> as a <code>float</code>.
- *
- * @return the float value
- */
- public float floatValue()
- {
- return value;
- }
-
- /**
- * Return the value of this <code>Integer</code> as a <code>double</code>.
- *
- * @return the double value
- */
- public double doubleValue()
- {
- return value;
- }
-
- /**
- * Converts the <code>Integer</code> value to a <code>String</code> and
- * assumes a radix of 10.
- *
- * @return the <code>String</code> representation
- */
- public String toString()
- {
- return String.valueOf(value);
- }
-
- /**
- * Return a hashcode representing this Object. <code>Integer</code>'s hash
- * code is simply its value.
- *
- * @return this Object's hash code
- */
- public int hashCode()
- {
- return value;
- }
-
- /**
- * Returns <code>true</code> if <code>obj</code> is an instance of
- * <code>Integer</code> and represents the same int value.
- *
- * @param obj the object to compare
- * @return whether these Objects are semantically equal
- */
- public boolean equals(Object obj)
- {
- return obj instanceof Integer && value == ((Integer) obj).value;
- }
-
- /**
- * Get the specified system property as an <code>Integer</code>. The
- * <code>decode()</code> method will be used to interpret the value of
- * the property.
- *
- * @param nm the name of the system property
- * @return the system property as an <code>Integer</code>, or null if the
- * property is not found or cannot be decoded
- * @throws SecurityException if accessing the system property is forbidden
- * @see System#getProperty(String)
- * @see #decode(String)
- */
- public static Integer getInteger(String nm)
- {
- return getInteger(nm, null);
- }
-
- /**
- * Get the specified system property as an <code>Integer</code>, or use a
- * default <code>int</code> value if the property is not found or is not
- * decodable. The <code>decode()</code> method will be used to interpret
- * the value of the property.
- *
- * @param nm the name of the system property
- * @param val the default value
- * @return the value of the system property, or the default
- * @throws SecurityException if accessing the system property is forbidden
- * @see System#getProperty(String)
- * @see #decode(String)
- */
- public static Integer getInteger(String nm, int val)
- {
- Integer result = getInteger(nm, null);
- return result == null ? new Integer(val) : result;
- }
-
- /**
- * Get the specified system property as an <code>Integer</code>, or use a
- * default <code>Integer</code> value if the property is not found or is
- * not decodable. The <code>decode()</code> method will be used to
- * interpret the value of the property.
- *
- * @param nm the name of the system property
- * @param def the default value
- * @return the value of the system property, or the default
- * @throws SecurityException if accessing the system property is forbidden
- * @see System#getProperty(String)
- * @see #decode(String)
- */
- public static Integer getInteger(String nm, Integer def)
- {
- if (nm == null || "".equals(nm))
- return def;
- nm = System.getProperty(nm);
- if (nm == null)
- return def;
- try
- {
- return decode(nm);
- }
- catch (NumberFormatException e)
- {
- return def;
- }
- }
-
- /**
- * Convert the specified <code>String</code> into an <code>Integer</code>.
- * The <code>String</code> may represent decimal, hexadecimal, or
- * octal numbers.
- *
- * <p>The extended BNF grammar is as follows:<br>
- * <pre>
- * <em>DecodableString</em>:
- * ( [ <code>-</code> ] <em>DecimalNumber</em> )
- * | ( [ <code>-</code> ] ( <code>0x</code> | <code>0X</code>
- * | <code>#</code> ) <em>HexDigit</em> { <em>HexDigit</em> } )
- * | ( [ <code>-</code> ] <code>0</code> { <em>OctalDigit</em> } )
- * <em>DecimalNumber</em>:
- * <em>DecimalDigit except '0'</em> { <em>DecimalDigit</em> }
- * <em>DecimalDigit</em>:
- * <em>Character.digit(d, 10) has value 0 to 9</em>
- * <em>OctalDigit</em>:
- * <em>Character.digit(d, 8) has value 0 to 7</em>
- * <em>DecimalDigit</em>:
- * <em>Character.digit(d, 16) has value 0 to 15</em>
- * </pre>
- * Finally, the value must be in the range <code>MIN_VALUE</code> to
- * <code>MAX_VALUE</code>, or an exception is thrown.
- *
- * @param str the <code>String</code> to interpret
- * @return the value of the String as an <code>Integer</code>
- * @throws NumberFormatException if <code>s</code> cannot be parsed as a
- * <code>int</code>
- * @throws NullPointerException if <code>s</code> is null
- * @since 1.2
- */
- public static Integer decode(String str)
- {
- return new Integer(parseInt(str, 10, true));
- }
-
- /**
- * Compare two Integers numerically by comparing their <code>int</code>
- * values. The result is positive if the first is greater, negative if the
- * second is greater, and 0 if the two are equal.
- *
- * @param i the Integer to compare
- * @return the comparison
- * @since 1.2
- */
- public int compareTo(Integer i)
- {
- if (value == i.value)
- return 0;
- // Returns just -1 or 1 on inequality; doing math might overflow.
- return value > i.value ? 1 : -1;
- }
-
- /**
- * Return the number of bits set in x.
- * @param x value to examine
- * @since 1.5
- */
- public static int bitCount(int x)
- {
- // Successively collapse alternating bit groups into a sum.
- x = ((x >> 1) & 0x55555555) + (x & 0x55555555);
- x = ((x >> 2) & 0x33333333) + (x & 0x33333333);
- x = ((x >> 4) & 0x0f0f0f0f) + (x & 0x0f0f0f0f);
- x = ((x >> 8) & 0x00ff00ff) + (x & 0x00ff00ff);
- return ((x >> 16) & 0x0000ffff) + (x & 0x0000ffff);
- }
-
- /**
- * Rotate x to the left by distance bits.
- * @param x the value to rotate
- * @param distance the number of bits by which to rotate
- * @since 1.5
- */
- public static int rotateLeft(int x, int distance)
- {
- // This trick works because the shift operators implicitly mask
- // the shift count.
- return (x << distance) | (x >>> - distance);
- }
-
- /**
- * Rotate x to the right by distance bits.
- * @param x the value t...
[truncated message content] |
|
From: <ls...@us...> - 2007-08-11 11:23:43
|
Revision: 3385
http://jnode.svn.sourceforge.net/jnode/?rev=3385&view=rev
Author: lsantha
Date: 2007-08-11 04:23:39 -0700 (Sat, 11 Aug 2007)
Log Message:
-----------
Openjdk integration.
Removed Paths:
-------------
trunk/core/src/classpath/java/java/lang/Void.java
trunk/core/src/classpath/java/java/lang/annotation/
Deleted: trunk/core/src/classpath/java/java/lang/Void.java
===================================================================
--- trunk/core/src/classpath/java/java/lang/Void.java 2007-08-11 10:57:11 UTC (rev 3384)
+++ trunk/core/src/classpath/java/java/lang/Void.java 2007-08-11 11:23:39 UTC (rev 3385)
@@ -1,68 +0,0 @@
-/* Void.class - defines void.class
- Copyright (C) 1998, 1999, 2001, 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 java.lang;
-
-
-/**
- * Void is a placeholder class so that the variable <code>Void.TYPE</code>
- * (also available as <code>void.class</code>) can be supported for
- * reflection return types.
- *
- * <p>This class could be Serializable, but that is up to Sun.</p>
- *
- * @author Paul Fisher
- * @author John Keiser
- * @author Eric Blake (eb...@em...)
- * @since 1.1
- * @status updated to 1.5
- */
-public final class Void
-{
- /**
- * The return type <code>void</code> is represented by this
- * <code>Class</code> object.
- */
- public static final Class<Void> TYPE = (Class<Void>) VMClassLoader.getPrimitiveClass('V');
-
- /**
- * Void is non-instantiable.
- */
- private Void()
- {
- }
-}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ls...@us...> - 2007-09-06 14:49:07
|
Revision: 3463
http://jnode.svn.sourceforge.net/jnode/?rev=3463&view=rev
Author: lsantha
Date: 2007-09-06 07:49:03 -0700 (Thu, 06 Sep 2007)
Log Message:
-----------
openjdk integration
Removed Paths:
-------------
trunk/core/src/classpath/java/java/lang/Boolean.java
trunk/core/src/classpath/java/java/lang/Character.java
trunk/core/src/classpath/java/java/lang/Compiler.java
trunk/core/src/classpath/java/java/lang/Enum.java
trunk/core/src/classpath/java/java/lang/StackTraceElement.java
trunk/core/src/classpath/java/java/lang/String.java
trunk/core/src/classpath/java/java/lang/StringBuffer.java
trunk/core/src/classpath/java/java/lang/StringBuilder.java
Deleted: trunk/core/src/classpath/java/java/lang/Boolean.java
===================================================================
--- trunk/core/src/classpath/java/java/lang/Boolean.java 2007-09-06 14:48:42 UTC (rev 3462)
+++ trunk/core/src/classpath/java/java/lang/Boolean.java 2007-09-06 14:49:03 UTC (rev 3463)
@@ -1,251 +0,0 @@
-/* Boolean.java -- object wrapper for boolean
- Copyright (C) 1998, 2001, 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 java.lang;
-
-import java.io.Serializable;
-
-/**
- * Instances of class <code>Boolean</code> represent primitive
- * <code>boolean</code> values.
- *
- * @author Paul Fisher
- * @author Eric Blake (eb...@em...)
- * @since 1.0
- * @status updated to 1.5
- */
-public final class Boolean implements Serializable, Comparable<Boolean>
-{
- /**
- * Compatible with JDK 1.0.2+.
- */
- private static final long serialVersionUID = -3665804199014368530L;
-
- /**
- * This field is a <code>Boolean</code> object representing the
- * primitive value <code>true</code>. This instance is returned
- * by the static <code>valueOf()</code> methods if they return
- * a <code>Boolean</code> representing <code>true</code>.
- */
- public static final Boolean TRUE = new Boolean(true);
-
- /**
- * This field is a <code>Boolean</code> object representing the
- * primitive value <code>false</code>. This instance is returned
- * by the static <code>valueOf()</code> methods if they return
- * a <code>Boolean</code> representing <code>false</code>.
- */
- public static final Boolean FALSE = new Boolean(false);
-
- /**
- * The primitive type <code>boolean</code> is represented by this
- * <code>Class</code> object.
- *
- * @since 1.1
- */
- public static final Class<Boolean> TYPE = (Class<Boolean>) VMClassLoader.getPrimitiveClass('Z');
-
- /**
- * The immutable value of this Boolean.
- * @serial the wrapped value
- */
- private final boolean value;
-
- /**
- * Create a <code>Boolean</code> object representing the value of the
- * argument <code>value</code>. In general the use of the static
- * method <code>valueof(boolean)</code> is more efficient since it will
- * not create a new object.
- *
- * @param value the primitive value of this <code>Boolean</code>
- * @see #valueOf(boolean)
- */
- public Boolean(boolean value)
- {
- this.value = value;
- }
-
- /**
- * Creates a <code>Boolean</code> object representing the primitive
- * <code>true</code> if and only if <code>s</code> matches
- * the string "true" ignoring case, otherwise the object will represent
- * the primitive <code>false</code>. In general the use of the static
- * method <code>valueof(String)</code> is more efficient since it will
- * not create a new object.
- *
- * @param s the <code>String</code> representation of <code>true</code>
- * or false
- */
- public Boolean(String s)
- {
- value = "true".equalsIgnoreCase(s);
- }
-
- /**
- * Return the primitive <code>boolean</code> value of this
- * <code>Boolean</code> object.
- *
- * @return true or false, depending on the value of this Boolean
- */
- public boolean booleanValue()
- {
- return value;
- }
-
- /**
- * Returns the Boolean <code>TRUE</code> if the given boolean is
- * <code>true</code>, otherwise it will return the Boolean
- * <code>FALSE</code>.
- *
- * @param b the boolean to wrap
- * @return the wrapper object
- * @see #TRUE
- * @see #FALSE
- * @since 1.4
- */
- public static Boolean valueOf(boolean b)
- {
- return b ? TRUE : FALSE;
- }
-
- /**
- * Returns the Boolean <code>TRUE</code> if and only if the given
- * String is equal, ignoring case, to the the String "true", otherwise
- * it will return the Boolean <code>FALSE</code>.
- *
- * @param s the string to convert
- * @return a wrapped boolean from the string
- */
- public static Boolean valueOf(String s)
- {
- return "true".equalsIgnoreCase(s) ? TRUE : FALSE;
- }
-
- /**
- * Returns "true" if the value of the give boolean is <code>true</code> and
- * returns "false" if the value of the given boolean is <code>false</code>.
- *
- * @param b the boolean to convert
- * @return the string representation of the boolean
- * @since 1.4
- */
- public static String toString(boolean b)
- {
- return b ? "true" : "false";
- }
-
- /**
- * Returns "true" if the value of this object is <code>true</code> and
- * returns "false" if the value of this object is <code>false</code>.
- *
- * @return the string representation of this
- */
- public String toString()
- {
- return value ? "true" : "false";
- }
-
- /**
- * Returns the integer <code>1231</code> if this object represents
- * the primitive <code>true</code> and the integer <code>1237</code>
- * otherwise.
- *
- * @return the hash code
- */
- public int hashCode()
- {
- return value ? 1231 : 1237;
- }
-
- /**
- * If the <code>obj</code> is an instance of <code>Boolean</code> and
- * has the same primitive value as this object then <code>true</code>
- * is returned. In all other cases, including if the <code>obj</code>
- * is <code>null</code>, <code>false</code> is returned.
- *
- * @param obj possibly an instance of any <code>Class</code>
- * @return true if <code>obj</code> equals this
- */
- public boolean equals(Object obj)
- {
- return obj instanceof Boolean && value == ((Boolean) obj).value;
- }
-
- /**
- * If the value of the system property <code>name</code> matches
- * "true" ignoring case then the function returns <code>true</code>.
- *
- * @param name the property name to look up
- * @return true if the property resulted in "true"
- * @throws SecurityException if accessing the system property is forbidden
- * @see System#getProperty(String)
- */
- public static boolean getBoolean(String name)
- {
- if (name == null || "".equals(name))
- return false;
- return "true".equalsIgnoreCase(System.getProperty(name));
- }
-
- /**
- * Compares this Boolean to another.
- *
- * @param other the Boolean to compare this Boolean to
- * @return 0 if both Booleans represent the same value, a positive number
- * if this Boolean represents true and the other false, and a negative
- * number otherwise.
- * @since 1.5
- */
- public int compareTo(Boolean other)
- {
- return value == other.value ? 0 : (value ? 1 : -1);
- }
-
- /**
- * If the String argument is "true", ignoring case, return true.
- * Otherwise, return false.
- *
- * @param b String to parse
- * @since 1.5
- */
- public static boolean parseBoolean(String b)
- {
- return "true".equalsIgnoreCase(b) ? true : false;
- }
-
-}
Deleted: trunk/core/src/classpath/java/java/lang/Character.java
===================================================================
--- trunk/core/src/classpath/java/java/lang/Character.java 2007-09-06 14:48:42 UTC (rev 3462)
+++ trunk/core/src/classpath/java/java/lang/Character.java 2007-09-06 14:49:03 UTC (rev 3463)
@@ -1,4551 +0,0 @@
-/* java.lang.Character -- Wrapper class for char, and Unicode subsets
- Copyright (C) 1998, 1999, 2001, 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 java.lang;
-
-import gnu.java.lang.CharData;
-
-import java.io.Serializable;
-import java.text.Collator;
-import java.util.Locale;
-
-/**
- * Wrapper class for the primitive char data type. In addition, this class
- * allows one to retrieve property information and perform transformations
- * on the defined characters in the Unicode Standard, Version 4.0.0.
- * java.lang.Character is designed to be very dynamic, and as such, it
- * retrieves information on the Unicode character set from a separate
- * database, gnu.java.lang.CharData, which can be easily upgraded.
- *
- * <p>For predicates, boundaries are used to describe
- * the set of characters for which the method will return true.
- * This syntax uses fairly normal regular expression notation.
- * See 5.13 of the Unicode Standard, Version 4.0, for the
- * boundary specification.
- *
- * <p>See <a href="http://www.unicode.org">http://www.unicode.org</a>
- * for more information on the Unicode Standard.
- *
- * @author Tom Tromey (tr...@cy...)
- * @author Paul N. Fisher
- * @author Jochen Hoenicke
- * @author Eric Blake (eb...@em...)
- * @author Andrew John Hughes (gnu...@me...)
- * @see CharData
- * @since 1.0
- * @status partly updated to 1.5; some things still missing
- */
-public final class Character implements Serializable, Comparable<Character>
-{
- /**
- * A subset of Unicode blocks.
- *
- * @author Paul N. Fisher
- * @author Eric Blake (eb...@em...)
- * @since 1.2
- */
- public static class Subset
- {
- /** The name of the subset. */
- private final String name;
-
- /**
- * Construct a new subset of characters.
- *
- * @param name the name of the subset
- * @throws NullPointerException if name is null
- */
- protected Subset(String name)
- {
- // Note that name.toString() is name, unless name was null.
- this.name = name.toString();
- }
-
- /**
- * Compares two Subsets for equality. This is <code>final</code>, and
- * restricts the comparison on the <code>==</code> operator, so it returns
- * true only for the same object.
- *
- * @param o the object to compare
- * @return true if o is this
- */
- public final boolean equals(Object o)
- {
- return o == this;
- }
-
- /**
- * Makes the original hashCode of Object final, to be consistent with
- * equals.
- *
- * @return the hash code for this object
- */
- public final int hashCode()
- {
- return super.hashCode();
- }
-
- /**
- * Returns the name of the subset.
- *
- * @return the name
- */
- public final String toString()
- {
- return name;
- }
- } // class Subset
-
- /**
- * A family of character subsets in the Unicode specification. A character
- * is in at most one of these blocks.
- *
- * This inner class was generated automatically from
- * <code>doc/unicode/Blocks-4.0.0.txt</code>, by some perl scripts.
- * This Unicode definition file can be found on the
- * <a href="http://www.unicode.org">http://www.unicode.org</a> website.
- * JDK 1.5 uses Unicode version 4.0.0.
- *
- * @author scripts/unicode-blocks.pl (written by Eric Blake)
- * @since 1.2
- */
- public static final class UnicodeBlock extends Subset
- {
- /** The start of the subset. */
- private final int start;
-
- /** The end of the subset. */
- private final int end;
-
- /** The canonical name of the block according to the Unicode standard. */
- private final String canonicalName;
-
- /** Enumeration for the <code>forName()</code> method */
- private enum NameType { CANONICAL, NO_SPACES, CONSTANT; }
-
- /**
- * Constructor for strictly defined blocks.
- *
- * @param start the start character of the range
- * @param end the end character of the range
- * @param name the block name
- * @param canonicalName the name of the block as defined in the Unicode
- * standard.
- */
- private UnicodeBlock(int start, int end, String name,
- String canonicalName)
- {
- super(name);
- this.start = start;
- this.end = end;
- this.canonicalName = canonicalName;
- }
-
- /**
- * Returns the Unicode character block which a character belongs to.
- * <strong>Note</strong>: This method does not support the use of
- * supplementary characters. For such support, <code>of(int)</code>
- * should be used instead.
- *
- * @param ch the character to look up
- * @return the set it belongs to, or null if it is not in one
- */
- public static UnicodeBlock of(char ch)
- {
- return of((int) ch);
- }
-
- /**
- * Returns the Unicode character block which a code point belongs to.
- *
- * @param codePoint the character to look up
- * @return the set it belongs to, or null if it is not in one.
- * @throws IllegalArgumentException if the specified code point is
- * invalid.
- * @since 1.5
- */
- public static UnicodeBlock of(int codePoint)
- {
- if (codePoint > MAX_CODE_POINT)
- throw new IllegalArgumentException("The supplied integer value is " +
- "too large to be a codepoint.");
- // Simple binary search for the correct block.
- int low = 0;
- int hi = sets.length - 1;
- while (low <= hi)
- {
- int mid = (low + hi) >> 1;
- UnicodeBlock b = sets[mid];
- if (codePoint < b.start)
- hi = mid - 1;
- else if (codePoint > b.end)
- low = mid + 1;
- else
- return b;
- }
- return null;
- }
-
- /**
- * <p>
- * Returns the <code>UnicodeBlock</code> with the given name, as defined
- * by the Unicode standard. The version of Unicode in use is defined by
- * the <code>Character</code> class, and the names are given in the
- * <code>Blocks-<version>.txt</code> file corresponding to that version.
- * The name may be specified in one of three ways:
- * </p>
- * <ol>
- * <li>The canonical, human-readable name used by the Unicode standard.
- * This is the name with all spaces and hyphens retained. For example,
- * `Basic Latin' retrieves the block, UnicodeBlock.BASIC_LATIN.</li>
- * <li>The canonical name with all spaces removed e.g. `BasicLatin'.</li>
- * <li>The name used for the constants specified by this class, which
- * is the canonical name with all spaces and hyphens replaced with
- * underscores e.g. `BASIC_LATIN'</li>
- * </ol>
- * <p>
- * The names are compared case-insensitively using the case comparison
- * associated with the U.S. English locale. The method recognises the
- * previous names used for blocks as well as the current ones. At
- * present, this simply means that the deprecated `SURROGATES_AREA'
- * will be recognised by this method (the <code>of()</code> methods
- * only return one of the three new surrogate blocks).
- * </p>
- *
- * @param blockName the name of the block to look up.
- * @return the specified block.
- * @throws NullPointerException if the <code>blockName</code> is
- * <code>null</code>.
- * @throws IllegalArgumentException if the name does not match any Unicode
- * block.
- * @since 1.5
- */
- public static final UnicodeBlock forName(String blockName)
- {
- NameType type;
- if (blockName.indexOf(' ') != -1)
- type = NameType.CANONICAL;
- else if (blockName.indexOf('_') != -1)
- type = NameType.CONSTANT;
- else
- type = NameType.NO_SPACES;
- Collator usCollator = Collator.getInstance(Locale.US);
- usCollator.setStrength(Collator.PRIMARY);
- /* Special case for deprecated blocks not in sets */
- switch (type)
- {
- case CANONICAL:
- if (usCollator.compare(blockName, "Surrogates Area") == 0)
- return SURROGATES_AREA;
- break;
- case NO_SPACES:
- if (usCollator.compare(blockName, "SurrogatesArea") == 0)
- return SURROGATES_AREA;
- break;
- case CONSTANT:
- if (usCollator.compare(blockName, "SURROGATES_AREA") == 0)
- return SURROGATES_AREA;
- break;
- }
- /* Other cases */
- switch (type)
- {
- case CANONICAL:
- for (UnicodeBlock block : sets)
- if (usCollator.compare(blockName, block.canonicalName) == 0)
- return block;
- break;
- case NO_SPACES:
- for (UnicodeBlock block : sets)
- {
- String nsName = block.canonicalName.replaceAll(" ","");
- if (usCollator.compare(blockName, nsName) == 0)
- return block;
- }
- break;
- case CONSTANT:
- for (UnicodeBlock block : sets)
- if (usCollator.compare(blockName, block.toString()) == 0)
- return block;
- break;
- }
- throw new IllegalArgumentException("No Unicode block found for " +
- blockName + ".");
- }
-
- /**
- * Basic Latin.
- * 0x0000 - 0x007F.
- */
- public static final UnicodeBlock BASIC_LATIN
- = new UnicodeBlock(0x0000, 0x007F,
- "BASIC_LATIN",
- "Basic Latin");
-
- /**
- * Latin-1 Supplement.
- * 0x0080 - 0x00FF.
- */
- public static final UnicodeBlock LATIN_1_SUPPLEMENT
- = new UnicodeBlock(0x0080, 0x00FF,
- "LATIN_1_SUPPLEMENT",
- "Latin-1 Supplement");
-
- /**
- * Latin Extended-A.
- * 0x0100 - 0x017F.
- */
- public static final UnicodeBlock LATIN_EXTENDED_A
- = new UnicodeBlock(0x0100, 0x017F,
- "LATIN_EXTENDED_A",
- "Latin Extended-A");
-
- /**
- * Latin Extended-B.
- * 0x0180 - 0x024F.
- */
- public static final UnicodeBlock LATIN_EXTENDED_B
- = new UnicodeBlock(0x0180, 0x024F,
- "LATIN_EXTENDED_B",
- "Latin Extended-B");
-
- /**
- * IPA Extensions.
- * 0x0250 - 0x02AF.
- */
- public static final UnicodeBlock IPA_EXTENSIONS
- = new UnicodeBlock(0x0250, 0x02AF,
- "IPA_EXTENSIONS",
- "IPA Extensions");
-
- /**
- * Spacing Modifier Letters.
- * 0x02B0 - 0x02FF.
- */
- public static final UnicodeBlock SPACING_MODIFIER_LETTERS
- = new UnicodeBlock(0x02B0, 0x02FF,
- "SPACING_MODIFIER_LETTERS",
- "Spacing Modifier Letters");
-
- /**
- * Combining Diacritical Marks.
- * 0x0300 - 0x036F.
- */
- public static final UnicodeBlock COMBINING_DIACRITICAL_MARKS
- = new UnicodeBlock(0x0300, 0x036F,
- "COMBINING_DIACRITICAL_MARKS",
- "Combining Diacritical Marks");
-
- /**
- * Greek.
- * 0x0370 - 0x03FF.
- */
- public static final UnicodeBlock GREEK
- = new UnicodeBlock(0x0370, 0x03FF,
- "GREEK",
- "Greek");
-
- /**
- * Cyrillic.
- * 0x0400 - 0x04FF.
- */
- public static final UnicodeBlock CYRILLIC
- = new UnicodeBlock(0x0400, 0x04FF,
- "CYRILLIC",
- "Cyrillic");
-
- /**
- * Cyrillic Supplementary.
- * 0x0500 - 0x052F.
- * @since 1.5
- */
- public static final UnicodeBlock CYRILLIC_SUPPLEMENTARY
- = new UnicodeBlock(0x0500, 0x052F,
- "CYRILLIC_SUPPLEMENTARY",
- "Cyrillic Supplementary");
-
- /**
- * Armenian.
- * 0x0530 - 0x058F.
- */
- public static final UnicodeBlock ARMENIAN
- = new UnicodeBlock(0x0530, 0x058F,
- "ARMENIAN",
- "Armenian");
-
- /**
- * Hebrew.
- * 0x0590 - 0x05FF.
- */
- public static final UnicodeBlock HEBREW
- = new UnicodeBlock(0x0590, 0x05FF,
- "HEBREW",
- "Hebrew");
-
- /**
- * Arabic.
- * 0x0600 - 0x06FF.
- */
- public static final UnicodeBlock ARABIC
- = new UnicodeBlock(0x0600, 0x06FF,
- "ARABIC",
- "Arabic");
-
- /**
- * Syriac.
- * 0x0700 - 0x074F.
- * @since 1.4
- */
- public static final UnicodeBlock SYRIAC
- = new UnicodeBlock(0x0700, 0x074F,
- "SYRIAC",
- "Syriac");
-
- /**
- * Thaana.
- * 0x0780 - 0x07BF.
- * @since 1.4
- */
- public static final UnicodeBlock THAANA
- = new UnicodeBlock(0x0780, 0x07BF,
- "THAANA",
- "Thaana");
-
- /**
- * Devanagari.
- * 0x0900 - 0x097F.
- */
- public static final UnicodeBlock DEVANAGARI
- = new UnicodeBlock(0x0900, 0x097F,
- "DEVANAGARI",
- "Devanagari");
-
- /**
- * Bengali.
- * 0x0980 - 0x09FF.
- */
- public static final UnicodeBlock BENGALI
- = new UnicodeBlock(0x0980, 0x09FF,
- "BENGALI",
- "Bengali");
-
- /**
- * Gurmukhi.
- * 0x0A00 - 0x0A7F.
- */
- public static final UnicodeBlock GURMUKHI
- = new UnicodeBlock(0x0A00, 0x0A7F,
- "GURMUKHI",
- "Gurmukhi");
-
- /**
- * Gujarati.
- * 0x0A80 - 0x0AFF.
- */
- public static final UnicodeBlock GUJARATI
- = new UnicodeBlock(0x0A80, 0x0AFF,
- "GUJARATI",
- "Gujarati");
-
- /**
- * Oriya.
- * 0x0B00 - 0x0B7F.
- */
- public static final UnicodeBlock ORIYA
- = new UnicodeBlock(0x0B00, 0x0B7F,
- "ORIYA",
- "Oriya");
-
- /**
- * Tamil.
- * 0x0B80 - 0x0BFF.
- */
- public static final UnicodeBlock TAMIL
- = new UnicodeBlock(0x0B80, 0x0BFF,
- "TAMIL",
- "Tamil");
-
- /**
- * Telugu.
- * 0x0C00 - 0x0C7F.
- */
- public static final UnicodeBlock TELUGU
- = new UnicodeBlock(0x0C00, 0x0C7F,
- "TELUGU",
- "Telugu");
-
- /**
- * Kannada.
- * 0x0C80 - 0x0CFF.
- */
- public static final UnicodeBlock KANNADA
- = new UnicodeBlock(0x0C80, 0x0CFF,
- "KANNADA",
- "Kannada");
-
- /**
- * Malayalam.
- * 0x0D00 - 0x0D7F.
- */
- public static final UnicodeBlock MALAYALAM
- = new UnicodeBlock(0x0D00, 0x0D7F,
- "MALAYALAM",
- "Malayalam");
-
- /**
- * Sinhala.
- * 0x0D80 - 0x0DFF.
- * @since 1.4
- */
- public static final UnicodeBlock SINHALA
- = new UnicodeBlock(0x0D80, 0x0DFF,
- "SINHALA",
- "Sinhala");
-
- /**
- * Thai.
- * 0x0E00 - 0x0E7F.
- */
- public static final UnicodeBlock THAI
- = new UnicodeBlock(0x0E00, 0x0E7F,
- "THAI",
- "Thai");
-
- /**
- * Lao.
- * 0x0E80 - 0x0EFF.
- */
- public static final UnicodeBlock LAO
- = new UnicodeBlock(0x0E80, 0x0EFF,
- "LAO",
- "Lao");
-
- /**
- * Tibetan.
- * 0x0F00 - 0x0FFF.
- */
- public static final UnicodeBlock TIBETAN
- = new UnicodeBlock(0x0F00, 0x0FFF,
- "TIBETAN",
- "Tibetan");
-
- /**
- * Myanmar.
- * 0x1000 - 0x109F.
- * @since 1.4
- */
- public static final UnicodeBlock MYANMAR
- = new UnicodeBlock(0x1000, 0x109F,
- "MYANMAR",
- "Myanmar");
-
- /**
- * Georgian.
- * 0x10A0 - 0x10FF.
- */
- public static final UnicodeBlock GEORGIAN
- = new UnicodeBlock(0x10A0, 0x10FF,
- "GEORGIAN",
- "Georgian");
-
- /**
- * Hangul Jamo.
- * 0x1100 - 0x11FF.
- */
- public static final UnicodeBlock HANGUL_JAMO
- = new UnicodeBlock(0x1100, 0x11FF,
- "HANGUL_JAMO",
- "Hangul Jamo");
-
- /**
- * Ethiopic.
- * 0x1200 - 0x137F.
- * @since 1.4
- */
- public static final UnicodeBlock ETHIOPIC
- = new UnicodeBlock(0x1200, 0x137F,
- "ETHIOPIC",
- "Ethiopic");
-
- /**
- * Cherokee.
- * 0x13A0 - 0x13FF.
- * @since 1.4
- */
- public static final UnicodeBlock CHEROKEE
- = new UnicodeBlock(0x13A0, 0x13FF,
- "CHEROKEE",
- "Cherokee");
-
- /**
- * Unified Canadian Aboriginal Syllabics.
- * 0x1400 - 0x167F.
- * @since 1.4
- */
- public static final UnicodeBlock UNIFIED_CANADIAN_ABORIGINAL_SYLLABICS
- = new UnicodeBlock(0x1400, 0x167F,
- "UNIFIED_CANADIAN_ABORIGINAL_SYLLABICS",
- "Unified Canadian Aboriginal Syllabics");
-
- /**
- * Ogham.
- * 0x1680 - 0x169F.
- * @since 1.4
- */
- public static final UnicodeBlock OGHAM
- = new UnicodeBlock(0x1680, 0x169F,
- "OGHAM",
- "Ogham");
-
- /**
- * Runic.
- * 0x16A0 - 0x16FF.
- * @since 1.4
- */
- public static final UnicodeBlock RUNIC
- = new UnicodeBlock(0x16A0, 0x16FF,
- "RUNIC",
- "Runic");
-
- /**
- * Tagalog.
- * 0x1700 - 0x171F.
- * @since 1.5
- */
- public static final UnicodeBlock TAGALOG
- = new UnicodeBlock(0x1700, 0x171F,
- "TAGALOG",
- "Tagalog");
-
- /**
- * Hanunoo.
- * 0x1720 - 0x173F.
- * @since 1.5
- */
- public static final UnicodeBlock HANUNOO
- = new UnicodeBlock(0x1720, 0x173F,
- "HANUNOO",
- "Hanunoo");
-
- /**
- * Buhid.
- * 0x1740 - 0x175F.
- * @since 1.5
- */
- public static final UnicodeBlock BUHID
- = new UnicodeBlock(0x1740, 0x175F,
- "BUHID",
- "Buhid");
-
- /**
- * Tagbanwa.
- * 0x1760 - 0x177F.
- * @since 1.5
- */
- public static final UnicodeBlock TAGBANWA
- = new UnicodeBlock(0x1760, 0x177F,
- "TAGBANWA",
- "Tagbanwa");
-
- /**
- * Khmer.
- * 0x1780 - 0x1...
[truncated message content] |