96dd155e2c
2005-02-17 Michael Koch <konqueror@gmx.de> * gnu/java/awt/peer/gtk/GThreadNativeMethodRunner.java, gnu/java/awt/peer/gtk/GdkFontPeer.java, gnu/java/awt/peer/gtk/GdkGlyphVector.java, gnu/java/awt/peer/gtk/GdkGraphics.java, gnu/java/awt/peer/gtk/GdkGraphics2D.java, gnu/java/awt/peer/gtk/GdkGraphicsConfiguration.java, gnu/java/awt/peer/gtk/GdkGraphicsEnvironment.java, gnu/java/awt/peer/gtk/GdkPixbufDecoder.java, gnu/java/awt/peer/gtk/GdkRobotPeer.java, gnu/java/awt/peer/gtk/GdkScreenGraphicsDevice.java, gnu/java/awt/peer/gtk/GdkTextLayout.java, gnu/java/awt/peer/gtk/GtkCheckboxMenuItemPeer.java, gnu/java/awt/peer/gtk/GtkChoicePeer.java, gnu/java/awt/peer/gtk/GtkClipboard.java, gnu/java/awt/peer/gtk/GtkComponentPeer.java, gnu/java/awt/peer/gtk/GtkFileDialogPeer.java, gnu/java/awt/peer/gtk/GtkFontPeer.java, gnu/java/awt/peer/gtk/GtkLabelPeer.java, gnu/java/awt/peer/gtk/GtkMenuBarPeer.java, gnu/java/awt/peer/gtk/GtkMenuItemPeer.java, gnu/java/awt/peer/gtk/GtkMenuPeer.java, gnu/java/awt/peer/gtk/GtkScrollPanePeer.java, gnu/java/awt/peer/gtk/GtkScrollbarPeer.java, gnu/java/awt/peer/gtk/GtkToolkit.java, gnu/java/awt/peer/gtk/GtkWindowPeer.java, java/applet/Applet.java, java/awt/AWTError.java, java/awt/AWTEvent.java, java/awt/AWTEventMulticaster.java, java/awt/AWTException.java, java/awt/AWTKeyStroke.java, java/awt/AWTPermission.java, java/awt/ActiveEvent.java, java/awt/Adjustable.java, java/awt/AlphaComposite.java, java/awt/AttributeValue.java, java/awt/BorderLayout.java, java/awt/BufferCapabilities.java, java/awt/Button.java, java/awt/Canvas.java, java/awt/CheckboxGroup.java, java/awt/CheckboxMenuItem.java, java/awt/Color.java, java/awt/ColorPaintContext.java, java/awt/Component.java, java/awt/ComponentOrientation.java, java/awt/Composite.java, java/awt/CompositeContext.java, java/awt/Container.java, java/awt/ContainerOrderFocusTraversalPolicy.java, java/awt/DefaultFocusTraversalPolicy.java, java/awt/Dialog.java, java/awt/Dimension.java, java/awt/DisplayMode.java, java/awt/EventQueue.java, java/awt/FileDialog.java, java/awt/FontFormatException.java, java/awt/Graphics.java, java/awt/Graphics2D.java, java/awt/GraphicsConfigTemplate.java, java/awt/GraphicsConfiguration.java, java/awt/GraphicsDevice.java, java/awt/GridBagLayout.java, java/awt/GridBagLayoutInfo.java, java/awt/GridLayout.java, java/awt/HeadlessException.java, java/awt/IllegalComponentStateException.java, java/awt/Image.java, java/awt/Insets.java, java/awt/ItemSelectable.java, java/awt/JobAttributes.java, java/awt/KeyEventDispatcher.java, java/awt/KeyEventPostProcessor.java, java/awt/KeyboardFocusManager.java, java/awt/Label.java, java/awt/LayoutManager.java, java/awt/MenuBar.java, java/awt/MenuComponent.java, java/awt/MenuContainer.java, java/awt/PageAttributes.java, java/awt/Paint.java, java/awt/PaintContext.java, java/awt/Panel.java, java/awt/Point.java, java/awt/Polygon.java, java/awt/PrintGraphics.java, java/awt/PrintJob.java, java/awt/Rectangle.java, java/awt/RenderingHints.java, java/awt/Shape.java, java/awt/Stroke.java, java/awt/SystemColor.java, java/awt/Toolkit.java, java/awt/Transparency.java, java/awt/Window.java, java/awt/color/CMMException.java, java/awt/color/ColorSpace.java, java/awt/color/ICC_ColorSpace.java, java/awt/color/ICC_Profile.java, java/awt/color/ProfileDataException.java, java/awt/datatransfer/FlavorTable.java, java/awt/datatransfer/MimeTypeParseException.java, java/awt/datatransfer/Transferable.java, java/awt/datatransfer/UnsupportedFlavorException.java, java/awt/dnd/Autoscroll.java, java/awt/dnd/DnDConstants.java, java/awt/dnd/DragGestureListener.java, java/awt/dnd/DragSourceAdapter.java, java/awt/dnd/DragSourceDropEvent.java, java/awt/dnd/DragSourceListener.java, java/awt/dnd/DragSourceMotionListener.java, java/awt/dnd/DropTargetAdapter.java, java/awt/dnd/DropTargetContext.java, java/awt/dnd/DropTargetListener.java, java/awt/dnd/InvalidDnDOperationException.java, java/awt/dnd/MouseDragGestureRecognizer.java, java/awt/dnd/peer/DropTargetContextPeer.java, java/awt/event/AWTEventListener.java, java/awt/event/AWTEventListenerProxy.java, java/awt/event/ActionEvent.java, java/awt/event/AdjustmentEvent.java, java/awt/event/AdjustmentListener.java, java/awt/event/ComponentAdapter.java, java/awt/event/ComponentEvent.java, java/awt/event/ComponentListener.java, java/awt/event/ContainerAdapter.java, java/awt/event/ContainerEvent.java, java/awt/event/ContainerListener.java, java/awt/event/FocusAdapter.java, java/awt/event/FocusEvent.java, java/awt/event/FocusListener.java, java/awt/event/InputEvent.java, java/awt/event/InputMethodEvent.java, java/awt/event/InputMethodListener.java, java/awt/event/InvocationEvent.java, java/awt/event/ItemEvent.java, java/awt/event/ItemListener.java, java/awt/event/KeyAdapter.java, java/awt/event/KeyEvent.java, java/awt/event/KeyListener.java, java/awt/event/MouseAdapter.java, java/awt/event/MouseEvent.java, java/awt/event/MouseListener.java, java/awt/event/MouseMotionAdapter.java, java/awt/event/MouseMotionListener.java, java/awt/event/MouseWheelEvent.java, java/awt/event/MouseWheelListener.java, java/awt/event/PaintEvent.java, java/awt/event/TextEvent.java, java/awt/event/TextListener.java, java/awt/event/WindowAdapter.java, java/awt/event/WindowEvent.java, java/awt/event/WindowFocusListener.java, java/awt/event/WindowListener.java, java/awt/event/WindowStateListener.java, java/awt/font/TextHitInfo.java, java/awt/geom/CubicCurve2D.java, java/awt/geom/Dimension2D.java, java/awt/geom/Ellipse2D.java, java/awt/geom/IllegalPathStateException.java, java/awt/geom/Line2D.java, java/awt/geom/NoninvertibleTransformException.java, java/awt/geom/PathIterator.java, java/awt/geom/Point2D.java, java/awt/geom/QuadCurve2D.java, java/awt/geom/RectangularShape.java, java/awt/geom/RoundRectangle2D.java, java/awt/im/InputContext.java, java/awt/im/InputMethodHighlight.java, java/awt/im/InputMethodRequests.java, java/awt/im/InputSubset.java, java/awt/im/spi/InputMethod.java, java/awt/im/spi/InputMethodDescriptor.java, java/awt/image/BandCombineOp.java, java/awt/image/BandedSampleModel.java, java/awt/image/ByteLookupTable.java, java/awt/image/ComponentSampleModel.java, java/awt/image/DataBuffer.java, java/awt/image/DataBufferByte.java, java/awt/image/DataBufferDouble.java, java/awt/image/DataBufferFloat.java, java/awt/image/DataBufferInt.java, java/awt/image/DataBufferShort.java, java/awt/image/DataBufferUShort.java, java/awt/image/ImagingOpException.java, java/awt/image/Kernel.java, java/awt/image/LookupTable.java, java/awt/image/MultiPixelPackedSampleModel.java, java/awt/image/PackedColorModel.java, java/awt/image/PixelInterleavedSampleModel.java, java/awt/image/RGBImageFilter.java, java/awt/image/Raster.java, java/awt/image/RasterFormatException.java, java/awt/image/SampleModel.java, java/awt/image/ShortLookupTable.java, java/awt/image/SinglePixelPackedSampleModel.java, java/awt/image/WritableRaster.java, java/awt/print/PrinterAbortException.java, java/awt/print/PrinterException.java, java/awt/print/PrinterIOException.java, java/beans/AppletInitializer.java, java/beans/ExceptionListener.java, java/beans/PropertyChangeEvent.java, java/beans/PropertyChangeListenerProxy.java, java/beans/PropertyChangeSupport.java, java/beans/PropertyDescriptor.java, java/beans/VetoableChangeListenerProxy.java, java/beans/VetoableChangeSupport.java, java/io/BufferedReader.java, java/io/ByteArrayInputStream.java, java/io/ByteArrayOutputStream.java, java/io/CharArrayReader.java, java/io/CharArrayWriter.java, java/io/CharConversionException.java, java/io/DataInput.java, java/io/DataInputStream.java, java/io/DataOutput.java, java/io/DataOutputStream.java, java/io/EOFException.java, java/io/FileInputStream.java, java/io/FileNotFoundException.java, java/io/FileOutputStream.java, java/io/FilenameFilter.java, java/io/FilterInputStream.java, java/io/FilterOutputStream.java, java/io/FilterReader.java, java/io/FilterWriter.java, java/io/IOException.java, java/io/InputStream.java, java/io/InterruptedIOException.java, java/io/LineNumberInputStream.java, java/io/LineNumberReader.java, java/io/ObjectInputStream.java, java/io/ObjectStreamException.java, java/io/OptionalDataException.java, java/io/OutputStream.java, java/io/OutputStreamWriter.java, java/io/PrintStream.java, java/io/PrintWriter.java, java/io/PushbackInputStream.java, java/io/PushbackReader.java, java/io/RandomAccessFile.java, java/io/Reader.java, java/io/SequenceInputStream.java, java/io/Serializable.java, java/io/StreamCorruptedException.java, java/io/StreamTokenizer.java, java/io/StringBufferInputStream.java, java/io/StringWriter.java, java/io/SyncFailedException.java, java/io/UTFDataFormatException.java, java/io/UnsupportedEncodingException.java, java/io/WriteAbortedException.java, java/io/Writer.java, java/lang/AbstractMethodError.java, java/lang/ArithmeticException.java, java/lang/ArrayIndexOutOfBoundsException.java, java/lang/ArrayStoreException.java, java/lang/AssertionError.java, java/lang/Boolean.java, java/lang/Byte.java, java/lang/Class.java, java/lang/ClassCastException.java, java/lang/ClassCircularityError.java, java/lang/ClassLoader.java, java/lang/ClassNotFoundException.java, java/lang/CloneNotSupportedException.java, java/lang/Cloneable.java, java/lang/Comparable.java, java/lang/Compiler.java, java/lang/Double.java, java/lang/Error.java, java/lang/Exception.java, java/lang/ExceptionInInitializerError.java, java/lang/Float.java, java/lang/IllegalAccessError.java, java/lang/IllegalAccessException.java, java/lang/IllegalArgumentException.java, java/lang/IllegalMonitorStateException.java, java/lang/IllegalStateException.java, java/lang/IllegalThreadStateException.java, java/lang/IncompatibleClassChangeError.java, java/lang/IndexOutOfBoundsException.java, java/lang/InheritableThreadLocal.java, java/lang/InstantiationError.java, java/lang/InstantiationException.java, java/lang/Integer.java, java/lang/InternalError.java, java/lang/InterruptedException.java, java/lang/LinkageError.java, java/lang/Long.java, java/lang/NegativeArraySizeException.java, java/lang/NoClassDefFoundError.java, java/lang/NoSuchFieldError.java, java/lang/NoSuchFieldException.java, java/lang/NoSuchMethodError.java, java/lang/NoSuchMethodException.java, java/lang/NullPointerException.java, java/lang/Number.java, java/lang/NumberFormatException.java, java/lang/OutOfMemoryError.java, java/lang/Process.java, java/lang/Runnable.java, java/lang/Runtime.java, java/lang/RuntimeException.java, java/lang/RuntimePermission.java, java/lang/SecurityException.java, java/lang/SecurityManager.java, java/lang/Short.java, java/lang/StackOverflowError.java, java/lang/StackTraceElement.java, java/lang/StringBuffer.java, java/lang/StringIndexOutOfBoundsException.java, java/lang/ThreadDeath.java, java/lang/ThreadGroup.java, java/lang/Throwable.java, java/lang/UnsatisfiedLinkError.java, java/lang/UnsupportedOperationException.java, java/lang/VerifyError.java, java/lang/VirtualMachineError.java, java/lang/reflect/AccessibleObject.java, java/lang/reflect/Array.java, java/lang/reflect/InvocationTargetException.java, java/lang/reflect/Member.java, java/lang/reflect/Modifier.java, java/lang/reflect/Proxy.java, java/lang/reflect/ReflectPermission.java, java/lang/reflect/UndeclaredThrowableException.java, java/math/BigInteger.java, java/net/NetworkInterface.java, java/nio/ByteBufferHelper.java, java/nio/ByteBufferImpl.java, java/nio/DirectByteBufferImpl.java, java/nio/DoubleBufferImpl.java, java/nio/FloatBufferImpl.java, java/nio/IntBufferImpl.java, java/nio/LongBufferImpl.java, java/nio/ShortBufferImpl.java, java/nio/channels/Channel.java, java/nio/channels/IllegalBlockingModeException.java, java/nio/charset/spi/CharsetProvider.java, java/security/AccessControlException.java, java/security/BasicPermission.java, java/security/DigestException.java, java/security/DigestInputStream.java, java/security/DigestOutputStream.java, java/security/GeneralSecurityException.java, java/security/Guard.java, java/security/GuardedObject.java, java/security/InvalidAlgorithmParameterException.java, java/security/InvalidKeyException.java, java/security/InvalidParameterException.java, java/security/Key.java, java/security/KeyException.java, java/security/KeyManagementException.java, java/security/KeyStoreException.java, java/security/MessageDigestSpi.java, java/security/NoSuchAlgorithmException.java, java/security/NoSuchProviderException.java, java/security/Permission.java, java/security/PermissionCollection.java, java/security/Permissions.java, java/security/Principal.java, java/security/PrivateKey.java, java/security/PrivilegedActionException.java, java/security/ProviderException.java, java/security/PublicKey.java, java/security/SecureRandom.java, java/security/SecureRandomSpi.java, java/security/SignatureException.java, java/security/SignatureSpi.java, java/security/SignedObject.java, java/security/Signer.java, java/security/UnrecoverableKeyException.java, java/security/UnresolvedPermission.java, java/security/acl/AclNotFoundException.java, java/security/acl/LastOwnerException.java, java/security/acl/NotOwnerException.java, java/security/cert/CertPath.java, java/security/cert/CertPathBuilderException.java, java/security/cert/CertPathValidatorException.java, java/security/cert/CertStoreException.java, java/text/BreakIterator.java, java/text/ChoiceFormat.java, java/text/CollationElementIterator.java, java/text/CollationKey.java, java/text/Collator.java, java/text/DateFormat.java, java/text/DateFormatSymbols.java, java/text/DecimalFormat.java, java/text/DecimalFormatSymbols.java, java/text/FieldPosition.java, java/text/Format.java, java/text/NumberFormat.java, java/text/ParseException.java, java/text/ParsePosition.java, java/text/StringCharacterIterator.java, java/util/AbstractCollection.java, java/util/AbstractList.java, java/util/AbstractMap.java, java/util/AbstractSequentialList.java, java/util/AbstractSet.java, java/util/ArrayList.java, java/util/Arrays.java, java/util/BitSet.java, java/util/Collection.java, java/util/Collections.java, java/util/Comparator.java, java/util/ConcurrentModificationException.java, java/util/Currency.java, java/util/Date.java, java/util/EmptyStackException.java, java/util/Enumeration.java, java/util/EventListener.java, java/util/EventListenerProxy.java, java/util/EventObject.java, java/util/HashMap.java, java/util/HashSet.java, java/util/Hashtable.java, java/util/IdentityHashMap.java, java/util/Iterator.java, java/util/LinkedHashSet.java, java/util/LinkedList.java, java/util/List.java, java/util/ListIterator.java, java/util/ListResourceBundle.java, java/util/Map.java, java/util/MissingResourceException.java, java/util/NoSuchElementException.java, java/util/Observable.java, java/util/Observer.java, java/util/Properties.java, java/util/PropertyPermissionCollection.java, java/util/RandomAccess.java, java/util/Set.java, java/util/SortedMap.java, java/util/SortedSet.java, java/util/Stack.java, java/util/StringTokenizer.java, java/util/TooManyListenersException.java, java/util/TreeMap.java, java/util/TreeSet.java, java/util/Vector.java, java/util/logging/FileHandler.java, java/util/logging/Level.java, java/util/prefs/BackingStoreException.java, java/util/prefs/InvalidPreferencesFormatException.java, java/util/prefs/Preferences.java, javax/accessibility/Accessible.java, javax/accessibility/AccessibleAction.java, javax/accessibility/AccessibleBundle.java, javax/accessibility/AccessibleComponent.java, javax/accessibility/AccessibleContext.java, javax/accessibility/AccessibleEditableText.java, javax/accessibility/AccessibleExtendedComponent.java, javax/accessibility/AccessibleExtendedTable.java, javax/accessibility/AccessibleHyperlink.java, javax/accessibility/AccessibleHypertext.java, javax/accessibility/AccessibleIcon.java, javax/accessibility/AccessibleKeyBinding.java, javax/accessibility/AccessibleRelation.java, javax/accessibility/AccessibleRelationSet.java, javax/accessibility/AccessibleResourceBundle.java, javax/accessibility/AccessibleRole.java, javax/accessibility/AccessibleSelection.java, javax/accessibility/AccessibleState.java, javax/accessibility/AccessibleStateSet.java, javax/accessibility/AccessibleTable.java, javax/accessibility/AccessibleTableModelChange.java, javax/accessibility/AccessibleText.java, javax/accessibility/AccessibleValue.java, javax/imageio/IIOException.java, javax/imageio/ImageIO.java, javax/imageio/spi/IIOServiceProvider.java, javax/imageio/spi/ImageInputStreamSpi.java, javax/imageio/spi/ImageOutputStreamSpi.java, javax/imageio/spi/ImageReaderWriterSpi.java, javax/imageio/spi/ImageTranscoderSpi.java, javax/imageio/spi/RegisterableService.java, javax/imageio/spi/ServiceRegistry.java, javax/imageio/stream/IIOByteBuffer.java, javax/imageio/stream/ImageInputStream.java, javax/imageio/stream/ImageOutputStream.java, javax/naming/Binding.java, javax/naming/CannotProceedException.java, javax/naming/CompositeName.java, javax/naming/CompoundName.java, javax/naming/LinkException.java, javax/naming/LinkRef.java, javax/naming/NameClassPair.java, javax/naming/Reference.java, javax/naming/ReferralException.java, javax/naming/directory/Attribute.java, javax/naming/directory/AttributeModificationException.java, javax/naming/directory/Attributes.java, javax/naming/directory/DirContext.java, javax/naming/directory/ModificationItem.java, javax/naming/directory/SearchControls.java, javax/naming/directory/SearchResult.java, javax/naming/event/EventContext.java, javax/naming/event/EventDirContext.java, javax/naming/event/NamespaceChangeListener.java, javax/naming/event/NamingExceptionEvent.java, javax/naming/event/NamingListener.java, javax/naming/event/ObjectChangeListener.java, javax/naming/ldap/Control.java, javax/naming/ldap/ExtendedResponse.java, javax/naming/ldap/HasControls.java, javax/naming/ldap/LdapContext.java, javax/naming/ldap/UnsolicitedNotification.java, javax/naming/ldap/UnsolicitedNotificationEvent.java, javax/naming/ldap/UnsolicitedNotificationListener.java, javax/naming/spi/DirectoryManager.java, javax/naming/spi/ResolveResult.java, javax/naming/spi/Resolver.java, javax/security/auth/callback/Callback.java, javax/security/auth/callback/CallbackHandler.java, javax/security/auth/callback/ChoiceCallback.java, javax/security/auth/callback/ConfirmationCallback.java, javax/security/auth/callback/LanguageCallback.java, javax/security/auth/callback/NameCallback.java, javax/security/auth/callback/PasswordCallback.java, javax/security/auth/callback/TextInputCallback.java, javax/security/auth/callback/TextOutputCallback.java, javax/security/auth/callback/UnsupportedCallbackException.java, javax/security/sasl/Sasl.java, javax/security/sasl/SaslServerFactory.java, javax/swing/DefaultBoundedRangeModel.java, javax/swing/JComponent.java, javax/swing/JList.java, javax/swing/JProgressBar.java, javax/swing/JRadioButton.java, javax/swing/JTextArea.java, javax/swing/JTextField.java, javax/swing/JToggleButton.java, javax/swing/JTree.java, javax/swing/SpinnerListModel.java, javax/swing/event/EventListenerList.java, javax/swing/text/JTextComponent.java, javax/swing/text/StringContent.java, javax/swing/text/Utilities.java, javax/swing/undo/UndoManager.java, javax/swing/undo/UndoableEditSupport.java, javax/transaction/HeuristicCommitException.java, javax/transaction/HeuristicMixedException.java, javax/transaction/HeuristicRollbackException.java, javax/transaction/InvalidTransactionException.java, javax/transaction/NotSupportedException.java, javax/transaction/RollbackException.java, javax/transaction/Status.java, javax/transaction/Synchronization.java, javax/transaction/SystemException.java, javax/transaction/Transaction.java, javax/transaction/TransactionManager.java, javax/transaction/TransactionRequiredException.java, javax/transaction/TransactionRolledbackException.java, javax/transaction/UserTransaction.java, javax/transaction/xa/XAException.java, javax/transaction/xa/XAResource.java, javax/transaction/xa/Xid.java, javax/xml/XMLConstants.java, javax/xml/datatype/DatatypeConfigurationException.java, javax/xml/datatype/DatatypeConstants.java, javax/xml/datatype/DatatypeFactory.java, javax/xml/datatype/Duration.java, javax/xml/datatype/XMLGregorianCalendar.java, javax/xml/namespace/NamespaceContext.java, javax/xml/namespace/QName.java, javax/xml/parsers/DocumentBuilder.java, javax/xml/parsers/DocumentBuilderFactory.java, javax/xml/parsers/FactoryConfigurationError.java, javax/xml/parsers/ParserConfigurationException.java, javax/xml/parsers/SAXParser.java, javax/xml/parsers/SAXParserFactory.java, javax/xml/transform/ErrorListener.java, javax/xml/transform/OutputKeys.java, javax/xml/transform/Result.java, javax/xml/transform/Source.java, javax/xml/transform/SourceLocator.java, javax/xml/transform/Templates.java, javax/xml/transform/Transformer.java, javax/xml/transform/TransformerConfigurationException.java, javax/xml/transform/TransformerException.java, javax/xml/transform/TransformerFactory.java, javax/xml/transform/TransformerFactoryConfigurationError.java, javax/xml/transform/URIResolver.java, javax/xml/transform/dom/DOMLocator.java, javax/xml/transform/dom/DOMResult.java, javax/xml/transform/dom/DOMSource.java, javax/xml/transform/sax/SAXResult.java, javax/xml/transform/sax/SAXSource.java, javax/xml/transform/sax/SAXTransformerFactory.java, javax/xml/transform/sax/TemplatesHandler.java, javax/xml/transform/sax/TransformerHandler.java, javax/xml/transform/stream/StreamResult.java, javax/xml/transform/stream/StreamSource.java, javax/xml/validation/Schema.java, javax/xml/validation/SchemaFactory.java, javax/xml/validation/TypeInfoProvider.java, javax/xml/validation/Validator.java, javax/xml/validation/ValidatorHandler.java, javax/xml/xpath/XPathConstants.java, javax/xml/xpath/XPathException.java, javax/xml/xpath/XPathExpression.java, javax/xml/xpath/XPathExpressionException.java, javax/xml/xpath/XPathFactory.java, javax/xml/xpath/XPathFactoryConfigurationException.java, javax/xml/xpath/XPathFunction.java, javax/xml/xpath/XPathFunctionException.java, javax/xml/xpath/XPathFunctionResolver.java: Fixed usage of @author tag, reworked import statements, removed CVS tags, changed the modifier order and fixed HTML usage in javadocs. From-SVN: r95152
1266 lines
33 KiB
Java
1266 lines
33 KiB
Java
/* DecimalFormat.java -- Formats and parses numbers
|
|
Copyright (C) 1999, 2000, 2001, 2003, 2004 Free Software Foundation, Inc.
|
|
|
|
This file is part of GNU Classpath.
|
|
|
|
GNU Classpath is free software; you can redistribute it and/or modify
|
|
it under the terms of the GNU General Public License as published by
|
|
the Free Software Foundation; either version 2, or (at your option)
|
|
any later version.
|
|
|
|
GNU Classpath is distributed in the hope that it will be useful, but
|
|
WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
General Public License for more details.
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
along with GNU Classpath; see the file COPYING. If not, write to the
|
|
Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
|
|
02111-1307 USA.
|
|
|
|
Linking this library statically or dynamically with other modules is
|
|
making a combined work based on this library. Thus, the terms and
|
|
conditions of the GNU General Public License cover the whole
|
|
combination.
|
|
|
|
As a special exception, the copyright holders of this library give you
|
|
permission to link this library with independent modules to produce an
|
|
executable, regardless of the license terms of these independent
|
|
modules, and to copy and distribute the resulting executable under
|
|
terms of your choice, provided that you also meet, for each linked
|
|
independent module, the terms and conditions of the license of that
|
|
module. An independent module is a module which is not derived from
|
|
or based on this library. If you modify this library, you may extend
|
|
this exception to your version of the library, but you are not
|
|
obligated to do so. If you do not wish to do so, delete this
|
|
exception statement from your version. */
|
|
|
|
package java.text;
|
|
|
|
import gnu.java.text.AttributedFormatBuffer;
|
|
import gnu.java.text.FormatBuffer;
|
|
import gnu.java.text.FormatCharacterIterator;
|
|
import gnu.java.text.StringFormatBuffer;
|
|
|
|
import java.io.IOException;
|
|
import java.io.ObjectInputStream;
|
|
import java.util.Currency;
|
|
import java.util.HashMap;
|
|
import java.util.Locale;
|
|
|
|
/**
|
|
* @author Tom Tromey (tromey@cygnus.com)
|
|
* @author Andrew John Hughes (gnu_andrew@member.fsf.org)
|
|
* @date March 4, 1999
|
|
*/
|
|
/* Written using "Java Class Libraries", 2nd edition, plus online
|
|
* API docs for JDK 1.2 from http://www.javasoft.com.
|
|
* Status: Believed complete and correct to 1.2.
|
|
* Note however that the docs are very unclear about how format parsing
|
|
* should work. No doubt there are problems here.
|
|
*/
|
|
public class DecimalFormat extends NumberFormat
|
|
{
|
|
// This is a helper for applyPatternWithSymbols. It reads a prefix
|
|
// or a suffix. It can cause some side-effects.
|
|
private int scanFix (String pattern, int index, FormatBuffer buf,
|
|
String patChars, DecimalFormatSymbols syms,
|
|
boolean is_suffix)
|
|
{
|
|
int len = pattern.length();
|
|
boolean quoteStarted = false;
|
|
buf.clear();
|
|
|
|
boolean multiplierSet = false;
|
|
while (index < len)
|
|
{
|
|
char c = pattern.charAt(index);
|
|
|
|
if (quoteStarted)
|
|
{
|
|
if (c == '\'')
|
|
quoteStarted = false;
|
|
else
|
|
buf.append(c);
|
|
index++;
|
|
continue;
|
|
}
|
|
|
|
if (c == '\'' && index + 1 < len
|
|
&& pattern.charAt(index + 1) == '\'')
|
|
{
|
|
buf.append(c);
|
|
index++;
|
|
}
|
|
else if (c == '\'')
|
|
{
|
|
quoteStarted = true;
|
|
}
|
|
else if (c == '\u00a4')
|
|
{
|
|
if (index + 1 < len && pattern.charAt(index + 1) == '\u00a4')
|
|
{
|
|
buf.append(syms.getInternationalCurrencySymbol(), NumberFormat.Field.CURRENCY);
|
|
index++;
|
|
}
|
|
else
|
|
buf.append(syms.getCurrencySymbol(), NumberFormat.Field.CURRENCY);
|
|
}
|
|
else if (c == syms.getPercent())
|
|
{
|
|
if (multiplierSet)
|
|
throw new IllegalArgumentException ("multiplier already set " +
|
|
"- index: " + index);
|
|
multiplierSet = true;
|
|
multiplier = 100;
|
|
buf.append(c, NumberFormat.Field.PERCENT);
|
|
}
|
|
else if (c == syms.getPerMill())
|
|
{
|
|
if (multiplierSet)
|
|
throw new IllegalArgumentException ("multiplier already set " +
|
|
"- index: " + index);
|
|
multiplierSet = true;
|
|
multiplier = 1000;
|
|
buf.append(c, NumberFormat.Field.PERMILLE);
|
|
}
|
|
else if (patChars.indexOf(c) != -1)
|
|
{
|
|
// This is a pattern character.
|
|
break;
|
|
}
|
|
else
|
|
buf.append(c);
|
|
index++;
|
|
}
|
|
|
|
if (quoteStarted)
|
|
throw new IllegalArgumentException ("pattern is lacking a closing quote");
|
|
|
|
return index;
|
|
}
|
|
|
|
// A helper which reads a number format.
|
|
private int scanFormat (String pattern, int index, String patChars,
|
|
DecimalFormatSymbols syms, boolean is_positive)
|
|
{
|
|
int max = pattern.length();
|
|
|
|
int countSinceGroup = 0;
|
|
int zeroCount = 0;
|
|
boolean saw_group = false;
|
|
|
|
//
|
|
// Scan integer part.
|
|
//
|
|
while (index < max)
|
|
{
|
|
char c = pattern.charAt(index);
|
|
|
|
if (c == syms.getDigit())
|
|
{
|
|
if (zeroCount > 0)
|
|
throw new IllegalArgumentException ("digit mark following " +
|
|
"zero - index: " + index);
|
|
++countSinceGroup;
|
|
}
|
|
else if (c == syms.getZeroDigit())
|
|
{
|
|
++zeroCount;
|
|
++countSinceGroup;
|
|
}
|
|
else if (c == syms.getGroupingSeparator())
|
|
{
|
|
countSinceGroup = 0;
|
|
saw_group = true;
|
|
}
|
|
else
|
|
break;
|
|
|
|
++index;
|
|
}
|
|
|
|
// We can only side-effect when parsing the positive format.
|
|
if (is_positive)
|
|
{
|
|
groupingUsed = saw_group;
|
|
groupingSize = (byte) countSinceGroup;
|
|
minimumIntegerDigits = zeroCount;
|
|
}
|
|
|
|
// Early termination.
|
|
if (index == max || pattern.charAt(index) == syms.getGroupingSeparator())
|
|
{
|
|
if (is_positive)
|
|
decimalSeparatorAlwaysShown = false;
|
|
return index;
|
|
}
|
|
|
|
if (pattern.charAt(index) == syms.getDecimalSeparator())
|
|
{
|
|
++index;
|
|
|
|
//
|
|
// Scan fractional part.
|
|
//
|
|
int hashCount = 0;
|
|
zeroCount = 0;
|
|
while (index < max)
|
|
{
|
|
char c = pattern.charAt(index);
|
|
if (c == syms.getZeroDigit())
|
|
{
|
|
if (hashCount > 0)
|
|
throw new IllegalArgumentException ("zero mark " +
|
|
"following digit - index: " + index);
|
|
++zeroCount;
|
|
}
|
|
else if (c == syms.getDigit())
|
|
{
|
|
++hashCount;
|
|
}
|
|
else if (c != syms.getExponential()
|
|
&& c != syms.getPatternSeparator()
|
|
&& c != syms.getPercent()
|
|
&& c != syms.getPerMill()
|
|
&& patChars.indexOf(c) != -1)
|
|
throw new IllegalArgumentException ("unexpected special " +
|
|
"character - index: " + index);
|
|
else
|
|
break;
|
|
|
|
++index;
|
|
}
|
|
|
|
if (is_positive)
|
|
{
|
|
maximumFractionDigits = hashCount + zeroCount;
|
|
minimumFractionDigits = zeroCount;
|
|
}
|
|
|
|
if (index == max)
|
|
return index;
|
|
}
|
|
|
|
if (pattern.charAt(index) == syms.getExponential())
|
|
{
|
|
//
|
|
// Scan exponential format.
|
|
//
|
|
zeroCount = 0;
|
|
++index;
|
|
while (index < max)
|
|
{
|
|
char c = pattern.charAt(index);
|
|
if (c == syms.getZeroDigit())
|
|
++zeroCount;
|
|
else if (c == syms.getDigit())
|
|
{
|
|
if (zeroCount > 0)
|
|
throw new
|
|
IllegalArgumentException ("digit mark following zero " +
|
|
"in exponent - index: " +
|
|
index);
|
|
}
|
|
else if (patChars.indexOf(c) != -1)
|
|
throw new IllegalArgumentException ("unexpected special " +
|
|
"character - index: " +
|
|
index);
|
|
else
|
|
break;
|
|
|
|
++index;
|
|
}
|
|
|
|
if (is_positive)
|
|
{
|
|
useExponentialNotation = true;
|
|
minExponentDigits = (byte) zeroCount;
|
|
}
|
|
|
|
maximumIntegerDigits = groupingSize;
|
|
groupingSize = 0;
|
|
if (maximumIntegerDigits > minimumIntegerDigits && maximumIntegerDigits > 0)
|
|
{
|
|
minimumIntegerDigits = 1;
|
|
exponentRound = maximumIntegerDigits;
|
|
}
|
|
else
|
|
exponentRound = 1;
|
|
}
|
|
|
|
return index;
|
|
}
|
|
|
|
// This helper function creates a string consisting of all the
|
|
// characters which can appear in a pattern and must be quoted.
|
|
private String patternChars (DecimalFormatSymbols syms)
|
|
{
|
|
StringBuffer buf = new StringBuffer ();
|
|
buf.append(syms.getDecimalSeparator());
|
|
buf.append(syms.getDigit());
|
|
buf.append(syms.getExponential());
|
|
buf.append(syms.getGroupingSeparator());
|
|
// Adding this one causes pattern application to fail.
|
|
// Of course, omitting is causes toPattern to fail.
|
|
// ... but we already have bugs there. FIXME.
|
|
// buf.append(syms.getMinusSign());
|
|
buf.append(syms.getPatternSeparator());
|
|
buf.append(syms.getPercent());
|
|
buf.append(syms.getPerMill());
|
|
buf.append(syms.getZeroDigit());
|
|
buf.append('\u00a4');
|
|
return buf.toString();
|
|
}
|
|
|
|
private void applyPatternWithSymbols(String pattern, DecimalFormatSymbols syms)
|
|
{
|
|
// Initialize to the state the parser expects.
|
|
negativePrefix = "";
|
|
negativeSuffix = "";
|
|
positivePrefix = "";
|
|
positiveSuffix = "";
|
|
decimalSeparatorAlwaysShown = false;
|
|
groupingSize = 0;
|
|
minExponentDigits = 0;
|
|
multiplier = 1;
|
|
useExponentialNotation = false;
|
|
groupingUsed = false;
|
|
maximumFractionDigits = 0;
|
|
maximumIntegerDigits = MAXIMUM_INTEGER_DIGITS;
|
|
minimumFractionDigits = 0;
|
|
minimumIntegerDigits = 1;
|
|
|
|
AttributedFormatBuffer buf = new AttributedFormatBuffer ();
|
|
String patChars = patternChars (syms);
|
|
|
|
int max = pattern.length();
|
|
int index = scanFix (pattern, 0, buf, patChars, syms, false);
|
|
buf.sync();
|
|
positivePrefix = buf.getBuffer().toString();
|
|
positivePrefixRanges = buf.getRanges();
|
|
positivePrefixAttrs = buf.getAttributes();
|
|
|
|
index = scanFormat (pattern, index, patChars, syms, true);
|
|
|
|
index = scanFix (pattern, index, buf, patChars, syms, true);
|
|
buf.sync();
|
|
positiveSuffix = buf.getBuffer().toString();
|
|
positiveSuffixRanges = buf.getRanges();
|
|
positiveSuffixAttrs = buf.getAttributes();
|
|
|
|
if (index == pattern.length())
|
|
{
|
|
// No negative info.
|
|
negativePrefix = null;
|
|
negativeSuffix = null;
|
|
}
|
|
else
|
|
{
|
|
if (pattern.charAt(index) != syms.getPatternSeparator())
|
|
throw new IllegalArgumentException ("separator character " +
|
|
"expected - index: " + index);
|
|
|
|
index = scanFix (pattern, index + 1, buf, patChars, syms, false);
|
|
buf.sync();
|
|
negativePrefix = buf.getBuffer().toString();
|
|
negativePrefixRanges = buf.getRanges();
|
|
negativePrefixAttrs = buf.getAttributes();
|
|
|
|
// We parse the negative format for errors but we don't let
|
|
// it side-effect this object.
|
|
index = scanFormat (pattern, index, patChars, syms, false);
|
|
|
|
index = scanFix (pattern, index, buf, patChars, syms, true);
|
|
buf.sync();
|
|
negativeSuffix = buf.getBuffer().toString();
|
|
negativeSuffixRanges = buf.getRanges();
|
|
negativeSuffixAttrs = buf.getAttributes();
|
|
|
|
if (index != pattern.length())
|
|
throw new IllegalArgumentException ("end of pattern expected " +
|
|
"- index: " + index);
|
|
}
|
|
}
|
|
|
|
public void applyLocalizedPattern (String pattern)
|
|
{
|
|
// JCL p. 638 claims this throws a ParseException but p. 629
|
|
// contradicts this. Empirical tests with patterns of "0,###.0"
|
|
// and "#.#.#" corroborate the p. 629 statement that an
|
|
// IllegalArgumentException is thrown.
|
|
applyPatternWithSymbols (pattern, symbols);
|
|
}
|
|
|
|
public void applyPattern (String pattern)
|
|
{
|
|
// JCL p. 638 claims this throws a ParseException but p. 629
|
|
// contradicts this. Empirical tests with patterns of "0,###.0"
|
|
// and "#.#.#" corroborate the p. 629 statement that an
|
|
// IllegalArgumentException is thrown.
|
|
applyPatternWithSymbols (pattern, nonLocalizedSymbols);
|
|
}
|
|
|
|
public Object clone ()
|
|
{
|
|
DecimalFormat c = (DecimalFormat) super.clone ();
|
|
c.symbols = (DecimalFormatSymbols) symbols.clone ();
|
|
return c;
|
|
}
|
|
|
|
public DecimalFormat ()
|
|
{
|
|
this ("#,##0.###");
|
|
}
|
|
|
|
public DecimalFormat (String pattern)
|
|
{
|
|
this (pattern, new DecimalFormatSymbols ());
|
|
}
|
|
|
|
public DecimalFormat (String pattern, DecimalFormatSymbols symbols)
|
|
{
|
|
this.symbols = symbols;
|
|
applyPattern (pattern);
|
|
}
|
|
|
|
private boolean equals(String s1, String s2)
|
|
{
|
|
if (s1 == null || s2 == null)
|
|
return s1 == s2;
|
|
return s1.equals(s2);
|
|
}
|
|
|
|
public boolean equals (Object obj)
|
|
{
|
|
if (! (obj instanceof DecimalFormat))
|
|
return false;
|
|
DecimalFormat dup = (DecimalFormat) obj;
|
|
return (decimalSeparatorAlwaysShown == dup.decimalSeparatorAlwaysShown
|
|
&& groupingSize == dup.groupingSize
|
|
&& minExponentDigits == dup.minExponentDigits
|
|
&& multiplier == dup.multiplier
|
|
&& equals(negativePrefix, dup.negativePrefix)
|
|
&& equals(negativeSuffix, dup.negativeSuffix)
|
|
&& equals(positivePrefix, dup.positivePrefix)
|
|
&& equals(positiveSuffix, dup.positiveSuffix)
|
|
&& symbols.equals(dup.symbols)
|
|
&& useExponentialNotation == dup.useExponentialNotation);
|
|
}
|
|
|
|
private void formatInternal (double number, FormatBuffer dest,
|
|
FieldPosition fieldPos)
|
|
{
|
|
// A very special case.
|
|
if (Double.isNaN(number))
|
|
{
|
|
dest.append(symbols.getNaN());
|
|
if (fieldPos != null &&
|
|
(fieldPos.getField() == INTEGER_FIELD ||
|
|
fieldPos.getFieldAttribute() == NumberFormat.Field.INTEGER))
|
|
{
|
|
int index = dest.length();
|
|
fieldPos.setBeginIndex(index - symbols.getNaN().length());
|
|
fieldPos.setEndIndex(index);
|
|
}
|
|
return;
|
|
}
|
|
|
|
boolean is_neg = number < 0;
|
|
if (is_neg)
|
|
{
|
|
if (negativePrefix != null)
|
|
dest.append(negativePrefix, negativePrefixRanges, negativePrefixAttrs);
|
|
else
|
|
{
|
|
dest.append(symbols.getMinusSign(), NumberFormat.Field.SIGN);
|
|
dest.append(positivePrefix, positivePrefixRanges, positivePrefixAttrs);
|
|
}
|
|
number = - number;
|
|
}
|
|
else
|
|
dest.append(positivePrefix, positivePrefixRanges, positivePrefixAttrs);
|
|
|
|
int integerBeginIndex = dest.length();
|
|
int integerEndIndex = 0;
|
|
int zeroStart = symbols.getZeroDigit() - '0';
|
|
|
|
if (Double.isInfinite (number))
|
|
{
|
|
dest.append(symbols.getInfinity());
|
|
integerEndIndex = dest.length();
|
|
}
|
|
else
|
|
{
|
|
number *= multiplier;
|
|
|
|
// Compute exponent.
|
|
long exponent = 0;
|
|
double baseNumber;
|
|
if (useExponentialNotation)
|
|
{
|
|
exponent = (long) Math.floor (Math.log(number) / Math.log(10));
|
|
exponent = exponent - (exponent % exponentRound);
|
|
if (minimumIntegerDigits > 0)
|
|
exponent -= minimumIntegerDigits - 1;
|
|
baseNumber = (number / Math.pow(10.0, exponent));
|
|
}
|
|
else
|
|
baseNumber = number;
|
|
|
|
// Round to the correct number of digits.
|
|
baseNumber += 5 * Math.pow(10.0, - maximumFractionDigits - 1);
|
|
|
|
int index = dest.length();
|
|
//double intPart = Math.floor(baseNumber);
|
|
String intPart = Long.toString((long)Math.floor(baseNumber));
|
|
int count, groupPosition = intPart.length();
|
|
|
|
dest.setDefaultAttribute(NumberFormat.Field.INTEGER);
|
|
|
|
for (count = 0; count < minimumIntegerDigits-intPart.length(); count++)
|
|
dest.append(symbols.getZeroDigit());
|
|
|
|
for (count = 0;
|
|
count < maximumIntegerDigits && count < intPart.length();
|
|
count++)
|
|
{
|
|
int dig = intPart.charAt(count);
|
|
|
|
// Append group separator if required.
|
|
if (groupingUsed && count > 0 && groupingSize != 0 && groupPosition % groupingSize == 0)
|
|
{
|
|
dest.append(symbols.getGroupingSeparator(), NumberFormat.Field.GROUPING_SEPARATOR);
|
|
dest.setDefaultAttribute(NumberFormat.Field.INTEGER);
|
|
}
|
|
dest.append((char) (zeroStart + dig));
|
|
|
|
groupPosition--;
|
|
}
|
|
dest.setDefaultAttribute(null);
|
|
|
|
integerEndIndex = dest.length();
|
|
|
|
int decimal_index = integerEndIndex;
|
|
int consecutive_zeros = 0;
|
|
int total_digits = 0;
|
|
|
|
int localMaximumFractionDigits = maximumFractionDigits;
|
|
|
|
if (useExponentialNotation)
|
|
localMaximumFractionDigits += minimumIntegerDigits - count;
|
|
|
|
// Strip integer part from NUMBER.
|
|
double fracPart = baseNumber - Math.floor(baseNumber);
|
|
|
|
if ( ((fracPart != 0 || minimumFractionDigits > 0) && localMaximumFractionDigits > 0)
|
|
|| decimalSeparatorAlwaysShown)
|
|
{
|
|
dest.append (symbols.getDecimalSeparator(), NumberFormat.Field.DECIMAL_SEPARATOR);
|
|
}
|
|
|
|
int fraction_begin = dest.length();
|
|
dest.setDefaultAttribute(NumberFormat.Field.FRACTION);
|
|
for (count = 0;
|
|
count < localMaximumFractionDigits
|
|
&& (fracPart != 0 || count < minimumFractionDigits);
|
|
++count)
|
|
{
|
|
++total_digits;
|
|
fracPart *= 10;
|
|
long dig = (long) fracPart;
|
|
if (dig == 0)
|
|
++consecutive_zeros;
|
|
else
|
|
consecutive_zeros = 0;
|
|
dest.append((char) (symbols.getZeroDigit() + dig));
|
|
|
|
// Strip integer part from FRACPART.
|
|
fracPart = fracPart - Math.floor (fracPart);
|
|
}
|
|
|
|
// Strip extraneous trailing `0's. We can't always detect
|
|
// these in the loop.
|
|
int extra_zeros = Math.min (consecutive_zeros,
|
|
total_digits - minimumFractionDigits);
|
|
if (extra_zeros > 0)
|
|
{
|
|
dest.cutTail(extra_zeros);
|
|
total_digits -= extra_zeros;
|
|
if (total_digits == 0 && !decimalSeparatorAlwaysShown)
|
|
dest.cutTail(1);
|
|
}
|
|
|
|
if (fieldPos != null && fieldPos.getField() == FRACTION_FIELD)
|
|
{
|
|
fieldPos.setBeginIndex(fraction_begin);
|
|
fieldPos.setEndIndex(dest.length());
|
|
}
|
|
|
|
// Finally, print the exponent.
|
|
if (useExponentialNotation)
|
|
{
|
|
dest.append(symbols.getExponential(), NumberFormat.Field.EXPONENT_SYMBOL);
|
|
if (exponent < 0)
|
|
{
|
|
dest.append (symbols.getMinusSign (), NumberFormat.Field.EXPONENT_SIGN);
|
|
exponent = - exponent;
|
|
}
|
|
index = dest.length();
|
|
dest.setDefaultAttribute(NumberFormat.Field.EXPONENT);
|
|
String exponentString = Long.toString ((long) exponent);
|
|
|
|
for (count = 0; count < minExponentDigits-exponentString.length();
|
|
count++)
|
|
dest.append((char) symbols.getZeroDigit());
|
|
|
|
for (count = 0;
|
|
count < exponentString.length();
|
|
++count)
|
|
{
|
|
int dig = exponentString.charAt(count);
|
|
dest.append((char) (zeroStart + dig));
|
|
}
|
|
}
|
|
}
|
|
|
|
if (fieldPos != null &&
|
|
(fieldPos.getField() == INTEGER_FIELD ||
|
|
fieldPos.getFieldAttribute() == NumberFormat.Field.INTEGER))
|
|
{
|
|
fieldPos.setBeginIndex(integerBeginIndex);
|
|
fieldPos.setEndIndex(integerEndIndex);
|
|
}
|
|
|
|
if (is_neg && negativeSuffix != null)
|
|
dest.append(negativeSuffix, negativeSuffixRanges, negativeSuffixAttrs);
|
|
else
|
|
dest.append(positiveSuffix, positiveSuffixRanges, positiveSuffixAttrs);
|
|
}
|
|
|
|
public StringBuffer format (double number, StringBuffer dest,
|
|
FieldPosition fieldPos)
|
|
{
|
|
formatInternal (number, new StringFormatBuffer(dest), fieldPos);
|
|
return dest;
|
|
}
|
|
|
|
public AttributedCharacterIterator formatToCharacterIterator (Object value)
|
|
{
|
|
AttributedFormatBuffer sbuf = new AttributedFormatBuffer();
|
|
|
|
if (value instanceof Number)
|
|
formatInternal(((Number) value).doubleValue(), sbuf, null);
|
|
else
|
|
throw new IllegalArgumentException
|
|
("Cannot format given Object as a Number");
|
|
|
|
sbuf.sync();
|
|
return new FormatCharacterIterator(sbuf.getBuffer().toString(),
|
|
sbuf.getRanges(),
|
|
sbuf.getAttributes());
|
|
}
|
|
|
|
public StringBuffer format (long number, StringBuffer dest,
|
|
FieldPosition fieldPos)
|
|
{
|
|
// If using exponential notation, we just format as a double.
|
|
if (useExponentialNotation)
|
|
return format ((double) number, dest, fieldPos);
|
|
|
|
boolean is_neg = number < 0;
|
|
if (is_neg)
|
|
{
|
|
if (negativePrefix != null)
|
|
dest.append(negativePrefix);
|
|
else
|
|
{
|
|
dest.append(symbols.getMinusSign());
|
|
dest.append(positivePrefix);
|
|
}
|
|
number = - number;
|
|
}
|
|
else
|
|
dest.append(positivePrefix);
|
|
|
|
int integerBeginIndex = dest.length();
|
|
int index = dest.length();
|
|
int count = 0;
|
|
while (count < maximumIntegerDigits
|
|
&& (number > 0 || count < minimumIntegerDigits))
|
|
{
|
|
long dig = number % 10;
|
|
number /= 10;
|
|
// NUMBER and DIG will be less than 0 if the original number
|
|
// was the most negative long.
|
|
if (dig < 0)
|
|
{
|
|
dig = - dig;
|
|
number = - number;
|
|
}
|
|
|
|
// Append group separator if required.
|
|
if (groupingUsed && count > 0 && groupingSize != 0 && count % groupingSize == 0)
|
|
dest.insert(index, symbols.getGroupingSeparator());
|
|
|
|
dest.insert(index, (char) (symbols.getZeroDigit() + dig));
|
|
|
|
++count;
|
|
}
|
|
|
|
if (fieldPos != null && fieldPos.getField() == INTEGER_FIELD)
|
|
{
|
|
fieldPos.setBeginIndex(integerBeginIndex);
|
|
fieldPos.setEndIndex(dest.length());
|
|
}
|
|
|
|
if (decimalSeparatorAlwaysShown || minimumFractionDigits > 0)
|
|
{
|
|
dest.append(symbols.getDecimalSeparator());
|
|
if (fieldPos != null && fieldPos.getField() == FRACTION_FIELD)
|
|
{
|
|
fieldPos.setBeginIndex(dest.length());
|
|
fieldPos.setEndIndex(dest.length() + minimumFractionDigits);
|
|
}
|
|
}
|
|
|
|
for (count = 0; count < minimumFractionDigits; ++count)
|
|
dest.append(symbols.getZeroDigit());
|
|
|
|
dest.append((is_neg && negativeSuffix != null)
|
|
? negativeSuffix
|
|
: positiveSuffix);
|
|
return dest;
|
|
}
|
|
|
|
/**
|
|
* Returns the currency corresponding to the currency symbol stored
|
|
* in the instance of <code>DecimalFormatSymbols</code> used by this
|
|
* <code>DecimalFormat</code>.
|
|
*
|
|
* @return A new instance of <code>Currency</code> if
|
|
* the currency code matches a known one, null otherwise.
|
|
*/
|
|
public Currency getCurrency()
|
|
{
|
|
return symbols.getCurrency();
|
|
}
|
|
|
|
public DecimalFormatSymbols getDecimalFormatSymbols ()
|
|
{
|
|
return symbols;
|
|
}
|
|
|
|
public int getGroupingSize ()
|
|
{
|
|
return groupingSize;
|
|
}
|
|
|
|
public int getMultiplier ()
|
|
{
|
|
return multiplier;
|
|
}
|
|
|
|
public String getNegativePrefix ()
|
|
{
|
|
return negativePrefix;
|
|
}
|
|
|
|
public String getNegativeSuffix ()
|
|
{
|
|
return negativeSuffix;
|
|
}
|
|
|
|
public String getPositivePrefix ()
|
|
{
|
|
return positivePrefix;
|
|
}
|
|
|
|
public String getPositiveSuffix ()
|
|
{
|
|
return positiveSuffix;
|
|
}
|
|
|
|
public int hashCode ()
|
|
{
|
|
int hash = (negativeSuffix.hashCode() ^ negativePrefix.hashCode()
|
|
^positivePrefix.hashCode() ^ positiveSuffix.hashCode());
|
|
// FIXME.
|
|
return hash;
|
|
}
|
|
|
|
public boolean isDecimalSeparatorAlwaysShown ()
|
|
{
|
|
return decimalSeparatorAlwaysShown;
|
|
}
|
|
|
|
public Number parse (String str, ParsePosition pos)
|
|
{
|
|
/*
|
|
* Our strategy is simple: copy the text into separate buffers: one for the int part,
|
|
* one for the fraction part and for the exponential part.
|
|
* We translate or omit locale-specific information.
|
|
* If exponential is sufficiently big we merge the fraction and int part and
|
|
* remove the '.' and then we use Long to convert the number. In the other
|
|
* case, we use Double to convert the full number.
|
|
*/
|
|
|
|
boolean is_neg = false;
|
|
int index = pos.getIndex();
|
|
StringBuffer int_buf = new StringBuffer ();
|
|
|
|
// We have to check both prefixes, because one might be empty. We
|
|
// want to pick the longest prefix that matches.
|
|
boolean got_pos = str.startsWith(positivePrefix, index);
|
|
String np = (negativePrefix != null
|
|
? negativePrefix
|
|
: positivePrefix + symbols.getMinusSign());
|
|
boolean got_neg = str.startsWith(np, index);
|
|
|
|
if (got_pos && got_neg)
|
|
{
|
|
// By checking this way, we preserve ambiguity in the case
|
|
// where the negative format differs only in suffix. We
|
|
// check this again later.
|
|
if (np.length() > positivePrefix.length())
|
|
{
|
|
is_neg = true;
|
|
index += np.length();
|
|
}
|
|
else
|
|
index += positivePrefix.length();
|
|
}
|
|
else if (got_neg)
|
|
{
|
|
is_neg = true;
|
|
index += np.length();
|
|
}
|
|
else if (got_pos)
|
|
index += positivePrefix.length();
|
|
else
|
|
{
|
|
pos.setErrorIndex (index);
|
|
return null;
|
|
}
|
|
|
|
// FIXME: handle Inf and NaN.
|
|
|
|
// FIXME: do we have to respect minimum digits?
|
|
// What about multiplier?
|
|
|
|
StringBuffer buf = int_buf;
|
|
StringBuffer frac_buf = null;
|
|
StringBuffer exp_buf = null;
|
|
int start_index = index;
|
|
int max = str.length();
|
|
int exp_index = -1;
|
|
int last = index + maximumIntegerDigits;
|
|
|
|
if (maximumFractionDigits > 0)
|
|
last += maximumFractionDigits + 1;
|
|
|
|
if (useExponentialNotation)
|
|
last += minExponentDigits + 1;
|
|
|
|
if (last > 0 && max > last)
|
|
max = last;
|
|
|
|
char zero = symbols.getZeroDigit();
|
|
int last_group = -1;
|
|
boolean int_part = true;
|
|
boolean exp_part = false;
|
|
for (; index < max; ++index)
|
|
{
|
|
char c = str.charAt(index);
|
|
|
|
// FIXME: what about grouping size?
|
|
if (groupingUsed && c == symbols.getGroupingSeparator())
|
|
{
|
|
if (last_group != -1
|
|
&& groupingSize != 0
|
|
&& (index - last_group) % groupingSize != 0)
|
|
{
|
|
pos.setErrorIndex(index);
|
|
return null;
|
|
}
|
|
last_group = index+1;
|
|
}
|
|
else if (c >= zero && c <= zero + 9)
|
|
{
|
|
buf.append((char) (c - zero + '0'));
|
|
}
|
|
else if (parseIntegerOnly)
|
|
break;
|
|
else if (c == symbols.getDecimalSeparator())
|
|
{
|
|
if (last_group != -1
|
|
&& groupingSize != 0
|
|
&& (index - last_group) % groupingSize != 0)
|
|
{
|
|
pos.setErrorIndex(index);
|
|
return null;
|
|
}
|
|
buf = frac_buf = new StringBuffer();
|
|
frac_buf.append('.');
|
|
int_part = false;
|
|
}
|
|
else if (c == symbols.getExponential())
|
|
{
|
|
buf = exp_buf = new StringBuffer();
|
|
int_part = false;
|
|
exp_part = true;
|
|
exp_index = index+1;
|
|
}
|
|
else if (exp_part
|
|
&& (c == '+' || c == '-' || c == symbols.getMinusSign()))
|
|
{
|
|
// For exponential notation.
|
|
buf.append(c);
|
|
}
|
|
else
|
|
break;
|
|
}
|
|
|
|
if (index == start_index)
|
|
{
|
|
// Didn't see any digits.
|
|
pos.setErrorIndex(index);
|
|
return null;
|
|
}
|
|
|
|
// Check the suffix. We must do this before converting the
|
|
// buffer to a number to handle the case of a number which is
|
|
// the most negative Long.
|
|
boolean got_pos_suf = str.startsWith(positiveSuffix, index);
|
|
String ns = (negativePrefix == null ? positiveSuffix : negativeSuffix);
|
|
boolean got_neg_suf = str.startsWith(ns, index);
|
|
if (is_neg)
|
|
{
|
|
if (! got_neg_suf)
|
|
{
|
|
pos.setErrorIndex(index);
|
|
return null;
|
|
}
|
|
}
|
|
else if (got_pos && got_neg && got_neg_suf)
|
|
{
|
|
is_neg = true;
|
|
}
|
|
else if (got_pos != got_pos_suf && got_neg != got_neg_suf)
|
|
{
|
|
pos.setErrorIndex(index);
|
|
return null;
|
|
}
|
|
|
|
String suffix = is_neg ? ns : positiveSuffix;
|
|
long multiplier = 1;
|
|
boolean use_long;
|
|
|
|
if (is_neg)
|
|
int_buf.insert(0, '-');
|
|
|
|
// Now handle the exponential part if there is one.
|
|
if (exp_buf != null)
|
|
{
|
|
int exponent_value;
|
|
|
|
try
|
|
{
|
|
exponent_value = Integer.parseInt(exp_buf.toString());
|
|
}
|
|
catch (NumberFormatException x1)
|
|
{
|
|
pos.setErrorIndex(exp_index);
|
|
return null;
|
|
}
|
|
|
|
if (frac_buf == null)
|
|
{
|
|
// We only have to add some zeros to the int part.
|
|
// Build a multiplier.
|
|
for (int i = 0; i < exponent_value; i++)
|
|
int_buf.append('0');
|
|
|
|
use_long = true;
|
|
}
|
|
else
|
|
{
|
|
boolean long_sufficient;
|
|
|
|
if (exponent_value < frac_buf.length()-1)
|
|
{
|
|
int lastNonNull = -1;
|
|
/* We have to check the fraction buffer: it may only be full of '0'
|
|
* or be sufficiently filled with it to convert the number into Long.
|
|
*/
|
|
for (int i = 1; i < frac_buf.length(); i++)
|
|
if (frac_buf.charAt(i) != '0')
|
|
lastNonNull = i;
|
|
|
|
long_sufficient = (lastNonNull < 0 || lastNonNull <= exponent_value);
|
|
}
|
|
else
|
|
long_sufficient = true;
|
|
|
|
if (long_sufficient)
|
|
{
|
|
for (int i = 1; i < frac_buf.length() && i < exponent_value; i++)
|
|
int_buf.append(frac_buf.charAt(i));
|
|
for (int i = frac_buf.length()-1; i < exponent_value; i++)
|
|
int_buf.append('0');
|
|
use_long = true;
|
|
}
|
|
else
|
|
{
|
|
/*
|
|
* A long type is not sufficient, we build the full buffer to
|
|
* be parsed by Double.
|
|
*/
|
|
int_buf.append(frac_buf);
|
|
int_buf.append('E');
|
|
int_buf.append(exp_buf);
|
|
use_long = false;
|
|
}
|
|
}
|
|
}
|
|
else
|
|
{
|
|
if (frac_buf != null)
|
|
{
|
|
/* Check whether the fraction buffer contains only '0' */
|
|
int i;
|
|
for (i = 1; i < frac_buf.length(); i++)
|
|
if (frac_buf.charAt(i) != '0')
|
|
break;
|
|
|
|
if (i != frac_buf.length())
|
|
{
|
|
use_long = false;
|
|
int_buf.append(frac_buf);
|
|
}
|
|
else
|
|
use_long = true;
|
|
}
|
|
else
|
|
use_long = true;
|
|
}
|
|
|
|
String t = int_buf.toString();
|
|
Number result = null;
|
|
if (use_long)
|
|
{
|
|
try
|
|
{
|
|
result = new Long (t);
|
|
}
|
|
catch (NumberFormatException x1)
|
|
{
|
|
}
|
|
}
|
|
else
|
|
{
|
|
try
|
|
{
|
|
result = new Double (t);
|
|
}
|
|
catch (NumberFormatException x2)
|
|
{
|
|
}
|
|
}
|
|
if (result == null)
|
|
{
|
|
pos.setErrorIndex(index);
|
|
return null;
|
|
}
|
|
|
|
pos.setIndex(index + suffix.length());
|
|
|
|
return result;
|
|
}
|
|
|
|
/**
|
|
* Sets the <code>Currency</code> on the
|
|
* <code>DecimalFormatSymbols</code> used, which also sets the
|
|
* currency symbols on those symbols.
|
|
*/
|
|
public void setCurrency(Currency currency)
|
|
{
|
|
symbols.setCurrency(currency);
|
|
}
|
|
|
|
public void setDecimalFormatSymbols (DecimalFormatSymbols newSymbols)
|
|
{
|
|
symbols = newSymbols;
|
|
}
|
|
|
|
public void setDecimalSeparatorAlwaysShown (boolean newValue)
|
|
{
|
|
decimalSeparatorAlwaysShown = newValue;
|
|
}
|
|
|
|
public void setGroupingSize (int groupSize)
|
|
{
|
|
groupingSize = (byte) groupSize;
|
|
}
|
|
|
|
public void setMaximumFractionDigits (int newValue)
|
|
{
|
|
super.setMaximumFractionDigits(Math.min(newValue, 340));
|
|
}
|
|
|
|
public void setMaximumIntegerDigits (int newValue)
|
|
{
|
|
super.setMaximumIntegerDigits(Math.min(newValue, 309));
|
|
}
|
|
|
|
public void setMinimumFractionDigits (int newValue)
|
|
{
|
|
super.setMinimumFractionDigits(Math.min(newValue, 340));
|
|
}
|
|
|
|
public void setMinimumIntegerDigits (int newValue)
|
|
{
|
|
super.setMinimumIntegerDigits(Math.min(newValue, 309));
|
|
}
|
|
|
|
public void setMultiplier (int newValue)
|
|
{
|
|
multiplier = newValue;
|
|
}
|
|
|
|
public void setNegativePrefix (String newValue)
|
|
{
|
|
negativePrefix = newValue;
|
|
}
|
|
|
|
public void setNegativeSuffix (String newValue)
|
|
{
|
|
negativeSuffix = newValue;
|
|
}
|
|
|
|
public void setPositivePrefix (String newValue)
|
|
{
|
|
positivePrefix = newValue;
|
|
}
|
|
|
|
public void setPositiveSuffix (String newValue)
|
|
{
|
|
positiveSuffix = newValue;
|
|
}
|
|
|
|
private void quoteFix(StringBuffer buf, String text, String patChars)
|
|
{
|
|
int len = text.length();
|
|
for (int index = 0; index < len; ++index)
|
|
{
|
|
char c = text.charAt(index);
|
|
if (patChars.indexOf(c) != -1)
|
|
{
|
|
buf.append('\'');
|
|
buf.append(c);
|
|
buf.append('\'');
|
|
}
|
|
else
|
|
buf.append(c);
|
|
}
|
|
}
|
|
|
|
private String computePattern(DecimalFormatSymbols syms)
|
|
{
|
|
StringBuffer mainPattern = new StringBuffer ();
|
|
// We have to at least emit a zero for the minimum number of
|
|
// digits. Past that we need hash marks up to the grouping
|
|
// separator (and one beyond).
|
|
int total_digits = Math.max(minimumIntegerDigits,
|
|
groupingUsed ? groupingSize + 1: groupingSize);
|
|
for (int i = 0; i < total_digits - minimumIntegerDigits; ++i)
|
|
mainPattern.append(syms.getDigit());
|
|
for (int i = total_digits - minimumIntegerDigits; i < total_digits; ++i)
|
|
mainPattern.append(syms.getZeroDigit());
|
|
// Inserting the gropuing operator afterwards is easier.
|
|
if (groupingUsed)
|
|
mainPattern.insert(mainPattern.length() - groupingSize,
|
|
syms.getGroupingSeparator());
|
|
// See if we need decimal info.
|
|
if (minimumFractionDigits > 0 || maximumFractionDigits > 0
|
|
|| decimalSeparatorAlwaysShown)
|
|
mainPattern.append(syms.getDecimalSeparator());
|
|
for (int i = 0; i < minimumFractionDigits; ++i)
|
|
mainPattern.append(syms.getZeroDigit());
|
|
for (int i = minimumFractionDigits; i < maximumFractionDigits; ++i)
|
|
mainPattern.append(syms.getDigit());
|
|
if (useExponentialNotation)
|
|
{
|
|
mainPattern.append(syms.getExponential());
|
|
for (int i = 0; i < minExponentDigits; ++i)
|
|
mainPattern.append(syms.getZeroDigit());
|
|
if (minExponentDigits == 0)
|
|
mainPattern.append(syms.getDigit());
|
|
}
|
|
|
|
String main = mainPattern.toString();
|
|
String patChars = patternChars (syms);
|
|
mainPattern.setLength(0);
|
|
|
|
quoteFix (mainPattern, positivePrefix, patChars);
|
|
mainPattern.append(main);
|
|
quoteFix (mainPattern, positiveSuffix, patChars);
|
|
|
|
if (negativePrefix != null)
|
|
{
|
|
quoteFix (mainPattern, negativePrefix, patChars);
|
|
mainPattern.append(main);
|
|
quoteFix (mainPattern, negativeSuffix, patChars);
|
|
}
|
|
|
|
return mainPattern.toString();
|
|
}
|
|
|
|
public String toLocalizedPattern ()
|
|
{
|
|
return computePattern (symbols);
|
|
}
|
|
|
|
public String toPattern ()
|
|
{
|
|
return computePattern (nonLocalizedSymbols);
|
|
}
|
|
|
|
private static final int MAXIMUM_INTEGER_DIGITS = 309;
|
|
|
|
// These names are fixed by the serialization spec.
|
|
private boolean decimalSeparatorAlwaysShown;
|
|
private byte groupingSize;
|
|
private byte minExponentDigits;
|
|
private int exponentRound;
|
|
private int multiplier;
|
|
private String negativePrefix;
|
|
private String negativeSuffix;
|
|
private String positivePrefix;
|
|
private String positiveSuffix;
|
|
private int[] negativePrefixRanges, positivePrefixRanges;
|
|
private HashMap[] negativePrefixAttrs, positivePrefixAttrs;
|
|
private int[] negativeSuffixRanges, positiveSuffixRanges;
|
|
private HashMap[] negativeSuffixAttrs, positiveSuffixAttrs;
|
|
private int serialVersionOnStream = 1;
|
|
private DecimalFormatSymbols symbols;
|
|
private boolean useExponentialNotation;
|
|
private static final long serialVersionUID = 864413376551465018L;
|
|
|
|
private void readObject(ObjectInputStream stream)
|
|
throws IOException, ClassNotFoundException
|
|
{
|
|
stream.defaultReadObject();
|
|
if (serialVersionOnStream < 1)
|
|
{
|
|
useExponentialNotation = false;
|
|
serialVersionOnStream = 1;
|
|
}
|
|
}
|
|
|
|
// The locale-independent pattern symbols happen to be the same as
|
|
// the US symbols.
|
|
private static final DecimalFormatSymbols nonLocalizedSymbols
|
|
= new DecimalFormatSymbols (Locale.US);
|
|
}
|