From 554fd8c5195424bdbcabf5de30fdc183aba391bd Mon Sep 17 00:00:00 2001 From: upstream source tree Date: Sun, 15 Mar 2015 20:14:05 -0400 Subject: obtained gcc-4.6.4.tar.bz2 from upstream website; verified gcc-4.6.4.tar.bz2.sig; imported gcc-4.6.4 source tree from verified upstream tarball. downloading a git-generated archive based on the 'upstream' tag should provide you with a source tree that is binary identical to the one extracted from the above tarball. if you have obtained the source via the command 'git clone', however, do note that line-endings of files in your working directory might differ from line-endings of the respective files in the upstream repository. --- .../javax/management/openmbean/SimpleType.java | 350 +++++++++++++++++++++ 1 file changed, 350 insertions(+) create mode 100644 libjava/classpath/javax/management/openmbean/SimpleType.java (limited to 'libjava/classpath/javax/management/openmbean/SimpleType.java') diff --git a/libjava/classpath/javax/management/openmbean/SimpleType.java b/libjava/classpath/javax/management/openmbean/SimpleType.java new file mode 100644 index 000000000..81b991bdf --- /dev/null +++ b/libjava/classpath/javax/management/openmbean/SimpleType.java @@ -0,0 +1,350 @@ +/* SimpleType.java -- Open type descriptor for the base types. + Copyright (C) 2006, 2007 Free Software Foundation, Inc. + +This file is part of GNU Classpath. + +GNU Classpath is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2, or (at your option) +any later version. + +GNU Classpath is distributed in the hope that it will be useful, but +WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +General Public License for more details. + +You should have received a copy of the GNU General Public License +along with GNU Classpath; see the file COPYING. If not, write to the +Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA +02110-1301 USA. + +Linking this library statically or dynamically with other modules is +making a combined work based on this library. Thus, the terms and +conditions of the GNU General Public License cover the whole +combination. + +As a special exception, the copyright holders of this library give you +permission to link this library with independent modules to produce an +executable, regardless of the license terms of these independent +modules, and to copy and distribute the resulting executable under +terms of your choice, provided that you also meet, for each linked +independent module, the terms and conditions of the license of that +module. An independent module is a module which is not derived from +or based on this library. If you modify this library, you may extend +this exception to your version of the library, but you are not +obligated to do so. If you do not wish to do so, delete this +exception statement from your version. */ + +package javax.management.openmbean; + +import java.io.InvalidObjectException; +import java.io.ObjectStreamException; + +import java.math.BigDecimal; +import java.math.BigInteger; + +import java.util.Date; + +import javax.management.ObjectName; + +/** + * The open type descriptor for data values that are members + * of one of the simple types (such as an integer or a string). + * The other open types ({@link ArrayType}, {@link CompositeType}, + * {@link TabularType}) are constructed from one or more of these + * types. The simple types are formed from a small subset of + * basic Java types. As a result, the valid instances of this + * class are predefined, and no constructor is given for creating + * new instances. + * + * @author Andrew John Hughes (gnu_andrew@member.fsf.org) + * @since 1.5 + */ +public final class SimpleType + extends OpenType +{ + + /** + * The {@link SimpleType} representation of + * java.math.BigDecimal. + */ + public static final SimpleType BIGDECIMAL; + + /** + * The {@link SimpleType} representation of + * java.math.BigInteger. + */ + public static final SimpleType BIGINTEGER; + + /** + * The {@link SimpleType} representation of + * java.lang.Boolean. + */ + public static final SimpleType BOOLEAN; + + /** + * The {@link SimpleType} representation of + * java.lang.Byte. + */ + public static final SimpleType BYTE; + + /** + * The {@link SimpleType} representation of + * java.lang.Character. + */ + public static final SimpleType CHARACTER; + + /** + * The {@link SimpleType} representation of + * java.util.Date. + */ + public static final SimpleType DATE; + + /** + * The {@link SimpleType} representation of + * java.lang.Double. + */ + public static final SimpleType DOUBLE; + + /** + * The {@link SimpleType} representation of + * java.lang.Float. + */ + public static final SimpleType FLOAT; + + /** + * The {@link SimpleType} representation of + * java.lang.Integer. + */ + public static final SimpleType INTEGER; + + /** + * The {@link SimpleType} representation of + * java.lang.Long. + */ + public static final SimpleType LONG; + + /** + * The {@link SimpleType} representation of + * javax.management.ObjectName. + */ + public static final SimpleType OBJECTNAME; + + + /** + * The {@link SimpleType} representation of + * java.lang.Short. + */ + public static final SimpleType SHORT; + + /** + * The {@link SimpleType} representation of + * java.lang.String. + */ + public static final SimpleType STRING; + + /** + * The {@link SimpleType} representation of + * java.lang.Void. + */ + public static final SimpleType VOID; + + /** + * Compatible with JDK 1.5 + */ + private static final long serialVersionUID = 2215577471957694503L; + + /** + * The hash code of this instance. + */ + private transient Integer hashCode; + + /** + * The toString() result of this instance. + */ + private transient String string; + + /** + * Static construction of the {@link SimpleType} instances. + */ + static + { + try + { + BIGDECIMAL = new SimpleType("java.math.BigDecimal"); + BIGINTEGER = new SimpleType("java.math.BigInteger"); + BOOLEAN = new SimpleType("java.lang.Boolean"); + BYTE = new SimpleType("java.lang.Byte"); + CHARACTER = new SimpleType("java.lang.Character"); + DATE = new SimpleType("java.util.Date"); + DOUBLE = new SimpleType("java.lang.Double"); + FLOAT = new SimpleType("java.lang.Float"); + INTEGER = new SimpleType("java.lang.Integer"); + LONG = new SimpleType("java.lang.Long"); + OBJECTNAME = + new SimpleType("javax.management.ObjectName"); + SHORT = new SimpleType("java.lang.Short"); + STRING = new SimpleType("java.lang.String"); + VOID = new SimpleType("java.lang.Void"); + } + catch (OpenDataException e) + { + /* In normal circumstances, this shouldn't be possible. */ + throw new IllegalStateException("A invalid class name " + + "was passed to the SimpleType " + + "constructor.", e); + } + } + + /** + * Constructs a new {@link SimpleType} instance for the given + * class name. The class name is also used as the type name + * and description of the {@link OpenType} instance. + * + * @param name the name of the class this instance should + * represent. + * @throws OpenDataException if somehow the constructor of the + * superclass is passed an invalid + * class name. + */ + private SimpleType(String name) + throws OpenDataException + { + super(name, name, name); + } + + /** + *

+ * Compares this simple data type with another object + * for equality. The objects are judged to be equal if: + *

+ *
    + *
  • obj is not null.
  • + *
  • obj is an instance of + * {@link SimpleType}.
  • + *
  • The class names are equal.
  • + *
+ * + * @param obj the object to compare with. + * @return true if the conditions above hold. + */ + public boolean equals(Object obj) + { + if (!(obj instanceof SimpleType)) + return false; + SimpleType sType = (SimpleType) obj; + return sType.getClassName().equals(getClassName()); + } + + /** + *

+ * Returns the hash code of the simple data type. + * This is simply the hash code of the class name, + * which is the same element of the type compared + * as part of the + * {@link #equals(java.lang.Object)} method, thus ensuring + * that the hashcode is compatible with the equality + * test. + *

+ *

+ * As instances of this class are immutable, the hash code + * is computed just once for each instance and reused + * throughout its life. + *

+ * + * @return the hash code of this instance. + */ + public int hashCode() + { + if (hashCode == null) + hashCode = Integer.valueOf(getClassName().hashCode()); + return hashCode.intValue(); + } + + /** + * Returns true if the specified object is a member of this + * simple type. The object is judged to be so if it is + * non-null and its class name is the same as that returned + * by {@link SimpleType#getClassName()}. + * + * @param obj the object to test for membership. + * @return true if the object is a member of this type. + */ + public boolean isValue(Object obj) + { + if (obj == null) + return false; + return obj.getClass().getName().equals(getClassName()); + } + + /** + * Replaces instances of this class read from an + * {@link java.io.ObjectInputStream} with one of the predefined + * values. This ensures that each existing instance of + * this class is one of these unique instances. + * + * @return the replacement object. + * @throws ObjectStreamException if the object can not be + * resolved. + */ + public Object readResolve() + throws ObjectStreamException + { + if (equals(BIGDECIMAL)) + return BIGDECIMAL; + if (equals(BIGINTEGER)) + return BIGINTEGER; + if (equals(BOOLEAN)) + return BOOLEAN; + if (equals(BYTE)) + return BYTE; + if (equals(CHARACTER)) + return CHARACTER; + if (equals(DATE)) + return DATE; + if (equals(DOUBLE)) + return DOUBLE; + if (equals(FLOAT)) + return FLOAT; + if (equals(INTEGER)) + return INTEGER; + if (equals(LONG)) + return LONG; + if (equals(OBJECTNAME)) + return OBJECTNAME; + if (equals(SHORT)) + return SHORT; + if (equals(STRING)) + return STRING; + if (equals(VOID)) + return VOID; + throw new InvalidObjectException("Invalid simple type instance " + + "deserialized."); + } + + /** + *

+ * Returns a textual representation of this instance. This + * is constructed using the class name + * (javax.management.openmbean.SimpleType) + * and the name of the class the type represents. + *

+ *

+ * As instances of this class are immutable, the return value + * is computed just once for each instance and reused + * throughout its life. + *

+ * + * @return a @link{java.lang.String} instance representing + * the instance in textual form. + */ + public String toString() + { + if (string == null) + string = getClass().getName() + + "[name=" + getClassName() + + "]"; + return string; + } + +} -- cgit v1.2.3