mirror of git://gcc.gnu.org/git/gcc.git
PropertyChangeEvent.java (oldVal): Renamed to oldValue.
* java/beans/PropertyChangeEvent.java (oldVal): Renamed to oldValue. (newVal): Renamed to newValue. * java/beans/PropertyVetoException.java (changeEvent): Renamed to evt. * java/beans/beancontext/BeanContextServiceRevokedEvent.java (revokeNow): Renamed to invalidateRefs. * java/io/OptionalDataException.java: Updated FIXME. (eof): New placeholder field. (length); Ditto. * java/io/WriteAbortedException.java (message): Made transient. * java/lang/ClassNotFoundException.java: Updated comments for JDK 1.2. * java/lang/Throwable.java (stackTrace): Made transient. * java/net/InetAddress.java: Made Serializable. * java/security/KeyPair.java: Made Serializable. * java/security/Provider.java: Replaced with Classpath version that implements serialization and proper methods. * java/text/ChoiceFormat.java (strings): Renamed to choiceFormats. (limits): Renamed to choiceLimits. Serialization changes per: http://java.sun.com/products/jdk/1.2/docs/api/serialized-form.html From-SVN: r34726
This commit is contained in:
parent
cf1748bfce
commit
7b245d2461
|
|
@ -1,3 +1,23 @@
|
||||||
|
2000-06-26 Warren Levy <warrenl@cygnus.com>
|
||||||
|
|
||||||
|
* java/beans/PropertyChangeEvent.java (oldVal): Renamed to oldValue.
|
||||||
|
(newVal): Renamed to newValue.
|
||||||
|
* java/beans/PropertyVetoException.java (changeEvent): Renamed to evt.
|
||||||
|
* java/beans/beancontext/BeanContextServiceRevokedEvent.java
|
||||||
|
(revokeNow): Renamed to invalidateRefs.
|
||||||
|
* java/io/OptionalDataException.java: Updated FIXME.
|
||||||
|
(eof): New placeholder field.
|
||||||
|
(length); Ditto.
|
||||||
|
* java/io/WriteAbortedException.java (message): Made transient.
|
||||||
|
* java/lang/ClassNotFoundException.java: Updated comments for JDK 1.2.
|
||||||
|
* java/lang/Throwable.java (stackTrace): Made transient.
|
||||||
|
* java/net/InetAddress.java: Made Serializable.
|
||||||
|
* java/security/KeyPair.java: Made Serializable.
|
||||||
|
* java/security/Provider.java: Replaced with Classpath version that
|
||||||
|
implements serialization and proper methods.
|
||||||
|
* java/text/ChoiceFormat.java (strings): Renamed to choiceFormats.
|
||||||
|
(limits): Renamed to choiceLimits.
|
||||||
|
|
||||||
2000-06-24 Tom Tromey <tromey@cygnus.com>
|
2000-06-24 Tom Tromey <tromey@cygnus.com>
|
||||||
|
|
||||||
* java/lang/natDouble.cc (parseDouble): Renamed from
|
* java/lang/natDouble.cc (parseDouble): Renamed from
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
/* java.beans.PropertyChangeEvent
|
/* java.beans.PropertyChangeEvent
|
||||||
Copyright (C) 1998 Free Software Foundation, Inc.
|
Copyright (C) 1998, 2000 Free Software Foundation, Inc.
|
||||||
|
|
||||||
This file is part of GNU Classpath.
|
This file is part of GNU Classpath.
|
||||||
|
|
||||||
|
|
@ -50,8 +50,8 @@ package java.beans;
|
||||||
|
|
||||||
public class PropertyChangeEvent extends java.util.EventObject {
|
public class PropertyChangeEvent extends java.util.EventObject {
|
||||||
String propertyName;
|
String propertyName;
|
||||||
Object oldVal;
|
Object oldValue;
|
||||||
Object newVal;
|
Object newValue;
|
||||||
Object propagationId;
|
Object propagationId;
|
||||||
|
|
||||||
/** Create a new PropertyChangeEvent. Remember that if
|
/** Create a new PropertyChangeEvent. Remember that if
|
||||||
|
|
@ -60,14 +60,14 @@ public class PropertyChangeEvent extends java.util.EventObject {
|
||||||
** from the old PropertyChangeEvent.
|
** from the old PropertyChangeEvent.
|
||||||
** @param source the Bean containing the property.
|
** @param source the Bean containing the property.
|
||||||
** @param propertyName the property's name.
|
** @param propertyName the property's name.
|
||||||
** @param oldVal the old value of the property.
|
** @param oldValue the old value of the property.
|
||||||
** @param newVal the new value of the property.
|
** @param newValue the new value of the property.
|
||||||
**/
|
**/
|
||||||
public PropertyChangeEvent(Object source, String propertyName, Object oldVal, Object newVal) {
|
public PropertyChangeEvent(Object source, String propertyName, Object oldVal, Object newVal) {
|
||||||
super(source);
|
super(source);
|
||||||
this.propertyName = propertyName;
|
this.propertyName = propertyName;
|
||||||
this.oldVal = oldVal;
|
oldValue = oldVal;
|
||||||
this.newVal = newVal;
|
newValue = newVal;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Get the property name.
|
/** Get the property name.
|
||||||
|
|
@ -81,14 +81,14 @@ public class PropertyChangeEvent extends java.util.EventObject {
|
||||||
** @return the property's old value.
|
** @return the property's old value.
|
||||||
**/
|
**/
|
||||||
public Object getOldValue() {
|
public Object getOldValue() {
|
||||||
return oldVal;
|
return oldValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Get the property's new value.
|
/** Get the property's new value.
|
||||||
** @return the property's new value.
|
** @return the property's new value.
|
||||||
**/
|
**/
|
||||||
public Object getNewValue() {
|
public Object getNewValue() {
|
||||||
return newVal;
|
return newValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Set the propagation ID. This is a way for the event
|
/** Set the propagation ID. This is a way for the event
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
/* java.beans.PropertyVetoException
|
/* java.beans.PropertyVetoException
|
||||||
Copyright (C) 1998 Free Software Foundation, Inc.
|
Copyright (C) 1998, 2000 Free Software Foundation, Inc.
|
||||||
|
|
||||||
This file is part of GNU Classpath.
|
This file is part of GNU Classpath.
|
||||||
|
|
||||||
|
|
@ -37,7 +37,7 @@ package java.beans;
|
||||||
**/
|
**/
|
||||||
|
|
||||||
public class PropertyVetoException extends Exception {
|
public class PropertyVetoException extends Exception {
|
||||||
PropertyChangeEvent changeEvent;
|
PropertyChangeEvent evt;
|
||||||
|
|
||||||
/** Instantiate this exception with the given message and property change.
|
/** Instantiate this exception with the given message and property change.
|
||||||
** @param msg the reason for the veto.
|
** @param msg the reason for the veto.
|
||||||
|
|
@ -45,11 +45,11 @@ public class PropertyVetoException extends Exception {
|
||||||
**/
|
**/
|
||||||
public PropertyVetoException(String msg, PropertyChangeEvent changeEvent) {
|
public PropertyVetoException(String msg, PropertyChangeEvent changeEvent) {
|
||||||
super(msg);
|
super(msg);
|
||||||
this.changeEvent = changeEvent;
|
evt = changeEvent;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Get the PropertyChange event that was vetoed. **/
|
/** Get the PropertyChange event that was vetoed. **/
|
||||||
public PropertyChangeEvent getPropertyChangeEvent() {
|
public PropertyChangeEvent getPropertyChangeEvent() {
|
||||||
return changeEvent;
|
return evt;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
/* java.beans.beancontext.BeanContextServiceRevokedEvent
|
/* java.beans.beancontext.BeanContextServiceRevokedEvent
|
||||||
Copyright (C) 1999 Free Software Foundation, Inc.
|
Copyright (C) 1999, 2000 Free Software Foundation, Inc.
|
||||||
|
|
||||||
This file is part of GNU Classpath.
|
This file is part of GNU Classpath.
|
||||||
|
|
||||||
|
|
@ -41,7 +41,7 @@ public class BeanContextServiceRevokedEvent extends BeanContextEvent {
|
||||||
* available.
|
* available.
|
||||||
*/
|
*/
|
||||||
protected Class serviceClass;
|
protected Class serviceClass;
|
||||||
private boolean revokeNow;
|
private boolean invalidateRefs;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create a new service revoked event.
|
* Create a new service revoked event.
|
||||||
|
|
@ -55,7 +55,7 @@ public class BeanContextServiceRevokedEvent extends BeanContextEvent {
|
||||||
public BeanContextServiceRevokedEvent(BeanContextServices services, Class serviceClass, boolean revokeNow) {
|
public BeanContextServiceRevokedEvent(BeanContextServices services, Class serviceClass, boolean revokeNow) {
|
||||||
super(services);
|
super(services);
|
||||||
this.serviceClass = serviceClass;
|
this.serviceClass = serviceClass;
|
||||||
this.revokeNow = revokeNow;
|
invalidateRefs = revokeNow;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -94,6 +94,6 @@ public class BeanContextServiceRevokedEvent extends BeanContextEvent {
|
||||||
* usable.
|
* usable.
|
||||||
*/
|
*/
|
||||||
public boolean isCurrentServiceInvalidNow() {
|
public boolean isCurrentServiceInvalidNow() {
|
||||||
return revokeNow;
|
return invalidateRefs;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -19,6 +19,10 @@ package java.io;
|
||||||
|
|
||||||
public class OptionalDataException extends ObjectStreamException
|
public class OptionalDataException extends ObjectStreamException
|
||||||
{
|
{
|
||||||
|
// FIXME: Need to set these fields per the doc in a constructor.
|
||||||
|
public boolean eof;
|
||||||
|
public int length;
|
||||||
|
|
||||||
public OptionalDataException()
|
public OptionalDataException()
|
||||||
{
|
{
|
||||||
super();
|
super();
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
/* WriteAbortedException.java -- An exception occured while writing a
|
/* WriteAbortedException.java -- An exception occured while writing a
|
||||||
serialization stream
|
serialization stream
|
||||||
Copyright (C) 1998 Free Software Foundation, Inc.
|
Copyright (C) 1998, 2000 Free Software Foundation, Inc.
|
||||||
|
|
||||||
This file is part of GNU Classpath.
|
This file is part of GNU Classpath.
|
||||||
|
|
||||||
|
|
@ -47,7 +47,7 @@ public class WriteAbortedException extends ObjectStreamException
|
||||||
* The detailed exception that caused this exception to be thrown
|
* The detailed exception that caused this exception to be thrown
|
||||||
*/
|
*/
|
||||||
public Exception detail;
|
public Exception detail;
|
||||||
private String message;
|
private transient String message;
|
||||||
|
|
||||||
/*************************************************************************/
|
/*************************************************************************/
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
/* Copyright (C) 1998, 1999 Free Software Foundation
|
/* Copyright (C) 1998, 1999, 2000 Free Software Foundation
|
||||||
|
|
||||||
This file is part of libgcj.
|
This file is part of libgcj.
|
||||||
|
|
||||||
|
|
@ -20,6 +20,9 @@ package java.lang;
|
||||||
|
|
||||||
public class ClassNotFoundException extends Exception
|
public class ClassNotFoundException extends Exception
|
||||||
{
|
{
|
||||||
|
// TODO12:
|
||||||
|
// Throwable ex;
|
||||||
|
|
||||||
public ClassNotFoundException()
|
public ClassNotFoundException()
|
||||||
{
|
{
|
||||||
super();
|
super();
|
||||||
|
|
@ -28,6 +31,7 @@ public class ClassNotFoundException extends Exception
|
||||||
// TODO12:
|
// TODO12:
|
||||||
// public ClassNotFoundException(String msg, Throwable ex)
|
// public ClassNotFoundException(String msg, Throwable ex)
|
||||||
// {
|
// {
|
||||||
|
// FIXME: Set 'ex' here.
|
||||||
// }
|
// }
|
||||||
|
|
||||||
public ClassNotFoundException(String msg)
|
public ClassNotFoundException(String msg)
|
||||||
|
|
|
||||||
|
|
@ -164,5 +164,5 @@ public class Throwable implements Serializable
|
||||||
// Name of this field comes from serialization spec.
|
// Name of this field comes from serialization spec.
|
||||||
private String detailMessage;
|
private String detailMessage;
|
||||||
|
|
||||||
private byte stackTrace[];
|
private transient byte stackTrace[];
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -22,10 +22,10 @@ package java.net;
|
||||||
* Status: Believed complete and correct.
|
* Status: Believed complete and correct.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
public final class InetAddress
|
public final class InetAddress implements java.io.Serializable
|
||||||
{
|
{
|
||||||
String hostname;
|
|
||||||
byte[] address;
|
byte[] address;
|
||||||
|
String hostname;
|
||||||
|
|
||||||
InetAddress (byte[] address, String hostname)
|
InetAddress (byte[] address, String hostname)
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -17,7 +17,7 @@ package java.security;
|
||||||
* Status: Believed complete and correct.
|
* Status: Believed complete and correct.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
public class KeyPair /* FIXME: implements serializable */
|
public class KeyPair implements java.io.Serializable
|
||||||
{
|
{
|
||||||
public KeyPair (PublicKey publicKey, PrivateKey privateKey)
|
public KeyPair (PublicKey publicKey, PrivateKey privateKey)
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -1,53 +1,197 @@
|
||||||
/* Copyright (C) 2000 Free Software Foundation
|
/* Provider.java -- Security provider information
|
||||||
|
Copyright (C) 1998, 1999 Free Software Foundation, Inc.
|
||||||
|
|
||||||
This file is part of libgcj.
|
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. */
|
||||||
|
|
||||||
This software is copyrighted work licensed under the terms of the
|
|
||||||
Libgcj License. Please consult the file "LIBGCJ_LICENSE" for
|
|
||||||
details. */
|
|
||||||
|
|
||||||
package java.security;
|
package java.security;
|
||||||
|
|
||||||
|
import java.io.Serializable;
|
||||||
import java.util.Properties;
|
import java.util.Properties;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Warren Levy <warrenl@cygnus.com>
|
* This class represents a Java security architecture service provider.
|
||||||
* @date February 7, 2000.
|
* The services provided by a such a provider can range from security
|
||||||
|
* algorithms to key generation.
|
||||||
|
* <p>
|
||||||
|
* Providers are installed by name and verion number. There is one
|
||||||
|
* standard provider supplied with the class library. This is the
|
||||||
|
* "GNU" provider, which can also be accessed by the alias "SUN" for
|
||||||
|
* compatibility with the JDK.
|
||||||
|
*
|
||||||
|
* @version 0.0
|
||||||
|
*
|
||||||
|
* @author Aaron M. Renn (arenn@urbanophile.com)
|
||||||
|
*/
|
||||||
|
public abstract class Provider extends Properties implements Serializable
|
||||||
|
{
|
||||||
|
|
||||||
|
/*************************************************************************/
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Instance Variables
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Written using on-line Java Platform 1.2 API Specification.
|
* This is a textual description of the provider
|
||||||
* Status: Partially implemented.
|
*/
|
||||||
|
private String info;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This is the name of the provider
|
||||||
|
*/
|
||||||
|
private String name;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This is the version number of the provider
|
||||||
|
*/
|
||||||
|
private double version;
|
||||||
|
|
||||||
|
/*************************************************************************/
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Constructors
|
||||||
*/
|
*/
|
||||||
|
|
||||||
public abstract class Provider extends Properties
|
/**
|
||||||
|
* This method initializes a new instance of <code>Provider</code> to have
|
||||||
|
* the specified name, version, and description information.
|
||||||
|
*
|
||||||
|
* @param name The name to assign to this <code>Provider</code>.
|
||||||
|
* @param version The version number for this <code>Provider</code>.
|
||||||
|
* @param info A textual description of this provider.
|
||||||
|
*/
|
||||||
|
protected
|
||||||
|
Provider(String name, double version, String info)
|
||||||
{
|
{
|
||||||
// FIXME: Check the following property values against specs!
|
this.name = name;
|
||||||
protected Provider(String name, double version, String info)
|
this.version = version;
|
||||||
{
|
this.info = info;
|
||||||
super();
|
}
|
||||||
put("java.security.Provider.Name", name);
|
|
||||||
put("java.security.Provider.Version", Double.toString(version));
|
|
||||||
put("java.security.Provider.Info", info);
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getName()
|
/*************************************************************************/
|
||||||
{
|
|
||||||
return getProperty("java.security.Provider.Name");
|
|
||||||
}
|
|
||||||
|
|
||||||
public double getVersion()
|
/*
|
||||||
{
|
* Instance Methods
|
||||||
return Double.valueOf(getProperty("java.security.Provider.Version")).doubleValue();
|
*/
|
||||||
}
|
|
||||||
|
|
||||||
public String getInfo()
|
/**
|
||||||
{
|
* This method returns the name assigned to this <code>Provider</code>.
|
||||||
return getProperty("java.security.Provider.Info");
|
*
|
||||||
}
|
* @return The <code>Provider</code>'s name.
|
||||||
|
*/
|
||||||
public String toString()
|
public String
|
||||||
{
|
getName()
|
||||||
// FIXME: Check this string against the spec.
|
{
|
||||||
return getName() + " " + getProperty("java.security.Provider.Version");
|
return(name);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*************************************************************************/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This method retunrs the version number of this <code>Provider</code>.
|
||||||
|
*
|
||||||
|
* @return The <code>Provider</code>'s version number.
|
||||||
|
*/
|
||||||
|
public double
|
||||||
|
getVersion()
|
||||||
|
{
|
||||||
|
return(version);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*************************************************************************/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This method returns a textual description of the <code>Provider</code>.
|
||||||
|
*
|
||||||
|
* @return A description of the <code>Provider</code>.
|
||||||
|
*/
|
||||||
|
public String
|
||||||
|
getInfo()
|
||||||
|
{
|
||||||
|
return(info);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*************************************************************************/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This method sets the specified key to have the specified value.
|
||||||
|
*
|
||||||
|
* @param key The property key
|
||||||
|
* @param value The property value
|
||||||
|
*
|
||||||
|
* @return The previous value for this key, or <code>null</code> if no previous value.
|
||||||
|
*/
|
||||||
|
public Object
|
||||||
|
put(Object key, Object value)
|
||||||
|
{
|
||||||
|
return(super.put(key, value));
|
||||||
|
}
|
||||||
|
|
||||||
|
/*************************************************************************/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This method removes the specified key entry (and its associated value)
|
||||||
|
* from the property mapping list.
|
||||||
|
*
|
||||||
|
* @param key The key to remove
|
||||||
|
*
|
||||||
|
* @return The previous value for this key, or <code>null</code> if no previous value.
|
||||||
|
*/
|
||||||
|
public Object
|
||||||
|
remove(Object key)
|
||||||
|
{
|
||||||
|
return(super.remove(key));
|
||||||
|
}
|
||||||
|
|
||||||
|
/*************************************************************************/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This method clears the entire property list such that it no longer
|
||||||
|
* contains the properties used to look up the services provided by
|
||||||
|
* the <code>Provider</code>.
|
||||||
|
*/
|
||||||
|
public void
|
||||||
|
clear()
|
||||||
|
{
|
||||||
|
super.clear();
|
||||||
|
}
|
||||||
|
|
||||||
|
/*************************************************************************/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This method returns a <code>String</code> representation of this
|
||||||
|
* object. This will include the <code>Provider</code> name and
|
||||||
|
* version number.
|
||||||
|
*
|
||||||
|
* @return A <code>String</code> representation of this object.
|
||||||
|
*/
|
||||||
|
public String
|
||||||
|
toString()
|
||||||
|
{
|
||||||
|
return(getClass().getName() + ": name=" + getName() + " version=" + version);
|
||||||
|
}
|
||||||
|
|
||||||
|
} // class Provider
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -84,14 +84,14 @@ public class ChoiceFormat extends NumberFormat
|
||||||
++index;
|
++index;
|
||||||
}
|
}
|
||||||
|
|
||||||
strings = new String[stringVec.size()];
|
choiceFormats = new String[stringVec.size()];
|
||||||
stringVec.copyInto(strings);
|
stringVec.copyInto(choiceFormats);
|
||||||
|
|
||||||
limits = new double[limitVec.size()];
|
choiceLimits = new double[limitVec.size()];
|
||||||
for (int i = 0; i < limits.length; ++i)
|
for (int i = 0; i < choiceLimits.length; ++i)
|
||||||
{
|
{
|
||||||
Double d = (Double) limitVec.elementAt(i);
|
Double d = (Double) limitVec.elementAt(i);
|
||||||
limits[i] = d.doubleValue();
|
choiceLimits[i] = d.doubleValue();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -101,15 +101,15 @@ public class ChoiceFormat extends NumberFormat
|
||||||
applyPattern (newPattern);
|
applyPattern (newPattern);
|
||||||
}
|
}
|
||||||
|
|
||||||
public ChoiceFormat (double[] limits, String[] strings)
|
public ChoiceFormat (double[] choiceLimits, String[] choiceFormats)
|
||||||
{
|
{
|
||||||
super ();
|
super ();
|
||||||
setChoices (limits, strings);
|
setChoices (choiceLimits, choiceFormats);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Object clone ()
|
public Object clone ()
|
||||||
{
|
{
|
||||||
return new ChoiceFormat (limits, strings);
|
return new ChoiceFormat (choiceLimits, choiceFormats);
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean equals (Object obj)
|
public boolean equals (Object obj)
|
||||||
|
|
@ -117,12 +117,12 @@ public class ChoiceFormat extends NumberFormat
|
||||||
if (! (obj instanceof ChoiceFormat))
|
if (! (obj instanceof ChoiceFormat))
|
||||||
return false;
|
return false;
|
||||||
ChoiceFormat cf = (ChoiceFormat) obj;
|
ChoiceFormat cf = (ChoiceFormat) obj;
|
||||||
if (limits.length != cf.limits.length)
|
if (choiceLimits.length != cf.choiceLimits.length)
|
||||||
return false;
|
return false;
|
||||||
for (int i = limits.length - 1; i >= 0; --i)
|
for (int i = choiceLimits.length - 1; i >= 0; --i)
|
||||||
{
|
{
|
||||||
if (limits[i] != cf.limits[i]
|
if (choiceLimits[i] != cf.choiceLimits[i]
|
||||||
|| !strings[i].equals(cf.strings[i]))
|
|| !choiceFormats[i].equals(cf.choiceFormats[i]))
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
|
|
@ -137,42 +137,42 @@ public class ChoiceFormat extends NumberFormat
|
||||||
public StringBuffer format (double num, StringBuffer appendBuf,
|
public StringBuffer format (double num, StringBuffer appendBuf,
|
||||||
FieldPosition pos)
|
FieldPosition pos)
|
||||||
{
|
{
|
||||||
if (limits.length == 0)
|
if (choiceLimits.length == 0)
|
||||||
return appendBuf;
|
return appendBuf;
|
||||||
|
|
||||||
int index = 0;
|
int index = 0;
|
||||||
if (! Double.isNaN(num) && num >= limits[0])
|
if (! Double.isNaN(num) && num >= choiceLimits[0])
|
||||||
{
|
{
|
||||||
for (; index < limits.length - 1; ++index)
|
for (; index < choiceLimits.length - 1; ++index)
|
||||||
{
|
{
|
||||||
if (limits[index] <= num
|
if (choiceLimits[index] <= num
|
||||||
&& index != limits.length - 2
|
&& index != choiceLimits.length - 2
|
||||||
&& num < limits[index + 1])
|
&& num < choiceLimits[index + 1])
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return appendBuf.append(strings[index]);
|
return appendBuf.append(choiceFormats[index]);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Object[] getFormats ()
|
public Object[] getFormats ()
|
||||||
{
|
{
|
||||||
return (Object[]) strings.clone();
|
return (Object[]) choiceFormats.clone();
|
||||||
}
|
}
|
||||||
|
|
||||||
public double[] getLimits ()
|
public double[] getLimits ()
|
||||||
{
|
{
|
||||||
return (double[]) limits.clone();
|
return (double[]) choiceLimits.clone();
|
||||||
}
|
}
|
||||||
|
|
||||||
public int hashCode ()
|
public int hashCode ()
|
||||||
{
|
{
|
||||||
int hash = 0;
|
int hash = 0;
|
||||||
for (int i = 0; i < limits.length; ++i)
|
for (int i = 0; i < choiceLimits.length; ++i)
|
||||||
{
|
{
|
||||||
long v = Double.doubleToLongBits(limits[i]);
|
long v = Double.doubleToLongBits(choiceLimits[i]);
|
||||||
hash ^= (v ^ (v >>> 32));
|
hash ^= (v ^ (v >>> 32));
|
||||||
hash ^= strings[i].hashCode();
|
hash ^= choiceFormats[i].hashCode();
|
||||||
}
|
}
|
||||||
return hash;
|
return hash;
|
||||||
}
|
}
|
||||||
|
|
@ -238,12 +238,12 @@ public class ChoiceFormat extends NumberFormat
|
||||||
public Number parse (String sourceStr, ParsePosition pos)
|
public Number parse (String sourceStr, ParsePosition pos)
|
||||||
{
|
{
|
||||||
int index = pos.getIndex();
|
int index = pos.getIndex();
|
||||||
for (int i = 0; i < limits.length; ++i)
|
for (int i = 0; i < choiceLimits.length; ++i)
|
||||||
{
|
{
|
||||||
if (sourceStr.startsWith(strings[i], index))
|
if (sourceStr.startsWith(choiceFormats[i], index))
|
||||||
{
|
{
|
||||||
pos.setIndex(index + strings[i].length());
|
pos.setIndex(index + choiceFormats[i].length());
|
||||||
return new Double (limits[i]);
|
return new Double (choiceLimits[i]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
pos.setErrorIndex(index);
|
pos.setErrorIndex(index);
|
||||||
|
|
@ -255,12 +255,14 @@ public class ChoiceFormat extends NumberFormat
|
||||||
return nextDouble (d, false);
|
return nextDouble (d, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setChoices (double[] limits, String[] strings)
|
public void setChoices (double[] choiceLimits, String[] choiceFormats)
|
||||||
{
|
{
|
||||||
if (limits.length != strings.length)
|
if (choiceLimits == null || choiceFormats == null)
|
||||||
|
throw new NullPointerException ();
|
||||||
|
if (choiceLimits.length != choiceFormats.length)
|
||||||
throw new IllegalArgumentException ();
|
throw new IllegalArgumentException ();
|
||||||
this.strings = (String[]) strings.clone();
|
this.choiceFormats = (String[]) choiceFormats.clone();
|
||||||
this.limits = (double[]) limits.clone();
|
this.choiceLimits = (double[]) choiceLimits.clone();
|
||||||
}
|
}
|
||||||
|
|
||||||
private final void quoteString (StringBuffer dest, String text)
|
private final void quoteString (StringBuffer dest, String text)
|
||||||
|
|
@ -288,18 +290,18 @@ public class ChoiceFormat extends NumberFormat
|
||||||
public String toPattern ()
|
public String toPattern ()
|
||||||
{
|
{
|
||||||
StringBuffer result = new StringBuffer ();
|
StringBuffer result = new StringBuffer ();
|
||||||
for (int i = 0; i < limits.length; ++i)
|
for (int i = 0; i < choiceLimits.length; ++i)
|
||||||
{
|
{
|
||||||
result.append(limits[i]);
|
result.append(choiceLimits[i]);
|
||||||
result.append('#');
|
result.append('#');
|
||||||
quoteString (result, strings[i]);
|
quoteString (result, choiceFormats[i]);
|
||||||
}
|
}
|
||||||
return result.toString();
|
return result.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Formats and limits.
|
// Formats and limits.
|
||||||
private String[] strings;
|
private String[] choiceFormats;
|
||||||
private double[] limits;
|
private double[] choiceLimits;
|
||||||
|
|
||||||
// Number of mantissa bits in double.
|
// Number of mantissa bits in double.
|
||||||
private static final int mantissaBits = 52;
|
private static final int mantissaBits = 52;
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue