Commit 6c80c45e by Tom Tromey

Jumbo patch:

* Imported beans and serialization
* Updated IA-64 port
* Miscellaneous bug fixes

From-SVN: r34028
parent 021c89ed
#!/bin/awk -f
# 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.
# This script emulates a little of the functionality of addr2line for
# those systems that don't have it. The only command line argument is
# an executable name. The script reads hexadecimal addresses from
# stdin and prints the corresponding symbol names to stdout. The
# addresses must begin with "0x" and be fully zero filled or this
# won't work.
BEGIN {
object = ARGV[1];
ARGV[1] = "";
while ("nm " object "| sort" | getline) {
if ($2 == "t" || $2 == "T") {
address[i] = "0x" $1; name[i] = $3;
i++;
}
}
syms = i;
}
{
lo = 0;
hi = syms - 1;
while ((hi-1) > lo)
{
try = int ((hi + lo) / 2);
if ($0 < address[try])
hi = try;
else if ($0 >= address[try])
lo = try;
}
print name[lo] "\n"; fflush();
}
......@@ -5118,24 +5118,33 @@ done
test -n "$PERL" || PERL="false"
if test "$enable_sjlj_exceptions" = yes; then
SYSDEP_SOURCES=
case "${host}" in
i?86-*-linux*)
SIGNAL_HANDLER=include/i386-signal.h
;;
sparc-sun-solaris*)
SIGNAL_HANDLER=include/sparc-signal.h
;;
ia64-*)
SYSDEP_SOURCES=sysdep/ia64.c
test -d sysdep || mkdir sysdep
;;
*)
SIGNAL_HANDLER=include/default-signal.h
;;
esac
# If we're using sjlj exceptions, forget what we just learned.
if test "$libgcj_sjlj" = yes; then
SIGNAL_HANDLER=include/default-signal.h
else
case "${host}" in
i?86-*-linux*)
SIGNAL_HANDLER=include/i386-signal.h
;;
sparc-sun-solaris*)
SIGNAL_HANDLER=include/sparc-signal.h
;;
*)
SIGNAL_HANDLER=include/default-signal.h
;;
esac
fi
if test "${multilib}" = "yes"; then
multilib_arg="--enable-multilib"
else
......@@ -5367,6 +5376,7 @@ s%@EH_COMMON_INCLUDE@%$EH_COMMON_INCLUDE%g
s%@AM_RUNTESTFLAGS@%$AM_RUNTESTFLAGS%g
s%@ALLOCA@%$ALLOCA%g
s%@PERL@%$PERL%g
s%@SYSDEP_SOURCES@%$SYSDEP_SOURCES%g
s%@here@%$here%g
CEOF
......
......@@ -66,6 +66,11 @@ case "${host}" in
;;
sparc-*)
;;
ia64-*)
libgcj_flags="${libgcj_flags} -funwind-tables"
libgcj_sjlj=yes
libgcj_interpreter=yes
;;
*)
libgcj_sjlj=yes
;;
......
......@@ -733,22 +733,31 @@ AC_FUNC_ALLOCA
AC_CHECK_PROGS(PERL, perl, false)
if test "$enable_sjlj_exceptions" = yes; then
SYSDEP_SOURCES=
case "${host}" in
i?86-*-linux*)
SIGNAL_HANDLER=include/i386-signal.h
;;
sparc-sun-solaris*)
SIGNAL_HANDLER=include/sparc-signal.h
;;
ia64-*)
SYSDEP_SOURCES=sysdep/ia64.c
test -d sysdep || mkdir sysdep
;;
*)
SIGNAL_HANDLER=include/default-signal.h
;;
esac
# If we're using sjlj exceptions, forget what we just learned.
if test "$libgcj_sjlj" = yes; then
SIGNAL_HANDLER=include/default-signal.h
else
case "${host}" in
i?86-*-linux*)
SIGNAL_HANDLER=include/i386-signal.h
;;
sparc-sun-solaris*)
SIGNAL_HANDLER=include/sparc-signal.h
;;
*)
SIGNAL_HANDLER=include/default-signal.h
;;
esac
fi
AC_SUBST(SYSDEP_SOURCES)
AC_LINK_FILES($SIGNAL_HANDLER, include/java-signal.h)
if test "${multilib}" = "yes"; then
......
......@@ -99,6 +99,7 @@ OBJDUMP = @OBJDUMP@
PACKAGE = @PACKAGE@
PERL = @PERL@
RANLIB = @RANLIB@
SYSDEP_SOURCES = @SYSDEP_SOURCES@
SYSTEMSPEC = @SYSTEMSPEC@
THREADDEPS = @THREADDEPS@
THREADINCS = @THREADINCS@
......
......@@ -69,8 +69,24 @@ extern "Java"
class InputStream;
class InputStreamReader;
class InterruptedIOException;
class InvalidClassException;
class InvalidObjectException;
class LineNumberInputStream;
class LineNumberReader;
class NotActiveException;
class NotSerializableException;
class ObjectInput;
class ObjectInputStream;
class ObjectInputStream$GetField;
class ObjectInputValidation;
class ObjectOutput;
class ObjectOutputStream;
class ObjectOutputStream$PutField;
class ObjectStreamClass;
class ObjectStreamConstants;
class ObjectStreamException;
class ObjectStreamField;
class OptionalDataException;
class OutputStream;
class OutputStreamWriter;
class PipedInputStream;
......@@ -85,6 +101,9 @@ extern "Java"
class Reader;
class SequenceInputStream;
class Serializable;
class SerializablePermission;
class SimpleDigestStream;
class StreamCorruptedException;
class StreamTokenizer;
class StringBufferInputStream;
class StringReader;
......
// 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;
}
}
// 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 <config.h>
#include <string.h>
#include <stdlib.h>
#include <gnu/gcj/io/SimpleSHSStream.h>
#include <gcj/cni.h>
#include <jvm.h>
#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;
}
/* --------------------------------- 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 <string.h>
#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);
}
/* --------------------------------- 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
/* 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.<P>
**
** 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<methods.size();i++) {
Method thisMethod = ((MethodDescriptor)methods.elementAt(i)).getMethod();
if(m.getMethod().getName().equals(thisMethod.getName())
&& ArrayHelper.equalsArray(m.getMethod().getParameterTypes(), thisMethod.getParameterTypes())) {
return true;
}
}
return false;
}
public void addMethod(MethodDescriptor m) {
methods.addElement(m);
}
public void setDefaultPropertyName(String defaultPropertyName) {
this.defaultPropertyName = defaultPropertyName;
}
public void setDefaultEventName(String defaultEventName) {
this.defaultEventName = defaultEventName;
}
public void setIcons(java.awt.Image[] im) {
this.im = im;
}
}
/* gnu.java.beans.EmptyBeanInfo
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.*;
/**
** EmptyBeanInfo is a BeanInfo that discloses no
** information about the Bean and does not allow
** Introspection. The Introspector uses instances of this
** class to create empty BeanInfos, but it could also be
** used as a base class for BeanInfos that do not allow
** Introspection and provide only a little bit of
** information.<P>
**
** @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);
}
}
/* 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;
}
}
/* gnu.java.beans.editors.ColorEditor
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.*;
import java.awt.Color;
/**
** NativeByteEditor is a property editor for the
** byte type.
**
** @author John Keiser
** @version 1.1.0, 29 Jul 1998
**/
public class ColorEditor extends PropertyEditorSupport {
Color[] stdColors = {Color.black,Color.blue,Color.cyan,
Color.darkGray,Color.gray,Color.green,
Color.lightGray,Color.magenta,Color.orange,
Color.pink,Color.red,Color.white,
Color.yellow};
String[] stdColorNames = {"black","blue","cyan",
"dark gray","gray","green",
"light gray","magenta","orange",
"pink","red","white",
"yellow"};
/** setAsText for Color checks for standard color names
** and then checks for a #RRGGBB value or just RRGGBB,
** both in hex.
**/
public void setAsText(String val) throws IllegalArgumentException {
if(val.length() == 0) {
throw new IllegalArgumentException("Tried to set empty value!");
}
for(int i=0;i<stdColorNames.length;i++) {
if(stdColorNames[i].equalsIgnoreCase(val)) {
setValue(stdColors[i]);
return;
}
}
if(val.charAt(0) == '#') {
setValue(new Color(Integer.parseInt(val.substring(1),16)));
} else {
setValue(new Color(Integer.parseInt(val,16)));
}
}
/** getAsText for Color turns the color into either one of the standard
** colors or into an RGB hex value with # prepended. **/
public String getAsText() {
for(int i=0;i<stdColors.length;i++) {
if(stdColors[i].equals(getValue())) {
return stdColorNames[i];
}
}
return "#" + Integer.toHexString(((Color)getValue()).getRGB() & 0x00FFFFFF);
}
/** getTags for Color returns a list of standard colors. **/
public String[] getTags() {
return stdColorNames;
}
}
/* gnu.java.beans.editors.FontEditor
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.*;
import java.awt.Font;
/**
** FontEditor is a property editor for java.awt.Font.
**
** <STRONG>To Do:</STRONG> 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();
}
}
}
/* 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.<P>
**
** <STRONG>To Do:</STRONG> 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();
}
}
/* 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();
}
}
/* 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();
}
}
/* 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();
}
}
/* 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();
}
}
/* 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();
}
}
/* 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();
}
}
/* 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();
}
}
/* 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;
}
}
/* 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);
}
}
/* 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() {}
}
/* 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 <code>Object</code> that makes
the methods <code>hashCode()</code> and <code>equals(Object)</code>
as discriminating as possible.
*/
public class ObjectIdentityWrapper
{
/**
Constructs a <code>ObjectIdentityWrapper</code> that is wrapped
around o.
*/
public ObjectIdentityWrapper( Object o )
{
object = o;
}
/**
Uses <code>System.identityHashCode(Object)</code> to compute a
hash code for the object wrapped by this
<code>ObjectIdentityWrapper</code>.
@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 <code>==</code> operator to test for equality between
the object wrapped by this <code>ObjectIdentityWrapper</code> and
the object wrapped by the <code>ObjectIdentityWrapper</code> o.
Returns false if o is not a <code>ObjectIdentityWrapper</code>.
@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 <code>Object</code> wrapped by this
<code>ObjectIdentityWrapper</code>.
*/
public Object object;
}
/* 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;i<array.length;i++) {
if(array[i].equals(searchFor)) {
return i;
}
}
return -1;
}
public static boolean equalsArray(Object[] a, Object[] b) {
if(a.length == b.length) {
for(int i=0;i<a.length;i++) {
if(!a[i].equals(b[i])) {
return false;
}
}
return true;
} else {
return false;
}
}
}
/* gnu.java.lang.ClassHelper
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;
import java.util.*;
import java.lang.reflect.*;
/**
** ClassHelper has various methods that ought to have been
** in class.
**
** @author John Keiser
** @version 1.1.0, 29 Jul 1998
**/
public class ClassHelper {
/** Strip the package part from the class name.
** @param clazz the class to get the truncated name from
** @return the truncated class name.
**/
public static String getTruncatedClassName(Class clazz) {
return getTruncatedName(clazz.getName());
}
/** Strip the package part from the class name, or the
** class part from the method or field name.
** @param name the name to truncate.
** @return the truncated name.
**/
public static String getTruncatedName(String name) {
int lastInd = name.lastIndexOf('.');
if(lastInd == -1) {
return name;
} else {
return name.substring(lastInd+1);
}
}
/** Strip the last portion of the name (after the last
** dot).
** @param name the name to get package of.
** @return the package name. "" if no package.
**/
public static String getPackagePortion(String name) {
int lastInd = name.lastIndexOf('.');
if(lastInd == -1) {
return "";
} else {
return name.substring(0,lastInd);
}
}
static Hashtable allMethods = new Hashtable();
static Hashtable allMethodsAtDeclaration = new Hashtable();
/** Get all the methods, public, private and
** otherwise, from the class, getting them
** from the most recent class to find them.
**/
public static Method[] getAllMethods(Class clazz) {
Method[] retval = (Method[])allMethods.get(clazz);
if(retval == null) {
Method[] superMethods;
if(clazz.getSuperclass() != null) {
superMethods = getAllMethods(clazz.getSuperclass());
} else {
superMethods = new Method[0];
}
Vector v = new Vector();
Method[] currentMethods = clazz.getDeclaredMethods();
for(int i=0;i<currentMethods.length;i++) {
v.addElement(currentMethods[i]);
}
for(int i=0;i<superMethods.length;i++) {
boolean addOK = true;
for(int j=0;j<currentMethods.length;j++) {
if(getTruncatedName(superMethods[i].getName()).equals(getTruncatedName(currentMethods[j].getName()))
&& ArrayHelper.equalsArray(superMethods[i].getParameterTypes(),currentMethods[j].getParameterTypes())) {
addOK = false;
}
}
if(addOK) {
v.addElement(superMethods[i]);
}
}
retval = new Method[v.size()];
v.copyInto(retval);
allMethods.put(clazz,retval);
}
return retval;
}
/** Get all the methods, public, private and
** otherwise, from the class, and get them from
** their point of declaration.
**/
public static Method[] getAllMethodsAtDeclaration(Class clazz) {
Method[] retval = (Method[])allMethodsAtDeclaration.get(clazz);
if(retval == null) {
Method[] superMethods;
if(clazz.getSuperclass() != null) {
superMethods = getAllMethodsAtDeclaration(clazz.getSuperclass());
} else {
superMethods = new Method[0];
}
Vector v = new Vector();
Method[] currentMethods = clazz.getDeclaredMethods();
for(int i=0;i<superMethods.length;i++) {
v.addElement(superMethods[i]);
}
for(int i=0;i<superMethods.length;i++) {
boolean addOK = true;
for(int j=0;j<currentMethods.length;j++) {
if(getTruncatedName(superMethods[i].getName()).equals(getTruncatedName(currentMethods[j].getName()))
&& ArrayHelper.equalsArray(superMethods[i].getParameterTypes(),currentMethods[j].getParameterTypes())) {
addOK = false;
}
}
if(addOK) {
v.addElement(superMethods[i]);
}
}
retval = new Method[v.size()];
v.copyInto(retval);
allMethodsAtDeclaration.put(clazz,retval);
}
return retval;
}
static Hashtable allFields = new Hashtable();
static Hashtable allFieldsAtDeclaration = new Hashtable();
/** Get all the fields, public, private and
** otherwise, from the class, getting them
** from the most recent class to find them.
**/
public static Field[] getAllFields(Class clazz) {
Field[] retval = (Field[])allFields.get(clazz);
if(retval == null) {
Field[] superFields;
if(clazz.getSuperclass() != null) {
superFields = getAllFields(clazz.getSuperclass());
} else {
superFields = new Field[0];
}
Vector v = new Vector();
Field[] currentFields = clazz.getDeclaredFields();
for(int i=0;i<currentFields.length;i++) {
v.addElement(currentFields[i]);
}
for(int i=0;i<superFields.length;i++) {
boolean addOK = true;
for(int j=0;j<currentFields.length;j++) {
if(getTruncatedName(superFields[i].getName()).equals(getTruncatedName(currentFields[j].getName()))) {
addOK = false;
}
}
if(addOK) {
v.addElement(superFields[i]);
}
}
retval = new Field[v.size()];
v.copyInto(retval);
allFields.put(clazz,retval);
}
return retval;
}
/** Get all the fields, public, private and
** otherwise, from the class, and get them from
** their point of declaration.
**/
public static Field[] getAllFieldsAtDeclaration(Class clazz) {
Field[] retval = (Field[])allFieldsAtDeclaration.get(clazz);
if(retval == null) {
Field[] superFields;
if(clazz.getSuperclass() != null) {
superFields = getAllFieldsAtDeclaration(clazz.getSuperclass());
} else {
superFields = new Field[0];
}
Vector v = new Vector();
Field[] currentFields = clazz.getDeclaredFields();
for(int i=0;i<superFields.length;i++) {
v.addElement(superFields[i]);
}
for(int i=0;i<superFields.length;i++) {
boolean addOK = true;
for(int j=0;j<currentFields.length;j++) {
if(getTruncatedName(superFields[i].getName()).equals(getTruncatedName(currentFields[j].getName()))) {
addOK = false;
}
}
if(addOK) {
v.addElement(superFields[i]);
}
}
retval = new Field[v.size()];
v.copyInto(retval);
allFieldsAtDeclaration.put(clazz,retval);
}
return retval;
}
}
/* TypeSignature.java -- Class used to compute type signatures
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.reflect;
import java.lang.reflect.Constructor;
import java.lang.reflect.Field;
import java.lang.reflect.Member;
import java.lang.reflect.Method;
/**
This class provides static methods that can be used to compute
type-signatures of <code>Class</code>s or <code>Member</code>s.
More specific methods are also provided for computing the
type-signature of <code>Constructor</code>s and
<code>Method</code>s. Methods are also provided to go in the
reverse direction.
*/
public class TypeSignature
{
/**
Returns a <code>String</code> representing the type-encoding of
CLAZZ. Type-encodings are computed as follows:
<pre>
boolean -> "Z"
byte -> "B"
char -> "C"
double -> "D"
float -> "F"
int -> "I"
long -> "J"
short -> "S"
void -> "V"
arrays -> "[" + type-encoding of component type
object -> "L"
+ fully qualified class name with "."'s replaced by "/"'s
+ ";"</pre>
*/
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 <code>getEncodingOfClass</code>.
@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 <code>String</code> 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 <code>String</code> 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 <code>String</code> representing the type-encoding of
MEM. <code>Constructor</code>s are handled by
<code>getEncodingOfConstructor</code>. <code>Method</code>s are
handled by <code>getEncodingOfMethod</code>. <code>Field</code>s
are handled by returning the encoding of the type of the
<code>Field</code>.
*/
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() );
}
}
......@@ -99,6 +99,7 @@ OBJDUMP = @OBJDUMP@
PACKAGE = @PACKAGE@
PERL = @PERL@
RANLIB = @RANLIB@
SYSDEP_SOURCES = @SYSDEP_SOURCES@
SYSTEMSPEC = @SYSTEMSPEC@
THREADDEPS = @THREADDEPS@
THREADINCS = @THREADINCS@
......@@ -127,7 +128,7 @@ DIST_COMMON = ./stamp-h.in Makefile.am Makefile.in config.h.in
DISTFILES = $(DIST_COMMON) $(SOURCES) $(HEADERS) $(TEXINFOS) $(EXTRA_DIST)
TAR = gtar
TAR = tar
GZIP_ENV = --best
all: all-redirect
.SUFFIXES:
......@@ -224,7 +225,7 @@ distdir: $(DISTFILES)
@for file in $(DISTFILES); do \
d=$(srcdir); \
if test -d $$d/$$file; then \
cp -pr $$d/$$file $(distdir)/$$file; \
cp -pr $$/$$file $(distdir)/$$file; \
else \
test -f $(distdir)/$$file \
|| ln $$d/$$file $(distdir)/$$file 2> /dev/null \
......
......@@ -344,8 +344,14 @@
/* Version number of package */
#undef VERSION
/* Define if gethostbyname_r is only declared if _REENTRANT is defined */
#undef GETHOSTBYNAME_R_NEEDS_REENTRANT
/* Required define if using POSIX threads */
#undef _REENTRANT
/* Required define if using POSIX threads */
#undef _POSIX_PTHREAD_SEMANTICS
/* Required define if using POSIX threads */
#undef _REENTRANT
/* Define if struct hostent_data is defined in netdb.h */
#undef HAVE_STRUCT_HOSTENT_DATA
......
// default-signal.h - Catch runtime signals and turn them into exceptions.
/* Copyright (C) 1998, 1999 Free Software Foundation
/* Copyright (C) 1998, 1999, 2000 Free Software Foundation
This file is part of libgcj.
......@@ -38,7 +38,7 @@ do \
} \
while (0)
#define MAKE_THROW_FRAME do {} while (0)
#define MAKE_THROW_FRAME(_exception) do {} while (0)
#else /* SJLJ_EXCEPTIONS */
......
......@@ -24,7 +24,7 @@ details. */
#define SIGNAL_HANDLER(_name) \
static void _name (int _dummy)
#define MAKE_THROW_FRAME \
#define MAKE_THROW_FRAME(_exception) \
do \
{ \
void **_p = (void **)&_dummy; \
......
......@@ -48,11 +48,6 @@ static void throw_incompatible_class_change_error (jstring msg)
static void throw_null_pointer_exception ()
__attribute__ ((__noreturn__));
#endif
#ifndef HANDLE_FPE
static void throw_arithmetic_exception ()
__attribute__ ((__noreturn__));
#endif
extern "C" double __ieee754_fmod __P((double,double));
......@@ -193,12 +188,6 @@ static jint get4(unsigned char* loc) {
do { if ((X)==NULL) throw_null_pointer_exception (); } while (0)
#endif
#ifdef HANDLE_FPE
#define ZEROCHECK(X)
#else
#define ZEROCHECK(X) \
do { if ((X) == 0) throw_arithmetic_exception (); } while (0)
#endif
// this method starts the actual running of the method. It is inlined
// in three different variants in the static methods run_normal,
......@@ -408,8 +397,8 @@ void _Jv_InterpMethod::continue1 (_Jv_InterpMethodInvocation *inv)
{
using namespace java::lang::reflect;
register _Jv_word *sp = inv->sp;
register unsigned char *pc = inv->pc;
_Jv_word *sp = inv->sp;
unsigned char *pc = inv->pc;
_Jv_word *locals = inv->local_base ();
_Jv_word *pool_data = defining_class->constants.data;
......@@ -1390,8 +1379,7 @@ void _Jv_InterpMethod::continue1 (_Jv_InterpMethodInvocation *inv)
{
jint value2 = POPI();
jint value1 = POPI();
ZEROCHECK (value2);
jint res = value1 / value2;
jint res = _Jv_divI (value1, value2);
PUSHI (res);
}
NEXT_INSN;
......@@ -1401,8 +1389,7 @@ void _Jv_InterpMethod::continue1 (_Jv_InterpMethodInvocation *inv)
{
jlong value2 = POPL();
jlong value1 = POPL();
ZEROCHECK (value2);
jlong res = value1 / value2;
jlong res = _Jv_divJ (value1, value2);
PUSHL (res);
}
NEXT_INSN;
......@@ -1412,7 +1399,6 @@ void _Jv_InterpMethod::continue1 (_Jv_InterpMethodInvocation *inv)
{
jfloat value2 = POPF();
jfloat value1 = POPF();
ZEROCHECK (value2);
jfloat res = value1 / value2;
PUSHF (res);
}
......@@ -1423,7 +1409,6 @@ void _Jv_InterpMethod::continue1 (_Jv_InterpMethodInvocation *inv)
{
jdouble value2 = POPD();
jdouble value1 = POPD();
ZEROCHECK (value2);
jdouble res = value1 / value2;
PUSHD (res);
}
......@@ -1433,9 +1418,8 @@ void _Jv_InterpMethod::continue1 (_Jv_InterpMethodInvocation *inv)
SAVE_PC;
{
jint value2 = POPI();
jint value1 = POPI();
ZEROCHECK (value2);
jint res = value1 % value2;
jint value1 = POPI();
jint res = _Jv_remI (value1, value2);
PUSHI (res);
}
NEXT_INSN;
......@@ -1445,8 +1429,7 @@ void _Jv_InterpMethod::continue1 (_Jv_InterpMethodInvocation *inv)
{
jlong value2 = POPL();
jlong value1 = POPL();
ZEROCHECK (value2);
jlong res = value1 % value2;
jlong res = _Jv_remJ (value1, value2);
PUSHL (res);
}
NEXT_INSN;
......@@ -1456,7 +1439,6 @@ void _Jv_InterpMethod::continue1 (_Jv_InterpMethodInvocation *inv)
{
jfloat value2 = POPF();
jfloat value1 = POPF();
ZEROCHECK (value2);
jfloat res = __ieee754_fmod (value1, value2);
PUSHF (res);
}
......@@ -1467,7 +1449,6 @@ void _Jv_InterpMethod::continue1 (_Jv_InterpMethodInvocation *inv)
{
jdouble value2 = POPD();
jdouble value1 = POPD();
ZEROCHECK (value2);
jdouble res = __ieee754_fmod (value1, value2);
PUSHD (res);
}
......@@ -2447,18 +2428,4 @@ throw_null_pointer_exception ()
}
#endif
#ifndef HANDLE_FPE
static java::lang::ArithmeticException *arithmetic_exc;
static void
throw_arithmetic_exception ()
{
if (arithmetic_exc == NULL)
arithmetic_exc = new java::lang::ArithmeticException
(JvNewStringLatin1 ("/ by zero"));
JvThrow (arithmetic_exc);
}
#endif
#endif // INTERPRETER
/* java.beans.BeanDescriptor
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 java.beans;
import java.util.*;
/**
** BeanDescriptor describes general information about a Bean, plus
** stores the Bean's Class and it's customizer's Class.<P>
**
** @author John Keiser
** @since JDK1.1
** @version 1.1.0, 31 May 1998
**/
public class BeanDescriptor extends FeatureDescriptor {
Class beanClass;
Class customizerClass;
/** Create a new BeanDescriptor with the given beanClass and
** no customizer class.
** @param beanClass the class of the Bean.
**/
public BeanDescriptor(Class beanClass) {
this(beanClass,null);
}
/** Create a new BeanDescriptor with the given bean class and
** customizer class.
** @param beanClass the class of the Bean.
** @param customizerClass the class of the Bean's Customizer.
**/
public BeanDescriptor(Class beanClass, Class customizerClass) {
this.beanClass = beanClass;
this.customizerClass = customizerClass;
}
/** Get the Bean's class. **/
public Class getBeanClass() {
return beanClass;
}
/** Get the Bean's customizer's class. **/
public Class getCustomizerClass() {
return customizerClass;
}
}
/* java.beans.BeanInfo
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 java.beans;
/**
** BeanInfo can be implemented in order to provide explicit information to the Introspector.
**
** When you write a BeanInfo class, you implement this interface
** and provide explicit information by returning a non-null
** value from the appropriate method. If you wish the
** Introspector to determine certain information in the normal
** way, just return null (or in the case of int methods, return
** -1). There is a class called SimpleBeanInfo which returns
** null from all methods, which you may extend and only
** override the methods you wish to override.<P>
**
** When you have written the class, give it the name
** <CODE>&lt;Bean Class Name&gt;BeanInfo</CODE> and place it in
** the same package as the Bean, or in the bean info search path
** (see Introspector for information on search paths).<P>
**
** A simple note about the way the Introspector interacts with
** BeanInfo. Introspectors look at a Bean class and determine
** if there is a BeanInfo class with it. If there is not a
** BeanInfo class, it will behave as if the BeanInfo class
** provided was a SimpleBeanInfo class (i.e. it will determine
** all information automatically).<P>If there is a BeanInfo
** class, then any methods that do *not* return null are
** regarded as providing definitive information about the class
** and all of its superclasses for those information types.
** Even if a parent BeanInfo class explicitly returns that
** information, it will not be used.
**
** @author John Keiser
** @since JDK1.1
** @version 1.1.0, 28 Jul 1998
**/
public interface BeanInfo {
/** Use this as a parameter for the getIcon() command to retrieve a certain type of icon. **/
public static int ICON_COLOR_16x16 = 1;
/** Use this as a parameter for the getIcon() command to retrieve a certain type of icon. **/
public static int ICON_COLOR_32x32 = 2;
/** Use this as a parameter for the getIcon() command to retrieve a certain type of icon. **/
public static int ICON_MONO_16x16 = 3;
/** Use this as a parameter for the getIcon() command to retrieve a certain type of icon. **/
public static int ICON_MONO_32x32 = 4;
/** Get the general description of this Bean type.
** @return the BeanDescriptor for the Bean, or null if
** the BeanDescriptor should be obtained by
** Introspection.
**/
public abstract BeanDescriptor getBeanDescriptor();
/** Get the events this Bean type fires.
** @return the EventDescriptors representing events this
** Bean fires. Returns <CODE>null</CODE> if the
** events are to be acquired by Introspection.
**/
public abstract EventSetDescriptor[] getEventSetDescriptors();
/** Get the "default" event, basically the one a RAD tool
** user is most likely to select.
** @return the index into the getEventSetDescriptors()
** that the user is most likely to use. Returns
** <CODE>-1</CODE> if there is no default event.
**/
public abstract int getDefaultEventIndex();
/** Get the properties (get/set method pairs) this Bean
** type supports.
** @return the PropertyDescriptors representing the
** properties this Bean type supports.
** Returns <CODE>null</CODE> if the properties
** are to be obtained by Introspection.
**/
public abstract PropertyDescriptor[] getPropertyDescriptors();
/** Get the "default" property, basically the one a RAD
** tool user is most likely to select.
** @return the index into the getPropertyDescriptors()
** that the user is most likely to use. Returns
** <CODE>-1</CODE> if there is no default event.
**/
public abstract int getDefaultPropertyIndex();
/** Get the methods this Bean type supports.
** @return the MethodDescriptors representing the
** methods this Bean type supports. Returns
** <CODE>null</CODE> if the methods are to be
** obtained by Introspection.
**/
public abstract MethodDescriptor[] getMethodDescriptors();
/** Get additional BeanInfos representing this Bean.
** In this version of JavaBeans, this method is used so
** that space and time can be saved by reading a BeanInfo
** for each class in the hierarchy (super, super(super),
** and so on).<P>
**
** The order of precedence when two pieces of BeanInfo
** conflict (such as two PropertyDescriptors that have
** the same name), in order from highest precedence to
** lowest, is:
** <OL>
** <LI>This BeanInfo object.</LI>
** <LI><CODE>getAdditionalBeanInfo()[getAdditionalBeanInfo().length]</CODE></LI>
** <LI> ... </LI>
** <LI><CODE>getAdditionalBeanInfo()[1]</CODE></LI>
** <LI><CODE>getAdditionalBeanInfo()[0]</CODE></LI>
** </OL><P>
**
** <STRONG>Spec Note:</STRONG> It is possible that
** returning <CODE>null</CODE> from this method could
** stop Introspection in its tracks, but it is unclear
** from the spec whether this is the case.
**
** @return additional BeanInfos representing this Bean.
** <CODE>null</CODE> may be returned (see Spec
** Note, above).
**/
public abstract BeanInfo[] getAdditionalBeanInfo();
/** Get a visual icon for this Bean.
** A Bean does not have to support icons, and if it does
** support icons, it does not have to support every single
** type. Sun recommends that if you only support one
** type, you support 16x16 color. Sun also notes that you
** should try to use a type (like GIF) that allows for
** transparent pixels, so that the background of the RAD
** tool can show through.<P>
**
** <STRONG>Spec Note:</STRONG> If you do not support the
** type of icon that is being asked for, but you do
** support another type, it is unclear whether you should
** return the other type or not. I would presume not.
**
** @param iconType the type of icon to get (see the
** ICON_* constants in this class).
** @return the icon, or null if that type of icon is
** unsupported by this Bean.
**/
public abstract java.awt.Image getIcon(int iconType);
}
/* java.beans.Beans
Copyright (C) 1998, 1999 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 java.beans;
import java.io.*;
// import java.applet.*;
import gnu.java.io.*;
/**
* <code>Beans</code> provides some helper methods that allow the basic operations of Bean-ness.
*
* @author John Keiser
* @since JDK1.1
* @version 1.1.0, 29 Jul 1998
*
*/
public class Beans {
static boolean designTime = false;
static boolean guiAvailable = true;
/**
* Once again, we have a java.beans class with only
* static methods that can be instantiated. When
* will the madness end? :)
*/
public Beans() {
}
/**
* Allows you to instantiate a Bean. This method takes
* a ClassLoader from which to read the Bean and the
* name of the Bean.<P>
*
* The Bean name should be a dotted name, like a class.
* It can represent several things. Beans will search
* for the Bean using the name like this:<P>
* <OL>
* <LI>Searches for a serialized instance of the Bean
* using getResource(), mangling the Bean name by
* replacing the dots with slashes and appending .ser
* (for example, gnu.beans.BlahDeBlah would cause
* Beans to search for gnu/beans/BlahDeBlah.ser using
* getResource()).</LI>
* <LI>Searches for the Bean class using the beanName,
* and then instantiates it with the no-arg constructor.
* At that point, if it is an Applet, it provides it
* with AppletContext and AppletStub, and then calls
* init().</LI>
* </OL>
* @param cl the ClassLoader to use, or <CODE>null</CODE>
* to use the default ClassLoader.
* @param beanName the name of the Bean.
* @return the Bean.
* @XXX
*/
public static Object instantiate(ClassLoader cl, String beanName) throws IOException, ClassNotFoundException {
Object bean;
InputStream serStream;
if(cl == null) {
serStream = ClassLoader.getSystemResourceAsStream(beanName.replace('.','/')+".ser");
} else {
serStream = cl.getResourceAsStream(beanName.replace('.','/')+".ser");
}
if(serStream != null) {
if(cl == null) {
ObjectInputStream ois = new ObjectInputStream(serStream);
bean = ois.readObject();
} else {
ClassLoaderObjectInputStream ois = new ClassLoaderObjectInputStream(serStream, cl);
bean = ois.readObject();
}
} else if(cl == null) {
Class beanClass = Class.forName(beanName);
try {
bean = beanClass.newInstance();
} catch(IllegalAccessException E) {
bean = null;
} catch(InstantiationException E) {
bean = null;
}
} else {
Class beanClass = cl.loadClass(beanName);
try {
bean = beanClass.newInstance();
} catch(IllegalAccessException E) {
bean = null;
} catch(InstantiationException E) {
bean = null;
}
}
/* FIXME - Turned off since java.applet doesn't exist for libgcj.
* FIXME if(bean instanceof Applet) {
* FIXME Applet a = (Applet)bean;
* FIXME //a.setAppletContext(???);
* FIXME //a.setStub(???);
* FIXME if(serStream == null) {
* FIXME a.init();
* FIXME }
* FIXME }
* FIXME ********************************************************/
return bean;
}
/**
* Get the Bean as a different class type.
* This should be used instead of casting to get a new
* type view of a Bean, because in the future there may
* be new types of Bean, even Beans spanning multiple
* Objects.
* @param bean the Bean to cast.
* @param newClass the Class to cast it to.
* @return the Bean as a new view, or if the operation
* could not be performed, the Bean itself.
*/
public static Object getInstanceOf(Object bean, Class newClass) {
return bean;
}
/**
* Determine whether the Bean can be cast to a different
* class type.
* This should be used instead of instanceof to determine
* a Bean's castability, because in the future there may
* be new types of Bean, even Beans spanning multiple
* Objects.
* @param bean the Bean to cast.
* @param newClass the Class to cast it to.
* @return whether the Bean can be cast to the class type
* in question.
*/
public static boolean isInstanceOf(Object bean, Class newBeanClass) {
return newBeanClass.isInstance(bean);
}
/**
* Find out whether the GUI is available to use.
* Defaults to true.
* @return whether the GUI is available to use.
*/
public static boolean isGuiAvailable() {
return guiAvailable;
}
/**
* Find out whether it is design time. Design time means
* we are in a RAD tool.
* Defaults to false.
* @return whether it is design time.
*/
public static boolean isDesignTime() {
return designTime;
}
/**
* Set whether the GUI is available to use.
* @param guiAvailable whether the GUI is available to use.
*/
public static void setGuiAvailable(boolean guiAvailable) throws SecurityException {
Beans.guiAvailable = guiAvailable;
}
/**
* Set whether it is design time. Design time means we
* are in a RAD tool.
* @param designTime whether it is design time.
*/
public static void setDesignTime(boolean designTime) throws SecurityException {
Beans.designTime = designTime;
}
}
/* java.beans.Customizer
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 java.beans;
/**
** You may explicitly provide a Customizer for your Bean
** class, which allows you complete control of the editing
** of the Bean.<P>
**
** A Customizer is meant to be embedded in an RAD tool,
** and thus must be a descendant of <CODE>java.awt.Component</CODE>.<P>
**
** It must also have a constructor with no arguments. This
** is the constructor that will be called by the RAD tool to
** instantiate the Customizer.<P>
**
** Over its lifetime, an instance of a Customizer will only
** customize one single Bean. A new instance of the
** Customizer will be instantiated to edit any other Beans.<P>
**
** The Customizer is responsible for notifying its
** PropertyChangeListeners of any changes that are made,
** according to the rules of PropertyChangeListeners (i.e.
** notify the clients <EM>after</EM> the property has
** changed).
**
** @author John Keiser
** @since JDK1.1
** @version 1.1.0, 29 Jul 1998
** @see java.beans.BeanDescriptor.getCustomizerClass()
**/
public interface Customizer {
/** Set the object to Customize. This will always be a
** Bean that had a BeanDescriptor indicating this
** Customizer.
** @param bean the Bean to customize.
**/
public abstract void setObject(Object bean);
/** Add a PropertyChangeListener.
** @param l the PropertyChangeListener to add.
**/
public abstract void addPropertyChangeListener(PropertyChangeListener l);
/** Remove a PropertyChangeListener.
** @param l the PropertyChangeListener to remove.
**/
public abstract void removePropertyChangeListener(PropertyChangeListener l);
}
/* java.beans.DesignMode
Copyright (C) 1999 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 java.beans;
/**
* <code>BeanContextChild</code> implementors implement this to get information about whether they are in a design time or runtime environment.
* The reason this is restricted to <code>BeanContextChild</code>ren is that
* only things in the <code>BeanContext</code> hierarchy are given this
* information in the first place.
*
* @author John Keiser
* @since JDK1.2
* @see java.beans.beancontext.BeanContextChild
*/
public interface DesignMode {
/**
* Use this name when firing <code>PropertyChangeEvent</code>s from your Bean.
* @fixme Check whether PROPERTYNAME is set to same value as Sun.
*/
public static final String PROPERTYNAME = "designTime";
/**
* The environment will call this method on your
* <code>BeanContextChild</code> when it is registered in a parent
* <code>BeanContext</code> or when behavior needs to switch from
* design time to runtime behavior (or vice versa).
* <P>
*
* <code>BeanContext</code>s are required to fire
* <code>PropertyChangeEvent</code>s when properties change.
* <code>designTime</code> is a property, and therefore when you
* implement <code>setDesignTime()</code>, you need to fire a
* <code>PropertyChangeEvent</code> with the old value, the new
* value and using <code>PROPERTYNAME</code> as the property name.
*
* @param designTime the new value of design time,
* <code>true</code> if it is design time,
* <code>false</code> if it is runtime.
*
* @fixme I'm frankly not really sure whether it's the case that
* the BeanContext can <em>change</em> the status of the Bean from
* design time to runtime. But it appears that it may be so.
*
* @see java.util.PropertyChangeEvent
* @see java.beans.beancontext.BeanContext
* @see #PROPERTYNAME
*/
public void setDesignTime(boolean designTime);
/**
* This method should tell whether it is design time or runtime.
* @return <code>true</code> if design time, <code>false</code> if
* runtime.
*/
public boolean isDesignTime();
}
/* java.beans.FeatureDescriptor
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 java.beans;
import java.util.*;
/**
** FeatureDescriptor is the common superclass for all JavaBeans Descriptor classes.
** JavaBeans descriptors are abstract descriptors of properties,
** events, methods, beans, etc.<P>
**
** <STRONG>Documentation Convention:</STRONG> for proper
** Internalization of Beans inside an RAD tool, sometimes there
** are two names for a property or method: a programmatic, or
** locale-independent name, which can be used anywhere, and a
** localized, display name, for ease of use. In the
** documentation I will specify different String values as
** either <EM>programmatic</EM> or <EM>localized</EM> to
** make this distinction clear.
**
** @author John Keiser
** @since JDK1.1
** @version 1.1.0, 31 May 1998
**/
public class FeatureDescriptor {
String name;
String displayName;
String shortDescription;
boolean expert;
boolean hidden;
Hashtable valueHash;
/** Instantiate this FeatureDescriptor with appropriate default values.**/
public FeatureDescriptor() {
valueHash = new Hashtable();
}
/** Get the programmatic name of this feature. **/
public String getName() {
return name;
}
/** Set the programmatic name of this feature.
** @param name the new name for this feature.
**/
public void setName(String name) {
this.name = name;
}
/** Get the localized (display) name of this feature. **/
public String getDisplayName() {
return displayName;
}
/** Set the localized (display) name of this feature.
** @param displayName the new display name for this feature.
**/
public void setDisplayName(String displayName) {
this.displayName = displayName;
}
/** Get the localized short description for this feature. **/
public String getShortDescription() {
return shortDescription;
}
/** Set the localized short description for this feature.
** @param shortDescription the new short description for this feature.
**/
public void setShortDescription(String shortDescription) {
this.shortDescription = shortDescription;
}
/** Indicates whether this feature is for expert use only.
** @return true if for use by experts only, or false if anyone can use it.
**/
public boolean isExpert() {
return expert;
}
/** Set whether this feature is for expert use only.
** @param expert true if for use by experts only, or false if anyone can use it.
**/
public void setExpert(boolean expert) {
this.expert = expert;
}
/** Indicates whether this feature is for use by tools only.
** If it is for use by tools only, then it should not be displayed.
** @return true if tools only should use it, or false if anyone can see it.
**/
public boolean isHidden() {
return hidden;
}
/** Set whether this feature is for use by tools only.
** If it is for use by tools only, then it should not be displayed.
** @param hidden true if tools only should use it, or false if anyone can see it.
**/
public void setHidden(boolean hidden) {
this.hidden = hidden;
}
/** Get an arbitrary value set with setValue().
** @param name the programmatic name of the key.
** @return the value associated with this name, or null if there is none.
**/
public Object getValue(String name) {
return valueHash.get(name);
}
/** Set an arbitrary string-value pair with this feature.
** @param name the programmatic name of the key.
** @param value the value to associate with the name.
**/
public void setValue(String name, Object value) {
valueHash.put(name, value);
}
/** Get a list of the programmatic key names set with setValue().
** @return an Enumerator over all the programmatic key names associated
** with this feature.
**/
public Enumeration attributeNames() {
return valueHash.keys();
}
}
/* java.beans.IntrospectionException
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 java.beans;
/**
** IntrospectionException is thrown when the Introspector fails. Surprise, surprise.
**
** @author John Keiser
** @since JDK1.1
** @version 1.1.0, 31 May 1998
** @see java.beans.Introspector
**/
public class IntrospectionException extends Exception {
/** Instantiate this exception with the given message.
** @param msg the message for the exception.
**/
public IntrospectionException(String msg) {
super(msg);
}
}
/* java.beans.MethodDescriptor
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 java.beans;
import java.lang.reflect.*;
/** MethodDescriptor describes information about a JavaBeans method.
** It's a fairly straightforward class (at least something in this
** package is straightforward!).
**
** @author John Keiser
** @since JDK1.1
** @version 1.1.0, 26 Jul 1998
**/
public class MethodDescriptor extends FeatureDescriptor {
private Method m;
private ParameterDescriptor[] parameterDescriptors;
/** Create a new MethodDescriptor.
** This method sets the name to the name of the method (Method.getName()).
** @param m the method it will represent.
**/
public MethodDescriptor(Method m) {
setName(m.getName());
this.m = m;
}
/** Create a new MethodDescriptor.
** This method sets the name to the name of the method (Method.getName()).
** @param m the method it will represent.
** @param parameterDescriptors descriptions of the parameters (especially names).
**/
public MethodDescriptor(Method m, ParameterDescriptor[] parameterDescriptors) {
setName(m.getName());
this.m = m;
this.parameterDescriptors = parameterDescriptors;
}
/** Get the parameter descriptors from this method.
** Since MethodDescriptor has no way of determining what
** the parameter names were, this defaults to null.
**/
public ParameterDescriptor[] getParameterDescriptors() {
return parameterDescriptors;
}
/** Get the method this MethodDescriptor represents. **/
public Method getMethod() {
return m;
}
}
/* java.beans.MethodDescriptor
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 java.beans;
/** ParameterDescriptor represents a single parameter to a method.
** As it turns out, FeatureDescriptor is sufficient to hold all
** the information. Use its constructor and methods to set
** the appropriate values.
**
** @author John Keiser
** @since JDK1.1
** @version 1.1.0, 26 Jul 1998
**/
public class ParameterDescriptor extends FeatureDescriptor {
}
/* java.beans.PropertyChangeEvent
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 java.beans;
/**
** PropertyChangeEvents are fired in the PropertyChange
** and VetoableChange event classes. They represent the
** old and new values as well as the source Bean.<P>
**
** If the old or new value is a primitive type, it must
** be wrapped in the appropriate wrapper type
** (java.lang.Integer for int, etc., etc.).<P>
**
** If the old or new values are unknown (although why
** that would be I do not know), they may be null.<P>
**
** Right now Sun put in a propagationId, reserved for
** future use. Read the comments on the constructor
** and on setPropagationId for more information.
**
** @author John Keiser
** @since JDK1.1
** @version 1.1.0, 29 Jul 1998
**/
public class PropertyChangeEvent extends java.util.EventObject {
String propertyName;
Object oldVal;
Object newVal;
Object propagationId;
/** Create a new PropertyChangeEvent. Remember that if
** you received a PropertyChangeEvent and are sending
** a new one, you should also set the propagation ID
** from the old PropertyChangeEvent.
** @param source the Bean containing the property.
** @param propertyName the property's name.
** @param oldVal the old value of the property.
** @param newVal the new value of the property.
**/
public PropertyChangeEvent(Object source, String propertyName, Object oldVal, Object newVal) {
super(source);
this.propertyName = propertyName;
this.oldVal = oldVal;
this.newVal = newVal;
}
/** Get the property name.
** @return the property name.
**/
public String getPropertyName() {
return propertyName;
}
/** Get the property's old value.
** @return the property's old value.
**/
public Object getOldValue() {
return oldVal;
}
/** Get the property's new value.
** @return the property's new value.
**/
public Object getNewValue() {
return newVal;
}
/** Set the propagation ID. This is a way for the event
** to be passed from hand to hand and retain a little
** extra state. Right now it is unused, but it should
** be propagated anyway so that future versions of
** JavaBeans can use it, for God knows what.
** @param propagationId the propagation ID.
**/
public void setPropagationId(Object propagationId) {
this.propagationId = propagationId;
}
/** Get the propagation ID.
** @return the propagation ID.
**/
public Object getPropagationId() {
return propagationId;
}
}
/* java.beans.PropertyChangeListener
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 java.beans;
/**
** PropertyChangeListener allows a class to monitor
** properties of a Bean for changes.<P>
**
** A propertyChange() event will only be fired
** <EM>after</EM> the property has changed.
**
** @author John Keiser
** @since JDK1.1
** @version 1.1.0, 29 Jul 1998
** @see java.beans.PropertyChangeSupport
**/
public interface PropertyChangeListener {
/** Fired after a Bean's property has changed.
** @param e the change (containing the old and new values)
**/
public abstract void propertyChange(PropertyChangeEvent e);
}
/* java.beans.PropertyChangeSupport
Copyright (C) 1998, 1999 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 java.beans;
import java.util.Hashtable;
import java.util.Vector;
/**
** PropertyChangeSupport makes it easy to fire property
** change events and handle listeners.
**
** @author John Keiser
** @since JDK1.1
** @version 1.2.0, 15 Mar 1999
**/
public class PropertyChangeSupport implements java.io.Serializable {
Hashtable propertyListeners = new Hashtable();
Vector listeners = new Vector();
Object bean;
/** Create PropertyChangeSupport to work with a specific
** source bean.
** @param bean the source bean to use.
**/
public PropertyChangeSupport(Object bean) {
this.bean = bean;
}
/** Adds a PropertyChangeListener to the list of listeners.
** All property change events will be sent to this listener.
** <P>
**
** The listener add is not unique: that is, <em>n</em> adds with
** the same listener will result in <em>n</em> events being sent
** to that listener for every property change.
** <P>
**
** Adding a null listener will cause undefined behavior.
**
** @param l the listener to add.
**/
public void addPropertyChangeListener(PropertyChangeListener l) {
listeners.addElement(l);
}
/** Adds a PropertyChangeListener listening on the specified property.
** Events will be sent to the listener for that particular property.
** <P>
**
** The listener add is not unique; that is, <em>n</em> adds on a
** particular property for a particular listener will result in
** <em>n</em> events being sent to that listener when that
** property is changed.
** <P>
**
** The effect is cumulative, too; if you are registered to listen
** to receive events on all property changes, and then you
** register on a particular property, you will receive change
** events for that property twice.
** <P>
**
** Adding a null listener will cause undefined behavior.
**
** @param propertyName the name of the property to listen on.
** @param l the listener to add.
**/
public void addPropertyChangeListener(String propertyName, PropertyChangeListener l) {
synchronized(propertyListeners) {
Vector v = (Vector)propertyListeners.get(propertyName);
try {
v.addElement(l);
} catch(NullPointerException e) {
/* If v is not found, create a new vector. */
v = new Vector();
v.addElement(l);
propertyListeners.put(propertyName, v);
}
}
}
/** Removes a PropertyChangeListener from the list of listeners.
** If any specific properties are being listened on, they must
** be deregistered by themselves; this will only remove the
** general listener to all properties.
** <P>
**
** If <code>add()</code> has been called multiple times for a
** particular listener, <code>remove()</code> will have to be
** called the same number of times to deregister it.
**
** @param l the listener to remove.
**/
public void removePropertyChangeListener(PropertyChangeListener l) {
listeners.removeElement(l);
}
/** Removes a PropertyChangeListener from listening to a specific property.
** <P>
**
** If <code>add()</code> has been called multiple times for a
** particular listener on a property, <code>remove()</code> will
** have to be called the same number of times to deregister it.
**
** @param propertyName the property to stop listening on.
** @param l the listener to remove.
**/
public void removePropertyChangeListener(String propertyName, PropertyChangeListener l) {
synchronized(propertyListeners) {
Vector v = (Vector)propertyListeners.get(propertyName);
try {
v.removeElement(l);
if(v.size() == 0) {
propertyListeners.remove(propertyName);
}
} catch(NullPointerException e) {
/* if v is not found, do nothing. */
}
}
}
/** Fire a PropertyChangeEvent to all the listeners.
**
** @param event the event to fire.
**/
public void firePropertyChange(PropertyChangeEvent event) {
for(int i=0;i<listeners.size();i++) {
((PropertyChangeListener)listeners.elementAt(i)).propertyChange(event);
}
Vector moreListeners = (Vector)propertyListeners.get(event.getPropertyName());
if(moreListeners != null) {
for(int i=0;i<moreListeners.size();i++) {
((PropertyChangeListener)moreListeners.elementAt(i)).propertyChange(event);
}
}
}
/** Fire a PropertyChangeEvent containing the old and new values of the property to all the listeners.
**
** @param propertyName the name of the property that changed.
** @param oldVal the old value.
** @param newVal the new value.
**/
public void firePropertyChange(String propertyName, Object oldVal, Object newVal) {
firePropertyChange(new PropertyChangeEvent(bean,propertyName,oldVal,newVal));
}
/** Fire a PropertyChangeEvent containing the old and new values of the property to all the listeners.
**
** @param propertyName the name of the property that changed.
** @param oldVal the old value.
** @param newVal the new value.
**/
public void firePropertyChange(String propertyName, boolean oldVal, boolean newVal) {
firePropertyChange(new PropertyChangeEvent(bean, propertyName, new Boolean(oldVal), new Boolean(newVal)));
}
/** Fire a PropertyChangeEvent containing the old and new values of the property to all the listeners.
**
** @param propertyName the name of the property that changed.
** @param oldVal the old value.
** @param newVal the new value.
**/
public void firePropertyChange(String propertyName, int oldVal, int newVal) {
firePropertyChange(new PropertyChangeEvent(bean, propertyName, new Integer(oldVal), new Integer(newVal)));
}
/** Tell whether the specified property is being listened on or not.
** This will only return <code>true</code> if there are listeners
** on all properties or if there is a listener specifically on this
** property.
**
** @param propertyName the property that may be listened on
** @return whether the property is being listened on
**/
public boolean hasListeners(String propertyName) {
return listeners.size() > 0 || propertyListeners.get(propertyName) != null;
}
}
/* java.beans.PropertyEditor
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 java.beans;
/**
** PropertyEditors are custom GUI editors for specific types of values.
**
** A PropertyEditor can be used, for example, if you are editing a type of value
** that can be more easily represented graphically, such as a Point, or one that
** can be more easily represented by a list, such as a boolean (true/false).<P>
**
** A PropertyEditor must be able to display its contents when asked to and
** be able to allow the user to change its underlying field value. However, it
** is not the PropertyEditor's responsibility to make the change to the
** underlying Object; in fact, the PropertyEditor does not even know about the
** Object it is actually editing--only about the property it is currently
** editing. When a change is made to the property, the PropertyEditor must
** simply fire a PropertyChangeEvent and allow the RAD tool to actually set
** the property in the underlying Bean.<P>
**
** PropertyEditors should not change the Objects they are given by setValue().
** These Objects may or may not be the actual Objects which are properties of
** the Bean being edited. Instead, PropertyEditors should create a new Object
** and fire a PropertyChangeEvent with the old and new values.<P>
**
** PropertyEditors also must support the ability to return a Java
** initialization string. See the getJavaInitializationString() method for
** details.<P>
**
** There are several different ways a PropertyEditor may display and control
** editing of its value. When multiple types of input and display are
** given by a single PropertyEditor, the RAD tool may decide which of the call
** to support. Some RAD tools may even be text-only, so even if you support
** a graphical set and get, it may choose the text set and get whenever it can.
** <OL>
** <LI>Every PropertyEditor must support getValue() and setValue(). For
** setValue(), the component must only support it when the argument is
** the same type that the PropertyEditor supports.</LI>
** <LI>Every PropertyEditor must support getJavaInitializationString().</LI>
** <LI>You may support painting the value yourself if you wish. To do this,
** have isPaintable() return true and implement the paintValue() method.
** This method does not determine in any way how the value is edited;
** merely how it is displayed.</LI>
** <LU>Let the caller of the PropertyEditor give the user a text input. Do
** this by returning a non-null String from getAsText(). If you support
** text input, you *must* support setAsText().</LI>
** <LI>Give the caller a set of possible values, such as "true"/"false", that
** the user must select from. To do this, return the list of Strings
** from the getTags() method. The RAD tool may choose to implement the
** user input any way it wishes, and only guarantees that setAsText() will
** only be called with one of the Strings returned from getTags().</LI>
** <LI>You may support a whole custom editing control by supporting
** getCustomEditor(). To do this, return true from supportsCustomEditor()
** and return a Component that does the job. It is the component's job,
** or the PropertyEditor's job, to make sure that when the editor changes
** its value, the PropertyChangeEvent is thrown.</LI>
** </OL>
**
** The PropertyEditor for a particular Bean can be found using the
** PropertyEditorManager class, which goes through a series of different
** checks to find the appropriate class.<P>
**
** A PropertyChangeEvent should be thrown from the PropertyEditor whenever a
** bound property (a property PropertyDescriptor.isBound() set to true)
** changes. When this happens, the editor itself should *not* change the value
** itself, but rather allow the RAD tool to call setValue() or setAsText().
**
** @author John Keiser
** @since JDK1.1
** @version 1.1.0, 30 June 1998
** @see java.beans.PropertyEditorManager
** @see java.beans.PropertyEditorSupport
**/
public interface PropertyEditor {
/** Called by the RAD tool to set the value of this property for the PropertyEditor.
** If the property type is native, it should be wrapped in the appropriate
** wrapper type.
** @param value the value to set this property to.
**/
public abstract void setValue(Object value);
/** Accessor method to get the current value the PropertyEditor is working with.
** If the property type is native, it will be wrapped in the appropriate
** wrapper type.
** @return the current value of the PropertyEditor.
**/
public abstract Object getValue();
/** Set the value of this property using a String.
** Whether or not this PropertyEditor is editing a String type, this converts
** the String into the type of the PropertyEditor.
** @param text the text to set it to.
** @exception IllegalArgumentException if the String is in the wrong format or setAsText() is not supported.
**/
public abstract void setAsText(String text) throws IllegalArgumentException;
/** Get the value of this property in String format.
** Many times this can simply use Object.toString().<P>
** Return null if you do not support getAsText()/setAsText().
** <code>setAsText(getAsText())</code> should be valid; i.e. the stuff you spit out in
** getAsText() should be able to go into setAsText().
** @return the value of this property in String format.
**/
public abstract String getAsText();
/** Get a list of possible Strings which this property type can have.
** The value of these will be used by the RAD tool to construct some sort
** of list box or to check text box input, and the resulting String passed
** to setAsText() should be one of these. Note, however, that like most things
** with this mammoth, unwieldy interface, this is not guaranteed. Thus, you
** must check the value in setAsText() anyway.
** @return the list of possible String values for this property type.
**/
public abstract String[] getTags();
/** The RAD tool calls this to find out whether the PropertyEditor can paint itself.
** @return true if it can paint itself graphically, false if it cannot.
**/
public abstract boolean isPaintable();
/** The RAD tool calls this to paint the actual value of the property.
** The Graphics context will have the same current font, color, etc. as the
** parent Container. You may safely change the font, color, etc. and not
** change them back.<P>
** This method should do a silent no-op if isPaintable() is false.
** @param g the Graphics context to paint on
** @param bounds the rectangle you have reserved to work in
**/
public abstract void paintValue(java.awt.Graphics g, java.awt.Rectangle bounds);
/** The RAD tool calls this to find out whether the PropertyEditor supports a custom component to edit and display itself.
** @return true if getCustomEditor() will return a component, false if not.
**/
public abstract boolean supportsCustomEditor();
/** The RAD tool calls this to grab the component that can edit this type.
** The component may be painted anywhere the RAD tool wants to paint it--
** even in its own window.<P>
** The component must hook up with the PropertyEditor and, whenever a
** change to the value is made, fire a PropertyChangeEvent to the source.<P>
** @return the custom editor for this property type.
**/
public abstract java.awt.Component getCustomEditor();
/** Adds a property change listener to this PropertyEditor.
** @param listener the listener to add
**/
public abstract void addPropertyChangeListener(PropertyChangeListener listener);
/** Removes a property change listener from this PropertyEditor.
** @param listener the listener to remove
**/
public abstract void removePropertyChangeListener(PropertyChangeListener listener);
/** Get a Java language-specific String which could be used to create an Object
** of the specified type. Every PropertyEditor must support this.<P>
** The reason for this is that while most RAD tools will serialize the Beans
** and deserialize them at runtime, some RAD tools will generate code that
** creates the Beans. Examples of Java initialization strings would be:<P>
** <OL>
** <LI><CODE>2</CODE></LI>
** <LI><CODE>"I am a String"</CODE></LI>
** <LI><CODE>new MyObject(2, "String", new StringBuffer())</CODE></LI>
** </OL>
** @return the initialization string for this object in Java.
**/
public abstract String getJavaInitializationString();
}
/* java.beans.PropertyEditorManager
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 java.beans;
import gnu.java.lang.ClassHelper;
/**
** PropertyEditorManager is used to find property editors
** for various types (not necessarily Beans).<P>
**
** It first checks to see if the property editor is
** already registered; if it is, that property editor is
** used. Next it takes the type's classname and appends
** "Editor" to it, and searches first in the class's
** package and then in the property editor search path.<P>
**
** Default property editors are provided for:<P>
** <OL>
** <LI>boolean, byte, short, int, long, float, and double</LI>
** <LI>java.lang.String</LI>
** <LI>java.awt.Color</LI>
** <LI>java.awt.Font</LI>
** <OL>
**
** <STRONG>Spec Suggestion:</STRONG> Perhaps an editor for
** Filename or something like it should be provided. As well
** as char.
**
** @author John Keiser
** @since JDK1.1
** @version 1.1.0, 29 Jul 1998
**/
public class PropertyEditorManager {
static java.util.Hashtable editors = new java.util.Hashtable();
static String[] editorSearchPath = {"gnu.java.beans.editors","sun.beans.editors"};
static {
registerEditor(java.lang.Boolean.TYPE, gnu.java.beans.editors.NativeBooleanEditor.class);
registerEditor(java.lang.Byte.TYPE, gnu.java.beans.editors.NativeByteEditor.class);
registerEditor(java.lang.Short.TYPE, gnu.java.beans.editors.NativeShortEditor.class);
registerEditor(java.lang.Integer.TYPE, gnu.java.beans.editors.NativeIntEditor.class);
registerEditor(java.lang.Long.TYPE, gnu.java.beans.editors.NativeLongEditor.class);
registerEditor(java.lang.Float.TYPE, gnu.java.beans.editors.NativeFloatEditor.class);
registerEditor(java.lang.Double.TYPE, gnu.java.beans.editors.NativeDoubleEditor.class);
registerEditor(java.lang.String.class, gnu.java.beans.editors.StringEditor.class);
registerEditor(java.awt.Color.class, gnu.java.beans.editors.ColorEditor.class);
registerEditor(java.awt.Font.class, gnu.java.beans.editors.FontEditor.class);
}
/** Beats me why this class can be instantiated, but there
** you have it.
**/
public PropertyEditorManager() { }
/** Register an editor for a class. Replaces old editor
** if there was one registered before.
** @param editedClass the class that the property editor
** will edit.
** @param editorClass the PropertyEditor class.
**/
public static void registerEditor(Class editedClass, Class editorClass) {
editors.put(editedClass, editorClass);
}
/** Returns a new instance of the property editor for the
** specified class.
** @param editedClass the class that the property editor
** will edit.
** @return a PropertyEditor instance that can edit the
** specified class.
**/
public static PropertyEditor findEditor(Class editedClass) {
try {
Class found = (Class)editors.get(editedClass);
if(found != null) {
return (PropertyEditor)found.newInstance();
}
try {
found = Class.forName(editedClass.getName()+"Editor");
registerEditor(editedClass,found);
return (PropertyEditor)found.newInstance();
} catch(ClassNotFoundException E) {
}
String appendName = "." + ClassHelper.getTruncatedClassName(editedClass) + "Editor";
synchronized(editorSearchPath) {
for(int i=0;i<editorSearchPath.length;i++) {
try {
found = Class.forName(editorSearchPath[i] + appendName);
registerEditor(editedClass,found);
return (PropertyEditor)found.newInstance();
} catch(ClassNotFoundException E) {
}
}
}
} catch(InstantiationException E) {
} catch(IllegalAccessException E) {
}
return null;
}
/** Get the editor search path.
** As a minor departure from the spec, the default value
** for the editor search path is "gnu.java.beans.editors",
** "sun.beans.editors".
** @return the editor search path.
**/
public static String[] getEditorSearchPath() {
return editorSearchPath;
}
/** Set the editor search path.
** @param editorSearchPath the new value for the editor
** search path.
**/
public static void setEditorSearchPath(String[] editorSearchPath) {
synchronized(editorSearchPath) {
PropertyEditorManager.editorSearchPath = editorSearchPath;
}
}
}
/* java.beans.PropertyEditorSupport
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 java.beans;
/**
** PropertyEditorSupport helps with PropertyEditors,
** implementing base functionality that they usually must
** have but which is a pain to implement. You may extend
** from this class or use it as a standalone.<P>
**
** This class does not do any painting or actual editing.
** For that, you must use or extend it. See the
** PropertyEditor class for better descriptions of what
** the various methods do.
**
** @author John Keiser
** @since JDK1.1
** @version 1.1.0, 29 Jul 1998
**/
public class PropertyEditorSupport implements PropertyEditor {
Object eventSource;
Object val;
PropertyChangeSupport pSupport;
/** Call this constructor when you are deriving from
** PropertyEditorSupport.
**/
protected PropertyEditorSupport() {
this.eventSource = this;
this.pSupport = new PropertyChangeSupport(this);
}
/** Call this constructor when you are using
** PropertyEditorSupport as a helper object.
** @param eventSource the source to use when firing
** property change events.
**/
protected PropertyEditorSupport(Object eventSource) {
this.eventSource = eventSource;
this.pSupport = new PropertyChangeSupport(this);
}
/** Set the current value of the property.
** <STRONG>Implementation Note</STRONG> Sun does not
** state what exactly this version of the method does.
** Thus, in this implementation, it sets the value, and
** then if the old and new values are different, it
** fires a property change event with no property name
** and the old and new values.
** @param val the new value for the property.
**/
public void setValue(Object val) {
Object oldVal = val;
this.val = val;
if(!oldVal.equals(val)) {
pSupport.firePropertyChange(null,oldVal,val);
}
}
/** Get the current value of the property.
** @return the current value of the property.
**/
public Object getValue() {
return val;
}
/** Get whether this object is paintable or not.
** @return <CODE>false</CODE>
**/
public boolean isPaintable() {
return false;
}
/** Paint this object. This class does nothing in
** this method.
**/
public void paintValue(java.awt.Graphics g, java.awt.Rectangle r) {
}
/** Get the Java initialization String for the current
** value of the Object. This class returns gibberish or
** null (though the spec does not say which).<P>
** <STRONG>Implementation Note:</STRONG> This class
** returns the string "@$#^" to make sure the code will
** be broken, so that you will know to override it when
** you create your own property editor.
** @return the Java initialization string.
**/
public String getJavaInitializationString() {
return "@$#^";
}
/** Get the value as text.
** In this class, you cannot count on getAsText() doing
** anything useful, although in this implementation I
** do toString().
** @return the value as text.
**/
public String getAsText() {
return val != null ? val.toString() : "null";
}
/** Set the value as text.
** In this class, you cannot count on setAsText() doing
** anything useful across implementations.
** <STRONG>Implementation Note:</STRONG> In this
** implementation it checks if the String is "null", and
** if it is, sets the value to null, otherwise it throws
** an IllegalArgumentException.
** @param s the text to convert to a new value.
** @exception IllegalArgumentException if the text is
** malformed.
**/
public void setAsText(String s) throws IllegalArgumentException {
if(s.equals("null")) {
setValue(null);
} else {
throw new IllegalArgumentException();
}
}
/** Returns a list of possible choices for the value.
** @return <CODE>null</CODE>
**/
public String[] getTags() {
return null;
}
/** Return a custom component to edit the value.
** @return <CODE>null</CODE> in this class.
**/
public java.awt.Component getCustomEditor() {
return null;
}
/** Find out whether this property editor supports a
** custom component to edit its value.
** @return <CODE>false</CODE> in this class.
**/
public boolean supportsCustomEditor() {
return false;
}
/** Add a property change listener to this property editor.
** @param l the listener to add.
**/
public void addPropertyChangeListener(PropertyChangeListener l) {
pSupport.addPropertyChangeListener(l);
}
/** Remove a property change listener from this property editor.
** @param l the listener to remove.
**/
public void removePropertyChangeListener(PropertyChangeListener l) {
pSupport.removePropertyChangeListener(l);
}
/** Notify people that we've changed, although we don't
** tell them just how. The only thing I can think of to
** send in the event is the new value (since the old value
** is unavailable and there is no property name).
** I confess I do not understand the point of this method.
**/
public void firePropertyChange() {
pSupport.firePropertyChange(null,null,val);
}
}
/* java.beans.PropertyVetoException
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 java.beans;
/**
** PropertyVetoException is thrown when a VetoableChangeListener doesn't like the proposed change.
**
** @author John Keiser
** @since JDK1.1
** @version 1.1.0, 31 May 1998
** @see java.beans.VetoableChangeListener
**/
public class PropertyVetoException extends Exception {
PropertyChangeEvent changeEvent;
/** Instantiate this exception with the given message and property change.
** @param msg the reason for the veto.
** @param changeEvent the PropertyChangeEvent that was thrown.
**/
public PropertyVetoException(String msg, PropertyChangeEvent changeEvent) {
super(msg);
this.changeEvent = changeEvent;
}
/** Get the PropertyChange event that was vetoed. **/
public PropertyChangeEvent getPropertyChangeEvent() {
return changeEvent;
}
}
/* java.beans.SimpleBeanInfo
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 java.beans;
import java.awt.*;
/**
** SimpleBeanInfo is a class you may extend to more easily
** provide select information to the Introspector. It
** implements all of the methods in BeanInfo by returning
** null and forces the Introspector to behave exactly as
** if there were no BeanInfo class at all (Introspecting
** everything).<P>
**
** Overriding one or two of these functions
** to give explicit information on only those things you
** wish to give explicit information is perfectly safe,
** and even desirable.<P>
**
** See the BeanInfo class for information on what the
** various methods actually do.
**
** @author John Keiser
** @since JDK1.1
** @version 1.1.0, 29 Jul 1998
** @see java.beans.BeanInfo
**/
public class SimpleBeanInfo implements BeanInfo {
/** Force Introspection of the general bean info.
** @return <CODE>null</CODE>.
**/
public BeanDescriptor getBeanDescriptor() {
return null;
}
/** Force Introspection of the events this Bean type
** fires.
** @return <CODE>null</CODE>
**/
public EventSetDescriptor[] getEventSetDescriptors() {
return null;
}
/** Say that there is no "default" event set.
** @return <CODE>-1</CODE>.
**/
public int getDefaultEventIndex() {
return -1;
}
/** Force Introspection of the Bean properties.
** @return <CODE>null</CODE>.
**/
public PropertyDescriptor[] getPropertyDescriptors() {
return null;
}
/** Say that there is no "default" property.
** @return <CODE>-1</CODE>.
**/
public int getDefaultPropertyIndex() {
return -1;
}
/** Force Introspection of the Bean's methods.
** @return <CODE>null</CODE>.
**/
public MethodDescriptor[] getMethodDescriptors() {
return null;
}
/** Tell the Introspector to go look for other BeanInfo
** itself.
** @return <CODE>null</CODE>.
**/
public BeanInfo[] getAdditionalBeanInfo() {
return null;
}
/** Say that this Bean has no icons.
** @param iconType the type of icon
** @return <CODE>null</CODE>.
**/
public Image getIcon(int iconType) {
return null;
}
/** Helper method to load an image using the Bean class
** getResource() method on the BeanInfo class (using
** getClass(), since you'll extend this class to get
** the BeanInfo). Basically it's assumed that the Bean
** and its BeanInfo are both loaded by the same
** ClassLoader, generally a reasonable assumption.
** @param location the URL relative
** @return the Image in question.
**/
public Image loadImage(String location) {
return Toolkit.getDefaultToolkit().getImage(getClass().getResource(location));
}
}
/* java.beans.VetoableChangeListener
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 java.beans;
/**
** VetoableChangeListener allows a class to monitor
** proposed changes to properties of a Bean and, if
** desired, prevent them from occurring.<P>
**
** A vetoableChange() event will be fired <EM>before</EM>
** the property has changed. If any listener rejects the
** change by throwing the PropertyChangeException, a new
** vetoableChange() event will be fired to all listeners
** who received a vetoableChange() event in the first
** place informing them of a reversion to the old value.
** The value, of course, never actually changed.<P>
**
** <STRONG>Note:</STRONG> This class may not be reliably
** used to determine whether a property has actually
** changed. Use the PropertyChangeListener interface
** for that instead.
**
** @author John Keiser
** @version 1.1.0, 29 Jul 1998
** @since JDK1.1
** @see java.beans.PropertyChangeListener
** @see java.beans.VetoableChangeSupport
**/
public interface VetoableChangeListener {
/** Fired before a Bean's property changes.
** @param e the change (containing the old and new values)
** @exception PropertyChangeException if the listener
** does not desire the change to be made.
**/
public abstract void vetoableChange(PropertyChangeEvent e) throws PropertyVetoException;
}
/*
* java.beans.VetoableChangeSupport: part of the Java Class Libraries project.
* Copyright (C) 1998 Free Software Foundation
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library 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
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
package java.beans;
import java.util.Hashtable;
import java.util.Vector;
/**
** VetoableChangeSupport makes it easy to fire vetoable
** change events and handle listeners as well as reversion
** of old values when things go wrong.
**
** @author John Keiser
** @since JDK1.1
** @version 1.2.0, 15 Mar 1998
**/
public class VetoableChangeSupport implements java.io.Serializable {
Hashtable propertyListeners = new Hashtable();
Vector listeners = new Vector();
Object bean;
/** Create VetoableChangeSupport to work with a specific
** source bean.
** @param bean the source bean to use.
**/
public VetoableChangeSupport(Object bean) {
this.bean = bean;
}
/** Adds a VetoableChangeListener to the list of listeners.
** All property change events will be sent to this listener.
** <P>
**
** The listener add is not unique: that is, <em>n</em> adds with
** the same listener will result in <em>n</em> events being sent
** to that listener for every property change.
** <P>
**
** Adding a null listener will cause undefined behavior.
**
** @param l the listener to add.
**/
public void addVetoableChangeListener(VetoableChangeListener l) {
listeners.addElement(l);
}
/** Adds a VetoableChangeListener listening on the specified property.
** Events will be sent to the listener for that particular property.
** <P>
**
** The listener add is not unique; that is, <em>n</em> adds on a
** particular property for a particular listener will result in
** <em>n</em> events being sent to that listener when that
** property is changed.
** <P>
**
** The effect is cumulative, too; if you are registered to listen
** to receive events on all property changes, and then you
** register on a particular property, you will receive change
** events for that property twice.
** <P>
**
** Adding a null listener will cause undefined behavior.
**
** @param propertyName the name of the property to listen on.
** @param l the listener to add.
**/
public void addVetoableChangeListener(String propertyName, VetoableChangeListener l) {
synchronized(propertyListeners) {
Vector v = (Vector)propertyListeners.get(propertyName);
try {
v.addElement(l);
} catch(NullPointerException e) {
/* If v is not found, create a new vector. */
v = new Vector();
v.addElement(l);
propertyListeners.put(propertyName, v);
}
}
}
/** Removes a VetoableChangeListener from the list of listeners.
** If any specific properties are being listened on, they must
** be deregistered by themselves; this will only remove the
** general listener to all properties.
** <P>
**
** If <code>add()</code> has been called multiple times for a
** particular listener, <code>remove()</code> will have to be
** called the same number of times to deregister it.
**
** @param l the listener to remove.
**/
public void removeVetoableChangeListener(VetoableChangeListener l) {
listeners.removeElement(l);
}
/** Removes a VetoableChangeListener from listening to a specific property.
** <P>
**
** If <code>add()</code> has been called multiple times for a
** particular listener on a property, <code>remove()</code> will
** have to be called the same number of times to deregister it.
**
** @param propertyName the property to stop listening on.
** @param l the listener to remove.
**/
public void removeVetoableChangeListener(String propertyName, VetoableChangeListener l) {
synchronized(propertyListeners) {
Vector v = (Vector)propertyListeners.get(propertyName);
try {
v.removeElement(l);
if(v.size() == 0) {
propertyListeners.remove(propertyName);
}
} catch(NullPointerException e) {
/* if v is not found, do nothing. */
}
}
}
/** Fire a VetoableChangeEvent to all the listeners.
** If any listener objects, a reversion event will be sent to
** those listeners who received the initial event.
**
** @param proposedChange the event to send.
** @exception PropertyVetoException if the change is vetoed.
**/
public void fireVetoableChange(PropertyChangeEvent proposedChange) throws PropertyVetoException {
int currentListener=0;
try {
for(;currentListener<listeners.size();currentListener++) {
((VetoableChangeListener)listeners.elementAt(currentListener)).vetoableChange(proposedChange);
}
} catch(PropertyVetoException e) {
PropertyChangeEvent reversion = new PropertyChangeEvent(proposedChange.getSource(),proposedChange.getPropertyName(),proposedChange.getNewValue(),proposedChange.getOldValue());
for(int sendAgain=0;sendAgain<currentListener;sendAgain++) {
try {
((VetoableChangeListener)listeners.elementAt(sendAgain)).vetoableChange(reversion);
} catch(PropertyVetoException e2) {
}
}
throw e;
}
Vector moreListeners = (Vector)propertyListeners.get(proposedChange.getPropertyName());
if(moreListeners != null) {
try {
for(currentListener = 0; currentListener < moreListeners.size(); currentListener++) {
((VetoableChangeListener)moreListeners.elementAt(currentListener)).vetoableChange(proposedChange);
}
} catch(PropertyVetoException e) {
PropertyChangeEvent reversion = new PropertyChangeEvent(proposedChange.getSource(),proposedChange.getPropertyName(),proposedChange.getNewValue(),proposedChange.getOldValue());
for(int sendAgain=0;sendAgain<listeners.size();sendAgain++) {
try {
((VetoableChangeListener)listeners.elementAt(currentListener)).vetoableChange(proposedChange);
} catch(PropertyVetoException e2) {
}
}
for(int sendAgain=0;sendAgain<currentListener;sendAgain++) {
try {
((VetoableChangeListener)moreListeners.elementAt(sendAgain)).vetoableChange(reversion);
} catch(PropertyVetoException e2) {
}
}
throw e;
}
}
}
/** Fire a VetoableChangeEvent containing the old and new values of the property to all the listeners.
** If any listener objects, a reversion event will be sent to
** those listeners who received the initial event.
**
** @param propertyName the name of the property that
** changed.
** @param oldVal the old value.
** @param newVal the new value.
** @exception PropertyVetoException if the change is vetoed.
**/
public void fireVetoableChange(String propertyName, Object oldVal, Object newVal) throws PropertyVetoException {
fireVetoableChange(new PropertyChangeEvent(bean,propertyName,oldVal,newVal));
}
/** Fire a VetoableChangeEvent containing the old and new values of the property to all the listeners.
** If any listener objects, a reversion event will be sent to
** those listeners who received the initial event.
**
** @param propertyName the name of the property that
** changed.
** @param oldVal the old value.
** @param newVal the new value.
** @exception PropertyVetoException if the change is vetoed.
**/
public void fireVetoableChange(String propertyName, boolean oldVal, boolean newVal) throws PropertyVetoException {
fireVetoableChange(new PropertyChangeEvent(bean,propertyName,new Boolean(oldVal),new Boolean(newVal)));
}
/** Fire a VetoableChangeEvent containing the old and new values of the property to all the listeners.
** If any listener objects, a reversion event will be sent to
** those listeners who received the initial event.
**
** @param propertyName the name of the property that
** changed.
** @param oldVal the old value.
** @param newVal the new value.
** @exception PropertyVetoException if the change is vetoed.
**/
public void fireVetoableChange(String propertyName, int oldVal, int newVal) throws PropertyVetoException {
fireVetoableChange(new PropertyChangeEvent(bean,propertyName,new Integer(oldVal),new Integer(newVal)));
}
/** Tell whether the specified property is being listened on or not.
** This will only return <code>true</code> if there are listeners
** on all properties or if there is a listener specifically on this
** property.
**
** @param propertyName the property that may be listened on
** @return whether the property is being listened on
**/
public boolean hasListeners(String propertyName) {
return listeners.size() > 0 || propertyListeners.get(propertyName) != null;
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment