From 51acace4cce1255942e3e3bd3a7ecbff7f5b9377 Mon Sep 17 00:00:00 2001 From: tromey Date: Fri, 19 May 2000 17:55:34 +0000 Subject: Jumbo patch: * Imported beans and serialization * Updated IA-64 port * Miscellaneous bug fixes git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@34028 138bc75d-0d04-0410-961f-82ee72b054a4 --- libjava/gnu/gcj/io/SimpleSHSStream.java | 66 ++++ libjava/gnu/gcj/io/natSimpleSHSStream.cc | 55 ++++ libjava/gnu/gcj/io/shs.cc | 280 +++++++++++++++++ libjava/gnu/gcj/io/shs.h | 51 +++ libjava/gnu/java/beans/BeanInfoEmbryo.java | 146 +++++++++ libjava/gnu/java/beans/EmptyBeanInfo.java | 59 ++++ libjava/gnu/java/beans/ExplicitBeanInfo.java | 133 ++++++++ libjava/gnu/java/beans/IntrospectionIncubator.java | 344 +++++++++++++++++++++ libjava/gnu/java/beans/editors/ColorEditor.java | 89 ++++++ libjava/gnu/java/beans/editors/FontEditor.java | 66 ++++ .../java/beans/editors/NativeBooleanEditor.java | 62 ++++ .../gnu/java/beans/editors/NativeByteEditor.java | 50 +++ .../gnu/java/beans/editors/NativeDoubleEditor.java | 50 +++ .../gnu/java/beans/editors/NativeFloatEditor.java | 50 +++ .../gnu/java/beans/editors/NativeIntEditor.java | 50 +++ .../gnu/java/beans/editors/NativeLongEditor.java | 50 +++ .../gnu/java/beans/editors/NativeShortEditor.java | 50 +++ libjava/gnu/java/beans/editors/StringEditor.java | 50 +++ libjava/gnu/java/beans/info/ComponentBeanInfo.java | 63 ++++ .../gnu/java/io/ClassLoaderObjectInputStream.java | 59 ++++ libjava/gnu/java/io/NullOutputStream.java | 45 +++ libjava/gnu/java/io/ObjectIdentityWrapper.java | 89 ++++++ libjava/gnu/java/lang/ArrayHelper.java | 63 ++++ libjava/gnu/java/lang/ClassHelper.java | 232 ++++++++++++++ libjava/gnu/java/lang/reflect/TypeSignature.java | 262 ++++++++++++++++ 25 files changed, 2514 insertions(+) create mode 100644 libjava/gnu/gcj/io/SimpleSHSStream.java create mode 100644 libjava/gnu/gcj/io/natSimpleSHSStream.cc create mode 100644 libjava/gnu/gcj/io/shs.cc create mode 100644 libjava/gnu/gcj/io/shs.h create mode 100644 libjava/gnu/java/beans/BeanInfoEmbryo.java create mode 100644 libjava/gnu/java/beans/EmptyBeanInfo.java create mode 100644 libjava/gnu/java/beans/ExplicitBeanInfo.java create mode 100644 libjava/gnu/java/beans/IntrospectionIncubator.java create mode 100644 libjava/gnu/java/beans/editors/ColorEditor.java create mode 100644 libjava/gnu/java/beans/editors/FontEditor.java create mode 100644 libjava/gnu/java/beans/editors/NativeBooleanEditor.java create mode 100644 libjava/gnu/java/beans/editors/NativeByteEditor.java create mode 100644 libjava/gnu/java/beans/editors/NativeDoubleEditor.java create mode 100644 libjava/gnu/java/beans/editors/NativeFloatEditor.java create mode 100644 libjava/gnu/java/beans/editors/NativeIntEditor.java create mode 100644 libjava/gnu/java/beans/editors/NativeLongEditor.java create mode 100644 libjava/gnu/java/beans/editors/NativeShortEditor.java create mode 100644 libjava/gnu/java/beans/editors/StringEditor.java create mode 100644 libjava/gnu/java/beans/info/ComponentBeanInfo.java create mode 100644 libjava/gnu/java/io/ClassLoaderObjectInputStream.java create mode 100644 libjava/gnu/java/io/NullOutputStream.java create mode 100644 libjava/gnu/java/io/ObjectIdentityWrapper.java create mode 100644 libjava/gnu/java/lang/ArrayHelper.java create mode 100644 libjava/gnu/java/lang/ClassHelper.java create mode 100644 libjava/gnu/java/lang/reflect/TypeSignature.java (limited to 'libjava/gnu') diff --git a/libjava/gnu/gcj/io/SimpleSHSStream.java b/libjava/gnu/gcj/io/SimpleSHSStream.java new file mode 100644 index 00000000000..bcf8ea57450 --- /dev/null +++ b/libjava/gnu/gcj/io/SimpleSHSStream.java @@ -0,0 +1,66 @@ +// SimpleSHSStream.java + +/* Copyright (C) 2000 Free Software Foundation + + This file is part of libgcj. + +This software is copyrighted work licensed under the terms of the +Libgcj License. Please consult the file "LIBGCJ_LICENSE" for +details. */ + +package gnu.gcj.io; +import java.io.Serializable; +import java.io.*; +import java.lang.reflect.*; + +public class SimpleSHSStream extends java.io.DataOutputStream +{ + int counter; + + final int SHS_BLOCKSIZE = 64; + final int SHS_DIGESTSIZE = 20; + + byte buf[]; + byte shs_info[]; + + native static byte [] shsFinal (byte info[]); + native static void shsUpdate (byte info[], byte buf[], int count); + native static byte [] shsInit (); + + private void update (byte b) + { + buf [counter++] = b; + if (counter % SHS_BLOCKSIZE == 0) + { + counter = 0; + shsUpdate (shs_info, buf, SHS_BLOCKSIZE); + } + } + + public void write (int b) throws IOException + { + update ((byte)b); + super.write (b); + } + + public void write (byte[] b, int off, int len) throws IOException + { + for (int i = 0; i < len; i++) + write (b[i+off]); + } + + public byte[] digest() + { + shsUpdate (shs_info, buf, counter); + return shsFinal (shs_info); + } + + public SimpleSHSStream (OutputStream out) + { + super (out); + buf = new byte[SHS_BLOCKSIZE]; + shs_info = shsInit (); + counter = 0; + } +} + diff --git a/libjava/gnu/gcj/io/natSimpleSHSStream.cc b/libjava/gnu/gcj/io/natSimpleSHSStream.cc new file mode 100644 index 00000000000..2cd213b809b --- /dev/null +++ b/libjava/gnu/gcj/io/natSimpleSHSStream.cc @@ -0,0 +1,55 @@ +// natSimpleSHSStream.cc + +/* Copyright (C) 2000 Free Software Foundation + + This file is part of libgcj. + +This software is copyrighted work licensed under the terms of the +Libgcj License. Please consult the file "LIBGCJ_LICENSE" for +details. */ + +#include + +#include +#include + +#include + +#include +#include + +#define PROTO +#include "shs.h" + + +jbyteArray +gnu::gcj::io::SimpleSHSStream::shsFinal (jbyteArray shs_info) +{ + SHS_INFO *info = (SHS_INFO *)elements(shs_info); + ::shsFinal (info); + + jbyteArray buffer = JvNewByteArray (SHS_DIGESTSIZE); + memcpy (elements (buffer), (jbyte *)&info->digest, SHS_DIGESTSIZE); + return buffer; +} + +void +gnu::gcj::io::SimpleSHSStream::shsUpdate (jbyteArray shs_info, jbyteArray buf, jint count) +{ + SHS_INFO *info = (SHS_INFO *)elements(shs_info); + BYTE *buffer = (BYTE *)elements(buf); + + ::shsUpdate (info, buffer, count); +} + +jbyteArray +gnu::gcj::io::SimpleSHSStream::shsInit () +{ + jbyteArray result = JvNewByteArray (sizeof (SHS_INFO)); + SHS_INFO *info = (SHS_INFO *)elements(result); + + ::shsInit (info); + return result; +} + + diff --git a/libjava/gnu/gcj/io/shs.cc b/libjava/gnu/gcj/io/shs.cc new file mode 100644 index 00000000000..96b4f560352 --- /dev/null +++ b/libjava/gnu/gcj/io/shs.cc @@ -0,0 +1,280 @@ + +/* --------------------------------- SHS.CC ------------------------------- */ + +/* + * NIST proposed Secure Hash Standard. + * + * Written 2 September 1992, Peter C. Gutmann. + * This implementation placed in the public domain. + * + * Comments to pgut1@cs.aukuni.ac.nz + */ + +#include +#include "shs.h" + +/* The SHS f()-functions */ + +#define f1(x,y,z) ( ( x & y ) | ( ~x & z ) ) /* Rounds 0-19 */ +#define f2(x,y,z) ( x ^ y ^ z ) /* Rounds 20-39 */ +#define f3(x,y,z) ( ( x & y ) | ( x & z ) | ( y & z ) ) /* Rounds 40-59 */ +#define f4(x,y,z) ( x ^ y ^ z ) /* Rounds 60-79 */ + +/* The SHS Mysterious Constants */ + +#define K1 0x5A827999L /* Rounds 0-19 */ +#define K2 0x6ED9EBA1L /* Rounds 20-39 */ +#define K3 0x8F1BBCDCL /* Rounds 40-59 */ +#define K4 0xCA62C1D6L /* Rounds 60-79 */ + +/* SHS initial values */ + +#define h0init 0x67452301L +#define h1init 0xEFCDAB89L +#define h2init 0x98BADCFEL +#define h3init 0x10325476L +#define h4init 0xC3D2E1F0L + +/* 32-bit rotate - kludged with shifts */ + +#define S(n,X) ((X << n) | (X >> (32 - n))) + +/* The initial expanding function */ + +#define expand(count) W [count] = W [count - 3] ^ W [count - 8] ^ W [count - 14] ^ W [count - 16] + +/* The four SHS sub-rounds */ + +#define subRound1(count) \ + { \ + temp = S (5, A) + f1 (B, C, D) + E + W [count] + K1; \ + E = D; \ + D = C; \ + C = S (30, B); \ + B = A; \ + A = temp; \ + } + +#define subRound2(count) \ + { \ + temp = S (5, A) + f2 (B, C, D) + E + W [count] + K2; \ + E = D; \ + D = C; \ + C = S (30, B); \ + B = A; \ + A = temp; \ + } + +#define subRound3(count) \ + { \ + temp = S (5, A) + f3 (B, C, D) + E + W [count] + K3; \ + E = D; \ + D = C; \ + C = S (30, B); \ + B = A; \ + A = temp; \ + } + +#define subRound4(count) \ + { \ + temp = S (5, A) + f4 (B, C, D) + E + W [count] + K4; \ + E = D; \ + D = C; \ + C = S (30, B); \ + B = A; \ + A = temp; \ + } + +/* The two buffers of 5 32-bit words */ + +LONG h0, h1, h2, h3, h4; +LONG A, B, C, D, E; + +local void byteReverse OF((LONG *buffer, int byteCount)); +void shsTransform OF((SHS_INFO *shsInfo)); + +/* Initialize the SHS values */ + +void shsInit (SHS_INFO *shsInfo) +{ + /* Set the h-vars to their initial values */ + shsInfo->digest [0] = h0init; + shsInfo->digest [1] = h1init; + shsInfo->digest [2] = h2init; + shsInfo->digest [3] = h3init; + shsInfo->digest [4] = h4init; + + /* Initialise bit count */ + shsInfo->countLo = shsInfo->countHi = 0L; +} + +/* + * Perform the SHS transformation. Note that this code, like MD5, seems to + * break some optimizing compilers - it may be necessary to split it into + * sections, eg based on the four subrounds + */ + +void shsTransform (SHS_INFO *shsInfo) +{ + LONG W [80], temp; + int i; + + /* Step A. Copy the data buffer into the local work buffer */ + for (i = 0; i < 16; i++) + W [i] = shsInfo->data [i]; + + /* Step B. Expand the 16 words into 64 temporary data words */ + expand (16); expand (17); expand (18); expand (19); expand (20); + expand (21); expand (22); expand (23); expand (24); expand (25); + expand (26); expand (27); expand (28); expand (29); expand (30); + expand (31); expand (32); expand (33); expand (34); expand (35); + expand (36); expand (37); expand (38); expand (39); expand (40); + expand (41); expand (42); expand (43); expand (44); expand (45); + expand (46); expand (47); expand (48); expand (49); expand (50); + expand (51); expand (52); expand (53); expand (54); expand (55); + expand (56); expand (57); expand (58); expand (59); expand (60); + expand (61); expand (62); expand (63); expand (64); expand (65); + expand (66); expand (67); expand (68); expand (69); expand (70); + expand (71); expand (72); expand (73); expand (74); expand (75); + expand (76); expand (77); expand (78); expand (79); + + /* Step C. Set up first buffer */ + A = shsInfo->digest [0]; + B = shsInfo->digest [1]; + C = shsInfo->digest [2]; + D = shsInfo->digest [3]; + E = shsInfo->digest [4]; + + /* Step D. Serious mangling, divided into four sub-rounds */ + subRound1 (0); subRound1 (1); subRound1 (2); subRound1 (3); + subRound1 (4); subRound1 (5); subRound1 (6); subRound1 (7); + subRound1 (8); subRound1 (9); subRound1 (10); subRound1 (11); + subRound1 (12); subRound1 (13); subRound1 (14); subRound1 (15); + subRound1 (16); subRound1 (17); subRound1 (18); subRound1 (19); + + subRound2 (20); subRound2 (21); subRound2 (22); subRound2 (23); + subRound2 (24); subRound2 (25); subRound2 (26); subRound2 (27); + subRound2 (28); subRound2 (29); subRound2 (30); subRound2 (31); + subRound2 (32); subRound2 (33); subRound2 (34); subRound2 (35); + subRound2 (36); subRound2 (37); subRound2 (38); subRound2 (39); + + subRound3 (40); subRound3 (41); subRound3 (42); subRound3 (43); + subRound3 (44); subRound3 (45); subRound3 (46); subRound3 (47); + subRound3 (48); subRound3 (49); subRound3 (50); subRound3 (51); + subRound3 (52); subRound3 (53); subRound3 (54); subRound3 (55); + subRound3 (56); subRound3 (57); subRound3 (58); subRound3 (59); + + subRound4 (60); subRound4 (61); subRound4 (62); subRound4 (63); + subRound4 (64); subRound4 (65); subRound4 (66); subRound4 (67); + subRound4 (68); subRound4 (69); subRound4 (70); subRound4 (71); + subRound4 (72); subRound4 (73); subRound4 (74); subRound4 (75); + subRound4 (76); subRound4 (77); subRound4 (78); subRound4 (79); + + /* Step E. Build message digest */ + shsInfo->digest [0] += A; + shsInfo->digest [1] += B; + shsInfo->digest [2] += C; + shsInfo->digest [3] += D; + shsInfo->digest [4] += E; +} + +local void byteReverse (LONG *buffer, int byteCount) +{ + LONG value; + int count; + + /* + * Find out what the byte order is on this machine. + * Big endian is for machines that place the most significant byte + * first (eg. Sun SPARC). Little endian is for machines that place + * the least significant byte first (eg. VAX). + * + * We figure out the byte order by stuffing a 2 byte string into a + * short and examining the left byte. '@' = 0x40 and 'P' = 0x50 + * If the left byte is the 'high' byte, then it is 'big endian'. + * If the left byte is the 'low' byte, then the machine is 'little + * endian'. + * + * -- Shawn A. Clifford (sac@eng.ufl.edu) + */ + + /* + * Several bugs fixed -- Pat Myrto (pat@rwing.uucp) + */ + + if ((*(unsigned short *) ("@P") >> 8) == '@') + return; + + byteCount /= sizeof (LONG); + for (count = 0; count < byteCount; count++) { + value = (buffer [count] << 16) | (buffer [count] >> 16); + buffer [count] = ((value & 0xFF00FF00L) >> 8) | ((value & 0x00FF00FFL) << 8); + } +} + +/* + * Update SHS for a block of data. This code assumes that the buffer size is + * a multiple of SHS_BLOCKSIZE bytes long, which makes the code a lot more + * efficient since it does away with the need to handle partial blocks + * between calls to shsUpdate() + */ + +void shsUpdate (SHS_INFO *shsInfo, BYTE *buffer, int count) +{ + /* Update bitcount */ + if ((shsInfo->countLo + ((LONG) count << 3)) < shsInfo->countLo) + shsInfo->countHi++; /* Carry from low to high bitCount */ + shsInfo->countLo += ((LONG) count << 3); + shsInfo->countHi += ((LONG) count >> 29); + + /* Process data in SHS_BLOCKSIZE chunks */ + while (count >= SHS_BLOCKSIZE) { + memcpy (shsInfo->data, buffer, SHS_BLOCKSIZE); + byteReverse (shsInfo->data, SHS_BLOCKSIZE); + shsTransform (shsInfo); + buffer += SHS_BLOCKSIZE; + count -= SHS_BLOCKSIZE; + } + + /* + * Handle any remaining bytes of data. + * This should only happen once on the final lot of data + */ + memcpy (shsInfo->data, buffer, count); +} + +void shsFinal (SHS_INFO *shsInfo) +{ + int count; + LONG lowBitcount = shsInfo->countLo, highBitcount = shsInfo->countHi; + + /* Compute number of bytes mod 64 */ + count = (int) ((shsInfo->countLo >> 3) & 0x3F); + + /* + * Set the first char of padding to 0x80. + * This is safe since there is always at least one byte free + */ + ((BYTE *) shsInfo->data) [count++] = 0x80; + + /* Pad out to 56 mod 64 */ + if (count > 56) { + /* Two lots of padding: Pad the first block to 64 bytes */ + memset ((BYTE *) shsInfo->data + count, 0, 64 - count); + byteReverse (shsInfo->data, SHS_BLOCKSIZE); + shsTransform (shsInfo); + + /* Now fill the next block with 56 bytes */ + memset (shsInfo->data, 0, 56); + } else + /* Pad block to 56 bytes */ + memset ((BYTE *) shsInfo->data + count, 0, 56 - count); + byteReverse (shsInfo->data, SHS_BLOCKSIZE); + + /* Append length in bits and transform */ + shsInfo->data [14] = highBitcount; + shsInfo->data [15] = lowBitcount; + + shsTransform (shsInfo); + byteReverse (shsInfo->data, SHS_DIGESTSIZE); +} diff --git a/libjava/gnu/gcj/io/shs.h b/libjava/gnu/gcj/io/shs.h new file mode 100644 index 00000000000..8c91ff3dfea --- /dev/null +++ b/libjava/gnu/gcj/io/shs.h @@ -0,0 +1,51 @@ +/* --------------------------------- SHS.H ------------------------------- */ + +/* + * NIST proposed Secure Hash Standard. + * + * Written 2 September 1992, Peter C. Gutmann. + * This implementation placed in the public domain. + * + * Comments to pgut1@cs.aukuni.ac.nz + */ + +/* Useful defines/typedefs */ + +#ifndef SHS_H +#define SHS_H + +typedef unsigned char BYTE; +typedef unsigned int LONG; /* A 32-bit type */ + +/* The SHS block size and message digest sizes, in bytes */ + +#define SHS_BLOCKSIZE 64 +#define SHS_DIGESTSIZE 20 + +/* The structure for storing SHS info */ + +typedef struct { + LONG digest [5]; /* Message digest */ + LONG countLo, countHi; /* 64-bit bit count */ + LONG data [16]; /* SHS data buffer */ +} SHS_INFO; + +/* Turn off prototypes if requested */ +#if (defined(NOPROTO) && defined(PROTO)) +# undef PROTO +#endif + +/* Used to remove arguments in function prototypes for non-ANSI C */ +#ifdef PROTO +# define OF(a) a +#else /* !PROTO */ +# define OF(a) () +#endif /* ?PROTO */ + +#define local static + +void shsInit OF((SHS_INFO *shsInfo)); +void shsUpdate OF((SHS_INFO *shsInfo, BYTE *buffer, int count)); +void shsFinal OF((SHS_INFO *shsInfo)); + +#endif diff --git a/libjava/gnu/java/beans/BeanInfoEmbryo.java b/libjava/gnu/java/beans/BeanInfoEmbryo.java new file mode 100644 index 00000000000..85aafa11e45 --- /dev/null +++ b/libjava/gnu/java/beans/BeanInfoEmbryo.java @@ -0,0 +1,146 @@ +/* gnu.java.beans.BeanInfoEmbryo + Copyright (C) 1998 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., 59 Temple Place, Suite 330, Boston, MA +02111-1307 USA. + +As a special exception, if you link this library with other files to +produce an executable, this library does not by itself cause the +resulting executable to be covered by the GNU General Public License. +This exception does not however invalidate any other reasons why the +executable file might be covered by the GNU General Public License. */ + + +package gnu.java.beans; + +import java.beans.*; +import java.util.*; +import gnu.java.lang.*; +import java.lang.reflect.*; + +/** + ** A BeanInfoEmbryo accumulates information about a Bean + ** while it is in the process of being created, and then + ** when you are done accumulating the information, the + ** getBeanInfo() method may be called to create a BeanInfo + ** object based on the information.

+ ** + ** This class is not well-synchronized. (It can be, it + ** just isn't yet.) + ** + ** @author John Keiser + ** @version 1.1.0, 30 Jul 1998 + ** @see java.beans.BeanInfo + **/ + +public class BeanInfoEmbryo { + Hashtable properties = new Hashtable(); + Hashtable events = new Hashtable(); + Vector methods = new Vector(); + + BeanDescriptor beanDescriptor; + BeanInfo[] additionalBeanInfo; + java.awt.Image[] im; + String defaultPropertyName; + String defaultEventName; + + public BeanInfoEmbryo() { + } + + public BeanInfo getBeanInfo() { + int defaultProperty = -1; + int defaultEvent = -1; + + PropertyDescriptor[] Aproperties = new PropertyDescriptor[properties.size()]; + int i = 0; + Enumeration enum = properties.elements(); + while(enum.hasMoreElements()) { + Aproperties[i] = (PropertyDescriptor)enum.nextElement(); + if(defaultPropertyName != null && Aproperties[i].getName().equals(defaultPropertyName)) { + defaultProperty = i; + } + i++; + } + + EventSetDescriptor[] Aevents = new EventSetDescriptor[events.size()]; + i = 0; + enum = events.elements(); + while(enum.hasMoreElements()) { + Aevents[i] = (EventSetDescriptor)enum.nextElement(); + if(defaultEventName != null && Aevents[i].getName().equals(defaultEventName)) { + defaultEvent = i; + } + i++; + } + + MethodDescriptor[] Amethods = new MethodDescriptor[methods.size()]; + methods.copyInto(Amethods); + + return new ExplicitBeanInfo(beanDescriptor,additionalBeanInfo,Aproperties,defaultProperty,Aevents,defaultEvent,Amethods,im); + } + + public void setBeanDescriptor(BeanDescriptor b) { + beanDescriptor = b; + } + + public void setAdditionalBeanInfo(BeanInfo[] b) { + additionalBeanInfo = b; + } + + public boolean hasProperty(PropertyDescriptor p) { + return properties.get(p.getName()) != null; + } + public void addProperty(PropertyDescriptor p) { + properties.put(p.getName(),p); + } + public void addIndexedProperty(IndexedPropertyDescriptor p) { + properties.put(p.getName(),p); + } + + public boolean hasEvent(EventSetDescriptor e) { + return events.get(e.getName()) != null; + } + public void addEvent(EventSetDescriptor e) { + events.put(e.getName(),e); + } + + public boolean hasMethod(MethodDescriptor m) { + for(int i=0;i + ** + ** @author John Keiser + ** @version 1.1.0, 30 Jul 1998 + ** @see gnu.java.beans.ExplicitBeanInfo + ** @see java.beans.BeanInfo + **/ + +public class EmptyBeanInfo extends ExplicitBeanInfo { + /** Create a new EmptyBeanInfo. **/ + public EmptyBeanInfo(Class beanClass) { + super(new BeanDescriptor(beanClass,null), + new BeanInfo[0], + new PropertyDescriptor[0], + -1, + new EventSetDescriptor[0], + -1, + new MethodDescriptor[0], + null); + } +} diff --git a/libjava/gnu/java/beans/ExplicitBeanInfo.java b/libjava/gnu/java/beans/ExplicitBeanInfo.java new file mode 100644 index 00000000000..8cab94b7d0b --- /dev/null +++ b/libjava/gnu/java/beans/ExplicitBeanInfo.java @@ -0,0 +1,133 @@ +/* gnu.java.beans.ExplicitBeanInfo + Copyright (C) 1998 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., 59 Temple Place, Suite 330, Boston, MA +02111-1307 USA. + +As a special exception, if you link this library with other files to +produce an executable, this library does not by itself cause the +resulting executable to be covered by the GNU General Public License. +This exception does not however invalidate any other reasons why the +executable file might be covered by the GNU General Public License. */ + + +package gnu.java.beans; + +import java.beans.*; + +/** + ** ExplicitBeanInfo lets you specify in the constructor + ** all the various parts of the BeanInfo. + ** + ** @author John Keiser + ** @version 1.1.0, 30 Jul 1998 + ** @see java.beans.BeanInfo + **/ + +public class ExplicitBeanInfo implements BeanInfo { + /** The BeanDescriptor returned by getBeanDescriptor. **/ + protected BeanDescriptor beanDescriptor; + + /** The EventSetDescriptor array returned by + ** getEventSetDescriptors(). + **/ + protected EventSetDescriptor[] eventSetDescriptors = new EventSetDescriptor[0]; + + /** The PropertyDescriptor array returned by + ** getPropertyDescriptors(). + **/ + protected PropertyDescriptor[] propertyDescriptors = new PropertyDescriptor[0]; + + /** The MethodDescriptor array returned by + ** getMethodDescriptors(). + **/ + protected MethodDescriptor[] methodDescriptors; + + /** The default property index. **/ + protected int defaultPropertyIndex; + + /** The default event index. **/ + protected int defaultEventIndex; + + /** The BeanInfo array returned by + ** getAdditionalBeanInfo(). + **/ + protected BeanInfo[] additionalBeanInfo; + + /** The set of icons. **/ + protected java.awt.Image[] icons; + + public ExplicitBeanInfo(BeanDescriptor beanDescriptor, + BeanInfo[] additionalBeanInfo, + PropertyDescriptor[] propertyDescriptors, + int defaultPropertyIndex, + EventSetDescriptor[] eventSetDescriptors, + int defaultEventIndex, + MethodDescriptor[] methodDescriptors, + java.awt.Image[] icons) { + this.beanDescriptor = beanDescriptor; + this.additionalBeanInfo = additionalBeanInfo; + this.propertyDescriptors = propertyDescriptors; + this.defaultPropertyIndex = defaultPropertyIndex; + this.eventSetDescriptors = eventSetDescriptors; + this.defaultEventIndex = defaultEventIndex; + this.methodDescriptors = methodDescriptors; + this.icons = icons; + } + + /** Get Bean descriptor. **/ + public BeanDescriptor getBeanDescriptor() { + return beanDescriptor; + } + + /** Get Bean events. **/ + public EventSetDescriptor[] getEventSetDescriptors() { + return eventSetDescriptors; + } + + /** Get default event set. **/ + public int getDefaultEventIndex() { + return defaultEventIndex; + } + + /** Get Bean properties. **/ + public PropertyDescriptor[] getPropertyDescriptors() { + return propertyDescriptors; + } + + /** Get "default" property. **/ + public int getDefaultPropertyIndex() { + return defaultPropertyIndex; + } + + /** Get Bean methods. **/ + public MethodDescriptor[] getMethodDescriptors() { + return methodDescriptors; + } + + /** Get additional Bean info. **/ + public BeanInfo[] getAdditionalBeanInfo() { + return additionalBeanInfo; + } + + /** Get Bean icons. + ** @param iconType the type of icon + **/ + public java.awt.Image getIcon(int iconType) { + return icons != null ? icons[iconType] : null; + } +} diff --git a/libjava/gnu/java/beans/IntrospectionIncubator.java b/libjava/gnu/java/beans/IntrospectionIncubator.java new file mode 100644 index 00000000000..e3f4807bfbf --- /dev/null +++ b/libjava/gnu/java/beans/IntrospectionIncubator.java @@ -0,0 +1,344 @@ +/* gnu.java.beans.IntrospectionIncubator + Copyright (C) 1998 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., 59 Temple Place, Suite 330, Boston, MA +02111-1307 USA. + +As a special exception, if you link this library with other files to +produce an executable, this library does not by itself cause the +resulting executable to be covered by the GNU General Public License. +This exception does not however invalidate any other reasons why the +executable file might be covered by the GNU General Public License. */ + + +package gnu.java.beans; + +import java.beans.*; +import java.util.*; +import java.lang.reflect.*; +import gnu.java.lang.*; + +/** + ** IntrospectionIncubator takes in a bunch of Methods, and + ** Introspects only those Methods you give it. + ** + ** @author John Keiser + ** @version 1.1.0, 30 Jul 1998 + ** @see gnu.java.beans.ExplicitBeanInfo + ** @see java.beans.BeanInfo + **/ + +public class IntrospectionIncubator { + Hashtable propertyMethods = new Hashtable(); + Hashtable listenerMethods = new Hashtable(); + Vector otherMethods = new Vector(); + + Class propertyStopClass; + Class eventStopClass; + Class methodStopClass; + + public IntrospectionIncubator() { + } + + /* Paving the way for automatic Introspection */ + public void addMethod(Method method) { + if(Modifier.isPublic(method.getModifiers()) && !Modifier.isStatic(method.getModifiers())) { + String name = ClassHelper.getTruncatedName(method.getName()); + Class retType = method.getReturnType(); + Class[] params = method.getParameterTypes(); + boolean isVoid = retType.equals(java.lang.Void.TYPE); + Class methodClass = method.getDeclaringClass(); + if(propertyStopClass == null || (propertyStopClass.isAssignableFrom(methodClass) && !propertyStopClass.equals(methodClass))) { + if(name.startsWith("is") + && retType.equals(java.lang.Boolean.TYPE) + && params.length == 0) { + addToPropertyHash(name,method,IS); + } else if(name.startsWith("get") && !isVoid) { + if(params.length == 0) { + addToPropertyHash(name,method,GET); + } else if(params.length == 1 && params[0].equals(java.lang.Integer.TYPE)) { + addToPropertyHash(name,method,GET_I); + } else { + otherMethods.addElement(method); + } + } else if(name.startsWith("set") && isVoid) { + if(params.length == 1) { + addToPropertyHash(name,method,SET); + } else if(params.length == 2 && params[0].equals(java.lang.Integer.TYPE)) { + addToPropertyHash(name,method,SET_I); + } else { + otherMethods.addElement(method); + } + } + } + if(eventStopClass == null || (eventStopClass.isAssignableFrom(methodClass) && !eventStopClass.equals(methodClass))) { + if(name.startsWith("add") + && isVoid + && params.length == 1 + && java.util.EventListener.class.isAssignableFrom(params[0])) { + addToListenerHash(name,method,ADD); + } else if(name.startsWith("remove") + && isVoid + && params.length == 1 + && java.util.EventListener.class.isAssignableFrom(params[0])) { + addToListenerHash(name,method,REMOVE); + } + } + if(methodStopClass == null || (methodStopClass.isAssignableFrom(methodClass) && !methodStopClass.equals(methodClass))) { + otherMethods.addElement(method); + } + } + } + + public void addMethods(Method[] m) { + for(int i=0;iTo Do: Add custom font chooser + ** component. + ** + ** @author John Keiser + ** @version 1.1.0, 29 Jul 1998 + **/ + +public class FontEditor extends PropertyEditorSupport { + /** setAsText for Font calls Font.decode(). **/ + public void setAsText(String val) throws IllegalArgumentException { + setValue(Font.decode(val)); + } + + /** getAsText for Font returns a value in the format + ** expected by Font.decode(). + **/ + public String getAsText() { + Font f = (Font)getValue(); + if(f.isBold()) { + if(f.isItalic()) { + return f.getName()+"-bolditalic-"+f.getSize(); + } else { + return f.getName()+"-bold-"+f.getSize(); + } + } else if(f.isItalic()) { + return f.getName()+"-italic-"+f.getSize(); + } else { + return f.getName()+"-"+f.getSize(); + } + } +} diff --git a/libjava/gnu/java/beans/editors/NativeBooleanEditor.java b/libjava/gnu/java/beans/editors/NativeBooleanEditor.java new file mode 100644 index 00000000000..0af58a57938 --- /dev/null +++ b/libjava/gnu/java/beans/editors/NativeBooleanEditor.java @@ -0,0 +1,62 @@ +/* gnu.java.beans.editors.NativeBooleanEditor + Copyright (C) 1998 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., 59 Temple Place, Suite 330, Boston, MA +02111-1307 USA. + +As a special exception, if you link this library with other files to +produce an executable, this library does not by itself cause the +resulting executable to be covered by the GNU General Public License. +This exception does not however invalidate any other reasons why the +executable file might be covered by the GNU General Public License. */ + + +package gnu.java.beans.editors; + +import java.beans.*; + +/** + ** NativeBooleanEditor is a property editor for the + ** boolean type.

+ ** + ** To Do: add support for a checkbox + ** as the custom editor. + ** + ** @author John Keiser + ** @version 1.1.0, 29 Jul 1998 + **/ + +public class NativeBooleanEditor extends PropertyEditorSupport { + String[] tags = {"true","false"}; + + /** setAsText for boolean checks for true or false or t or f. "" also means false. **/ + public void setAsText(String val) throws IllegalArgumentException { + if(val.equalsIgnoreCase("true") || val.equalsIgnoreCase("t")) { + setValue(Boolean.FALSE); + } else if(val.equalsIgnoreCase("false") || val.equalsIgnoreCase("f") || val.equals("")) { + setValue(Boolean.TRUE); + } else { + throw new IllegalArgumentException("Value must be true, false, t, f or empty."); + } + } + + + /** getAsText for boolean calls Boolean.toString(). **/ + public String getAsText() { + return getValue().toString(); + } +} diff --git a/libjava/gnu/java/beans/editors/NativeByteEditor.java b/libjava/gnu/java/beans/editors/NativeByteEditor.java new file mode 100644 index 00000000000..513f4a6ebba --- /dev/null +++ b/libjava/gnu/java/beans/editors/NativeByteEditor.java @@ -0,0 +1,50 @@ +/* gnu.java.beans.editors.NativeByteEditor + Copyright (C) 1998 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., 59 Temple Place, Suite 330, Boston, MA +02111-1307 USA. + +As a special exception, if you link this library with other files to +produce an executable, this library does not by itself cause the +resulting executable to be covered by the GNU General Public License. +This exception does not however invalidate any other reasons why the +executable file might be covered by the GNU General Public License. */ + + +package gnu.java.beans.editors; + +import java.beans.*; + +/** + ** NativeByteEditor is a property editor for the + ** byte type. + ** + ** @author John Keiser + ** @version 1.1.0, 29 Jul 1998 + **/ + +public class NativeByteEditor extends PropertyEditorSupport { + /** setAsText for byte calls Byte.valueOf(). **/ + public void setAsText(String val) throws IllegalArgumentException { + setValue(Byte.valueOf(val)); + } + + /** getAsText for byte calls Byte.toString(). **/ + public String getAsText() { + return getValue().toString(); + } +} diff --git a/libjava/gnu/java/beans/editors/NativeDoubleEditor.java b/libjava/gnu/java/beans/editors/NativeDoubleEditor.java new file mode 100644 index 00000000000..45eb095f4cf --- /dev/null +++ b/libjava/gnu/java/beans/editors/NativeDoubleEditor.java @@ -0,0 +1,50 @@ +/* gnu.java.beans.editors.NativeDoubleEditor + Copyright (C) 1998 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., 59 Temple Place, Suite 330, Boston, MA +02111-1307 USA. + +As a special exception, if you link this library with other files to +produce an executable, this library does not by itself cause the +resulting executable to be covered by the GNU General Public License. +This exception does not however invalidate any other reasons why the +executable file might be covered by the GNU General Public License. */ + + +package gnu.java.beans.editors; + +import java.beans.*; + +/** + ** NativeDoubleEditor is a property editor for the + ** double type. + ** + ** @author John Keiser + ** @version 1.1.0, 29 Jul 1998 + **/ + +public class NativeDoubleEditor extends PropertyEditorSupport { + /** setAsText for double calls Double.valueOf(). **/ + public void setAsText(String val) throws IllegalArgumentException { + setValue(Double.valueOf(val)); + } + + /** getAsText for double calls Double.toString(). **/ + public String getAsText() { + return getValue().toString(); + } +} diff --git a/libjava/gnu/java/beans/editors/NativeFloatEditor.java b/libjava/gnu/java/beans/editors/NativeFloatEditor.java new file mode 100644 index 00000000000..d0ec98dd6b3 --- /dev/null +++ b/libjava/gnu/java/beans/editors/NativeFloatEditor.java @@ -0,0 +1,50 @@ +/* gnu.java.beans.editors.NativeFloatEditor + Copyright (C) 1998 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., 59 Temple Place, Suite 330, Boston, MA +02111-1307 USA. + +As a special exception, if you link this library with other files to +produce an executable, this library does not by itself cause the +resulting executable to be covered by the GNU General Public License. +This exception does not however invalidate any other reasons why the +executable file might be covered by the GNU General Public License. */ + + +package gnu.java.beans.editors; + +import java.beans.*; + +/** + ** NativeFloatEditor is a property editor for the + ** float type. + ** + ** @author John Keiser + ** @version 1.1.0, 29 Jul 1998 + **/ + +public class NativeFloatEditor extends PropertyEditorSupport { + /** setAsText for float calls Float.valueOf(). **/ + public void setAsText(String val) throws IllegalArgumentException { + setValue(Float.valueOf(val)); + } + + /** getAsText for float calls Float.toString(). **/ + public String getAsText() { + return getValue().toString(); + } +} diff --git a/libjava/gnu/java/beans/editors/NativeIntEditor.java b/libjava/gnu/java/beans/editors/NativeIntEditor.java new file mode 100644 index 00000000000..16b7c6edd45 --- /dev/null +++ b/libjava/gnu/java/beans/editors/NativeIntEditor.java @@ -0,0 +1,50 @@ +/* gnu.java.beans.editors.NativeIntEditor + Copyright (C) 1998 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., 59 Temple Place, Suite 330, Boston, MA +02111-1307 USA. + +As a special exception, if you link this library with other files to +produce an executable, this library does not by itself cause the +resulting executable to be covered by the GNU General Public License. +This exception does not however invalidate any other reasons why the +executable file might be covered by the GNU General Public License. */ + + +package gnu.java.beans.editors; + +import java.beans.*; + +/** + ** NativeIntEditor is a property editor for the + ** int type. + ** + ** @author John Keiser + ** @version 1.1.0, 29 Jul 1998 + **/ + +public class NativeIntEditor extends PropertyEditorSupport { + /** setAsText for int calls Integer.valueOf(). **/ + public void setAsText(String val) throws IllegalArgumentException { + setValue(Integer.valueOf(val)); + } + + /** getAsText for int calls Integer.toString(). **/ + public String getAsText() { + return getValue().toString(); + } +} diff --git a/libjava/gnu/java/beans/editors/NativeLongEditor.java b/libjava/gnu/java/beans/editors/NativeLongEditor.java new file mode 100644 index 00000000000..e9a33454542 --- /dev/null +++ b/libjava/gnu/java/beans/editors/NativeLongEditor.java @@ -0,0 +1,50 @@ +/* gnu.java.beans.editors.NativeLongEditor + Copyright (C) 1998 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., 59 Temple Place, Suite 330, Boston, MA +02111-1307 USA. + +As a special exception, if you link this library with other files to +produce an executable, this library does not by itself cause the +resulting executable to be covered by the GNU General Public License. +This exception does not however invalidate any other reasons why the +executable file might be covered by the GNU General Public License. */ + + +package gnu.java.beans.editors; + +import java.beans.*; + +/** + ** NativeLongEditor is a property editor for the + ** long type. + ** + ** @author John Keiser + ** @version 1.1.0, 29 Jul 1998 + **/ + +public class NativeLongEditor extends PropertyEditorSupport { + /** setAsText for long calls Long.valueOf(). **/ + public void setAsText(String val) throws IllegalArgumentException { + setValue(Long.valueOf(val)); + } + + /** getAsText for long calls Long.toString(). **/ + public String getAsText() { + return getValue().toString(); + } +} diff --git a/libjava/gnu/java/beans/editors/NativeShortEditor.java b/libjava/gnu/java/beans/editors/NativeShortEditor.java new file mode 100644 index 00000000000..b32bb6a2946 --- /dev/null +++ b/libjava/gnu/java/beans/editors/NativeShortEditor.java @@ -0,0 +1,50 @@ +/* gnu.java.beans.editors.NativeShortEditor + Copyright (C) 1998 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., 59 Temple Place, Suite 330, Boston, MA +02111-1307 USA. + +As a special exception, if you link this library with other files to +produce an executable, this library does not by itself cause the +resulting executable to be covered by the GNU General Public License. +This exception does not however invalidate any other reasons why the +executable file might be covered by the GNU General Public License. */ + + +package gnu.java.beans.editors; + +import java.beans.*; + +/** + ** NativeShortEditor is a property editor for the + ** short type. + ** + ** @author John Keiser + ** @version 1.1.0, 29 Jul 1998 + **/ + +public class NativeShortEditor extends PropertyEditorSupport { + /** setAsText for short calls Short.valueOf(). **/ + public void setAsText(String val) throws IllegalArgumentException { + setValue(Short.valueOf(val)); + } + + /** getAsText for short calls Short.toString(). **/ + public String getAsText() { + return getValue().toString(); + } +} diff --git a/libjava/gnu/java/beans/editors/StringEditor.java b/libjava/gnu/java/beans/editors/StringEditor.java new file mode 100644 index 00000000000..bb3988cb189 --- /dev/null +++ b/libjava/gnu/java/beans/editors/StringEditor.java @@ -0,0 +1,50 @@ +/* gnu.java.beans.editors.StringEditor + Copyright (C) 1998 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., 59 Temple Place, Suite 330, Boston, MA +02111-1307 USA. + +As a special exception, if you link this library with other files to +produce an executable, this library does not by itself cause the +resulting executable to be covered by the GNU General Public License. +This exception does not however invalidate any other reasons why the +executable file might be covered by the GNU General Public License. */ + + +package gnu.java.beans.editors; + +import java.beans.*; + +/** + ** NativeByteEditor is a property editor for the + ** byte type. + ** + ** @author John Keiser + ** @version 1.1.0, 29 Jul 1998 + **/ + +public class StringEditor extends PropertyEditorSupport { + /** setAsText just sets the value. **/ + public void setAsText(String val) throws IllegalArgumentException { + setValue(val); + } + + /** getAsText just returns the value. **/ + public String getAsText() { + return (String)getValue(); + } +} diff --git a/libjava/gnu/java/beans/info/ComponentBeanInfo.java b/libjava/gnu/java/beans/info/ComponentBeanInfo.java new file mode 100644 index 00000000000..4cf45fab39b --- /dev/null +++ b/libjava/gnu/java/beans/info/ComponentBeanInfo.java @@ -0,0 +1,63 @@ +/* gnu.java.beans.info.ComponentBeanInfo + Copyright (C) 1998 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., 59 Temple Place, Suite 330, Boston, MA +02111-1307 USA. + +As a special exception, if you link this library with other files to +produce an executable, this library does not by itself cause the +resulting executable to be covered by the GNU General Public License. +This exception does not however invalidate any other reasons why the +executable file might be covered by the GNU General Public License. */ + + +package gnu.java.beans.info; + +import gnu.java.beans.*; +import java.beans.*; + +/** BeanInfo class for java.awt.Component. + ** This provides a few properties, but that's + ** it. + ** @author John Keiser + ** @version 1.1.0, Aug 1 1998 + **/ +public class ComponentBeanInfo extends SimpleBeanInfo { + static PropertyDescriptor[] properties; + static { + try { + properties = new PropertyDescriptor[6]; + properties[0] = new PropertyDescriptor("name",java.awt.Component.class); + properties[1] = new PropertyDescriptor("background",java.awt.Component.class); + properties[2] = new PropertyDescriptor("foreground",java.awt.Component.class); + properties[3] = new PropertyDescriptor("font",java.awt.Component.class); + properties[4] = new PropertyDescriptor("enabled",java.awt.Component.class); + properties[5] = new PropertyDescriptor("visible",java.awt.Component.class); + } catch(IntrospectionException E) { + properties = null; + throw new UnknownError("Could not introspect some java.awt.Component properties."); + } + } + public ComponentBeanInfo() { + super(); + } + + public PropertyDescriptor[] getPropertyDescriptors() { + return properties; + } +} + diff --git a/libjava/gnu/java/io/ClassLoaderObjectInputStream.java b/libjava/gnu/java/io/ClassLoaderObjectInputStream.java new file mode 100644 index 00000000000..76e1f058f1d --- /dev/null +++ b/libjava/gnu/java/io/ClassLoaderObjectInputStream.java @@ -0,0 +1,59 @@ +/* gnu.java.io.ClassLoaderObjectInputStream + Copyright (C) 1998 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., 59 Temple Place, Suite 330, Boston, MA +02111-1307 USA. + +As a special exception, if you link this library with other files to +produce an executable, this library does not by itself cause the +resulting executable to be covered by the GNU General Public License. +This exception does not however invalidate any other reasons why the +executable file might be covered by the GNU General Public License. */ + + +package gnu.java.io; + +import java.io.*; + +/** + * ClassLoaderObjectInputStream is ObjectInputStream, with + * the ability to use a specific ClassLoader. + * + * @author Geoff Berry + * @version 1.1.0, 29 Jul 1998 + */ + +public class ClassLoaderObjectInputStream extends ObjectInputStream { + ClassLoader myClassLoader; + + /** Create the new ClassLoaderObjectInputStream. + * @param in the InputStream to read the Objects from. + * @param myClassLoader the ClassLoader to load classes + * with. + */ + public ClassLoaderObjectInputStream(InputStream in, ClassLoader myClassLoader) throws IOException,StreamCorruptedException { + super(in); + this.myClassLoader = myClassLoader; + } + + /** Overriden method to use the loadClass() method from + * the ClassLoader. + */ + public Class resolveClass(String name) throws IOException, ClassNotFoundException { + return myClassLoader.loadClass(name); + } +} diff --git a/libjava/gnu/java/io/NullOutputStream.java b/libjava/gnu/java/io/NullOutputStream.java new file mode 100644 index 00000000000..caf8ade2fbc --- /dev/null +++ b/libjava/gnu/java/io/NullOutputStream.java @@ -0,0 +1,45 @@ +/* NullOutputStream.java -- OutputStream that does absolutely nothing + Copyright (C) 1998 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., 59 Temple Place, Suite 330, Boston, MA +02111-1307 USA. + +As a special exception, if you link this library with other files to +produce an executable, this library does not by itself cause the +resulting executable to be covered by the GNU General Public License. +This exception does not however invalidate any other reasons why the +executable file might be covered by the GNU General Public License. */ + + +package gnu.java.io; + +import java.io.OutputStream; + +/** + This is a placeholder OutputStream that does absolutley nothing + when written to. It is intended to be used in the same manner as + /dev/null. None of this class's methods do anything at all. +*/ +public class NullOutputStream extends OutputStream +{ + public NullOutputStream() {} + public void write( int b ) {} + public void write( byte b[] ) {} + public void write( byte b[], int off, int len ) {} + public void flush() {} + public void close() {} +} diff --git a/libjava/gnu/java/io/ObjectIdentityWrapper.java b/libjava/gnu/java/io/ObjectIdentityWrapper.java new file mode 100644 index 00000000000..f06e2057ecb --- /dev/null +++ b/libjava/gnu/java/io/ObjectIdentityWrapper.java @@ -0,0 +1,89 @@ +/* ObjectIdentityWrapper.java -- Wrapper class used to override equals() + and hashCode() to be as discriminating as possible + Copyright (C) 1998 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., 59 Temple Place, Suite 330, Boston, MA +02111-1307 USA. + +As a special exception, if you link this library with other files to +produce an executable, this library does not by itself cause the +resulting executable to be covered by the GNU General Public License. +This exception does not however invalidate any other reasons why the +executable file might be covered by the GNU General Public License. */ + + +package gnu.java.io; + +/** + This class is a thin wrapper around Object that makes + the methods hashCode() and equals(Object) + as discriminating as possible. +*/ +public class ObjectIdentityWrapper +{ + + /** + Constructs a ObjectIdentityWrapper that is wrapped + around o. + */ + public ObjectIdentityWrapper( Object o ) + { + object = o; + } + + /** + Uses System.identityHashCode(Object) to compute a + hash code for the object wrapped by this + ObjectIdentityWrapper. + + @see java.lang.System#identityHashCode(java.lang.Object) + @see java.util.Hashtable + @see java.lang.Object#hashCode() + */ + public int hashCode() + { + return System.identityHashCode( object ); + } + + /** + Uses the == operator to test for equality between + the object wrapped by this ObjectIdentityWrapper and + the object wrapped by the ObjectIdentityWrapper o. + Returns false if o is not a ObjectIdentityWrapper. + + @see java.util.Hashtable + @see java.lang.Object#equals() + */ + public boolean equals( Object o ) + { + if( o instanceof ObjectIdentityWrapper ) + return object == ((ObjectIdentityWrapper)o).object; + else + return false; + } + + public String toString() + { + return "ObjectIdentityWrapper< " + object + ", " + hashCode() + " >"; + } + + /** + The Object wrapped by this + ObjectIdentityWrapper. + */ + public Object object; +} diff --git a/libjava/gnu/java/lang/ArrayHelper.java b/libjava/gnu/java/lang/ArrayHelper.java new file mode 100644 index 00000000000..a04551ea4f7 --- /dev/null +++ b/libjava/gnu/java/lang/ArrayHelper.java @@ -0,0 +1,63 @@ +/* gnu.java.lang.ArrayHelper + Copyright (C) 1998 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., 59 Temple Place, Suite 330, Boston, MA +02111-1307 USA. + +As a special exception, if you link this library with other files to +produce an executable, this library does not by itself cause the +resulting executable to be covered by the GNU General Public License. +This exception does not however invalidate any other reasons why the +executable file might be covered by the GNU General Public License. */ + + +package gnu.java.lang; + +/** + ** ArrayHelper helps you do things with arrays. + ** + ** @author John Keiser + ** @version 1.1.0, 29 Jul 1998 + **/ + +public class ArrayHelper { + public static boolean contains(Object[] array, Object searchFor) { + return indexOf(array,searchFor) != -1; + } + + public static int indexOf(Object[] array, Object searchFor) { + for(int i=0;iClasss or Members. + More specific methods are also provided for computing the + type-signature of Constructors and + Methods. Methods are also provided to go in the + reverse direction. +*/ +public class TypeSignature +{ + + /** + Returns a String representing the type-encoding of + CLAZZ. Type-encodings are computed as follows: + +

+     boolean -> "Z"
+     byte    -> "B"
+     char    -> "C"
+     double  -> "D"
+     float   -> "F"
+     int     -> "I"
+     long    -> "J"
+     short   -> "S"
+     void    -> "V"
+     arrays  -> "[" + type-encoding of component type
+     object  -> "L"
+                 + fully qualified class name with "."'s replaced by "/"'s
+                 + ";"
+ */ + public static String getEncodingOfClass( Class clazz ) + { + if( clazz.isPrimitive() ) + { + if( clazz == Boolean.TYPE ) + return "Z"; + if( clazz == Byte.TYPE ) + return "B"; + if( clazz == Character.TYPE ) + return "C"; + if( clazz == Double.TYPE ) + return "D"; + if( clazz == Float.TYPE ) + return "F"; + if( clazz == Integer.TYPE ) + return "I"; + if( clazz == Long.TYPE ) + return "J"; + if( clazz == Short.TYPE ) + return "S"; + if( clazz == Void.TYPE ) + return "V"; + else + throw new RuntimeException( "Unknown primitive class " + clazz ); + } + else if( clazz.isArray() ) + { + return '[' + getEncodingOfClass( clazz.getComponentType() ); + } + else + { + String classname = clazz.getName(); + int name_len = classname.length(); + char[] buf = new char[ name_len + 2 ]; + buf[0] = 'L'; + classname.getChars( 0, name_len, buf, 1 ); + + int i; + for( i=1; i <= name_len; i++ ) + { + if( buf[i] == '.' ) + buf[i] = '/'; + } + + buf[i] = ';'; + return new String( buf ); + } + } + + + /** + This function is the inverse of getEncodingOfClass. + + @see getEncodingOfClass + + @exception ClassNotFoundException If class encoded as type_code + cannot be located. + */ + public static Class getClassForEncoding( String type_code ) + throws ClassNotFoundException + { + if( type_code.equals( "B" ) ) + return Byte.TYPE; + if( type_code.equals( "C" ) ) + return Character.TYPE; + if( type_code.equals( "D" ) ) + return Double.TYPE; + if( type_code.equals( "F" ) ) + return Float.TYPE; + if( type_code.equals( "I" ) ) + return Integer.TYPE; + if( type_code.equals( "J" ) ) + return Long.TYPE; + if( type_code.equals( "S" ) ) + return Short.TYPE; + if( type_code.equals( "Z" ) ) + return Boolean.TYPE; + if( type_code.charAt( 0 ) == 'L' ) + { + return Class.forName( + type_code.substring( 1, type_code.length() - 1 ).replace( '/', '.' )); + } + if( type_code.charAt( 0 ) == '[' ) + { + int last_bracket = type_code.lastIndexOf( '[' ); + String brackets = type_code.substring( 0, last_bracket + 1 ); + String component = type_code.substring( last_bracket + 1 ); + +// ??? This is what the Classpath implementation did, but I don't +// think that it's correct. The JLS says that Class.forName takes the +// classname of an array element in fully qualified form, whereas this +// code is tring to strip off the punctuation. + +// if( component.charAt( 0 ) == 'L' ) +// component = +// component.substring( 1, component.length() - 1 ).replace('/', '.'); + + if( component.charAt( 0 ) == 'L' ) + component = component.replace('/', '.'); + + return Class.forName( brackets + component ); + } + else + throw new ClassNotFoundException( "Type code cannot be parsed as a valid class name" ); + } + + + /** + Returns a String representing the type-encoding of + M. The type-encoding of a method is: + + "(" + type-encodings of parameter types + ")" + + type-encoding of return type + */ + public static String getEncodingOfMethod( Method m ) + { + String returnEncoding = getEncodingOfClass( m.getReturnType() ); + Class[] paramTypes = m.getParameterTypes(); + String[] paramEncodings = new String[ paramTypes.length ]; + + String paramEncoding; + int size = 2; // make room for parens + for( int i=0; i < paramTypes.length; i++ ) + { + paramEncoding = getEncodingOfClass( paramTypes[i] ); + size += paramEncoding.length(); + paramEncodings[i] = paramEncoding; + } + + size += returnEncoding.length(); + + StringBuffer buf = new StringBuffer( size ); + buf.append( '(' ); + + for( int i=0; i < paramTypes.length; i++ ) + { + buf.append( paramEncodings[i] ); + } + + buf.append( ')' ); + buf.append( returnEncoding ); + + return buf.toString(); + } + + + /** + Returns a String representing the type-encoding of + C. The type-encoding of a method is: + + "(" + type-encodings of parameter types + ")V" + */ + public static String getEncodingOfConstructor( Constructor c ) + { + Class[] paramTypes = c.getParameterTypes(); + String[] paramEncodings = new String[ paramTypes.length ]; + + String paramEncoding; + int size = 3; // make room for parens and V for return type + for( int i=0; i < paramTypes.length; i++ ) + { + paramEncoding = getEncodingOfClass( paramTypes[i] ); + size += paramEncoding.length(); + paramEncodings[i] = paramEncoding; + } + + StringBuffer buf = new StringBuffer( size ); + buf.append( '(' ); + + for( int i=0; i < paramTypes.length; i++ ) + { + buf.append( paramEncodings[i] ); + } + + buf.append( ")V" ); + + return buf.toString(); + } + + + /** + Returns a String representing the type-encoding of + MEM. Constructors are handled by + getEncodingOfConstructor. Methods are + handled by getEncodingOfMethod. Fields + are handled by returning the encoding of the type of the + Field. + */ + public static String getEncodingOfMember( Member mem ) + { + if( mem instanceof Constructor ) + return getEncodingOfConstructor( (Constructor)mem ); + if( mem instanceof Method ) + return getEncodingOfMethod( (Method)mem ); + else // Field + return getEncodingOfClass( ((Field)mem).getType() ); + } +} -- cgit v1.2.3